Skip to content
CCAR-FAcademy
Domain 1 · Statement 1.3 3 of 7
1.3

Configure subagent invocation, context passing, and spawning

  • allowedTools on the coordinator must include "Task" — without it the coordinator physically cannot spawn subagents.
  • Subagents inherit no parent context and share no memory across invocations, so every needed finding must be pasted into the subagent prompt.
  • An AgentDefinition carries a routing-oriented description, a role/system prompt, and least-privilege tool restrictions.
  • Pass context as structured data that keeps metadata (source URL, document name, page number) separate from content so attribution survives the handoff.
  • Emit multiple Task calls in one coordinator response to get real parallelism; separate turns serialize the fan-out.
  • Write coordinator prompts as goals plus quality criteria, not procedural step lists, so subagents can adapt.
  • Fork-based session management passes a shared analysis baseline to divergent explorations by inheritance rather than by pasting it into each prompt — every branch starts from identical context.

This statement is the mechanical half of 1.2: how a coordinator actually spawns and feeds subagents in the Claude Agent SDK.

The Task tool and allowedTools

Subagents are spawned with the Task tool. A coordinator that cannot see it cannot delegate, no matter how good its prompt is — so allowedTools on the coordinator must include the spawning tool. This is a favorite exam detail: a stem describes a coordinator that "keeps doing the work itself instead of delegating", and the correct answer is the missing allowedTools entry, not a prompt rewrite.

Task is the guide's spelling and the one to answer with. In the shipping SDK the tool was renamed to Agent (Claude Code v2.1.63) — current releases emit "Agent" in tool_use blocks while still reporting "Task" in the system:init tool list, which is why real detection code matches both.6 So on the exam: the missing-Task option is the credited one. In your own code: list "Agent", or the coordinator you build from this page will reproduce the exact bug this page teaches you to diagnose.

AgentDefinition

Each subagent type is declared as an AgentDefinition with three parts:7

Part What it holds Why it carries weight
description How the coordinator recognizes when this subagent applies It is doing selection work — write it as a routing signal, not a label
System prompt The subagent's role, output contract and quality bar None of the coordinator's reasoning is inherited, so this is the only place the role is stated
Tool restrictions Least privilege for that role A synthesis agent that cannot search cannot wander off and start researching

Context must be explicit

Because subagents have isolated context, complete findings from prior agents must be included directly in the subagent's prompt. If the synthesis subagent needs the web-search results and the document-analysis output, the coordinator pastes them in. There is no ambient state and no shared scratchpad by default, and nothing carries between two invocations of the same subagent type unless you deliberately arrange it. Two mechanisms in the shipping SDK do arrange it — resuming a subagent by its agentId, which restores its full history, and the memory field, which gives it a persistent notes directory of its own — but neither is what the guide means by context passing, and neither removes the requirement to put the other agents' findings in the prompt.6

That makes the format of passed context load-bearing. Use structured data that separates content from metadata — source URL, document name, page number, retrieval timestamp — as distinct fields rather than prose. Attribution survives the handoff, and the synthesis agent can cite precisely instead of guessing which claim came from which source.

Parallelism and prompt style

To run subagents concurrently, the coordinator must emit multiple Task tool calls in a single response.8 Spreading them across separate turns serializes them and multiplies latency — and repeatedly signals to the model that one-at-a-time is the expected shape.

Finally, coordinator prompts should specify research goals and quality criteria, not step-by-step procedures. Procedural scripts freeze the plan at design time and remove exactly the adaptability you spawned subagents to get. Say "every claim must carry a source URL and no sector may be unaddressed"; do not say "first call search with these five queries".

Fork-based context passing

Everything above passes context forward by writing it into a prompt. Fork-based session management is the complementary mechanism: rather than re-serializing a baseline into each new unit's prompt, fork_session branches from a session that already holds it, so every branch starts from the identical shared analysis baseline.9 It is the one case where a divergent exploration does not need its context pasted in — it inherits it by construction.

That makes it the right choice when the baseline is expensive and the branches genuinely start from the same place: map a codebase once, then explore two approaches from it. It is the wrong choice when the branches need different slices of context, which is ordinary prompt-level context passing. (1.7 covers the operational decision between resuming, forking and restarting.)

Spawning subagents with the Task toolShow that parallel subagents come from multiple Task calls in one coordinator response, and that each Task prompt must carry its own complete context.CoordinatorCoordinatorTask toolTask toolSearch subagentSearchsubagentAnalysis subagentAnalysissubagentSynthesis subagentSynthesissubagenttwo Task callsin one responseprompt withassigned subtopicprompt withassigned documentsstructured findingswith source URLsstructured findingswith page numbersthird Task callafter results arriveprompt containingall prior findingsciteddraftparallel
Spawning subagents with the Task tool

Show that parallel subagents come from multiple Task calls in one coordinator response, and that each Task prompt must carry its own complete context.

Declaring subagents and enabling delegation

Scenario 3 · Multi-Agent Research System

Each subagent is an AgentDefinition with a description written to help the coordinator route, a system prompt that states the output contract, and a minimal tool set. Note that the synthesis agent gets no search tools at all — least privilege keeps it synthesizing — and that the coordinator's allowedTools includes "Task".

typescript
const agents: Record<string, AgentDefinition> = {
  'web-search': {
    description:
      'Finds current public sources for ONE assigned subtopic. Use when the query needs recent or external information.',
    prompt:
      'You research a single assigned subtopic. Return JSON only: ' +
      '{ findings: [{ claim, sourceUrl, sourceTitle, retrievedAt }] }. ' +
      'Do not synthesize across subtopics; that is another agent\'s job.',
    tools: ['WebSearch', 'WebFetch'],
  },
  'document-analysis': {
    description:
      'Extracts claims from supplied documents. Use when the coordinator has PDFs or files rather than web sources.',
    prompt:
      'Analyze only the documents provided. Return JSON: ' +
      '{ findings: [{ claim, documentName, pageNumber }] }.',
    tools: ['Read', 'Grep'],
  },
  synthesis: {
    description:
      'Combines findings supplied in the prompt into a cited narrative. Never gathers new information.',
    prompt:
      'You synthesize ONLY the findings given to you. Cite every claim with the ' +
      'sourceUrl or documentName/pageNumber attached to it. Flag contradictions explicitly.',
    tools: [], // least privilege: cannot search, cannot wander
  },
};

const coordinatorOptions = {
  agents,
  // Without the spawning tool the coordinator cannot spawn ANY subagent.
  // "Task" is the guide's spelling; the shipping SDK renamed it to "Agent"
  // in Claude Code v2.1.63, so real code lists "Agent" here.
  allowedTools: ['Task', 'Read', 'Write'],
  systemPrompt: coordinatorSystemPrompt,
};
AgentDefinition set plus the required "Task" entry

Passing complete findings with attribution preserved

Scenario 3 · Multi-Agent Research System

A common bug: the coordinator sends the synthesis subagent a prose paragraph summarizing what search found. The synthesis agent then produces a plausible report with invented or misattributed citations, because the URLs were never actually passed.

The fix is to pass the complete findings as structured data, with metadata in named fields. The synthesis agent's prompt then contains everything it needs and every claim is traceable. This is also why the synthesis agent's tool list is empty: it should never need to go looking for a source that should already be in its prompt.

typescript
// Coordinator builds the synthesis prompt from prior agents' raw outputs.
const synthesisPrompt = [
  'Synthesize the findings below into a report on: ' + topic,
  '',
  'Quality criteria: every claim cites its source; no sector unaddressed;',
  'contradictions between sources are surfaced, not averaged.',
  '',
  'FINDINGS (JSON — content and metadata are separate fields):',
  JSON.stringify(
    {
      webFindings: webSearchResult.findings,   // { claim, sourceUrl, sourceTitle, retrievedAt }
      docFindings: docAnalysisResult.findings, // { claim, documentName, pageNumber }
      sectorsAssigned: enumeratedSectors,
    },
    null,
    2,
  ),
].join('\n');

// Spawn synthesis via the Task tool with the FULL context inline —
// it inherits nothing from this conversation.
Explicit, structured context handed to the synthesis subagent

Parallel fan-out in a single response

Scenario 4 · Developer Productivity with Claude

A developer-productivity agent must map an unfamiliar service: read the routing layer, read the data models, and read the test suite. These are independent. If the coordinator emits one Task call, waits for the result, then emits the next, wall-clock time is the sum of three subagent runs.

Emitting all three Task calls in the same assistant response runs them concurrently and the coordinator receives three results before its next decision. The coordinator prompt should say so explicitly — "when subtasks are independent, spawn them in the same response" — because the default conversational rhythm is one-at-a-time.

markdown
## Delegation

When two or more subtasks are independent (different files, different modules,
different source types), emit ALL of their Task calls in the SAME response so
they execute in parallel. Only serialize when a subtask genuinely needs a
previous subtask's result as input.

Each Task prompt must be self-contained: the subagent inherits none of this
conversation. Include the goal, the exact scope assigned to it, the output
format, and any findings from earlier agents it needs to do its job.
Coordinator instruction that produces real parallelism

Passing a shared baseline by inheritance instead of by prompt

Scenario 4 · Developer Productivity with Claude

Two ways to give two divergent explorations the same starting knowledge of a codebase, and the choice is a context-passing choice.

Prompt-level passing: run the mapping analysis once, summarize it, and paste that summary into two fresh subagent prompts. That is the right shape when the two units need different slices of context — but as a way to share one baseline it is lossy twice over. Whatever the mapping pass noticed and did not write down is gone, and each branch pays again to re-derive it.

Fork-based passing: run the mapping analysis once as a session, then fork_session from it for each branch. Every branch inherits the whole baseline — each file read, each dependency observed — with nothing re-serialized and nothing dropped, and each branch's later work stays out of the other's context. Use it when the baseline is expensive and the branches start from the same place; use explicit prompt context when they do not.

  • Omitting "Task" from the coordinator's allowedTools while relying on the system prompt to request delegation because the coordinator has no mechanism to spawn subagents and will silently do the work itself.
  • Assuming a subagent can see the coordinator's conversation history or a previous invocation's findings instead of passing them explicitly in the prompt because subagent context is isolated and nothing carries over.
  • Passing prior findings as a prose summary instead of structured data with separate metadata fields because source URLs, document names and page numbers are lost and the synthesis agent fabricates or misattributes citations.
  • Spawning parallel subagents across separate coordinator turns instead of emitting multiple Task calls in one response because the fan-out serializes and latency multiplies.
  • Writing coordinator prompts as step-by-step procedures instead of goals plus quality criteria because it removes the subagent adaptability that motivated the multi-agent design.
  • A stem where "the coordinator never delegates" or "subagents are never invoked" is the allowedTools spawning-tool item — check configuration before prompt wording. The guide spells it "Task"; that is the credited spelling.
  • When an option says a subagent "will have access to the earlier analysis", treat it as false unless that analysis is explicitly in the prompt; isolated context is tested directly.
  • Latency-reduction items often hinge on whether parallel Task calls are emitted in one response versus across turns — read the option for where the calls are emitted, not just whether they are described as "parallel".
Beyond the exam — what the API does that this does not grade

The spawning tool's real name. Claude Code v2.1.63 renamed Task to Agent. Current SDK releases emit "Agent" in tool_use blocks, but still report "Task" in the system:init tools list and in result.permission_denials[].tool_name. Detection code that must work across SDK versions checks both: block.name === 'Agent' || block.name === 'Task'.

Getting allowedTools wrong does not raise a warning. Without the spawning tool listed, spawn attempts fall through to your canUseTool callback — or, in dontAsk mode, are denied outright. The coordinator then does the work itself, which is exactly the symptom this section teaches you to diagnose.

References — 4 sources
  1. Subagents in the SDK Anthropic The "What subagents inherit" table, and the note that the spawning tool was renamed from `Task` to `Agent` in Claude Code v2.1.63.
  2. Agent SDK reference — TypeScript Anthropic The authoritative `AgentDefinition` field list, which is where you confirm the three fields taught here are the tested three rather than the only three.
  3. Parallel tool use Anthropic How multiple `tool_use` blocks in one assistant message are executed and returned together — the API layer beneath concurrent subagent spawning.
  4. Work with sessions (Agent SDK) Anthropic The actual fork contract — `resume` plus `forkSession` — and the warning that forking branches history, not the filesystem.
All sources verified ·

Live product docs — where they differ from the exam guide, answer from the guide. All references

Exam guide, verbatim — what is measured

Knowledge of

  • The Task tool as the mechanism for spawning subagents, and the requirement that allowedTools must include "Task" for a coordinator to invoke subagents
  • That subagent context must be explicitly provided in the prompt—subagents do not automatically inherit parent context or share memory between invocations
  • The AgentDefinition configuration including descriptions, system prompts, and tool restrictions for each subagent type
  • Fork-based session management for exploring divergent approaches from a shared analysis baseline

Skills in

  • Including complete findings from prior agents directly in the subagent's prompt (e.g., passing web search results and document analysis outputs to the synthesis subagent)
  • Using structured data formats to separate content from metadata (source URLs, document names, page numbers) when passing context between agents to preserve attribution
  • Spawning parallel subagents by emitting multiple Task tool calls in a single coordinator response rather than across separate turns
  • Designing coordinator prompts that specify research goals and quality criteria rather than step-by- step procedural instructions, to enable subagent adaptability
Back to top