What is a subagent in AI, and when is it worth splitting an agent into several?
An agent started by another agent for one part of a task. It works in its own fresh context and returns only its findings.
intermediate · Also called Sub-agent, Multi-Agent System, Worker Agent
A subagent is an agent that another agent starts to do one piece of a larger job. The lead agent writes it a task, the subagent works on it with its own tools and its own empty context windowContext WindowEverything a model can see at once while it writes an answer, counted in tokens. When the window is full, something has to be left out., and it hands back a short report. Everything it read along the way, the 20 search results and 3 long files, stays in its context and never reaches the lead's.
That is the main reason to use one: it keeps the lead agent's context small. In Anthropic's description, a subagent may work through tens of thousands of tokens and return a summary of often 1,000 to 2,000. The lead keeps the plan in view instead of filling up with raw material, and needs CompactionCompactionReplacing the older part of a long conversation with a summary, so an agent can keep working when its context fills up. later, if at all.
Where they help
Subagents earn their cost on work that splits into independent parts. Anthropic's Research feature has a lead agent that plans and starts subagents to search different angles at the same time. On its internal research eval, that arrangement beat a single agent of the lead's model by 90.2%. The same write-up found that how many tokens a system spent explained 80% of the variance in results on a browsing benchmark, BrowseComp, so part of the gain is simply that several agents read more.
Where they do not
- Cost. Anthropic measured agents using about 4 times the tokens of a chat, and multi-agent systems about 15 times. The task has to be worth it.
- Shared state. Work where every part depends on the others fits badly. Most coding is like that: 2 subagents editing the same module do not see each other's changes. The write-up names coding as a weaker fit than research.
- Bad briefs. A subagent knows only what it is told. Each needs an objective, the form its answer should take, which tools and sources to use, and where its task ends. Without that, subagents repeat each other's work or leave gaps.
In tools you may use
Coding agents use the same idea on a small scale. Claude Code can hand a search through a large codebase to a subagent so the main session gets only the answer; see subagents in Claude Code. In code you write yourself, a subagent is just another agent loop started by a tool call, whose final text becomes the tool's result.
Sources