Sometimes the cleanest move for an agent is to delegate. A subagent is a second agent instance, launched by the first, given a narrow task and its own blank context. It runs its own loop, uses its own tools, and hands back only its conclusion. The parent carries on with that result and none of the intermediate mess.
Why spawn one at all
The point is almost always about protecting the main context window:
- Isolation. A task like "search the whole codebase for every call site" can involve reading dozens of files. Done inline, that floods the main context. Done in a subagent, the parent only receives the tidy summary.
- Parallelism. Independent subtasks can run as several subagents at once, each in its own window, then their results are combined.
- Focus. A subagent starts fresh, so it is not distracted by the parent's long history. It sees only what it needs for its one job.
The tradeoff
Delegation is not free. The parent cannot see how the subagent reasoned, only what it returned, so a subagent that misunderstands its brief fails silently and hands back a confident but wrong answer. The skill is in the handoff: give the subagent a crisp task and enough context to do it, and treat its result as a report to sanity-check, not gospel.
Related terms
Agent
An agent is a language model wrapped in a loop that lets it call tools, read the results, and decide what to do next. The model supplies the judgement; the loop and the tools give it hands.
Read definition →Context window
The context window is the maximum amount of text, measured in tokens, that a model can consider for a single request. It is a hard ceiling, and it is the main resource you manage when working with an agent.
Read definition →Tool
A tool is a named action, with a typed input schema, that a model is allowed to call. Tools are how a model that can only produce text gets to actually do things: read a file, run a command, search the web.
Read definition →