Area 03 · AI Agents · Concept 11 of 20

Multi-agent Handoffs

One agent passes the task, with its context, to a more specialised agent.

11–20 · Production levelPhase 3 · Weeks 11–14≈ 1 hour

The idea

Instead of one agent with 40 tools and a giant prompt, split responsibilities: a triage agent talks to the user and hands off to a billing agent, a technical agent or a sales agent, each with its own instructions and a small tool set.

A handoff is usually implemented as a tool: transfer_to_billing(reason). Your code switches the active agent and passes along the conversation (or a summary of it). The new agent continues from there.

Keep the number of agents small and the boundaries clear. Every handoff is a chance to lose context or bounce the user around.

Why it matters

Specialised agents are easier to prompt, test and secure than one agent that does everything.

Picture it

Words to know

  • Triage agentThe front agent that routes to specialists.

Try it without code

Map your specialists

  1. For a support bot, list 3 specialist agents.
  2. Write each one’s tools and one rule only it follows.

Use it in code

Handoffs with the OpenAI Agents SDK.

python
# pip install openai-agents
from agents import Agent, Runner

billing = Agent(name="Billing", instructions="Handle refunds and invoices. Never promise refunds over 100 EUR.")
tech = Agent(name="Tech support", instructions="Debug login and API errors step by step.")
triage = Agent(name="Triage",
               instructions="Work out what the user needs and hand off to the right agent.",
               handoffs=[billing, tech])

result = Runner.run_sync(triage, "I was charged twice for March.")
print(result.last_agent.name, "->", result.final_output)
PRACTICE · TICK IT AFTER THIS

Build triage + 2 specialists and test 10 messages. Count wrong handoffs.

Common mistakes

  • Specialists that overlap, causing ping-pong.
  • Losing key facts during handoff.

Go deeper