Subagents: context isolation and orchestration for Claude
A subagent is a separate agent instance that the main agent spawns for a focused subtask. It works in its own context, and only its final message returns to the parent, so the parent's context grows by a summary rather than by every file the subagent read.
Why delegate
The Agent SDK lists four benefits. Context isolation: intermediate tool calls and results stay inside the subagent. Parallelization: independent subtasks run at once and finish in the time of the slowest one, not the sum. Specialized instructions: each subagent can have its own system prompt. Tool restrictions: a reviewer can be limited to Read, Grep and Glob.
In the Agent SDK you define subagents in the agents option of query(). Each AgentDefinition needs a description (when to use it) and a prompt (its system prompt), and can set tools, model, skills and more. Claude invokes them through the Agent tool. The built-in general-purpose subagent is available even if you define none.
What a subagent gets
A non-fork subagent starts fresh. It receives its own system prompt, the Agent tool's prompt string, the project CLAUDE.md, and its tool definitions. It does not receive the parent's conversation history, tool results or system prompt, and it does not get preloaded skill content unless the skill is listed in AgentDefinition.skills. Put file paths, errors and decisions it needs into the prompt you pass.
To continue a subagent later, capture the session's session_id, parse agentId from the Agent tool result, and pass resume in the next query(). The built-in Explore and Plan agents are one-shot and return no agentId.
Subagents in Managed Agents
In Claude Managed Agents you enable delegation in the agent's multiagent block. Every agent shares the session's sandbox, filesystem and vault credentials, but each runs in its own session thread with its own conversation history. The documented patterns are parallelization (for example analyzing separate files and synthesizing the results), specialization, and escalation. Delegation is one level deep, and a session can have at most 25 child threads at a time.
Where the exam catches people
A subagent does not inherit the parent's conversation or loaded skills: anything it needs must be in its prompt or listed in AgentDefinition.skills.
A small growth in the parent's context after delegation is expected, not truncation: only the subagent's final message returns.
Not every built-in subagent can be resumed: Explore and Plan are one-shot, so use general-purpose or a custom agent when you need follow-ups.
Running independent subtasks one after another wastes time; parallel subagents finish in the time of the slowest one.