Multi-Agent Orchestration
10 min read
Design patterns for coordinating multiple specialized agents — orchestrators, subagents, and parallel execution.
A single agent with many tools can handle diverse tasks, but as complexity grows it becomes unwieldy: the tool list grows long, reasoning quality degrades, and errors are hard to isolate. Multi-agent systems address this by decomposing work across specialized agents, each with a focused role and a smaller tool set.
Orchestrator and subagent pattern
The most common multi-agent pattern is an orchestrator-subagent hierarchy. An orchestrator agent receives the high-level task, breaks it into sub-tasks, and delegates each to a specialized subagent. Subagents return results to the orchestrator, which synthesizes them into a final answer. The orchestrator is the planner; subagents are the executors.
async def research_pipeline(topic: str) -> str:
# Orchestrator dispatches to specialists
search_result = await subagent(
name="search-agent",
task=f"Find the 5 most relevant sources about: {topic}",
)
analysis = await subagent(
name="analysis-agent",
task=f"Summarize and extract key insights from these sources:\n{search_result}",
)
draft = await subagent(
name="writer-agent",
task=f"Write a 3-paragraph briefing from these insights:\n{analysis}",
)
return draftParallel vs. sequential execution
Sequential orchestration runs subagents one at a time, feeding each output into the next. Parallel orchestration runs independent subtasks concurrently and joins results before the next step. Identify the dependency graph of sub-tasks first: tasks that do not depend on each other's outputs can run in parallel, cutting total wall-clock time significantly.
Communication between agents
- Shared message passing: orchestrator passes context in the subagent prompt
- Shared state store: agents read and write to a common key-value store or database
- Event-driven: agents emit events that other agents subscribe to
- Tool calls as delegation: the orchestrator calls subagents as if they were tools
Failure handling in multi-agent systems
Failures in multi-agent pipelines compound. A subagent returning an incorrect result can corrupt all downstream steps. Design for failure by validating subagent outputs before passing them on, retrying with error context injected, and having the orchestrator detect and reroute around persistent failures rather than propagating bad state silently.
Multi-agent systems multiply costs: each subagent call consumes tokens independently. Measure and budget per pipeline, not per call, and consider whether a single well-prompted agent achieves the same result at lower cost before splitting into multiple agents.
Give each agent a unique name or identifier in its system prompt. This helps trace errors back to the specific agent responsible, which is essential when debugging complex multi-agent pipelines.