# AI Subagents
Subagents are fresh agent instances dispatched by a parent agent to handle specific tasks with their own [[Context Window]]. The parent agent retains its context for coordination while the subagent works in isolation, returning a structured summary when done.
The primary value is context preservation. LLMs are constrained by their context limit, and quality typically degrades well before the theoretical maximum. By offloading research, testing, or file exploration to a subagent, the parent's context stays clean for high-level reasoning and decision-making.
## Common subagent roles
- **Explorer**: reads source code, searches for patterns, maps project structure, returns a summary the parent can act on
- **Code reviewer**: analyzes changes for bugs, design weaknesses, or style violations
- **Test runner**: executes test suites and processes verbose output without polluting the parent's context
- **Debugger**: isolates root causes in a focused context
## When to use them
Subagents shine when tasks are independent and can run in parallel (e.g., modifying files that don't depend on each other) or when a task would generate large amounts of output that the parent doesn't need to see in full. They also allow using faster, cheaper models for routine work while reserving expensive models for the parent.
The important caveat: don't over-use them. The parent agent is perfectly capable of handling debugging, review, and exploration when its context has room. Subagents add coordination overhead and lose the parent's accumulated understanding. Use them when context preservation or parallelism genuinely matters.
## References
- https://simonwillison.net/guides/agentic-engineering-patterns/subagents/
## Related
- [[AI Agent Orchestration]]
- [[AI Agents]]
- [[AI Agent Harness]]
- [[How coding agents work]]
- [[Agentic Engineering]]
- [[Context Window]]
- [[Token Budget]]
- [[Separation of Concerns]]
- [[Claude Code]]