Sub-Agent
An AI agent spawned by another agent to handle a specific sub-task, operating with its own context window and returning results to the parent.
A sub-agent is an AI agent created by another AI agent — the "parent" — to handle a specific piece of a larger task. The parent agent delegates work to sub-agents, collects their results, and coordinates the overall effort.
Why sub-agents exist
Every AI model has a context window — the maximum amount of text it can process at once. When a parent agent is handling a complex task, its context window fills up with instructions, conversation history, and intermediate results. Instead of cramming everything into one overloaded agent, you spawn sub-agents that each get their own fresh context window and a focused brief.
This is the AI equivalent of a manager delegating work. A marketing director does not write every blog post, design every graphic, and send every email personally. They delegate to specialists. Sub-agents work the same way.
How sub-agents work
- The parent agent receives a complex goal
- It breaks the goal into sub-tasks
- For each sub-task, it spawns a sub-agent with a specific brief
- Each sub-agent executes its task independently
- Results flow back to the parent agent
- The parent synthesises and delivers the final output
Spawning patterns
- Fan-out / Fan-in: Parent spawns multiple sub-agents in parallel (e.g., researching 5 competitors simultaneously), then collects all results
- Pipeline: Each sub-agent passes output to the next (research → write → edit → format)
- Specialist pool: Parent routes different task types to the appropriate specialist sub-agent
In practice
In Claude Code, the Agent tool spawns sub-agents. Each sub-agent has access to the same tools as the parent but operates with its own context. You can set `isolation: "worktree"` to give a sub-agent its own copy of the codebase for safe parallel development.
Key consideration: Every sub-agent uses tokens. A task that spawns 5 sub-agents costs roughly 3-5x more than a single agent doing everything sequentially. Use sub-agents when the quality or speed benefit justifies the additional cost.
Why This Matters
Sub-agents are how AI scales from handling individual tasks to managing entire projects. For teams deploying AI at scale, understanding sub-agents is essential for building reliable multi-step workflows that stay within context limits and produce consistent quality. The pattern also maps directly to how human teams work — making it intuitive to design and debug.
Related Terms
Continue learning in Expert
This topic is covered in our lesson: Sub-Agents: Making AI Clone Itself