Suryanand/ Bootcamp
suryanand.com ↗Let's talk
← AgentsAI guideAdvanced#agents#multi-agent#orchestration#handoffs
Frame · ai-engineering / agents / 08-multi-agent-architectures.mdGuide 032 / 103

Multi-agent architectures, supervisor, swarm and hierarchical

Once a single agent has too many tools, too much context or too many jobs, the natural move is to split it into several specialised agents. That can work very well, and it can also turn a debuggable system into a distributed one with all the usual headaches. In this doc I walk through the three common shapes, what the evidence says about when they help, and how to build one with real SDK primitives.

Why it matters

Anthropic's write-up on their multi-agent research system is the most detailed public case study. A lead agent (Claude Opus 4) coordinating parallel subagents (Claude Sonnet 4) outperformed a single Opus 4 agent by 90.2% on their internal research evaluation. The catch: multi-agent runs used roughly 15 times more tokens than a normal chat. Their analysis found that token usage itself explained much of the performance difference, which is a polite way of saying multi-agent systems often win by spending more.

Their conclusion is the one I would pass on: multi-agent designs shine on breadth-first tasks where independent directions can be explored in parallel, and on tasks whose context would overflow a single window. They are a weaker fit for tightly interdependent work, such as most coding, where agents need to share a lot of evolving context.

How it works

Supervisor (orchestrator). One agent receives the task, delegates subtasks to specialist agents, and synthesises their results. Specialists are typically called as tools: the supervisor keeps control and the conversation, and each specialist sees only the input it is given. This is the orchestrator-workers workflow with agents as workers.

Swarm (handoffs). Agents pass control directly to each other. A triage agent hands the conversation to a billing agent, which may hand it to a refunds agent. There is no central coordinator; the active agent owns the conversation until it hands off. LangGraph's swarm library and the OpenAI Agents SDK's handoffs both implement this.

Hierarchical. Supervisors of supervisors. A top-level planner delegates to team leads, each managing their own specialists. Useful when the work has natural sub-domains, but every layer adds latency and another place for instructions to get lost.

Rendering diagram…

The key mechanism is context isolation: each subagent burns through its own context window exploring, then returns a compact summary. The lead never sees the noise.

Reference architecture

Rendering diagram…

Here a triage agent uses handoffs (swarm style) for the front door, and the supervisor uses agents-as-tools for the heavy work. Mixing styles is normal.

Code

The OpenAI Agents SDK supports both styles. handoffs transfers the conversation to another agent; as_tool lets a manager call a specialist and keep control.

import asyncio
from agents import Agent, Runner

researcher = Agent(
    name="Researcher",
    instructions="Find facts relevant to the brief. Return 5 bullet points with sources.",
)
analyst = Agent(
    name="Analyst",
    instructions="Given bullet points, identify risks and open questions. Be concise.",
)

# Supervisor style: specialists are tools, the manager keeps the conversation
manager = Agent(
    name="Manager",
    instructions=(
        "Break the user's request into a research brief, call the researcher, "
        "then the analyst, and write a one-page summary. Use at most 3 tool calls."
    ),
    tools=[
        researcher.as_tool(tool_name="research", tool_description="Research a focused brief."),
        analyst.as_tool(tool_name="analyze", tool_description="Analyze research findings."),
    ],
)

# Swarm style: triage hands the whole conversation to the right agent
billing = Agent(name="Billing", instructions="Resolve billing questions.")
triage = Agent(
    name="Triage",
    instructions="If the user asks about invoices or charges, hand off to Billing. Otherwise hand off to Manager.",
    handoffs=[billing, manager],
)

async def main():
    result = await Runner.run(triage, "Should we expand our EV charging pilot to Malaysia?", max_turns=12)
    print(result.last_agent.name)
    print(result.final_output)

asyncio.run(main())

max_turns bounds the whole run across agents; the SDK raises MaxTurnsExceeded when it is hit.

Trade-offs and pitfalls

  • Token cost multiplies. Every agent carries its own system prompt, tools and history. Budget per run, not per agent.
  • Vague delegation. Anthropic found early versions of their lead agent gave subagents short, vague instructions, causing duplicated work. Each brief should state the objective, output format, tools to use and boundaries.
  • Effort scaling. Without guidance, orchestrators spawn many agents for simple questions. Put explicit rules in the prompt (simple fact lookup: one agent; broad research: several).
  • Lost context in handoffs. A swarm agent that receives a handoff may not know why. Pass a short reason or summary, or filter history deliberately.
  • Compounding errors. A wrong summary from a subagent becomes a "fact" for the lead. Ask subagents for sources and have the lead verify key claims.
  • Debugging is harder. You need traces that link parent and child runs. Without them, multi-agent failures are close to impossible to reproduce.
  • Library churn. LangGraph's own reference for langgraph-supervisor now recommends implementing the supervisor pattern directly with tools for most use cases. Prefer simple primitives over heavy wrappers.

Checklist

  • Confirm a single agent with better tools or context management is not enough.
  • Use multi-agent mainly for parallel, breadth-first or context-heavy work.
  • Write explicit briefs for each subagent: goal, format, tools, limits.
  • Cap the number of agents, turns and tokens per run.
  • Subagents return condensed results with sources, not raw transcripts.
  • Traces connect parent and child agent spans end to end.
  • Evaluate the multi-agent system against a single-agent baseline on cost and quality.

Further reading

Why this exists README

I learn best by explaining things, so I record the explanations. Everything here is free, with no sign-up. If a lesson helps you ship something, I'd love to hear about it.