You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At its core, tower-llm treats agents, tools, and coordinators as Tower services you compose with layers. This keeps business logic pure and testable while pushing side effects (I/O, retries, tracing, storage) to the edges.
67
+
68
+
- Agents are services that turn chat requests into outcomes.
69
+
- Tools are services invoked by the agent when the model asks for them.
70
+
- Layers add cross-cutting behavior without coupling concerns.
71
+
72
+
Why this design works well:
73
+
74
+
- Composable by default: you assemble exactly what you need.
75
+
- Static dependency injection: no global registries or runtime lookups.
76
+
- Functional core, imperative shell: easy to reason about and to test.
77
+
78
+
## A layered story: from hello world to production
79
+
80
+
Start small, add power as you go:
81
+
82
+
1. Hello world agent: see [Quickstart](#quickstart). One model, one tool, a simple stop policy.
83
+
84
+
2. Keep state between turns: add [Sessions](#sessions-stateful-agents) with `MemoryLayer` and an in-memory or SQLite store.
85
+
86
+
3. See what's happening: add [Observability](#observability-tracing-and-metrics) via `TracingLayer` and `MetricsLayer` to emit spans and metrics.
87
+
88
+
4. Bound cost and behavior: compose a [Budget policy](#budgeting-tokens-tools-time) with your stop policies.
89
+
90
+
5. Be resilient: wrap the agent with resilience layers (retry/timeout/circuit-breaker) from `resilience`.
91
+
92
+
6. Record and reproduce: tap runs with [Recording/Replay](#recording-and-replay) to debug or build fixtures without model calls.
93
+
94
+
7. Speed up tools: enable [Parallel tool execution](#parallel-tool-execution) and pick a join policy when multiple tools can run concurrently.
95
+
96
+
8. Stream in real time: use `streaming::StepStreamService` and `AgentLoopStreamLayer` for token-by-token UIs (see the streaming snippet below).
97
+
98
+
9. Go multi-agent: coordinate specialists with [Handoffs](#handoffs-multi-agent). Start with explicit or sequential policies; compose them as needed.
99
+
100
+
10. Keep context tight: add `auto_compaction::AutoCompactionLayer` or `groups::CompactingHandoffPolicy` to trim history during long runs (see `examples/handoff_compaction.rs`).
101
+
102
+
11. Validate conversations: use [Conversation validation](#conversation-validation-testsexamples) to assert invariants in tests and examples.
103
+
104
+
Throughout, you can swap providers or run entirely offline using [Provider override](#provider-override-no-network-testing).
105
+
106
+
## Layer catalog at a glance
107
+
108
+
- Sessions: persist and reload history around each call.
109
+
110
+
- When: you need stateful conversations or persistence.
111
+
- How: `sessions::MemoryLayer`, with `InMemorySessionStore` or `SqliteSessionStore`.
112
+
113
+
- Observability: trace spans and emit metrics for every step/agent call.
114
+
115
+
- When: you want visibility in dev and prod.
116
+
- How: `observability::{TracingLayer, MetricsLayer}` with your metrics sink.
117
+
118
+
- Approvals: gate model outputs and tool invocations.
119
+
120
+
- When: you need review or policy enforcement.
121
+
- How: `approvals::{ModelApprovalLayer, ToolApprovalLayer}` plus an `Approver` service.
122
+
123
+
- Resilience: retry, time out, and break circuits around calls.
124
+
125
+
- When: you want robust error handling for flaky dependencies.
0 commit comments