Subagent
A specialized AI agent spawned by a parent agent to handle a focused task in its own isolated context, then return only the result.
What Is a Subagent
A subagent is an AI agent launched by another agent — the parent or orchestrator — to carry out a narrowly scoped task. Instead of one agent juggling an entire job in a single, ever-growing context window, the parent delegates pieces of work to subagents that run independently and report back.
Each subagent typically gets:
- Its own context window — separate from the parent, so it doesn’t pollute or get polluted by unrelated history
- A focused instruction — one task, clearly defined
- A restricted toolset — only the tools relevant to its job
When the subagent finishes, only its final result is returned to the parent — not the full transcript of how it got there.
Why Subagents Matter
- Context isolation — long file dumps, search results, and dead ends stay inside the subagent and never bloat the parent’s context
- Parallelism — multiple independent subagents can run at once, cutting wall-clock time
- Specialization — each subagent can be given a distinct role, system prompt, and permissions (a code reviewer, a researcher, a tester)
- Reliability — a failure or hallucination in one subagent is contained rather than derailing the whole task
Subagents in Practice
The pattern is now standard in agentic developer tools. Claude Code, for example, lets a main agent dispatch subagents for research, search, and parallel implementation work.
A more ambitious example is gstack by Garry Tan — an open-source toolkit that turns Claude Code into a “virtual engineering team” of 23 specialized subagents. It assigns roles across the full software lifecycle: a CEO agent for strategic review, an Eng Manager for architecture, Engineers for implementation, a Staff Engineer for code review, a Security Officer for OWASP/STRIDE audits, a QA Lead for browser testing, and a Release Engineer for CI/CD. gstack can run 10–15 of these agent workflows in parallel, which is only practical because each subagent operates in its own isolated context.
Single Agent vs. Subagent Architecture
| Single agent | Orchestrator + subagents | |
|---|---|---|
| Context | One window for everything | Isolated per subagent |
| Speed | Sequential | Parallel where tasks are independent |
| Roles | One general-purpose agent | Many specialists |
| Failure blast radius | Whole task | Contained to one subagent |