GuideOpen

Claude Managed Agents multiagent sessions

Managed Agents Multiagent Sessions is a shared guide in Anthropic's claude-api skill for developers whose agent work splits into independent pieces. A coordinator agent delegates to other agents inside one session, each in its own thread with separate history, model, prompt and tools, while all share the same container and filesystem.

What it does

Threads run in parallel and persist, so the coordinator can follow up with a subagent that keeps its earlier turns. Only each subagent's report returns, which keeps the coordinator's context small, and delegation tools are given automatically.

How to use it

Reach for it on jobs shaped like researching several sources or processing many files, starting with self delegation and then cheaper workers.

Requirements and limits

It uses the same managed-agents-2026-04-01 beta header as other session calls, with no extra header.

More in Guides and the Claude Code library.

Full text

Managed Agents - Multiagent Sessions

A coordinator agent can delegate to other agents within one session. All agents share the container and filesystem; each runs in its own thread - a context-isolated event stream with its own conversation history, model, system prompt, tools, MCP servers, and skills (from that agent's own config). Threads are persistent: the coordinator can send a follow-up to a subagent it called earlier and that subagent retains its prior turns.

The SDK sets the managed-agents-2026-04-01 beta header automatically on all client.beta.{agents,sessions}.* calls; no additional header is required for multiagent.


When to use it - start with self, then add cheaper workers

If the agent's work splits into independent pieces - several sources to research, many files or records to process, anything shaped like "look into N things, then summarize" - or one piece would fill its context with reading, use a multiagent session instead of one long single-threaded loop. Each delegated piece runs in its own thread with a fresh context window, threads run in parallel in the same container, and only each subagent's report comes back, so the coordinator's context stays small. There is no orchestration code to write: the coordinator is given delegation tools automatically and decides when to use them, and your client still creates one session and reads one stream. For work too big to hand out one task at a time (reviewing hundreds of documents, cross-checking many sources), dynamic workflows fit better than a roster - see § Dynamic workflows below.

Not for one question at a time. An agent that answers questions or solves problems one at a time (Q&A over documents, a tutoring solver, a support agent) works out each answer itself: no roster of extra solvers, checkers, voters or auditors that redo or grade the same answer, and no client-side second pass - a re-check loop, another session or another model call - that checks it, votes on it or asks for another answer. This holds however strongly the request stresses accuracy; each extra pass multiplies the cost of every answer. A check in your own code that calls no model - such as confirming each cited quote appears word for word in the source - is fine, and so is sending an answer that fails it back to the same session a few times at most. For accuracy, give the agent the documents and tools it needs, tell it in its system prompt to check its own work before it replies, and raise its effort above the model's default (model: {"id": ..., "effort": ...} - shared/managed-agents-core.md § Effort on the agent model). An advisor the agent consults mid-turn (§ Advisor) is a separate choice, not an extra pass. If the user explicitly asks for a checker, build it and say what it adds to the cost of every answer. A roster or a workflow run is for a question whose work splits into independent pieces: if one question needs many sources or files read, delegating that reading is still fine (Step 1), and a question that spans hundreds of documents can use dynamic workflows.

Step 1 - the smallest useful roster is the agent itself. Add a multiagent block whose only entry is {"type": "self"}. The coordinator can then hand self-contained sub-tasks to copies of itself - same model, system prompt, and tools, minus the ability to delegate further - and combine what they report. Nothing else changes.

agent = client.beta.agents.create(
    name="Research assistant",
    description="Researches a question end to end. A copy can be spawned to own one well-scoped sub-question.",
    model="claude-opus-5-5",
    system="You are a research assistant. When a request splits into independent sub-questions, delegate each to a copy of yourself, one self-contained task per copy, then verify and combine their reports.",
    tools=[{"type": "agent_toolset_20260401",
            "default_config": {"permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": True} for n in ("web_fetch", "web_search")]}],  # research needs the web
    multiagent={"type": "coordinator", "agents": [{"type": "self"}]},  # the only change vs. a single agent
)

session = client.beta.sessions.create(agent=agent.id, environment_id=env.id)  # unchanged

Step 2 - move the reading-heavy work to a cheaper model. Delegated research work is mostly searching, reading, and extracting: many input tokens, little hard reasoning. Create a second agent on a smaller current-generation model (Claude Haiku 5.5, or Claude Sonnet 5.5 when the worker needs more judgment) with a narrow system prompt and only the tools it needs, and list it next to self. A roster entry is only a reference: the worker runs on its own model, system, and tools, and its tokens are billed at its own model's rates. The large model spends its tokens on planning, checking, and synthesis; the small model does the bulk reading.

worker = client.beta.agents.create(
    name="Web researcher",
    description="Fast, low-cost, read-only researcher. Give it one well-scoped question; it searches, reads, and reports findings with sources.",
    model="claude-haiku-5-5",
    system="Answer exactly the question you are given. Search and read as much as you need, then report concise findings with a source URL or file path for every claim.",
    tools=[{
        "type": "agent_toolset_20260401",
        "default_config": {"enabled": False, "permission_policy": {"type": "auto"}},
        "configs": [{"name": n, "enabled": True} for n in ("read", "glob", "grep", "web_fetch", "web_search")],
    }],
)

lead = client.beta.agents.create(
    name="Research lead",
    description="Plans and synthesizes research. A copy can be spawned to own one large sub-analysis.",
    model="claude-opus-5-5",
    system="Plan the work. Delegate each independent, reading-heavy question to Web researcher, one self-contained task per spawn, several in parallel. Keep verification and the final synthesis for yourself; spawn a copy of yourself only for a sub-analysis that needs your full capability.",
    tools=[{"type": "agent_toolset_20260401",
            "default_config": {"permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": True} for n in ("web_fetch", "web_search")]}],  # the lead verifies sources itself
    multiagent={"type": "coordinator", "agents": [worker.id, {"type": "self"}]},
)

Step 3 - add dedicated specialists. When the sub-tasks call for different skills, give each its own agent - its own model, a narrow system prompt, and only the tools it needs - and roster them by ID next to self. Here the lead makes a change itself, sends the same review brief to several read-only reviewer threads for independent passes (one rostered agent can be spawned many times), and hands a test writer a self-contained brief; it then de-duplicates the findings, checks each against the code, and keeps the fix and the summary for itself.

reviewer = client.beta.agents.create(
    name="Concurrency reviewer",
    description="Read-only reviewer for race conditions, deadlocks, lost updates, and retry/idempotency bugs. Give it the changed file paths and the invariants that must hold; it reports findings with file:line evidence. Spawn several on the same change for independent reviews.",
    model="claude-sonnet-5-5",
    system="Review only the files you are pointed at. Look for concurrency bugs: unsynchronized shared state, lock ordering, non-atomic read-modify-write, retries without idempotency. Report each finding as file:line, the interleaving that triggers it, and a suggested fix; say plainly if you found none.",
    tools=[{"type": "agent_toolset_20260401", "default_config": {"enabled": False, "permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": True} for n in ("read", "glob", "grep")]}],
)
test_writer = client.beta.agents.create(
    name="Test writer",
    description="Writes and runs tests. Give it the module path, the behavior to pin down, and the test command; it adds test files, runs them, and reports results with output.",
    model="claude-sonnet-5-5",
    system="Write focused tests for the behavior you are given, run them with the command you are given, and report pass/fail, the relevant output, and the paths of files you added. Do not edit non-test code; if the code under test looks wrong, report that instead.",
    tools=[{"type": "agent_toolset_20260401", "default_config": {"enabled": True, "permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": False} for n in ("web_fetch", "web_search")]}],
)
lead = client.beta.agents.create(
    name="Engineering lead",
    description="Plans and makes code changes and integrates specialist reports. A copy can be spawned to own one independent change.",
    model="claude-opus-5-5",
    system="Make the change yourself. Then, in parallel, send the changed paths and invariants to three Concurrency reviewers and the module path and test command to Test writer. Merge and de-duplicate the reviewers' findings, check each against the code before acting on it, fix, and have Test writer re-run. Keep design decisions and the final summary for yourself.",
    tools=[{"type": "agent_toolset_20260401",
            "default_config": {"permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": False} for n in ("web_fetch", "web_search")]}],
    multiagent={"type": "coordinator", "agents": [reviewer.id, test_writer.id, {"type": "self"}]},
)

The same shape fits a pipeline of different specialists: a fast document extractor (for example on Claude Haiku 5.5) that writes one JSON file per input document, a verifier that checks each file against its source, and a lead that applies the corrections and writes the final table to /mnt/session/outputs/. Put the input and output paths in every task: threads share the container's filesystem, not each other's conversation.

  • Good fits: parallel research across sources; reading large amounts of material without filling the coordinator's context; specialists with narrow prompts and tool sets rather than one agent carrying every tool. Poor fit: a small single-step task - every delegation costs a round-trip and a re-briefing.
  • Write name and description for the coordinator to read. The coordinator chooses whom to spawn from each roster entry's name and description (the self entry is listed under the coordinator's own name), so say what each agent is good at and what to hand it. Names must be unique across the roster; don't name an agent self.
  • Say how to delegate in the coordinator's system prompt - what to hand off and to whom, how many at once, what to keep for itself, and what is too small to be worth delegating (the Delegating to subagents sample prompt in shared/model-migration.md is a starting point). Subagents see none of the coordinator's conversation, so each task must carry the paths, constraints, and report format it needs. Spawning returns immediately; the subagent's report arrives in a later coordinator turn.
  • Web tool domain lists layer, never widen. A roster agent's web_search / web_fetch calls are bound by its own allowed_domains / blocked_domains, by those of every agent that called it, and by the coordinator's current lists (allow-lists intersect, block-lists union). Keep each roster agent's allow-list inside the coordinator's - disjoint lists leave the tool present but every call fails url_not_allowed. See shared/managed-agents-tools.md § Web search & web fetch settings.
  • Too big to hand out one task at a time? For work like reviewing hundreds of documents, cross-checking many sources, or repeating the same step across many items, turn on dynamic workflows (with or without a roster) - see § Dynamic workflows below.
  • Limits: 1-20 roster entries (at most one self; each rostered agent can be spawned many times), one level of delegation (a roster member must not have its own multiagent), and at most 25 child threads per session, idle ones included - archive finished threads if a long session needs more (see Interrupting and archiving threads below).

The sections below are the reference for rosters, threads, events, and client-side handling; the platform guide is https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration.md.


Declare the roster on the coordinator

multiagent is a top-level field on agents.create() / agents.update() - not a tools[] entry. agents lists 1-20 roster entries. (The other variant, {"type": "multiagent_20261001"}, puts the roster under subagents.predefined_agents, turns dynamic workflows on unless workflows is {"type": "disabled"}, and turns delegating on unless subagents is - for a roster only, use coordinator. See § Dynamic workflows.) Nothing changes on sessions.create() - the roster is resolved from the coordinator's config.

orchestrator = client.beta.agents.create(
    name="Engineering lead",
    model="claude-opus-5-5",
    system="You coordinate engineering work. Delegate code review to the reviewer and test writing to the test agent.",
    tools=[{"type": "agent_toolset_20260401",
            "default_config": {"permission_policy": {"type": "auto"}},
            "configs": [{"name": n, "enabled": False} for n in ("web_fetch", "web_search")]}],
    multiagent={
        "type": "coordinator",
        "agents": [
            reviewer.id,                                            # bare string - latest version
            {"type": "agent", "id": test_writer.id, "version": 4},  # pinned version
            {"type": "self"},                                       # the coordinator itself
        ],
    },
)

session = client.beta.sessions.create(agent=orchestrator.id, environment_id=env.id)
Roster entryShapeNotes
String shorthand"agent_abc123"References the latest version of a stored agent.
Agent reference{type: "agent", id, version?}Omit version to pin the latest at coordinator save time.
Self{type: "self"}The coordinator can spawn copies of itself.
Advisor{type: "advisor", model}A model the session's primary thread can consult mid-turn. At most one per roster. See § Advisor below.

If the session was created with agent_with_overrides (see shared/managed-agents-core.md -> Override agent configuration for a session), those overrides apply to the coordinator and its self copies. Roster agents referenced by ID always use their own as-created configuration - overrides do not propagate to them.

The coordinator's thread receives delegation tools for working the roster: list_agents (see the roster) and send_to_agent (task or message a member). Up to 20 unique agents in the roster; the coordinator may spawn multiple copies of each. One level of delegation only - and it is enforced rather than silently flattened: rostering an agent that itself has multiagent set (either type) fails the create or update with a validation error.

Inference geo pins must be roster-uniform. When agents pin an inference geography (model.inference_geo - see shared/managed-agents-core.md § Pinning inference geography), the coordinator's pin and every roster member's must all be the same value or all be unset. A mismatched roster is a 400 validation error, both when the agent is saved and when a session-create model override changes any of the pins.


Dynamic workflows - for work too big to hand out one task at a time

When the agent's job is too big to hand out one task at a time - reviewing hundreds of documents, cross-checking many sources, repeating the same step across many items - turn on dynamic workflows. The agent can then write a plan that runs many agents in phases and combines what they return; the server carries out the plan in the background as a workflow run, so the agent can keep working or end its turn while the run goes on. This is multiagent: {"type": "multiagent_20261001", "workflows": {"type": "enabled"}} on the Managed Agents agent you are writing code for - not Claude Code's own dynamic workflows (its Workflow tool).

If the user has said they do not want dynamic workflows - in the request, or at any point while you build - leave them off, and say in your closing reply that they are off. For a roster only, use the coordinator type; if you use the multiagent_20261001 type, write workflows: {"type": "disabled"}, because workflows are on by default on that type. A user who has said nothing about dynamic workflows has not said no: when the work is too big to hand out one task at a time, turn them on.

What to tell the user. When you turn dynamic workflows on, say in your closing reply that they are on, what they do for this job (many agents work through its pieces in phases, in the background, where a roster would have to run them in batches), that every agent in a run uses tokens, so the session needs a budget, and how to turn them off (workflows: {"type": "disabled"}, or the coordinator type for a roster only).

An agent can run dynamic workflows with or without a roster and an advisor. A run's plan can use the agents you list in workflows.predefined_agents and define agents of its own; it doesn't use the roster.

  • Roster ({"type": "coordinator", "agents": [...]}, above): the work has several well-scoped tasks, or needs cheaper workers or specialists with their own system prompts and tools. Each agent works in its own session thread, which you can list and stream, and the roster can include an advisor.
  • Dynamic workflows ({"type": "multiagent_20261001", "workflows": {"type": "enabled"}}): the work is too big to hand out one task at a time, with more pieces than a session's 25 child threads can hold at once. Count the pieces in the whole job: if a roster would have to run them in batches to stay under the 25-child-thread limit, use dynamic workflows. The plan can run the agents listed in workflows.predefined_agents and agents it defines (see "What a run's agents get", below). You follow the run by its phases and can read each of its threads. The same agent can also have a roster (subagents) and an advisor (advisor).
  • Neither: simple or single-step agents, and agents that answer one question at a time when answering needs no fan-out. Every agent in a run uses tokens, so set a session budget when they are on (below).

To turn it on, set multiagent to the multiagent_20261001 type with workflows enabled. Workflows default to enabled on that type, but write it out. To let a run's plan use agents you've already created, list them: workflows: {"type": "enabled", "predefined_agents": [...]} (up to 20, same entry forms as a roster minus the advisor). workflows.inline_agents (default {"type": "enabled"}) set to {"type": "disabled"} stops the plan from defining its own agents; the list then needs at least one agent, or the request is a 400. subagents works the same way: subagents: {"type": "enabled", "predefined_agents": [...]} is the roster (optional, up to 20), and subagents.inline_agents (default {"type": "enabled"}) lets the agent also delegate to agents it defines itself; set to {"type": "disabled"}, the roster needs at least one agent, or the request is a 400. For an advisor, add advisor: {"type": "enabled", "model": ...} to the same block. On this type the advisor is only the advisor member - never a {"type": "advisor"} entry in subagents.predefined_agents. On create, a member you omit takes its default (workflows and subagents enabled, advisor disabled):

agent = client.beta.agents.create(
    name="Contract Reviewer",
    model="claude-opus-5-5",
    system="You review contracts. When you're asked to review more than a few contracts, start a workflow run that reads them in parallel and combines the findings. Review one or two contracts yourself, without a run.",
    tools=[{"type": "agent_toolset_20260401"}],
    multiagent={"type": "multiagent_20261001", "workflows": {"type": "enabled"}},
)

In TypeScript:

const agent = await client.beta.agents.create({
  name: "Contract Reviewer",
  model: "claude-opus-5-5",
  system: "You review contracts. When you're asked to review more than a few contracts, start a workflow run that reads them in parallel and combines the findings. Review one or two contracts yourself, without a run.",
  tools: [{ type: "agent_toolset_20260401" }],
  multiagent: { type: "multiagent_20261001", workflows: { type: "enabled" } },
});

In an ant apply agent file, the same multiagent block goes in the YAML frontmatter.

Use the SDK's own types. The SDK release that adds dynamic workflows has types for the multiagent_20261001 block (BetaManagedAgentsMultiagent20261001Params in Python and TypeScript) and for every workflow_run.* event. On an older release, ask the user to upgrade the SDK (Python 0.x to 1.x: python/claude-api/sdk-upgrade.md); if they decline, or no release has the types yet, build the request via cURL / ant and leave a note to upgrade. Don't cast the block or the events, or silence the type checker, to make an older SDK accept them.

With workflows on, always add a system-prompt line that says when to start a run. You describe the work in a user.message; the agent writes the plan and decides whether to start a run, so there is no API call that starts one. Turning workflows on gives the agent the ability to start runs, but it should also be prompted to use it. The contract-review agent above uses this system prompt:

You review contracts. When you're asked to review more than a few contracts, start a workflow run that reads them in parallel and combines the findings. Review one or two contracts yourself, without a run.

To adapt it, name the kinds of tasks in the agent's domain that call for a run, such as scanning a whole repository or checking many sources, and the small tasks the agent should do itself. Keep runs to the tasks that need them - never "always use a workflow run" - because every agent in a run uses tokens. A user can also ask for a run in a user.message.

The system prompt can also shape how a run does the work. The agent writes the plan from what its prompt says, so add lines like these when the job calls for them, worded for the agent's domain:

  • A second look, when a miss is costly (the user stresses accuracy or completeness, or the job is a review, an audit or research): "In a run, use one agent per contract. Then have a second agent review every contract, not only the flagged ones, and look for what the first one missed. Anything that fails review is redone and reviewed again." Reading in parallel and combining gives speed and coverage; the review of every item is what raises quality. It also adds about one more agent per item: say so in your closing reply, and past about 500 items have each agent take several, so that the run stays under its limit of 1,000 (§ Limits). Leave it out when the user wants the job cheap or fast. This is about the items of a run: it doesn't change "Not for one question at a time" (above).
  • When an agent fails: "One agent failing must not fail the run. List a contract whose agent failed as not covered."
  • The date and time: a run's agents don't know them. "Take the current time inside the workflow and give the date and time to every agent." Today the plan can read the clock (in UTC; the API doesn't promise it), so this works for an agent that has no bash.
  • A time limit: "Give the run a one-hour time limit." Only the agent can set a run's lifetime (§ Limits), and the default is 24 hours, so ask for a few times what the work should take.

Tell the user what you built on. In your closing reply, say that the agent is built on Claude Managed Agents, and, if you turned dynamic workflows on, say so. If you chose Managed Agents because the project already uses it, or because the user's CLAUDE.md or your memory files say they use it, say so in one sentence.

What a run's agents get. Each of a run's threads runs an agent listed in workflows.predefined_agents or an agent the plan defines. A listed agent runs with its own configuration, as a roster agent does when the coordinator delegates to it. An agent the plan defines gets its system prompt from the plan and runs on the session agent's model. It gets the session agent's tools, mcp_servers, and skills (all of them today; the API doesn't promise that), and its tools keep their permission policies. With no list, the plan defines every agent it runs. The server creates session threads for the run as its plan needs them (§ Following a run, below).

Rules:

  • Updating: an agents.update() that sends the multiagent_20261001 type to an agent that already has it is merged into the stored block, level by level. Every object you send needs its type. A key you omit keeps its stored value. A key you send as null goes back to its default, and so does every key inside it. A predefined_agents list you send replaces the stored list. A member you send with a type other than the stored one (disabled to enabled, say) is replaced whole, so send its inline_agents and predefined_agents with it. An update that leaves multiagent out keeps it all. Sent to an agent that has the coordinator type, the update replaces the whole block, so send the roster again as subagents.predefined_agents and the advisor as advisor.
  • Turning it off: send workflows: {"type": "disabled"} in an agents.update(); it stays off until an update turns it on again. Don't send workflows: null: null puts a member back to its default, and the default for workflows is enabled. For a roster only, switch to the coordinator type: a change of type replaces the whole block, so send the roster as agents, with any advisor as an entry in it.
  • Existing sessions copy the setting at create; changing the agent later doesn't change them.
  • An agent with multiagent set (either type) can't be rostered by another agent, or listed in another agent's workflows.predefined_agents.
  • An agent with a custom tool named ant__... accepts only an update that sends tools with no ant__ name - rename or remove the tool in the update that turns workflows on. A new session whose agent (after any overrides), or an agent in its roster or in workflows.predefined_agents, has such a tool is refused with a 400; existing sessions go on.
  • Budget: set a session budget when you create the session to cap its spend, runs included - you can't add one to an existing session (shared/managed-agents-core.md § Session budgets). Runs pause when the session reaches the budget, and runs the budget paused resume when you raise or remove it.

Following a run. You follow a run through its events; you don't see the plan itself or the agent's calls that start and manage runs. These events appear on the primary thread's stream, and listing the session's events returns them too. They have no webhooks.

EventPayload highlights
workflow_run.createdworkflow_run_id (starts with wrun_), the run's name (written by the model, or assigned by the server) and description (null when the plan gives none), phases (the plan's declared phases, each with an id, a name and a description); a status event follows
workflow_run.status_runningworkflow_run_id - the run is running; sent when the run starts to execute, which can be a while after created, and again on each resume after a pause at the budget (a resume after an interrupt might not send it; a run that is idle from the start might get workflow_run.status_idle first)
workflow_run.status_idleworkflow_run_id - the run was paused, for example at the session budget (the state's name is idle); the event doesn't say why, and a pause after an interrupt might not send it
workflow_run.status_endedworkflow_run_id, result (a union on type: {"type": "completed"}, {"type": "error", "error": {"type": ..., "message": ...}}, or {"type": "stopped"}) - always the run's last status event
workflow_run.errorworkflow_run_id (null when no run was created), error (type and message, the same fields as result.error) - reports a run's error, or a start the server refused. A start at the limit of open runs (10 by default) is refused with error.type max_workflow_runs_error, which appears only on this event, with workflow_run_id null. A run that ends with result.type: "error" sends this event first, with the same error, and then workflow_run.status_ended; keep tracking the run until status_ended arrives
workflow_run.phase_startedworkflow_run_id, workflow_run_phase_id (today always a phase's id in phases; the event has no name, so look it up there, and fall back to the id)
workflow_run.phase_endedworkflow_run_id, workflow_run_phase_id, phase_started_id

The text continues at the source. Read the rest.

Source and license

Source: https://github.com/anthropics/skills/blob/main/skills/claude-api/shared/managed-agents-multiagent.md

Author: anthropics, Anthropic skills. License: Apache-2.0.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The Claude Code library holds 13,843 entries. Members can search all of them by meaning and read every one in full.