Subagent
A subagent is a helper agent that a main agent hands a task to. It works in its own fresh context window, often with its own instructions and tools, and returns only a summary of the result.
Also called: sub-agent
By Divya Sharma · Checked Nov 15, 2026 · How we review
Long agent sessions fill up with search results, logs and file contents that matter for one step and never again. A subagent keeps that clutter out of the main conversation. The main agent describes the side task, the subagent does the work in isolation, and only its short report comes back.
How it works
In Claude Code, a subagent is defined in a Markdown file: a name, a description of when to use it, an optional list of allowed tools and model, and a body that becomes its system prompt. When a task matches the description, the main agent delegates it. The subagent starts with an empty context window; it does not see the parent's history, so the hand-off message must carry what it needs. Other coding agents and agent frameworks offer similar delegation.
Why it matters
Subagents are a context engineering tool. They keep the main thread short, let several research or review tasks run in parallel, and let you restrict risky tools to one narrow helper, such as a reviewer that can read files but not edit them.
Subagent versus multi-agent system
A subagent is a child that reports back to one parent. A multi-agent system is the broader design, which can include peers that talk to each other. Subagents are the simplest and most common form.
Limits
Each subagent spends its own tokens, and anything left out of the hand-off or the summary is lost to the parent.
Related terms
- Multi-agent system
- A multi-agent system is a setup in which several AI agents, each with its own instructions, tools and context, work on parts of a task and pass results to each other or to a coordinating agent.
- Coding agent
- A coding agent is an AI agent that works on software directly: it reads a codebase, edits files, runs commands and tests, and repeats until a change works, rather than only suggesting code for a person to paste.
- Context engineering
- Context engineering is the practice of choosing and maintaining everything that goes into a language model's context window during a task: instructions, retrieved documents, tool definitions, tool results and conversation history.
- Agent orchestration
- Agent orchestration is the control of which agents or model calls run in an application, in what order, and how each next step is chosen, either by a model making the decision or by fixed code.
- Context window
- A context window is the maximum amount of text, counted in tokens, that a language model can consider at once, covering the system prompt, conversation, documents, tool results and the response it writes.