Subagents
Delegation with focus
Subagents are specialized workers delegated a bounded sub-goal with their own loop, tools, and context — the coordinator decomposes work and merges results. Parallelism and focus come at a coordination cost.
What you will learn
- Justify when subagents beat one big loop
- Bound sub-goals and context isolation
- Merge and verify subagent outputs
What is this?
Subagents are isolated loops with their own prompts, tools and history, delegated a bounded sub-goal by a coordinator. They win when tasks parallelize cleanly or need different tools/prompts than the main loop; they cost coordination, serialization overhead, and verification of their outputs.
Why do you need it?
- Isolation prevents cross-task context noise.
- Parallel subagents shorten wall-clock time.
- Specialized prompts/tools raise per-task quality.
- Scoped delegation matches how real teams work.
Mental model
A lead engineer and specialists
Subagents
The lead (coordinator) splits the ship into deck + engine + navigation, each specialist (subagent) runs their own checklists with their own tools, then reports back. Parallel and focused — but the lead owns integration, acceptance, and the schedule.
How it works
- Coordinator plans and identifies parallel/large sub-tasks.
- Spawn subagents with a clear objective + scoped tools.
- Share only what's needed (summary of context, not everything).
- Merge results into the coordinator's plan.
- Verify each subagent's deliverables before acceptance.
Fan-out, work, fan-in.
In production
- Research: one subagent per source/perspective, then synthesis.
- Repo ops: parallel review subagents for files or services.
- Multi-region ops: subagents run per-region runbooks concurrently.
Best practices
- Give each subagent a crisp objective + exit criteria.
- Scope tools and permissions per subagent.
- Share summaries, not backstories; keep context lean.
- Verify deliverables in the coordinator before integrating.
Common mistakes
- Subagents re-explore the same state the coordinator covered.
- Fan-out without caps — cost multiplies with agents.
- Blindly trusting subagent outputs as ground truth.
Common issues
Subagents block on shared resourcesContended tools
Serialize writes or partition work by resource scope.
Cost explodes with subagentsUnbounded fan-out
Cap parallel spawns; reuse results; merge related sub-tasks.
Debugging tips
- Slow convergence → overlapping sub-tasks; partition cleanly by ownership.
- Duplicate work → share a task log so workers don't collide.
- Inconsistent merges → define deliverable format per subagent.
Interview checkpoint
Quick quiz
A reason to use subagents:
Subagent outputs can be trusted without verification.