Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 51/ 160
03. AI Agents

Multi-agent Handoffs

Transferring control and context between specialist agents without losing state.

AdvancedHandoff · Specialists3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

One AI helper passes the customer to another helper who's better at that topic, along with the important details.

Think of it like…

A hospital's front desk: reception (triage) sends you to the right department, and the nurse writes a note so the specialist doesn't ask everything again. If the handover note is missing, you repeat yourself; if the desk sends you to the wrong department, you bounce back and forth.

Where you’ve seen it

A telecom assistant has a Triage agent (no tools, only routing instructions) and three specialists: Billing (invoice and payment tools), Technical (diagnostics, outage lookup) and Retention (offers, with approval rules). A customer says "my bill is double and my internet is slow". Triage hands off to Billing with {customer_id, issue: 'double charge', ...}; after resolving it, Billing hands off to Technical with the summary "billing fixed; customer reports slow internet since Monday". Each specialist's prompt and tools are small, and evaluation shows correct routing on 94 percent of 300 test conversations.

Words you’ll hear

Handoff
Transferring control (and context) of the conversation to another agent.
Triage / router agent
An agent whose job is to select the right specialist.
Context pass
What is carried across: full history, a summary, structured state, or a mix.
Handback
Returning control to the previous or a supervising agent when done.

Visual diagram

Loading interactive diagram

Theory & deep dive

How handoffs work

Frameworks model a handoff as a special tool the current agent can call: transfer_to_billing(). When invoked, the framework switches the active agent, swaps in its instructions and tools, and continues the same conversation. The OpenAI Agents SDK, LangGraph and others provide handoff primitives, often with an optional input schema (the reason for transfer, key fields) and filters that control which history the next agent sees. In graph frameworks a handoff is an edge to another node with updated state.

Design the transfer contract: required fields (customer id, issue, what has been tried), a concise summary written by the handing-off agent, and a history policy (full for simple cases, filtered or summarised when tool outputs are large or sensitive). Decide who owns the conversation afterwards: stay with the specialist until it hands back, or return to triage after each task.

A handoff with structured input

handoff(billing_agent, input_schema={"customer_id": str, "issue": str, "tried": list[str]}): the triage agent must fill customer_id and issue, so Billing starts with the facts instead of re-asking the customer.

Key takeaway: A handoff is a tool call that switches the active agent; define what context travels.

When to use handoffs, and what goes wrong

Use handoffs when roles are distinct and conversations naturally move between domains: support, sales, onboarding, IT help desks. Prefer a single agent when the task is simple or tools are few; multi-agent structures add latency, cost and failure modes. Compared with the orchestrator-worker pattern, handoffs transfer control (the user now talks to the specialist), while orchestrators keep control and delegate subtasks, returning results to the orchestrator.

Failure modes: wrong routing (ambiguous descriptions of specialists; fix with clear scopes and examples, and an escape hatch back to triage), lost context (re-asking for known facts), ping-pong loops (A hands to B, B hands back), permission drift (a specialist inheriting powers the user shouldn't have) and inconsistent tone or policy across agents. Mitigate with hop limits, shared structured state, per-agent permissions, a common style guide, tracing of the whole conversation across agents and evaluations of routing accuracy and end-to-end resolution.

A hop limit

Count handoffs per conversation; after 3, route to a human agent with the full trace instead of letting two specialists hand the customer back and forth.

Key takeaway: Clear scopes, shared state, hop limits and tracing prevent the common failures.

How it works, step by step

Step 1 of 4
Design

1. Define specialist scopes

Give each agent a narrow responsibility, small toolset and a description that makes routing unambiguous.

Billing · Technical · Retention
Key numbers at this step
Few tools
per agent

When to use it & trade-offs

What it is

A handoff transfers control of a conversation from one agent to another. A triage (or router) agent decides who should handle the request and hands off to a specialist (billing, technical support, refunds), which continues with its own instructions and tools. What travels with the handoff is the key design question: the conversation history, a summary, structured state (customer id, order id) or all three. After a handoff, the new agent usually becomes the active agent for subsequent turns, and may hand back or on to others.

Why it matters: One agent with 40 tools and a prompt covering every policy performs worse than several focused agents, each with a small toolset, a concise prompt and clear scope. Handoffs make that structure work in conversations. But badly designed handoffs lose context ("I already told the last agent my order number"), ping-pong between agents, or hand off to the wrong specialist, so the transfer contract needs care.

When to reach for it

  • Customer support across billing, technical and sales
  • IT and HR help desks
  • Systems where tool sets differ by domain

When to avoid or be careful

  • Handoffs for tasks one agent handles fine
  • Passing no state, forcing users to repeat themselves
  • Unlimited handoffs between agents

Single agent vs handoffs vs orchestrator

Single agent
Best for: Simple tasks with few tools

Strengths: Fewest moving parts.

Watch out: Prompt and tool sprawl as scope grows.

Handoffs between specialists
Best for: Conversations that move between domains

Strengths: Focused prompts and tools; clear ownership.

Watch out: Context loss and routing errors.

Orchestrator with workers
Best for: Decomposable tasks needing parallel work

Strengths: Parallelism; orchestrator keeps control.

Watch out: Higher cost; synthesis step needed.

Interview signals & numbers to know

When this topic comes up

  • “One agent with 40 tools performs badly”
  • “Customers repeat themselves after transfer”
  • “Triage agent”
  • Handoff vs delegation
  • Routing accuracy

Benchmarks & rules of thumb

94% -
routing accuracy in the example
3 -
hop limit in the example
small -
tool sets per specialist

Common mistakes & follow-ups

Common interview mistakes

  • Writing overlapping specialist descriptions, so triage routes inconsistently.
  • Handing off with only "customer needs help" and no structured details.
  • Letting a specialist inherit tools that the end user isn't authorised to use.

Likely interviewer follow-ups

  • What's the difference between a handoff and delegating to a worker?
  • What context should pass in a handoff?
  • How do you prevent routing loops?
Interview tip: Contrast handoff (control moves) with orchestrator-worker (control stays). It's the distinction interviewers most often probe.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Multi-agent Handoffs with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Agent Skills
Next topic
Orchestrator-Worker Pattern