Certopolis

Claude Certified Architect – Foundations

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.

Written from Anthropic's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An agent must review 200 changelog files and produce one consolidated summary. A single loop fills its context with the raw file text long before it finishes reading, and you want each file read handled outside the main loop. Which approach should you take?

    Right. In the game that’s Renown for your Agent Architecture and Orchestration building.

    Not that one: D is right. In the game your Agent Architecture and Orchestration building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Because each delegated agent runs in its own context-isolated session thread with its own conversation history, the bulk file text stays in the subagents' contexts and only their conclusions return to the coordinator. The coordinator is left holding the synthesis while the delegated agents carry the reading.

    Written from platform.claude.com/docs/en/managed-agents/multiagent-orchestration

  2. Your doc-reviewer subagent must apply your team's house-style skill. Your main session had that skill loaded when it delegated, but the subagent's review ignores every convention in it, and the subagent's transcript shows it never opened the skill at all. How should you restructure the delegation so the subagent applies that skill?

    Right. In the game that’s Renown for your Agent Architecture and Orchestration building.

    Not that one: A is right. In the game your Agent Architecture and Orchestration building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Naming the house-style skill in skills is what puts its content in the subagent's window from its first turn, which is what a convention the review must follow throughout requires.

    Written from code.claude.com/docs/en/agent-sdk/subagents

  3. You want a repository investigation delegated to a built-in subagent so its file reads stay out of your main context. Afterwards you must put follow-up questions to that same agent about what it found, from a second query() call, without it starting the investigation over. Which approach should you take?

    Right. In the game that’s Renown for your Agent Architecture and Orchestration building.

    Not that one: B is right. In the game your Agent Architecture and Orchestration building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Resuming a subagent means capturing the parent's session_id, parsing agentId: <id> out of the Agent tool result, then passing resume: sessionId in the second query and naming the agent id in the prompt, because each query() call otherwise starts a new session.

    Written from code.claude.com/docs/en/agent-sdk/subagents