What you will be able to do
- Explain how a coordinator spawns a subagent through the Agent tool (called Task in older SDK versions), and what listing it in allowedTools does
- Configure an AgentDefinition with a description, a system prompt and tool restrictions for each subagent type
- Explain why independent subagents should be launched in parallel rather than one after another
- Fork a session from a shared analysis baseline to explore a divergent approach without changing the original session
Key concept
Subagent as an isolated, delegated conversation — A subagent is a separate conversation that the coordinator starts through the Agent tool. The coordinator chooses it by its description and limits what it can do through its definition. The subagent never sees the coordinator's turns. Only its final message comes back to the coordinator.
1.The Agent tool: how a coordinator spawns a subagent
In the Claude Agent SDK, a coordinator delegates work by calling a tool. Exam questions and older code call it the Task tool. Current SDK versions emit it under the name Agent. The SDK's own detection sample checks for both names, so code that watches for subagent calls should do the same. Each call carries a subagent_type, which names the subagent that was picked.
# Check for subagent invocation. Match both names: older SDK
# versions emitted "Task", current versions emit "Agent".
if hasattr(message, "content") and message.content:
for block in message.content:
if isinstance(block, ToolUseBlock) and block.name in (
"Task",
"Agent",
):
print(f"Subagent invoked: {block.input.get('subagent_type')}")You can define subagents in code with the agents option of query(), or as markdown files in .claude/agents/. Claude can also call a built-in general-purpose subagent without any definition from you. Every coordinator sample in the docs also adds the tool to allowed_tools / allowedTools. The exam guide states this as a requirement: the coordinator's allowed tools must include "Task" (now "Agent"). Be precise about what that list does. The SDK reference calls it a list of tools to *auto-approve*, not a whitelist. Tools not on it fall through to permissionMode and canUseTool. Listing Agent means delegation runs without a permission prompt. To actually block a tool, use disallowedTools.
Checkpoint 1 of 8· Fill the gap
This coordinator should delegate to its subagents without a permission prompt. Which tool name completes the auto-approve list?
# Auto-approve these tools
allowed_tools=["Read", "Grep", "Glob", " ? "],Subagents are spawned through the Agent tool (Task in older SDKs). The documented coordinator lists it with the read-only tools so delegation is auto-approved.
Source: code.claude.comCheckpoint 2 of 8· Check yourself
A developer sets allowedTools to ["Read", "Agent"] and expects Claude to be unable to use any other tool. What is actually true?
The SDK reference describes allowedTools as an auto-approve list that does not restrict Claude to the listed tools. Blocking is done with disallowedTools.
“Tools to auto-approve without prompting. This does not restrict Claude to only these tools.”Source: code.claude.com
Checkpoint 3 of 8· Exam question
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.
2.AgentDefinition: description, system prompt, tool restrictions
Each subagent type is an AgentDefinition keyed by name. The fields have different jobs. description is what the coordinator reads to decide *when* to delegate. prompt is the subagent's own system prompt, which sets *how* it behaves after it is spawned. A detailed prompt does nothing for routing if the description is vague, because the coordinator chooses by description.
AGENTS = {
"endpoint-finder": AgentDefinition(
description="Locates and catalogs API endpoints in a codebase.",
prompt="You find and document API endpoints. Report each endpoint's path, method, and handler.",
tools=["Read", "Grep", "Glob"],
)
}| Field | Required | What it controls |
|---|---|---|
| description | Yes | Natural-language description of when to use this agent; the coordinator routes on it |
| prompt | Yes | The subagent's system prompt: its role and behaviour |
| tools | No | Allowed tool names; if omitted, the subagent inherits every tool available to subagents |
| disallowedTools | No | Tool names removed from the subagent's tool set |
| model | No | Model override such as 'sonnet', 'haiku' or 'inherit' |
Restricting tools does two things. It lowers the risk of unintended actions: a reviewer limited to Read and Grep can inspect files but cannot change them. It also saves context, because every tool definition takes space. The agent-loop docs recommend scoping each subagent to the smallest set of tools it needs. Leaving tools out does not make a subagent safe. It gets every tool available to subagents.
Checkpoint 4 of 8· Check yourself
A doc-reviewer subagent must never modify files. Which AgentDefinition setting enforces that?
The tools field limits the subagent to the listed tools. If you leave it out, the subagent gets every available tool, and a description affects routing, not permissions.
“A doc-reviewer subagent might only have access to Read and Grep tools, ensuring it can analyze but never accidentally modify your documentation files.”Source: code.claude.com
Checkpoint 5 of 8· Exam question
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.
Checkpoint 6 of 8· Exam question
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.
3.Spawning subagents in parallel
The SDK docs give the code-review case directly: style-checker, security-scanner and test-coverage subagents can run at the same time instead of one after another. Anthropic's Research system learned this from experience. Its early agents ran searches one at a time, which was very slow. The fix was to have the lead agent launch 3–5 subagents in parallel, and to have each subagent call 3 or more tools in parallel. The engineering post reports that this cut research time by up to 90% on complex queries.
Checkpoint 7 of 8· Check yourself
What did Anthropic change after its early research agents proved slow?
Their first fix for speed was having the lead agent launch subagents in parallel. The second was having each subagent call 3 or more tools in parallel.
“the lead agent spins up 3-5 subagents in parallel rather than serially”Source: www.anthropic.com
4.Forking a session to explore divergent approaches
Subagents are not the only way to explore alternatives. Sessions have their own tool for it. Suppose an agent has already analyzed the auth module in one session. That session is your shared analysis baseline. Resuming it appends to the same history, so a second approach would overwrite the first thread. Forking instead branches from the baseline into a new session. The fork starts with the baseline's analysis, so nothing has to be re-read, and it then diverges on its own. The sessions docs list this as the choice when you want to try an alternative approach without losing the original. In the SDK you pass resume with the baseline's session ID and also set fork_session (Python) or forkSession (TypeScript). The fork option only applies together with resume.
prompt="Instead of JWT, outline how OAuth2 would work for the auth module",
options=ClaudeAgentOptions(
resume=session_id,
fork_session=True,
max_turns=5,
),The sample captures the fork's session ID from the result message. That ID is distinct from the baseline's, so each branch can be resumed on its own later. Resuming the baseline ID continues the original thread, untouched by the fork. To compare several approaches, fork once per approach from the same baseline ID.
Checkpoint 8 of 8· Check yourself
An agent analyzed the auth module in session A, which suggested JWT. You want to try OAuth2 from that analysis without losing the JWT thread. What do you do?
Forking branches from the baseline into a new session, so the original session is untouched. Plain resume appends to the same history, and a query without resume starts fresh.
“When resuming with resume, fork to a new session ID instead of continuing the original session”Source: code.claude.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Putting tools in allowedTools restricts the coordinator to those tools only.Why is that wrong?
allowedTools only auto-approves the listed tools. Tools not on it fall through to permissionMode and canUseTool, and disallowedTools is what removes a tool.
Covered in The Agent tool: how a coordinator spawns a subagent
2.A detailed subagent prompt is what makes the coordinator delegate to it.Why is that wrong?
The coordinator decides when to delegate from the description field. The prompt only shapes the subagent's behaviour once it is running.
Covered in AgentDefinition: description, system prompt, tool restrictions
3.Launching independent subagents one per turn costs about the same time as launching them together.Why is that wrong?
Subagents that run concurrently finish in the time of the slowest one. Launching them one after another adds up all their run times.
Covered in Spawning subagents in parallel
4.Resuming a session with a new prompt is the way to try an alternative approach while keeping the original analysis intact.Why is that wrong?
Resume continues the original session. Forking creates a new session ID, and the original session stays as it was.
Covered in Forking a session to explore divergent approaches
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
“emitted "Task", current versions emit "Agent".”
↩︎ The Agent tool: how a coordinator spawns a subagent“Built-in general-purpose: Claude can invoke the built-in general-purpose subagent at any time via the Agent tool without you defining anything”
↩︎ The Agent tool: how a coordinator spawns a subagent“description tells Claude when to use this subagent”
↩︎ AgentDefinition: description, system prompt, tool restrictions“If omitted, inherits every tool available to subagents”
↩︎ AgentDefinition: description, system prompt, tool restrictions“multiple subagents can run concurrently, so independent subtasks finish in the time of the slowest one rather than the sum of all of them.”
↩︎ Spawning subagents in parallel“description tells Claude when to use this subagent”
↩︎ Exam trap 2“A doc-reviewer subagent might only have access to Read and Grep tools, ensuring it can analyze but never accidentally modify your documentation files.”
↩︎ Checkpoint - 2.https://code.claude.com/docs/en/agent-sdk/typescriptOfficial docs
“Tools to auto-approve without prompting. This does not restrict Claude to only these tools.”
↩︎ The Agent tool: how a coordinator spawns a subagent“When resuming with resume, fork to a new session ID instead of continuing the original session”
↩︎ Forking a session to explore divergent approaches“Tools to auto-approve without prompting. This does not restrict Claude to only these tools.”
↩︎ Exam trap 1 - 3.https://code.claude.com/docs/en/agent-sdk/agent-loopOfficial docs
“Use the tools field on AgentDefinition to scope subagents to the minimum set they need.”
↩︎ AgentDefinition: description, system prompt, tool restrictions“It does not see the parent’s turns, and only its final response returns to the parent as a tool result.”
↩︎ Key concept - 4.
“the lead agent spins up 3-5 subagents in parallel rather than serially”
↩︎ Spawning subagents in parallel“Our early agents executed sequential searches, which was painfully slow.”
↩︎ Exam trap 3 - 5.https://code.claude.com/docs/en/agent-sdk/sessionsOfficial docs
“Original session is untouched; resuming it continues the JWT thread”
↩︎ Forking a session to explore divergent approaches“Original session is untouched; resuming it continues the JWT thread”
↩︎ Exam trap 4 - 6.https://code.claude.com/docs/en/agent-sdk/pythonOfficial docs
“When resuming with resume, fork to a new session ID instead of continuing the original session”
↩︎ Forking a session to explore divergent approaches