CertSafari
    Anthropic Claude Certified Architect – Foundations (CCAR-F)· Lessons

    Domain 1 · Lesson 3/30

    Spawning Subagents: the Agent (Task) Tool and AgentDefinition

    Configure subagent invocation, context passing, and spawning

    12 min read
    3.86% of exam
    6 sources
    Published 4 Oct 2026
    Docs as of 30 Sep 2026

    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.

    Detecting a subagent invocation in the message stream. Older SDKs emit "Task" and current ones emit "Agent"python
            # 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", " ? "],

    Checkpoint 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?

    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?

    Sources12

    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.

    A read-only subagent definition: the description handles routing, the prompt sets behaviour, and tools limits what it can dopython
    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"],
        )
    }
    The AgentDefinition fields this objective tests
    FieldRequiredWhat it controls
    descriptionYesNatural-language description of when to use this agent; the coordinator routes on it
    promptYesThe subagent's system prompt: its role and behaviour
    toolsNoAllowed tool names; if omitted, the subagent inherits every tool available to subagents
    disallowedToolsNoTool names removed from the subagent's tool set
    modelNoModel 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?

    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?

    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?

    Sources13

    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?

    Sources14

    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.

    Forking from a baseline session to outline an OAuth2 approach. The fork gets its own session ID, and the original stays on the JWT threadpython
                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?

    Sources526

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 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. 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. 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. 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. 1.
      “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. 2.
      “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. 3.
      “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. 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. 5.
      “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. 6.
      “When resuming with resume, fork to a new session ID instead of continuing the original session”
      ↩︎ Forking a session to explore divergent approaches

    Continue to page 2 of 2

    Subagent Context Passing, Coordinator Prompts and Session Forking

    Spotted a mistake, or was something unclear? Tell us.