Multi-agent systems
Learn how to structure multi-agent architectures with orchestrators and specialists, when parallel subagents save time, and how to handle failures when individual agents go wrong.
TL;DR
- Multi-agent systems pair a coordinating orchestrator with specialized worker agents. The orchestrator decomposes and routes; workers execute and return typed results.
- For fully independent subtasks, parallel execution approaches latency = max(T_i), not sum(T_i). Ten 30-second tasks can finish in about 30 seconds rather than 300 seconds, subject to startup, quota, and aggregation overhead.
- Typed agent communication (Pydantic schemas, TypedDict) prevents the most common multi-agent bug: free-text handoffs that propagate malformed data silently into the synthesis step.
- Failure isolation is mandatory. One worker failing must not cancel the entire workflow. Use
return_exceptions=Truein async gather, retry once, then flag partial results. - Cost scales with the number of agents, tool calls, tokens, and selected model prices. A multi-agent run can cost several times a single-agent run without per-agent budgets; use current prices and measured token counts for estimates.
- The engineering decision this enables: when a task exceeds one context window or benefits from specialization, replace the overloaded single agent with a typed, budgeted multi-agent pipeline.
30-second mental model
A multi-agent system is a distributed workflow whose workers happen to use models. An orchestrator defines the dependency graph, workers have narrow responsibilities, and typed contracts carry results between them. Parallelism helps only when tasks are independent; otherwise it adds coordination, cost, and more places for a failure to hide.
5-minute explanation
First draw the dependency graph. Run independent retrieval or analysis tasks concurrently, then join their results before any dependent synthesis step. Give each worker a scoped tool set, input/output schema, deadline, token budget, and trace identifier. The orchestrator should preserve partial results, classify failures, and decide whether to retry, degrade, or stop.
Use the smallest number of agents that creates a measurable benefit. A single well-scoped agent or deterministic pipeline is often easier to evaluate. Add specialists when the task needs different tools, context limits, or concurrency—not merely to make the architecture look more sophisticated.
The problem it solves
Ask a single agent to "research the top 10 AI startups, analyze each one's competitive strategy, compare their technical approaches, and produce a board-ready report." The agent has two structural problems. First, doing all 10 companies sequentially means total wall-clock time is 10x the per-company time. Second, the same LLM doing raw retrieval, strategic analysis, and formatting is mediocre at all three because they demand different reasoning modes and different tools.
The cost of this in production: a research workflow that should take 3 minutes takes 30. Users abandon it. Engineers add retries that push it to 45 minutes. The underlying cause is not prompt quality; it is architecture.
The math is direct: $T_{sequential} = \sum_{i=1}^{n} T_i$ versus $T_{parallel} = \max(T_i)$ when the tasks are fully independent. For 10 equally-sized tasks, the idealized wall-clock improvement is 10x; real systems add dispatch, quota, and aggregation overhead. Dependency management is the orchestrator's job.
What is it?
A multi-agent system is a collection of individual AI agents coordinated by an orchestrator to complete tasks that benefit from specialization or parallelism. Each agent has its own system prompt, tool set, and context budget. The orchestrator manages the flow of work between them.
Think of it like a project manager with a team of specialists. The project manager does not write code, conduct interviews, or design the database schema. They decompose the project, assign work to the right specialist, monitor progress, and integrate the outputs into a coherent result. Each specialist excels at their narrow domain because they focus on it exclusively.
The fundamental distinction from a single agent in a loop: coordination and execution are handled by different agents. The orchestrator reasons about what to do next; workers do it.
Continue Reading with Premium
Unlock this article and every other in-depth system design guide on the platform with SDEpedia Premium.
Related Articles
Learn how the ReAct loop works, what tool use looks like under the hood, and why compound failure math is the central challenge every production agent team faces.
Learn how LangGraph models agent state as a typed graph, how conditional edges enable complex branching workflows, and how persistent checkpointing lets agents survive crashes and support human approval gates.
Learn why production agents fail when demos succeed, how to reduce blast radius through sandboxing and cost limits, and what reliability patterns make AI agents safe to deploy.
Learn when AI agents need human approval gates, how to implement pause-and-resume in LangGraph, and how to calibrate the approval threshold to balance safety with autonomy.