Skip to content

Commit 6c80589

Browse files
committed
docs: reframe sub-agents as per-agent-optimized delegation
1 parent e20ca7d commit 6c80589

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

website/docs/context-engineering.mdx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,13 @@ The practical framing: **AGENTS.md** holds what the agent should always know —
201201

202202
## Sub-Agents
203203

204-
Sub-agents run in completely separate context windows. A sub-agent might consume 50K–150K tokens researching a codebase, but return only a 2K–5K synthesis to the orchestrator.
204+
Sub-agents are **delegated agents** — independent instances that run in separate context windows under the direction of an orchestrator. Each sub-agent operates on its own task slice, and the orchestrator consumes only the returned synthesis rather than inheriting the full working trace.
205205

206-
**Context effect:** the prompt forks work into a separate window; only the returned synthesis enters the parent near the active turn. The parent pays for that synthesis, not the raw search trail, file reads, and partial interpretations. This keeps the orchestrator clean while making the return boundary intentionally lossy.
206+
**Context effect:** the prompt forks work into separate windows; each sub-agent carries its own context lifecycle, and only its synthesis returns to the orchestrator. The parent pays for that synthesis, not the raw search trail, file reads, and partial interpretations. This isolation keeps the orchestrator clean while making the return boundary intentionally lossy.
207207

208-
Think of a sub-agent like a function call for agents. The prompt is the parameter: "Find all JWT authentication code and explain the current implementation." The synthesis is the return value: "JWT implementation found at src/auth/jwt.ts using Passport.js..." You pay for work in both contexts, but the parent receives the compact result instead of inheriting the whole research journey.
208+
Sub-agents are the agentic analogue of a function call: the dispatch prompt is the parameter ("Find all JWT authentication code and explain the current implementation") and the synthesis is the return value ("JWT implementation found at src/auth/jwt.ts using Passport.js..."). You pay to process tokens in all participating contexts, but the orchestrator receives compact results instead of inheriting every delegate's full journey.
209+
210+
What makes sub-agents a first-class orchestration primitive — beyond context isolation — is **per-agent optimization**. With the right harness, each delegate can run on the LLM best suited to its sub-task: [pi](https://pi.dev) + [pi-agenticoding](https://github.com/agenticoding/pi-agenticoding) lets you route each sub-agent to the model that matches its cost-accuracy profile. Similarly, Claude Code, Codex, and OpenCode let you customize the system prompt per sub-agent, so each delegate carries only the instructions it needs for its slice of work. Regardless of the mechanism, the payoff is the same: **orchestrating a single task via multiple specialized agents** instead of overloading one context.
209211

210212
<DiagramFrame
211213
kicker="Context management"
@@ -218,17 +220,25 @@ Think of a sub-agent like a function call for agents. The prompt is the paramete
218220
<SubAgentFanoutDiagram />
219221
</DiagramFrame>
220222

221-
The tradeoffs:
223+
### Benefits and Costs
224+
225+
**Benefits:**
226+
- **Proper delegation** — the orchestrator assigns each sub-task to an independent agent rather than doing all work in one overloaded context
227+
- **LLM optimization per task** — pi + pi-agenticoding routes each delegate to the model best suited to its slice (e.g. high-throughput for research, precision-tuned for review)
228+
- **System prompt customization per agent** — Claude Code, Codex, and OpenCode let you tailor the system prompt to each delegate's role
229+
- **Parallel execution** — independent sub-tasks run concurrently instead of serially
230+
- **Cleaner orchestrator** — only syntheses cross back, keeping the parent window focused on coordination
222231

223-
- **No shared state** — each sub-agent starts fresh, so you pay the context-file loading cost again
224-
- **Synthesis can lose nuance** — the 2K summary omits details the parent might have needed
225-
- **Cost multiplied** — every sub-agent is a separate API call with its own token consumption
232+
**Costs:**
233+
- **No shared state** — each sub-agent starts fresh, so context-file loading cost is paid again per delegate
234+
- **Synthesis can lose nuance** — the compact return omits details the orchestrator might have needed
235+
- **Token cost multiplied** — every sub-agent is a separate API call with its own consumption
226236
- **No nesting** — sub-agents cannot spawn sub-agents; the orchestrator is always the root
227-
- **10 parallel cap** — Claude Code limits concurrent sub-agents to 10
237+
- **Concurrency cap** — Claude Code limits concurrent sub-agents to 10
228238

229-
The trade-off is token cost, not accuracy. You pay to process tokens in both contexts, but the orchestrator stays clean. That often improves first-iteration accuracy enough to save tokens compared with multiple correction cycles from a polluted parent context.
239+
These are token-cost tradeoffs in exchange for delegation and specialization — the right tradeoff when per-agent optimization improves outcome quality faster than the added token spend costs.
230240

231-
Sub-agents are ideal for heavy research, multi-file analysis, and exploratory tasks where the journey matters less than the destination. They can also generate independent plans or implementations when you want to compare options before applying one result.
241+
Sub-agents are ideal for delegating independent research, multi-file analysis, and exploratory tasks to the agent best suited for each slice, and for generating independent plans or implementations across specialized models when you want to compare options before applying one result.
232242

233243
## Context Compaction
234244

@@ -309,8 +319,8 @@ Eager loading is simple but charges the full catalog to every request. Deferred
309319
**Skills: procedure content arrives only when activated**
310320
A lightweight catalog supports discovery; the selected workflow enters near the active turn. Manual activation favors reliability, while model activation favors convenience.
311321

312-
**Sub-agents: raw exploration stays outside the parent**
313-
A sub-agent can consume 150K tokens internally while returning only a small synthesis. Use separate windows for research trails and multi-file exploration when the parent needs conclusions rather than the full journey.
322+
**Sub-Agents: delegation via isolated windows with per-agent optimization**
323+
A sub-agent can consume 150K tokens internally while returning only a small synthesis. Use delegation to assign sub-tasks to agents optimized per slice — the right LLM and system prompt for each work item — while the orchestrator stays focused on coordination.
314324

315325
**Compaction: working room is recovered by losing detail**
316326
A summary replaces accumulated history, so facts needed later may disappear. External checkpoint files provide exact recall; a fresh context restores inference quality.

website/docs/reliability-levers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ unnecessary dependent transformations and handoffs.
114114
<OrchestrationLeverDiagram />
115115
</DiagramFrame>
116116

117-
Orchestration also removes dependencies. Run independent research in parallel sub-agents rather than one long serial thread. Separate implementation from review when they need different judgment. Stop before code turns a human decision into structure. [Sub-agents](./context-engineering.mdx#sub-agents) are useful because they isolate noisy work and return compact results.
117+
Orchestration also removes dependencies. Run independent research in parallel sub-agents rather than one long serial thread. Separate implementation from review when they need different judgment. Stop before code turns a human decision into structure. [Sub-agents](./context-engineering.mdx#sub-agents) change orchestration by letting a single task be decomposed across multiple specialized agents — each running on the LLM and system prompt optimized for its slice — rather than overloading one context, isolating noisy work and reducing dependency length in the parent chain.
118118

119119
This lever does not fix missing facts or an unclear success condition. Better shape only helps when each unit is grounded and judgeable.
120120

0 commit comments

Comments
 (0)