Phase 4: Multi-Agent Systems · 55 min · Python · Anthropic SDK
Swarm Pattern
No one's in charge — but everyone knows where they belong.
Hiring signal: The swarm pattern is used in production customer experience systems at companies like Intercom, Zendesk, and Salesforce Service Cloud. Understanding when to use swarm vs. supervisor — and the specific failure modes of each — is the kind of trade-off reasoning that distinguishes architects from implementers.
What you will learn
- Implement the swarm pattern: agents hand off to each other based on capability and context
- Design clean context transfer between agents during handoffs
- Compare swarm vs. supervisor: choose the right architecture for a given use case
The Problem
The supervisor pattern requires a central planner to make all routing decisions. For complex analytical workflows, that's exactly what you want. But for real-time customer-facing flows, the supervisor's extra planning call adds latency that users feel. The swarm pattern eliminates the central planner: each agent decides for itself whether it's the right agent, and if not, it routes to the one that is.
The key insight: routing decisions are often local — the current agent can tell from the user's latest message whether it's still in scope. A billing agent doesn't need a supervisor to know it shouldn't handle "my app keeps crashing."
Swarm Architecture
No central supervisor. Each agent has a set of transfer_to_{name} tools that it can call to hand off the conversation to another agent. The runtime manages the active agent and processes transfers.
The mechanism:
- Runtime starts with the triage agent (or whatever agent is most general)
- Agent processes the user message
- If in scope: respond normally
- If out of scope: call
transfer_to_{appropriate_agent}(handoff_note="...") - Runtime switches the active agent, passes full context
- New agent continues from where the previous agent left off
Each agent is a specialist: it knows exactly what it handles, and it knows when to pass the baton.
In a swarm, an agent calls transfer_to_billing_agent(). What must be included in the transfer payload for the handoff to be seamless?
The receiving agent starts cold — it knows nothing about the conversation history or what was already resolved. Without full context, it will ask the user to repeat themselves (frustrating UX) or make incorrect assumptions. The handoff note tells it why it's being transferred — so it can pick up exactly where the previous agent left off.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Designing Handoffs, Swarm vs. Supervisor: Trade-Off Table, Build It — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy