# 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.

- Page: https://tecyfy.com/concepts/subagent
- Subject: AI agents (https://tecyfy.com/concepts)
- Level: 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 window](https://tecyfy.com/concepts/context-window), 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 [Compaction](https://tecyfy.com/concepts/compaction) 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](/coding-agents/claude-code/subagents). 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.

## Related

- [Agent](https://tecyfy.com/concepts/agent): A model that uses tools in a loop, deciding each next step from what the last one returned, until the task is done.
- [Context Engineering](https://tecyfy.com/concepts/context-engineering): Choosing what goes into a model's context at each step of a task, what to fetch only when needed, and what to clear, note down or summarise as the context grows.
- [Orchestration](https://tecyfy.com/concepts/orchestration): Running the steps of data pipelines in the right order and at the right time, retrying failures and alerting someone when a step breaks.
- [Planner-Executor Pattern](https://tecyfy.com/concepts/plannerexecutor-pattern): An agent design that splits the work in 2. A planner writes the whole plan first, and an executor, which can be cheaper code or smaller models, carries out each step. The plan is changed only when a step fails.
- [Compaction](https://tecyfy.com/concepts/compaction): Replacing the older part of a long conversation with a summary, so an agent can keep working when its context fills up.

## Sources

- [How we built our multi-agent research system](https://www.anthropic.com/engineering/multi-agent-research-system)
- [Effective context engineering for AI agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)
