What you will be able to do
- Configure a coordinator so it is allowed to spawn subagents, and explain why the spawning tool must be in its allowed tools
- Write an AgentDefinition whose description, system prompt and tool list each do their own job
- Explain why a subagent knows only what is in the prompt string it receives, and what comes back to the parent
- Fan out independent subagents by emitting several spawning tool calls in one coordinator response, and write their prompts as goals and quality criteria rather than step lists
- Pass earlier agents' complete findings into a synthesis subagent's prompt, keeping content separate from attribution metadata such as source URLs, document names and page numbers
- Choose fork over resume when several divergent approaches must start from the same analysis baseline
Key concept
Fresh-context subagent — A spawned subagent does not see the coordinator's conversation. It starts from its own system prompt plus the task prompt the coordinator writes, so anything the subagent needs must be written into that prompt, and only its final message comes back.
1.The spawning tool, and why the coordinator must be allowed to call it
A coordinator doesn't start subagents by magic. It makes a tool call. The exam guide calls this the Task tool. The current Agent SDK documentation calls the same thing the Agent tool, and its samples list "Agent" in the coordinator's allowed tools. The name you see depends on the version, but the rule is the same: the tool that spawns subagents has to be available to the coordinator. If it isn't, subagent definitions just sit there, because Claude has no way to delegate to them.
In the SDK sample below, allowed_tools is commented as the auto-approve list. "Agent" appears in it next to the read-only tools, and the agents map then defines what can be spawned. The two go together: agents says which subagents exist, and the spawning tool is how Claude actually calls one. You don't even need a custom definition to delegate. Claude can use a general-purpose subagent through the same tool.
# Auto-approve these tools
allowed_tools=["Read", "Grep", "Glob", "Agent"],
agents={
"code-reviewer": AgentDefinition(
# description tells Claude when to use this subagent
description="Expert code review specialist. Use for quality, security, and maintainability reviews.",The reverse also holds. Claude Code's documentation gives denying the spawning tool as the way to switch delegation off completely. So whether that tool is permitted is the single switch that decides whether a coordinator can fan out at all.
Once the tool is available, how the coordinator emits the calls decides whether subagents run in parallel or one after another. Subagents can run concurrently, and the documentation's promise is that independent subtasks then finish in the time of the slowest one rather than the sum of all of them. That promise only holds when the coordinator emits multiple Task tool calls in a single response. If it spawns one subagent, waits for the result, then spawns the next in a later turn, the work is serialised and the parallel benefit is gone. Anthropic's research system is built on exactly this: the lead agent analyses the query, develops a strategy, and spawns subagents to explore different aspects simultaneously. A code review that needs a style check, a security scan and a coverage report is the same shape. Three spawning calls in one coordinator response, not three turns.
What goes into each of those prompts matters as much as when they are sent. Research is open-ended and path-dependent, and Anthropic's engineering team is explicit that you can't hardcode a fixed path for exploring a complex topic. So a coordinator prompt that lists step-by-step procedural instructions ("search for X, then open the first three results, then extract Y") locks the subagent into a route the coordinator guessed in advance. The stronger pattern is to state the research goal, the scope, and the quality criteria the answer must meet, and let the subagent decide how to get there. That is what gives it the flexibility to pivot or follow a tangential lead as the investigation unfolds. Procedural steps belong in the subagent's system prompt only when the task really is mechanical, such as running a fixed test command.
A coordinator agent is configured with allowedTools set to ["Read", "Grep", "Glob"] and defines a "research-assistant" subagent in its agents map. When the coordinator tries to delegate a task to research-assistant, every invocation halts on a permission prompt instead of running automatically. What is the most likely cause and fix?
Correct answer: A — The subagent invocation tool, Task, is not listed in allowedTools, so each spawn attempt requires manual approval; add Task to allowedTools to auto-approve subagent calls
- A. Correct. Spawning a subagent goes through the dedicated invocation tool, and that tool name must be present in allowedTools for the coordinator to auto-approve delegation; otherwise every call falls through to a permission prompt.
- B. Incorrect. model is optional on an agent definition and defaults to the main model when omitted; its absence does not trigger permission prompts.
- C. Incorrect. Naming a subagent in the prompt affects whether Claude chooses to invoke it, not whether the invocation is auto-approved once chosen.
- D. Incorrect. A subagent's tools are a restriction subset, not an escalation; there is no privilege-escalation check that blocks delegation for this reason.
2.AgentDefinition: description, system prompt and tool restrictions
Each subagent type is an AgentDefinition, passed under agents in the query options. Two fields are required, and they do different jobs. The description is read by the coordinator to decide when to delegate. The prompt is the subagent's system prompt, which shapes how it behaves once it is running. A strong prompt doesn't help if the description never makes the coordinator reach for the subagent in the first place.
| Field | Required | What it controls |
|---|---|---|
| description | Yes | Natural language description of when to use this agent (read by the coordinator when deciding to delegate) |
| prompt | Yes | The subagent's system prompt: its role and behaviour |
| tools | No | Allowed tool names; if omitted, inherits every tool available to subagents |
| disallowedTools | No | Tool names removed from the subagent's tool set, including MCP server patterns such as mcp__server__* |
| model | No | Model override, e.g. 'sonnet', 'haiku', 'inherit', or a full model ID |
| maxTurns | No | Maximum agentic turns before the subagent stops |
Tool restrictions are how you give each subagent only the power its role needs. The documentation's example is a doc-reviewer that only has Read and Grep, so it can analyse files but can't change them. The default goes the other way, and this catches people out: if you leave out tools, the subagent gets every tool available to subagents. It does not get none. The test-runner below is given Bash on purpose, because running tests is its job.
"test-runner": AgentDefinition(
description="Runs and analyzes test suites. Use for test execution and coverage analysis.",
prompt="""You are a test execution specialist. Run tests and provide clear analysis of results.
Focus on:
- Running test commands
- Analyzing test output
- Identifying failing tests
- Suggesting fixes for failures""",
# Bash access lets this subagent run test commands
tools=["Bash", "Read", "Grep"],
),Probably not. The coordinator decides whether to delegate by reading the description, not the prompt. The prompt only matters after the subagent has been spawned. A vague description gives the coordinator no reason to hand the work off.
A coordinator runs a "web-researcher" subagent that gathers ten sources on a topic, then spawns a "synthesis" subagent to write the final report. The synthesis subagent's output ignores nearly all of the researcher's findings and instead re-derives generic conclusions from scratch. The coordinator's prompt to synthesis only said "Write a report based on the research that was just completed." What change fixes this?
Correct answer: A — Include the complete findings from web-researcher directly in synthesis's prompt, since subagents never automatically inherit parent or sibling context
- A. Correct. Each subagent starts with a fresh context window; the only channel from parent to subagent is the prompt string, so any prior findings the subagent needs must be written into that prompt explicitly.
- B. Incorrect. More turns does not give the subagent access to data it was never given; it would just spend more turns without the source material.
- C. Incorrect. A larger model cannot infer specific research findings it was never shown; model choice does not substitute for missing context in the prompt.
- D. Incorrect. Re-running the same searches is wasteful and non-deterministic; it does not guarantee the same findings and defeats the purpose of reusing completed work.
Sources1
3.Fresh context: the prompt string is the only way in
When the coordinator calls the spawning tool, the input is small. It has a short description, the prompt, and optionally a subagent type and a model. The documentation describes prompt as the task for the agent to perform. The subagent starts its own conversation, and nothing from the coordinator's history is added to it. The files the coordinator read, what the user said three turns ago, and earlier subagents' results are all missing from its context unless the coordinator writes them into this prompt.
{
"description": str, # A short (3-5 word) description of the task
"prompt": str, # The task for the agent to perform
"subagent_type": str | None, # The type of specialized agent to use
"model": "sonnet" | "opus" | "haiku" | "fable" | None, # Model override for this agentIsolation works in both directions. The subagent's intermediate tool calls and results stay inside the subagent, and only its final message goes back to the parent. That is why subagents are useful: a research subagent can read dozens of files and the coordinator gets a short summary instead of all that text. It also means nothing carries over between spawns. Each new subagent starts clean, so if a later subagent needs an earlier one's output, the coordinator has to pass it along in the prompt. Anthropic's workflow cookbook puts it plainly: each subagent sees only the prompt it is given.
State this as a rule, because the exam does: subagent context must be explicitly provided in the prompt. A subagent does not automatically inherit the parent's context, and there is no shared memory between invocations. Spawning the same subagent type twice gives you two unrelated conversations; the second one has no idea what the first one found. The only exception the documentation names is a fork, which deliberately starts from a copy of an existing conversation. For an ordinary spawn, assume the subagent knows nothing you have not typed into its prompt.
This is what context passing looks like in a real pipeline. In Anthropic's research system, each search subagent performs its own web searches and returns its findings to the lead agent, which synthesises them. When the lead agent then hands the report to a synthesis or citation agent, it passes all the findings along, because that agent cannot see the searches that produced them. The practical rule for a coordinator is to include the complete findings from prior agents directly in the next subagent's prompt: the actual web search results, the actual document analysis outputs, not a one-line reference to "the research above". A reference to something outside the prompt points at nothing.
How you lay that context out matters for attribution. If you paste findings as one undifferentiated block of text, the synthesis subagent loses track of which claim came from which source, and the final report cannot be attributed properly. Use a structured format that separates content from metadata: each finding carries its extracted text as one field and its provenance (source URL, document name, page number) as separate fields, whether that is JSON, a simple list of records, or clearly labelled blocks. The research system's final stage exists precisely so that every claim can be attributed to its source, and that is only possible if the metadata survived every hop between agents. Strip it at any one handoff and no later agent can recover it.
A team is building a "doc-reviewer" subagent that should be able to read and comment on documentation but must never be able to modify files, even accidentally. The coordinator itself has Read, Edit, Write, Grep, and Glob available. How should the doc-reviewer's AgentDefinition be configured to guarantee this constraint?
Correct answer: A — Set tools to ["Read", "Grep"] on the doc-reviewer definition so it inherits only the listed read tools regardless of what the coordinator has available
- A. Correct. The tools field on an AgentDefinition is an explicit allowlist; specifying only Read and Grep guarantees the subagent has no access to Edit or Write, independent of what the coordinator or parent session can do.
- B. Incorrect. Leaving tools unset means the subagent inherits all available tools; a prompt instruction is only a suggestion the model could still deviate from, not an enforced restriction.
- C. Incorrect. Restricting the coordinator's own tools would also block the coordinator's other legitimate work and is unrelated to constraining what a specific subagent can do.
- D. Incorrect. The description field only affects when Claude chooses to invoke the subagent; it does not restrict which tools the subagent can actually call once running.
4.Forking a session: divergent approaches from one analysis baseline
Fresh-context spawning is the normal case, but sometimes you want the opposite: several agents that all start from the same expensive analysis and then diverge. The SDK's session options handle that. A session has an ID you capture from the result message. Passing that ID as resume appends new turns to the same stored history, which is right for follow-up work like "now implement the refactoring you suggested". Forking a session, via the fork_session (Python) or forkSession (TypeScript) option alongside resume, branches a new independent session from that point instead, leaving the original untouched.
| Option | What it does | Use it when |
|---|---|---|
| resume | Continuing a stored session: new turns append to the same history | Follow up on a completed task without re-reading files |
| fork_session / forkSession | Branching a session: a new session that starts from a copy of the original | Try an alternative approach without losing the original |
async for message in query(
prompt="Now implement the refactoring you suggested",
options=ClaudeAgentOptions(
resume=session_id,
allowed_tools=["Read", "Edit", "Write", "Glob", "Grep"],
),
):The fork-based pattern for exploring divergent approaches goes like this. First, run one session that does the shared analysis, such as reading the auth module and mapping its dependencies, and capture its session ID. Then fork that session once per approach you want to try: one branch attempts a JWT migration, another keeps sessions server-side, a third explores a hybrid. Each fork begins with the complete baseline analysis already in its context, so none of them repeats the reading, and because each is an independent branch, none of them pollutes the others or the original. Compare the branches, keep the winner, and the baseline is still there if you want a fourth attempt. This is the same idea as the subagent documentation's note that a subagent's conversation starts fresh unless it is a fork: a fork is the one way to hand an agent a shared starting point without retyping it into a prompt.
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.A subagent can see the coordinator's conversation, so it already knows what was discussed.Why is that wrong?
A subagent starts a new conversation. What reaches it is its own system prompt plus the task prompt the coordinator writes, so context has to be passed in explicitly.
Covered in Fresh context: the prompt string is the only way in
2.A detailed, accurate prompt field is what makes the coordinator choose a subagent.Why is that wrong?
The coordinator reads the description to decide when to delegate. The prompt only shapes behaviour once the subagent is running.
Covered in AgentDefinition: description, system prompt and tool restrictions
3.Leaving tools out of an AgentDefinition gives the subagent a safe, minimal tool set.Why is that wrong?
When tools is omitted, the subagent inherits every tool available to subagents. To restrict it, list the tools you want or use disallowedTools.
Covered in AgentDefinition: description, system prompt and tool restrictions
4.Spawning three independent subagents one per turn gets the same speed-up as spawning them together.Why is that wrong?
The parallel benefit comes from subagents running concurrently, which needs the coordinator to emit the spawning calls in a single response. One call per turn serialises the work.
Covered in The spawning tool, and why the coordinator must be allowed to call it
5.The most reliable research subagent prompt is a precise step-by-step procedure.Why is that wrong?
Open-ended research is path-dependent and cannot be hardcoded in advance. Prompts that state goals and quality criteria let the subagent adapt as it discovers things; step lists lock it into a guessed route.
Covered in The spawning tool, and why the coordinator must be allowed to call it
6.To try two alternative implementations from the same analysis, resume the session twice.Why is that wrong?
Resume appends to one history, so the second attempt would see the first. Fork branches an independent session from the shared baseline for each alternative and leaves the original intact.
Covered in Forking a session: divergent approaches from one analysis baseline
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://code.claude.com/docs/en/agent-sdk/subagentsOfficial docs
“Auto-approve these tools”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“Claude can invoke the built-in general-purpose subagent at any time via the Agent tool without you defining anything”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“multiple subagents can run concurrently, so independent subtasks finish in the time of the slowest one rather than the sum of all of them”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“description tells Claude when to use this subagent”
↩︎ AgentDefinition: description, system prompt and tool restrictions“A doc-reviewer subagent might only have access to Read and Grep tools”
↩︎ AgentDefinition: description, system prompt and tool restrictions“Array of allowed tool names. If omitted, inherits every tool available to subagents”
↩︎ AgentDefinition: description, system prompt and tool restrictions“only its final message returns to the parent”
↩︎ Fresh context: the prompt string is the only way in“The parent receives a concise summary, not every file the subagent read.”
↩︎ Fresh context: the prompt string is the only way in“each subagent runs in its own conversation, which starts fresh unless the subagent is a fork”
↩︎ Fresh context: the prompt string is the only way in“which starts fresh unless the subagent is a fork”
↩︎ Forking a session: divergent approaches from one analysis baseline“each subagent runs in its own conversation, which starts fresh unless the subagent is a fork”
↩︎ Key concept“each subagent runs in its own conversation, which starts fresh unless the subagent is a fork”
↩︎ Exam trap 1“description tells Claude when to use this subagent”
↩︎ Exam trap 2“Array of allowed tool names. If omitted, inherits every tool available to subagents”
↩︎ Exam trap 3“multiple subagents can run concurrently, so independent subtasks finish in the time of the slowest one rather than the sum of all of them”
↩︎ Exam trap 4 - 2.https://code.claude.com/docs/en/sub-agentsOfficial docs
“To prevent Claude from delegating to any subagent, deny the Agent tool itself with permissions.deny.”
↩︎ The spawning tool, and why the coordinator must be allowed to call it - 3.
“the lead agent analyzes it, develops a strategy, and spawns subagents to explore different aspects simultaneously”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“You can’t hardcode a fixed path for exploring complex topics, as the process is inherently dynamic and path-dependent.”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“Research demands the flexibility to pivot or explore tangential connections as the investigation unfolds.”
↩︎ The spawning tool, and why the coordinator must be allowed to call it“Each Subagent independently performs web searches, evaluates tool results using interleaved thinking, and returns findings to the LeadResearcher.”
↩︎ Fresh context: the prompt string is the only way in“passes all findings to a CitationAgent, which processes the documents and research report to identify specific locations for citations”
↩︎ Fresh context: the prompt string is the only way in“This ensures all claims are properly attributed to their sources.”
↩︎ Fresh context: the prompt string is the only way in“You can’t hardcode a fixed path for exploring complex topics, as the process is inherently dynamic and path-dependent.”
↩︎ Exam trap 5 - 4.https://code.claude.com/docs/en/agent-sdk/pythonOfficial docs
“The task for the agent to perform”
↩︎ Fresh context: the prompt string is the only way in - 5.
“It starts with a clean context, sees only the prompt the script gives it”
↩︎ Fresh context: the prompt string is the only way in - 6.https://code.claude.com/docs/en/agent-sdk/sessionsOfficial docs
“Try an alternative approach without losing the original”
↩︎ Forking a session: divergent approaches from one analysis baseline“Follow up on a completed task. The agent already analyzed something; now you want it to act on that analysis without re-reading files.”
↩︎ Forking a session: divergent approaches from one analysis baseline“Try an alternative approach without losing the original”
↩︎ Exam trap 6 - 7.
“Branching a session”
↩︎ Forking a session: divergent approaches from one analysis baseline