What you will be able to do
- Explain why a hub-and-spoke coordinator routes all subagent communication through itself, and what that buys in observability, error handling and information flow
- Write delegation prompts that carry everything a context-isolated subagent needs, including decisions made earlier in the main conversation
- Design a coordinator that analyzes each query and invokes only the subagents it needs, instead of always running the full pipeline
- Partition a broad research topic across subagents so that coverage is complete and work is not duplicated
- Build an iterative refinement loop in which the coordinator finds gaps in a synthesis, re-delegates targeted queries and decides when coverage is enough
Key concept
Hub-and-spoke coordinator — One coordinator agent breaks the task down, delegates each piece to a subagent, collects what comes back and combines it. Subagents never talk to each other directly. Everything passes through the hub, which is the only agent that sees the whole picture.
1.Why every message goes through the coordinator
In a coordinator-subagent system, one agent sits at the centre and all the others are spokes. The coordinator splits the user's request into subtasks, gives each one to a subagent, reads each subagent's report and builds the final answer. Anthropic's Research feature works this way: a lead agent reads the query, plans a strategy and spawns subagents that explore different aspects of it in parallel. Their findings come back to the lead agent, which writes the answer.
The shape follows from how subagents work. Each subagent runs in its own conversation, and only its final message comes back to the parent (Subagents start with no parent context). The consequence for architecture is that spokes cannot see each other's work. A search subagent never sees what the analysis subagent concluded, and neither of them sees the user's earlier turns. If one spoke's output should shape another spoke's task, the coordinator has to read it and write it into the next delegation prompt. No other path exists.
This applies to the user's decisions as well as to subagent findings. Say the user picked an authentication provider three turns ago in the main conversation, and the coordinator then delegates an integration task. The subagent has never seen that turn. If the provider's name is not in the prompt text the coordinator sends, the subagent will choose one itself. The fix is to put the decision in the delegation prompt. Resuming the subagent's session won't help: a resumed subagent picks up its own earlier conversation with its full context, and that conversation never contained the user's turn. Widening tool permissions won't help either, because tools control what a subagent can do, not which conversation it can read. And a subagent's system prompt sets its role and expertise; it has no built-in rule for overriding the user.
Routing everything through the hub gives you three things.
- Observability. Every delegation and every result passes through one agent, so one transcript shows what was asked and what came back. In Managed Agents, each subagent also works in its own session thread, which you can list and stream.
- Consistent error handling. The coordinator applies the same checks to every result. The orchestrator-workers cookbook, for example, validates that workers return non-empty responses. A subagent that hits its
maxTurnslimit returns output marked as partial, and the coordinator decides whether to resume it, delegate again or go on without it. - Controlled information flow. Each spoke receives only what the coordinator chooses to send. That keeps its context focused and stops subagents from flooding each other with updates.
Checkpoint 1 of 7· Check yourself
A coordinator agent delegates an integration task to a subagent. Three turns earlier in the main conversation, the user chose a specific authentication provider. The subagent picks a different provider. What should the architect change?
Each subagent starts in its own new conversation and never sees the user's earlier turns. The coordinator is the only path, so the decision has to be in the delegation prompt. Resuming won't help because a resumed subagent continues its own conversation, which never held that turn. Tool permissions control what a subagent can do, not which conversation it can read. A system-prompt rule can't make the subagent defer to a decision it has never seen.
“Context isolation: each subagent runs in its own conversation, which starts fresh unless the subagent is a fork.”Source: code.claude.com
2.Selecting subagents per query instead of running the full pipeline
A coordinator does more than forward requests: it decides which spokes a request needs. Applied at the coordinator level, Prompt chaining vs dynamic decomposition means the coordinator picks which subagents to invoke, and with what scope, based on the query and on what it has found so far. In the orchestrator-workers pattern, subtasks are not fixed in advance. The orchestrator works them out from the specific input, which is what makes the pattern more adaptive than a predefined parallel workflow.
In the Agent SDK, the main thing the coordinator uses to decide is each subagent's description field, a natural-language statement of when that agent should be used. The developer decides which subagents exist, and the coordinating agent decides when to call each one. Write a vague description and the coordinator either calls a subagent at the wrong times or never calls it.
"test-runner": {
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"]
}Running every stage for every input is a common way to get this wrong. Picture a ticket-triage system that sends each ticket through a classifier, a sentiment analyzer, a knowledge-base search, a summarizer and an escalation checker, including one-line tickets that only need classifying. Every extra agent costs tokens, and in Anthropic's testing multi-agent setups use 3 to 10 times more tokens than a single agent doing the same task. Anthropic's early research agents made the same mistake from the other direction: they spawned 50 subagents for simple queries.
The fix is an analysis step at the start. The orchestrator-workers pattern begins with a planning phase in which the orchestrator reads the task and produces structured subtask descriptions. The coordinator can do the same with a cheap first call that returns a structured plan saying how complex the query is and which spokes it needs. The coordinator then invokes only those spokes.
Two tempting shortcuts don't help. Running all five subagents in parallel cuts wall-clock time to roughly that of the slowest one, but the system still pays for all five on every ticket. Parallelism is mainly for thoroughness, not speed, and multi-agent systems often take longer overall than a single agent because they do so much more total work. Removing the coordinator and letting the classifier call the other subagents directly gets rid of the hub, and with it the observability, consistent error handling and control over information flow from the previous section.
| Situation | Better fit | Reason |
|---|---|---|
| Subtasks are predictable and the same for every input | Predefined parallel stages | No analysis step is needed, so simpler parallelization is enough |
| The subtasks that matter depend on the specific input | Coordinator selects workers at runtime | The orchestrator works out the subtasks from the input instead of using a hardcoded set |
| Simple, single-output request | Little or no delegation | Extra agents add complexity and latency without adding value |
Checkpoint 2 of 7· Fill the gap
In this Agent SDK subagent definition, which field does the coordinating agent read to decide when to invoke the subagent?
"test-runner": {
? :
"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"]
}description is a plain-language statement of when to use the agent, and the coordinator reads it to decide whether this spoke fits the query. prompt sets what the subagent does once it has been called. initialPrompt only applies when the agent runs as the main thread and is ignored for subagents.
Checkpoint 3 of 7· Check yourself
Your ticket-triage system sends every ticket through five subagents: classifier, sentiment analyzer, knowledge-base search, summarizer and escalation checker. Token costs are too high, and most one-line tickets only need classifying. Which change addresses the problem?
The coordinator should work out the subtasks from each input and invoke only those spokes. Running all five in parallel shortens wall-clock time but still pays for all five on every ticket. Removing the hub throws away observability, consistent error handling and control over information flow.
“The orchestrator decides at runtime what subtasks to create, making this more adaptive than pre-defined parallel workflows.”Source: platform.claude.com
3.Partitioning research scope across subagents
Once the coordinator has decided to fan out, how it splits the work determines what the final answer covers. Each subagent should get its own distinct slice of the topic, such as a subtopic, a set of sources or a type of source, so that no two subagents search the same ground. Distinct slices also give each subagent its own tools, prompts and line of exploration, which reduces path dependency and lets each investigation run independently.
async def research_topic(query: str) -> dict:
# Lead agent breaks query into research facets
facets = await lead_agent.decompose_query(query)
# Spawn subagents to research each facet in parallel
tasks = [
research_subagent(facet)
for facet in facets
]
results = await asyncio.gather(*tasks)
# Lead agent synthesizes findings
return await lead_agent.synthesize(results)The facets list in that code is the full scope of the research. Nothing outside it gets searched. If the coordinator turns a broad question into a few detailed technical slivers, every subagent can do excellent work and the report will still have gaps: pricing models, regulatory incentives and the major competitors were never assigned to anyone. This is a coverage failure, not a quality failure. Thin search results, a premature synthesis or a budget shortfall would look different.
A good split has two properties, and both need checking. The facets together must cover the whole question: for a market landscape, that means competitors, pricing, regulation and technology, not two kinds of technology. And the facets must not overlap, so that two subagents don't both search the same ground. Splitting by source type is a useful second axis. One subagent searches filings, another searches news and a third searches technical documentation, each within the same broad scope.
Checkpoint 4 of 7· Fill the gap
In this fan-out, each subagent gets one item from a list. Which value goes in the blank, and so sets everything the research will cover?
async def research_topic(query: str) -> dict:
# Lead agent breaks query into research facets
facets = await lead_agent.decompose_query(query)
# Spawn subagents to research each facet in parallel
tasks = [
research_subagent(facet)
for facet in ?
]
results = await asyncio.gather(*tasks)
# Lead agent synthesizes findings
return await lead_agent.synthesize(results)Each subagent gets only the facet it was assigned, not the whole query. Synthesis then combines only what those subagents return. So the facets list the lead agent produces is the full scope of the research, and any part of the question that no facet covers never reaches the report.
4.The coordinator's iterative refinement loop
One round of fan-out and synthesis is where the work starts. Anthropic's lead research agent synthesizes what its subagents return, then decides whether more research is needed. If it is, the agent creates more subagents or changes its strategy, and it leaves the loop only once it has gathered enough information. Research can't follow a hardcoded path, because the useful next step depends on what the last round found.
Each pass through the loop has the same steps.
- The coordinator reads the current synthesis against the original question and lists what is missing, unsupported or contradictory.
- For each gap it writes a targeted query, such as 'regulatory incentives for charging networks in the EU', rather than repeating the broad one.
- It sends those queries to search and analysis subagents. These can be new spokes or ones it used before.
- It runs synthesis again with the new findings and checks coverage again.
Going back to an earlier spoke is cheaper than starting a new one when that spoke already holds useful context. That option exists in Managed Agents, the Claude Platform's multiagent orchestration, where one agent coordinates others within a single session and each subagent works in its own session thread. Unlike a fresh subagent call, which starts with an empty conversation, a subagent's thread persists: the coordinator can send a follow-up to a subagent it called before, and that subagent keeps everything from its earlier turns. A brand-new subagent knows only what the coordinator writes into its prompt, so the hub's job of routing information applies on every pass.
The loop also needs a way to stop. Anthropic's simulations showed agents carrying on after they already had enough results. So give the coordinator an explicit test for sufficient coverage, such as every facet of the question answered with supporting findings, and back it with a hard cap. maxTurns limits how many agentic turns a subagent can take, and a session budget caps total spend.
No. The coordinator should send a targeted query about that competitor to a search subagent, or follow up with the one that mentioned it. Then it passes the new findings to synthesis and runs synthesis again. The coordinator handles routing, and each spoke stays in its own role.
Checkpoint 5 of 7· Exam question
An architect delegates a task to a subagent using the Agent tool, expecting it to reference a decision the user made three turns earlier in the main conversation about which authentication provider to use. The subagent's response ignores that decision entirely and proposes a different provider. What is the most likely cause, and how should the architect fix it?
Correct answer: C — The subagent's context starts fresh each call, so the decision must be included directly in the Agent tool's prompt text
- A. Subagents don't cache or partially load prior turns; they simply never receive the parent conversation at all, so there is no stale copy to resume.
- B. Tool permissions govern which actions a subagent can take, not whether it receives conversation history, so widening tool access would not surface the missing decision.
- C. Correct. A subagent's context window starts fresh and does not automatically inherit the parent's conversation history, so any needed decisions must be passed explicitly in the Agent tool's prompt string.
- D. A custom system prompt defines the subagent's role and expertise; it doesn't override user decisions, and disabling it would remove needed specialization without fixing the missing context.
Checkpoint 6 of 7· Exam question
A support-ticket triage system always invokes a full pipeline of five subagents (classifier, sentiment analyzer, knowledge-base search, summarizer, and escalation checker) for every incoming ticket, including simple one-line requests that only need classification. Response times have become unacceptable. How should the coordinator be redesigned?
Correct answer: A — Have the coordinator assess each ticket's complexity by running a dedicated lightweight classification prompt that returns a structured JSON object with fields like complexity (e.g., low, medium, high) and required_subagents, then dynamically invoke only the subagents listed in that output.
- A. This directly addresses how to measure complexity on the coordinator: use a structured prompt contract that scores complexity and lists required subagents. Anthropic guidance recommends defining explicit output formats (e.g., JSON fields for severity, recommended owner, and similar) and using lightweight models like Claude Haiku for triage. The coordinator consumes this JSON and invokes only the listed subagents, avoiding the full five-subagent pipeline for simple tickets. Add few-shot examples and confidence thresholds, routing low-confidence classifications to a human review queue.
- B. Collapsing all subagents into one sequential process removes the coordinator but still runs every step for every ticket, including steps a simple ticket does not need. This does not fix the overprocessing problem and loses the separation of concerns and specialized tool/context isolation that Anthropic's multi-agent orchestration supports.
- C. Parallelism can reduce wall-clock latency, but it still invokes all five subagents for every ticket, wasting compute and tokens on unnecessary steps. Anthropic's guidance emphasizes complexity-aware delegation and dynamic invocation rather than running the full pipeline in parallel for all requests.
- D. Removing the coordinator does not follow the recommended orchestrator-subagent pattern. Anthropic documents a lead agent or coordinator as responsible for task decomposition and delegation, which keeps routing logic separate and manageable. Embedding that responsibility inside the classifier can reduce clarity and may introduce coordination challenges.
Checkpoint 7 of 7· Exam question
A coordinator for a market-research assistant splits the broad query 'analyze the competitive landscape for electric vehicle charging networks' into narrow subtasks like 'find charger connector types' and 'list charging speeds,' each assigned to a separate subagent. The synthesized report ends up missing pricing models, regulatory incentives, and major competitors entirely. What went wrong?
Correct answer: D — The coordinator broke the topic into a few detailed technical areas, so the remaining parts of the landscape had no subagent assigned
- A. Limited search access would weaken the findings on the assigned subtasks, but the report is missing whole topics that no subagent was asked to research. Better tooling would still leave those topics unaddressed.
- B. Starting synthesis early would drop results from subtasks that were assigned. Pricing, incentives and major competitors were never assigned to any subagent, so waiting for every subagent would not have added them.
- C. The assigned subtasks, such as connector types and charging speeds, are distinct from one another, so duplicated effort and a spent budget do not explain the gaps. The missing areas were never part of the task list.
- D. Correct. The coordinator turned a wide topic into a few detailed technical subtasks, so nothing in the plan covered pricing, regulation or competitors. The synthesized report could only reflect the subtasks that were assigned.
Sources
(6)
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
“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”
↩︎ Why every message goes through the coordinator“each subagent runs in its own conversation, which starts fresh unless the subagent is a fork.”
↩︎ Why every message goes through the coordinator“When the agent reaches the limit, Claude Code returns its output marked as partial, and you can resume the agent to continue.”
↩︎ Why every message goes through the coordinator“Natural language description of when to use this agent”
↩︎ Selecting subagents per query instead of running the full pipeline“Maximum number of agentic turns before the agent stops.”
↩︎ The coordinator's iterative refinement loop“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”
↩︎ Key concept“each subagent runs in its own conversation, which starts fresh unless the subagent is a fork.”
↩︎ Exam trap 1“Context isolation: each subagent runs in its own conversation, which starts fresh unless the subagent is a fork.”
↩︎ Checkpoint - 2.https://code.claude.com/docs/en/sub-agentsOfficial docs
“Claude resumes the subagent with full context from previous conversation”
↩︎ Why every message goes through the coordinator - 3.
“each agent runs in its own session thread, a context-isolated event stream with its own conversation history.”
↩︎ Why every message goes through the coordinator“Each subagent works in its own session thread, which you can list and stream.”
↩︎ Why every message goes through the coordinator“You decide which of these the agent can use, and the agent determines when to use them.”
↩︎ Selecting subagents per query instead of running the full pipeline“Parallelization: Fan out independent subtasks simultaneously (searching multiple sources, analyzing separate files) and have the agent synthesize the results.”
↩︎ Partitioning research scope across subagents“Coordinate multiple agents within a single session.”
↩︎ The coordinator's iterative refinement loop“The agent can send a follow-up to a subagent it called earlier, and that subagent retains everything from its previous turns.”
↩︎ The coordinator's iterative refinement loop“set a session budget to cap the session's spend, runs included”
↩︎ The coordinator's iterative refinement loop - 4.
“Error handling validates that workers return non-empty responses”
↩︎ Why every message goes through the coordinator“subtasks aren't pre-defined, but determined by the orchestrator based on the specific input.”
↩︎ Selecting subagents per query instead of running the full pipeline“generates structured subtask descriptions in XML format”
↩︎ Selecting subagents per query instead of running the full pipeline“The orchestrator decides at runtime what subtasks to create, making this more adaptive than pre-defined parallel workflows.”
↩︎ Checkpoint - 5.
“the lead agent analyzes it, develops a strategy, and spawns subagents to explore different aspects simultaneously.”
↩︎ Why every message goes through the coordinator“Early agents made errors like spawning 50 subagents for simple queries”
↩︎ Selecting subagents per query instead of running the full pipeline“which reduces path dependency and enables thorough, independent investigations.”
↩︎ Partitioning research scope across subagents“The LeadResearcher synthesizes these results and decides whether more research is needed”
↩︎ The coordinator's iterative refinement loop“Once sufficient information is gathered, the system exits the research loop”
↩︎ The coordinator's iterative refinement loop“You can’t hardcode a fixed path for exploring complex topics, as the process is inherently dynamic and path-dependent.”
↩︎ The coordinator's iterative refinement loop“agents continuing when they already had sufficient results”
↩︎ The coordinator's iterative refinement loop“The LeadResearcher synthesizes these results and decides whether more research is needed”
↩︎ Exam trap 4 - 6.
“multi-agent implementations typically use 3-10x more tokens than single-agent approaches for equivalent tasks”
↩︎ Selecting subagents per query instead of running the full pipeline“multi-agent systems often take longer overall than single-agent systems because of the sheer increase in total computation.”
↩︎ Selecting subagents per query instead of running the full pipeline“The core implementation decomposes a question into independent facets, runs subagents concurrently, then synthesizes the results.”
↩︎ Partitioning research scope across subagents“The primary benefit of parallelization is thoroughness, not speed.”
↩︎ Exam trap 2“The core implementation decomposes a question into independent facets, runs subagents concurrently, then synthesizes the results.”
↩︎ Exam trap 3