Sub-agents spawning sub-agents — the delegation pattern that changes everything
Claude Code just dropped a feature that changes how we think about agent architecture: sub-agents can now spawn their own sub-agents, up to 5 levels deep. This isn't just a technical upgrade — it's the first time an AI agent can delegate the way a human manager would.
Here's what this actually looks like in practice. Your main agent gets a task: "Build a user dashboard with authentication." Instead of trying to do everything itself, it spawns three sub-agents: one for the frontend, one for the backend, one for auth. The auth agent realizes it needs to research OAuth providers and spawns its own research sub-agent. The frontend agent spawns a sub-agent to handle CSS framework selection.
Each sub-agent reports back to its parent, which synthesizes the results and reports up the chain. Your main agent orchestrates the whole thing without getting lost in implementation details.
The key insight: delegation depth lets you match cognitive load to task complexity. Simple tasks stay shallow. Complex tasks naturally branch into manageable pieces.
But here's what nobody's talking about: orchestration overhead scales exponentially. Each delegation layer adds communication costs, context switching, and potential failure points. I've seen 5-level hierarchies spend more tokens on coordination than actual work.
The pattern that works: dynamic delegation with explicit budgets. Give each agent a token budget and a time limit. When a sub-agent hits either limit, it reports its current state and recommendations to its parent. The parent decides whether to continue, delegate differently, or escalate.
Here's the orchestration config I use:
delegation_policy:
max_depth: 3 # Rarely need more
token_budget_per_level: 2000
timeout_per_level: 300 # 5 minutes
escalation_triggers:
- budget_exceeded
- timeout_reached
- contradiction_detected
handoff_protocol: "state_summary_with_next_steps"The magic happens in the handoff protocol. Each sub-agent doesn't just report what it did — it reports its current understanding of the problem, what it tried, what worked, what didn't, and what the next logical steps are. This prevents the parent from having to reconstruct context from scratch.
Three patterns I've learned the hard way:
- Breadth before depth — Spawn siblings before spawning children. Get the full problem space mapped before diving deep.
- Explicit coordination checkpoints — Every 3 sub-agent actions, force a sync between siblings. Prevents duplicate work and conflicting approaches.
- Failure isolation — If a sub-agent fails, its siblings should be able to continue. Design for partial success.
The real test: Can you kill any sub-agent at any time and still make progress? If not, your orchestration is too brittle.
This changes everything about how we architect agent systems. Instead of building monolithic agents that try to handle every edge case, we can build specialist agents that know when to delegate and how to coordinate. The agent that spawns the right sub-agents is often more valuable than the agent that does the work itself.
But here's the thing — most people will build 5-level hierarchies because they can, not because they should. The real skill is knowing when to delegate and when to just do the work. Single agents are still faster for simple tasks. The delegation overhead isn't worth it until the task complexity crosses a threshold.
That threshold? When you find yourself writing task descriptions longer than 200 words. That's usually when breaking it into delegated pieces starts paying off.