Skip to content

Courses / Agentic AI / Module 7

Module 7: Multi-agent patterns: supervisor, hierarchical, swarm and handoffs

12 h · theory 4 · hands-on 5 · project 2 · revision 1

You will be able to

  • Build a supervisor that routes to specialist agents
  • Use handoffs and shared state safely
  • Compare LangGraph, OpenAI Agents SDK and Pydantic AI
  • Know when multi-agent is worse than one agent

Capstone increment: Supervisor with log, metrics and runbook agents.

Job-description skills: Multi-agent orchestration, Agent frameworks · Lab tools: langgraph, openai-agents, pydantic-ai

1. When more than one agent helps

Multiple agents earn their cost in three situations: work that can run in parallel (several lines of research at once), parts that need different tools or permissions (a read-only investigator and an approval-gated fixer), and contexts that would overflow a single agent. Anthropic reported that its multi-agent research system beat a single agent by a wide margin on research tasks, while using about 15 times the tokens of a chat.

The common shape is a supervisor that routes work to specialists with narrow tools and gathers their findings in shared state.

Incidentalert + contextSupervisorroutes, decidesFindingsreports, shared stateAnswerplus proposed fixLog agentsearch_logsMetrics agentquery_metricsRunbook agentRAG on runbooksOne coordinatorSpecialists with narrow toolsdelegate
Specialists keep prompts and tool lists small. You pay for it in handoffs, tokens and harder debugging.

2. Supervisor, hierarchy and handoffs

A supervisor (or orchestrator) decides which specialist works next and when the task is done. Hierarchies nest supervisors for large problems. Handoffs, as in the OpenAI Agents SDK, transfer the conversation from one agent to another; agents-as-tools keep one agent in charge and call others like functions.

Decide how agents share information: a shared state object (explicit, inspectable), or messages passed between them (flexible, easy to lose context in). Structured outputs from specialists (a claim, evidence, confidence) make the supervisor’s job and your evals much easier.

3. Reliability and cost

Every step can fail, and failures compound: twenty steps at 95% each finish about a third of the time. Splitting work across agents adds handoffs, each of which can drop context, and every agent pays for its own prompt and tools. Multi-agent designs win only when specialists are genuinely more reliable at their narrower job or when parallelism matters. Use the model below to explore the trade-off.

One agent or many?A task takes a number of steps; any failed step fails the task. Split it across specialists and compare reliability, tokens and time.
DesignTask successTokensTime
One agent60%97,50060 s
Supervisor + 4 specialists56%1,34,00072 s

Success = (per-step success)^steps × (handoff success)^handoffs. Real numbers come from your own evals, not from this model.

Guided experiments
  1. Leave the specialist gain at 0. Can any number of handoffs make the multi-agent design more reliable? Why do handoffs only ever subtract?
  2. Set 90% per step and 20 steps. What is one agent’s chance of finishing? This compounding is why long agent runs feel unreliable.
  3. Give specialists a gain of +3 points and 3 parallel workers. When does the supervisor design win on success and on time? Does it ever win on tokens?
  4. Drop handoff context to 90%. How much specialist gain do you now need to break even? What would you put in a handoff to keep it high?
Common misconception: “Multi-agent is the advanced version of an agent.” It is a trade: more parallelism and separation for more tokens, more handoffs and harder debugging. Cognition’s essay “Don’t Build Multi-Agents” argues the case against.

4. Frameworks compared

LangGraph models agents and supervisors as explicit graphs with shared state, checkpoints and interrupts: the most control. The OpenAI Agents SDK offers agents, handoffs, guardrails and built-in tracing with little code. Pydantic AI gives typed agents with dependency injection and validated outputs. CrewAI organises role-based crews with tasks.

Choose by how much control you need over flow and state, how you will test it, and which tracing and deployment story fits your stack. Build the same small supervisor in two frameworks before committing.

5. Handoffs that keep context

Most multi-agent failures are context failures: the next agent doesn’t know what was found, what was ruled out or what it must not do. Make the brief a schema: goal, findings so far, constraints, and the exact format to return.

Trace across agents with one trace id per task so you can see who did what. Then evaluate the multi-agent design against a single agent on the same scenarios; keep it only if it wins on what you care about.

In production: Give each specialist only the tools it needs. Separation of permissions is often the best reason to split an agent, and it’s lost if every agent can call everything.

Hands-on: coding window

The coding window and the full VS Code lab are available after you sign in.

Sign in to code

Labs

Lab 7.1: Supervisor in LangGraph

Build a supervisor with log, metrics and runbook specialists, each with its own tools, shared state for findings and a step budget.

Expected: Traces showing routing decisions and each specialist’s structured finding.

Lab 7.2: Same design, another framework

Rebuild the supervisor with the OpenAI Agents SDK using handoffs or agents-as-tools. Note lines of code, tracing quality and how you tested it.

Expected: A short comparison in docs/adr/0007-multi-agent-framework.md.

Lab 7.3: Single versus multi (capstone increment)

Run 10 incident scenarios 3 times with the single agent and with the supervisor. Compare success, tokens, latency and cost.

Expected: A table and a decision on which design the capstone keeps.

Go deeper

Videos

Further reading

  • Article How we built our multi-agent research system · Anthropic. An orchestrator with parallel sub-agents in production, with the token costs and the failures.
  • Article Don't Build Multi-Agents · Cognition. The counter-argument: shared context and single-threaded agents for coding tasks. Read it with the one above.
  • Paper Why Do Multi-Agent LLM Systems Fail? · Cemri et al., 2025. A taxonomy of 14 failure modes from 150+ traces of real multi-agent frameworks.
  • Docs Handoffs · OpenAI Agents SDK docs. How one framework passes control and context between agents.

GitHub repositories

Checkpoint quiz

1. Which is a good reason to split an agent?
2. Twenty steps at 95% success each finish roughly…
3. What most often breaks multi-agent systems?
4. Agents-as-tools differs from handoffs because…
5. How do you decide whether to keep a multi-agent design?

Interview questions

  1. When is a multi-agent system better than a single agent? When is it worse?
  2. Design a supervisor with three specialists for incident response.
  3. How do you prevent context loss in handoffs?
  4. Compare LangGraph, the OpenAI Agents SDK and Pydantic AI for a production agent.
  5. How do you trace and debug a run that spans several agents?

Ask the professor

Sign in to ask questions about this module.

Discussion

Community discussion appears here once giscus is configured (see README).