Why multi-agent?
A single agent can struggle with large or diverse tasks. Multi-agent systems let you:- Give each agent a narrow, well-defined role (developer, reviewer, researcher)
- Use different models for different jobs — a powerful model for reasoning, a fast cheap model for routine tasks
- Parallelize work by running multiple agents concurrently
- Keep tool permissions minimal — each agent only gets the tools it actually needs
The coordinator / sub-agent pattern
The root agent acts as a coordinator. When it needs help with a specialized task, it delegates to a sub-agent using the built-intransfer_task tool.
Coordinator decides who to delegate to
The root agent analyzes the request and selects the most appropriate sub-agent based on each agent’s
description.Sub-agent handles the task
The sub-agent runs its own agentic loop — calling its tools, reasoning, and producing a result.
The sub_agents field
List the names of sub-agents on the coordinator. Docker Agent automatically provides the transfer_task tool:
dev-team.yaml
The
transfer_task tool is always auto-approved — no user confirmation needed. This allows seamless, uninterrupted delegation between agents.Running a multi-agent config
Sequential vs. parallel delegation
- Sequential (transfer_task)
- Parallel (background_agents)
transfer_task is the default delegation mechanism. The coordinator waits for the sub-agent to finish before continuing. Best when the result of one task determines what happens next.The handoff tool
For delegation to remote agents (running as A2A servers), use thehandoff toolset instead of sub_agents:
agent.yaml
Multi-model teams
A key advantage of multi-agent systems is using the best model for each role. Use named models to keep configs readable:multi-code.yaml
Shared tools
Some toolsets can be shared across agents so they all read and write the same state. This is useful for coordinated task tracking:agent.yaml
Best practices
- Keep agents focused — each agent should have a clear, narrow role
- Write clear descriptions — the coordinator relies on
descriptionto choose who to delegate to - Give minimal tools — only give each agent the tools it needs for its specific job
- Give the coordinator the
thinktool — this lets it reason carefully about delegation decisions - Match model to role — use capable models for complex reasoning, fast/cheap models for routine tasks
Next steps
Background agents
Dispatch work to sub-agents concurrently.
Handoff tool
Delegate to remote agents via A2A.
A2A protocol
Interoperate with other agent frameworks.
Agent configuration reference
Full reference for all agent config fields.