wiki / concepts / subagents-and-context-management
Subagents and Context Management
Machine ingest — raw context
loading…
~… tokensappend .md to any wiki URL for this view
Subagents and Context Management
LLM context windows carry token budgets and degrade in reasoning sharpness as conversations grow bloated. Subagents solve this by isolating high-token exploratory work in ephemeral child contexts, returning only concise summaries to the root agent.
dispatch -> subagent context = goal + minimal files + output schema
collect -> parent receives result summary only (not the transcript)
Core Roles
- Exploration (e.g. Claude Code Explore): An isolated subagent searches the tree, locates relevant views/templates/functions, and hands back exact file paths and line numbers without flooding the root session.
- Parallel Subagents: Independent tasks (e.g. updating 5 decoupled template files or refactoring independent modules) dispatched concurrently across child agents to accelerate throughput.
- Specialist Subagents: Delegating specific roles like code reviewer, verbose test-runner filter, or debugger to dedicated prompts with customized system instructions.
Context Preservation Rule
The primary value of subagents is not unnecessary complexity, but preserving the root agent’s context window for architectural decisions, high-level verification, and user steering.
Failure Modes
| Symptom | Root cause | Fix |
|---|---|---|
| Subagent returns useless summary | Goal under-specified at dispatch | Goal = task + files + output schema, written down before dispatch |
| Parent context explodes on collect | Full transcripts merged back | Collect result summaries only; transcripts stay in the subagent |
| Subagents duplicate work | Overlapping scopes | Partition by file/area ownership before dispatch |
| Lost consensus across agents | No synthesis step | One parent-side synthesis pass over all summaries |
Rule of Thumb
Rule of Thumb
A subagent gets a goal, the minimum files, and an output schema - never the parent transcript. If it needs the transcript, the task split is wrong.
Related
Evidence — verified primary sources
| simon-willison-subagents-2026 | https://simonwillison.net/guides/agentic-engineering-patterns/subagents/ | ingested 2026-08-22 sha256:833ae739f8fe… |
| simon-willison-how-coding-agents-work-2026 | https://simonwillison.net/guides/agentic-engineering-patterns/how-coding-agents-work/ | ingested 2026-08-22 sha256:0cd16e1c94ce… |
Graph context