What you will be able to do
- Configure a coordinator and predefined subagents in a Managed Agents multiagent block
- Choose between subagents, dynamic workflows and an advisor in Managed Agents
- Define specialised subagents with AgentDefinition in the Agent SDK
- Choose between subagents, agent teams and dynamic workflows in Claude Code
1.Managed Agents: the multiagent block
A coordinator works the same way on every platform. It delegates to subagents, and each subagent runs in an isolated context and returns only a condensed result (see the companion page on designing multi-agent systems). What changes from platform to platform is where you declare the coordinator, its specialists and the alternatives to subagents. In Claude Managed Agents, you declare them in the multiagent block of the agent definition. With type multiagent_20261001, subagents and dynamic workflows are both on by default, and you can also give the session an advisor.
The table below talks about threads, so one definition first. Each agent in a session runs in its own session thread: a context-isolated event stream with its own conversation history. The agent that the session runs reports in the primary thread, the session-level event stream, and every delegated agent gets an additional thread spawned at runtime. Whether a thread can be messaged again after its agent reports is what separates subagents from workflow runs.
| Approach | Who directs the work | Choose it when | Watch for |
|---|---|---|---|
| Subagents | The agent delegates and reads each report. A subagent's thread persists, so the agent can send follow-ups | The agent needs to follow up with a subagent, or needs listed specialists with their own system prompts and tools | Delegation is one level deep, with at most 25 child threads per session, idle ones included |
| Dynamic workflows | A program the agent writes runs many agents in phases in the background and combines their results | Most work that needs several agents: audits, migrations, deep research, cross-checking | No follow-ups to a run's threads, and every agent uses tokens, so set a session budget |
| Advisor | One agent does the work and consults an advisor model mid-turn | One agent should do the work, with stronger judgment at planning or final review | Only the primary thread can consult it, and consultations are billed at the advisor model's rates |
You decide which of these the agent may use, and the agent decides when to use them. Steer that decision in the system prompt, for example by telling the agent when to start a workflow run. The coordinator below is a lead that lists two specialists by ID. Its system prompt is a short routing brief: send review work to the reviewer and test writing to the test writer. The reviewer and test writer are separate agents running claude-haiku-5-5, each with its own one-line system prompt.
---
name: Engineering Lead
model: claude-opus-5-5
tools:
- type: agent_toolset_20260401
multiagent:
type: multiagent_20261001
subagents:
type: enabled
predefined_agents:
- type: agent
id: $REVIEWER_AGENT_ID
- type: agent
id: $TEST_WRITER_AGENT_ID
---
You coordinate engineering work. Delegate code review to the reviewer agent
and test writing to the test agent.Checkpoint 1 of 5· Fill the gap
The Engineering Lead must hand review and test writing to two specialists you have already created, each with its own system prompt, and must be able to send them follow-up questions after they report. Which key under the multiagent block completes this definition?
---
name: Engineering Lead
model: claude-opus-5-5
tools:
- type: agent_toolset_20260401
multiagent:
type: multiagent_20261001
? :
type: enabled
predefined_agents:
- type: agent
id: $REVIEWER_AGENT_ID
- type: agent
id: $TEST_WRITER_AGENT_ID
---
You coordinate engineering work. Delegate code review to the reviewer agent
and test writing to the test agent.Use subagents when the agent needs listed specialists with their own system prompts and tools, or needs to follow up with them. A subagent's thread persists, so follow-ups work. A dynamic workflow's threads can't receive follow-ups. An advisor is a model that the primary thread consults while it does the work itself, so it doesn't delegate to listed agents.
Source: platform.claude.comSources1
2.Predefined and inline agents, and the limits on them
Each subagent is either predefined or inline. A predefined agent is one you have already created and listed. It runs with its own model, system prompt, tools, MCP servers and skills. An inline agent isn't saved anywhere. The coordinator, or a workflow, defines it at the moment it hands out the work, and it uses the coordinator's model, tools, MCP servers and skills. Inline agents are on by default, so unless you turn them off, the coordinator can create helpers you never reviewed.
Inline agents have no definition of their own, so you can't use one to narrow their access. They take on the MCP servers and tools of the agent the session runs. To give a specialist tools the coordinator doesn't have, make it a predefined agent. In the GitHub example, only a predefined researcher declares the GitHub MCP server, so the coordinator never has access to it. To allow only the agents you list, set inline_agents to {"type": "disabled"} under subagents and under workflows. Each setting with inline agents off needs at least one agent in its list, or the request fails with a 400 error.
{
"multiagent": {
"type": "multiagent_20261001",
"subagents": {
"type": "enabled",
"inline_agents": { "type": "disabled" },
"predefined_agents": ["agent_01J8XkN5uT3vHpLqRfWdY2", { "type": "self" }]
},
"workflows": {
"type": "enabled",
"inline_agents": { "type": "disabled" },
"predefined_agents": [
{ "type": "agent", "id": "agent_01Lm4cV8yQ2tNs7XbKdR5h", "version": 2 }
]
}
}
}The two predefined_agents lists are separate. Listing an agent under subagents does not make it available to workflows, and the reverse is also true. Four rules apply to both lists:
- Pinning: when you create or update the coordinator, each referenced agent is pinned to its version at that moment. Later edits to that agent don't reach the coordinator until you update the coordinator's list.
- One level: listing an agent that has its own
multiagentblock fails with a 400 validation error. - Up to 20 agents per list: the coordinator can still run several copies of each one, within the session's thread limit.
- Same inference geography: every listed agent must pin the same
inference_geoas the coordinator, or none of them may pin one.
Checkpoint 2 of 5· Check yourself
A helper needs to call the GitHub MCP server, but the coordinator must never get GitHub access itself. Which setup gives only the helper that access?
An inline agent has no definition of its own, so it can only use the coordinator's MCP servers and tools. A specialist that needs a tool the coordinator lacks has to be a predefined agent that declares the tool in its own definition.
“An inline agent has no agent definition, so it uses the MCP servers and tools of the agent that the session runs.”Source: platform.claude.com
Checkpoint 3 of 5· Check yourself
After the Engineering Lead coordinator is created, you edit the reviewer agent it lists and save a new version. The coordinator itself is left unchanged. What happens when the lead next delegates review work?
When the coordinator is created or updated, each agent it references is pinned to the version current at that moment. To delegate to the newer reviewer, update the coordinator so its list references that version.
“Referenced agents stay pinned to the versions resolved then and don't pick up later updates to their definitions.”Source: platform.claude.com
Sources1
3.Agent SDK: defining subagents with AgentDefinition
In the Claude Agent SDK, the coordinator is the agent that query() runs, and you declare its specialists in the agents option. Each one is an AgentDefinition keyed by name. There are two other routes. You can write agents as markdown files in .claude/agents/ directories. And Claude can call the built-in general-purpose subagent through the Agent tool without you defining anything. Include Agent in the coordinator's allowed_tools so it can delegate without asking for approval.
"code-reviewer": AgentDefinition(
# description tells Claude when to use this subagent
description="Expert code review specialist. Use for quality, security, and maintainability reviews.",
# prompt defines the subagent's behavior and expertise
prompt="""You are a code review specialist with expertise in security, performance, and best practices.
When reviewing code:
- Identify security vulnerabilities
- Check for performance issues
- Verify adherence to coding standards
- Suggest specific improvements
Be thorough but concise in your feedback.""",
# tools restricts what the subagent can do (read-only here)
tools=["Read", "Grep", "Glob"],
# model overrides the default model for this subagent
model="sonnet",
),| Field | Required | Design role |
|---|---|---|
| description | Yes | Tells the coordinator when to use this subagent, which makes it the routing signal |
| prompt | Yes | The subagent's system prompt: its role, expertise and constraints |
| tools | No | Allowed tools. If omitted, the subagent inherits every tool available to subagents |
| disallowedTools | No | Removes named tools. mcp__server removes every tool from that MCP server |
| model | No | Per-agent model: an alias such as 'haiku', 'inherit', or a full model ID |
| maxTurns | No | Caps agentic turns. At the limit, the output comes back marked as partial |
The same example defines a second specialist, test-runner, with Bash, Read and Grep. It gets Bash because running tests is its job. The reviewer stays read-only. Each specialist gets the tools its brief calls for, and no more.
Checkpoint 4 of 5· Fill the gap
This code-reviewer specialist must be able to inspect the codebase but never change it. Which tool name completes its tools list without breaking that guarantee?
"code-reviewer": AgentDefinition(
# description tells Claude when to use this subagent
description="Expert code review specialist. Use for quality, security, and maintainability reviews.",
# prompt defines the subagent's behavior and expertise
prompt="""You are a code review specialist with expertise in security, performance, and best practices.
When reviewing code:
- Identify security vulnerabilities
- Check for performance issues
- Verify adherence to coding standards
- Suggest specific improvements
Be thorough but concise in your feedback.""",
# tools restricts what the subagent can do (read-only here)
tools=["Read", "Grep", " ? "],
# model overrides the default model for this subagent
model="sonnet",
),Glob only finds files, so the reviewer stays read-only. Edit, Write and Bash can all change files. A reviewer that has them can modify code by accident, while a reviewer without them can't. Only the test-runner gets Bash, because its job is running test commands.
Source: code.claude.comSources2
4.Claude Code: subagents, agent teams or a dynamic workflow
Claude Code offers several ways to run work in parallel. Three of them are coordination patterns, and each one fits a different kind of work.
| Pattern | What it is | Use it when |
|---|---|---|
| Subagents | Delegated workers inside one session that do a side task in their own context and return a summary | A side task would flood the main conversation with search results, logs or file contents you won't need again |
| Agent teams | Multiple coordinated sessions with a shared task list and inter-agent messaging, managed by a lead. Experimental and off by default | Claude should split a project into pieces, assign them, and keep the workers in sync |
| Dynamic workflows | A script that runs many subagents and cross-checks their results | The job outgrows a handful of subagents, or findings need to be verified against each other |
The main difference is how the workers communicate. Subagents talk only to the session that started them, and each returns a single summary, so they suit isolated side tasks such as investigating one bug across dozens of files. Teammates in an agent team are peer sessions. They share a task list and message one another, which helps when pieces of a project depend on each other's progress. That shared state also brings back the coordination cost that subagents avoid. A dynamic workflow takes coordination out of the conversation entirely: a script runs the subagents and checks their results against each other, for jobs too big to manage one turn at a time. Agent teams are a Claude Code feature. They are experimental and must be turned on before use.
Checkpoint 5 of 5· Check yourself
In Claude Code, you want to find out why one test fails intermittently. That means reading CI logs and dozens of source files. You need only the root cause back, and the main conversation should stay focused on your feature work. Which coordination pattern fits?
A subagent fits one side task that would flood the main conversation with logs and file contents you won't need again. Its tool calls stay in its own context, and only its final summary comes back. An agent team is for keeping several interdependent workers in sync. It also brings back coordination cost. A dynamic workflow is for jobs too big for a handful of subagents, or for findings that must be checked against each other.
“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”Source: code.claude.com
Sources3
Practise it for real
Create a Managed Agents coordinator that delegates code review and test writing to two predefined subagents. You write each agent as a markdown file, ant apply creates the agents from those files, and claude-lock.json records the ID it assigned to each file under a .resources map keyed by file path.
1.Write reviewer.md and test-writer.md, each with a name, model: claude-haiku-5-5 and a one-line system prompt. Run ant apply reviewer.md test-writer.md.
Why: Predefined subagents must exist before a coordinator can list them by ID, and
ant applyis the command that creates them from the files.You should see: claude-lock.json now holds an ID for each file under .resources.
2.Read the IDs with jq -er '.resources["./reviewer.md"].id' claude-lock.json, and do the same for test-writer.md.
Why: The coordinator's predefined_agents list references agents by ID, and the lock file is where those IDs are recorded.
You should see: Two agent IDs in shell variables.
3.Write engineering-lead.md with model claude-opus-5-5, a multiagent block of type multiagent_20261001 that lists both IDs under subagents.predefined_agents, and a routing system prompt. Run ant apply on all three files.
Why: The coordinator definition pins both subagents at their current versions and tells the lead when to use each.
You should see: The lead agent is created. Listing an agent that has its own multiagent block would fail with a 400 instead.
4.Create a session with client.beta.sessions.create(agent=lead_agent.id, environment_id=environment.id) and ask for a review and tests. Here client is your API client, lead_agent is the lead you just created, and environment is an existing environment for the session to run in; have these ready before this step.
Why: Delegation happens at runtime: the lead decides when to call each subagent.
You should see: The lead reports in the primary thread, and each delegated subagent appears as its own session thread.
Stuck? Get a nudge
If you also want to block helpers you didn't define, set subagents.inline_agents to {"type": "disabled"}. Your list already has entries, so the 400 error won't trigger.
Sources
(3)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Delegation is one level deep, and a session can have at most 25 child threads at a time, idle ones included.”
↩︎ Managed Agents: the multiagent block“each agent runs in its own session thread, a context-isolated event stream with its own conversation history.”
↩︎ Managed Agents: the multiagent block“A subagent's thread stays available until you archive it, so the agent can send it follow-up messages.”
↩︎ Managed Agents: the multiagent block“The agent can't send follow-up messages to a run's threads, and the server archives each one by the end of its run.”
↩︎ Managed Agents: the multiagent block“An inline agent has no agent definition, so it uses the MCP servers and tools of the agent that the session runs.”
↩︎ Predefined and inline agents, and the limits on them“subagents.predefined_agents and workflows.predefined_agents are two separate lists.”
↩︎ Predefined and inline agents, and the limits on them“Inline agents are on by default under both settings.”
↩︎ Predefined and inline agents, and the limits on them“The predefined_agents list of subagents can list up to 20 unique agents.”
↩︎ Predefined and inline agents, and the limits on them“Referenced agents stay pinned to the versions resolved then and don't pick up later updates to their definitions.”
↩︎ Exam trap 1“Referencing another agent that has multiagent set fails the create or update request with a 400 validation error.”
↩︎ Exam trap 2“Referenced agents stay pinned to the versions resolved then and don't pick up later updates to their definitions.”
↩︎ Checkpoint - 2.https://code.claude.com/docs/en/agent-sdk/subagentsOfficial docs
“Filesystem-based: define agents as markdown files in .claude/agents/ directories.”
↩︎ Agent SDK: defining subagents with AgentDefinition“Claude can invoke the built-in general-purpose subagent at any time via the Agent tool without you defining anything”
↩︎ Agent SDK: defining subagents with AgentDefinition“intermediate tool calls and results stay inside the subagent; only its final message returns to the parent.”
↩︎ Checkpoint - 3.https://code.claude.com/docs/en/agentsOfficial docs
“Delegated workers inside one session that do a side task in their own context and return a summary”
↩︎ Claude Code: subagents, agent teams or a dynamic workflow“Multiple coordinated sessions with a shared task list and inter-agent messaging, managed by a lead. Experimental and disabled by default”
↩︎ Claude Code: subagents, agent teams or a dynamic workflow“A script that runs many subagents and cross-checks their results, for work too big to coordinate one turn at a time”
↩︎ Claude Code: subagents, agent teams or a dynamic workflow