How do multi-agent handoffs work in a voice AI system?

Authors
How do multi-agent handoffs work in a voice AI system?

A multi-agent handoff in a voice AI system is the moment when one AI agent passes a live phone call to another, more specialized AI agent, along with everything that has been said so far. The LLM of the current agent recommends the handoff, our code switches to the instructions and tools of the new agent, and the caller stays on the same call without repeating anything.

In this blog, we will learn about how multi-agent handoffs work in a voice AI system. We will also see why one big agent is not enough, how a handoff is described to the LLM as a tool, what our code does when the LLM recommends a handoff, how the conversation history travels to the next agent, what makes a handoff smooth for the caller, and where handoffs go wrong.

We will cover the following:

  • What is a multi-agent voice AI system?
  • Why not one big agent?
  • What is a handoff?
  • Where the handoff happens in the voice pipeline
  • Step 1: Describe the handoff as a tool
  • Step 2: The LLM recommends a handoff
  • Step 3: Our code swaps the active agent
  • Step 4: The context travels with the call
  • Step 5: The new agent speaks
  • The complete flow in one diagram
  • Making the handoff smooth for the caller
  • Handing back and handoff loops
  • Putting it all together in code

I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

I teach AI and Machine Learning at Outcome School.

Let's get started.

What is a multi-agent voice AI system?

A voice AI agent is a system built around an LLM (Large Language Model) that can talk with us over a phone call or a voice app. It listens to what we say, decides what to reply, and speaks the reply back to us.

A multi-agent voice AI system is a voice system where, instead of one agent doing everything, there are several specialized AI agents, and each one is good at one kind of job.

Let's say we call the help line of an online store. The system can have:

  • A Greeter agent that welcomes us and understands why we called.
  • An Orders agent that tracks orders and changes delivery addresses.
  • A Billing agent that handles refunds and payment problems.

Each agent has its own instructions, its own tools, and its own small job. This is very similar to a real office, where the person at the front desk sends us to the right department.

But, there is one big difference. In a real office, we walk to another room. In a voice AI system, the caller never moves. The call stays on the same line, and only the agent behind the voice changes.

We have a detailed blog on Multi-Agent Systems that explains when to use them in depth.

Why not one big agent?

Now, the question is: why do we need many agents at all? Why not write one agent that knows everything?

We can do that for a small system. But as the system grows, the following issues arise:

  • Long instructions confuse the LLM. When one prompt has rules for orders, billing, returns, and complaints all together, the LLM can mix them up and follow the wrong rule at the wrong time.
  • Too many tools make the choice harder. When the LLM sees 40 tools at once, it has a higher chance of picking the wrong one.
  • Voice needs speed. In a phone call, a pause of even one or two seconds feels awkward. A very long prompt with many tools means more tokens for the LLM to read on every turn, and that can add delay.
  • It is hard to change. A small change to the billing rules can break the orders behaviour, because everything lives in one place.

When we split the work, each agent gets a short prompt and the few tools it needs.

So, here comes the handoff to the rescue. It lets many small agents work together on one call, as if they were one.

What is a handoff?

A handoff is when the system sees that another agent can handle the request of the caller better, and passes control of the live conversation from the current agent to that agent.

After the handoff, the new agent becomes the active agent. From that point, every new thing the caller says goes to the new agent, until it hands the call to another agent or the call ends.

Three things matter in every handoff:

  • Who decides that a handoff is needed. In many systems, the LLM of the current agent recommends it. Sometimes, our code decides it with a fixed rule, like moving to the Billing agent right after the caller's identity is checked.
  • What moves to the new agent. This is the conversation history and any useful facts, like the order number.
  • What the caller hears during the switch. This must feel like one smooth conversation.

We will learn about each of them in detail.

Where the handoff happens in the voice pipeline

Before jumping into the steps, we must know how a voice agent is built. A common voice agent has three parts working one after another, like below:

Caller speaks
      ↓
Speech-to-Text (turns audio into text)
      ↓
LLM (decides what to reply, or which tool to use)
      ↓
Text-to-Speech (turns the reply into audio)
      ↓
Caller hears the reply

Here, we can see that the LLM sits in the middle of the pipeline. The phone line, the Speech-to-Text part, and the Text-to-Speech part stay the same for the whole call.

A handoff changes only what the LLM part is configured with: the instructions, the tools, and sometimes the voice used by the Text-to-Speech part. The phone connection is never dropped.

This is the reason why a handoff between AI agents takes very less time compared to transferring a call to a human. Nothing is dialled again. Our code changes the settings of the LLM part in the middle, and the call continues.

Note: Some voice agents use a speech-to-speech model, which listens to audio and speaks audio directly, without separate Speech-to-Text and Text-to-Speech parts. The idea of a handoff stays the same there: our code updates the live session with the instructions and tools of the new agent.

Planning your move into AI?

No matter which tech domain you work in today, with your effort, you can transition to these roles:

  • AI Engineer
  • Forward Deployed Engineer
  • AI Agent Engineer
  • Harness Engineer
  • Voice AI Engineer
  • AI Architect
  • LLM Engineer
  • LLM Inference Engineer
  • Gen AI Engineer
  • MLOps Engineer
  • ML Engineer
  • Deep Learning Engineer

Our AI and Machine Learning Program at Outcome School takes you there.

Step 1: Describe the handoff as a tool

The best way to learn this is by taking an example.

The LLM can only recommend things that we tell it about. So, we describe each possible handoff to the LLM as a tool, just like any other tool.

For the Greeter agent, we can describe the handoff tools as below:

[
  {
    "name": "transfer_to_orders",
    "description": "Use this when the caller wants to track an order or change a delivery address.",
    "parameters": { "reason": "string" }
  },
  {
    "name": "transfer_to_billing",
    "description": "Use this when the caller wants a refund or has a payment problem.",
    "parameters": { "reason": "string" }
  }
]

Here, we have two tools. Each tool has a name, a clear description, and one input called reason, where the LLM writes why it wants the handoff. The description is very important, because the LLM uses it to decide when to pick that tool.

We also write the instructions of the Greeter agent to say: "Find out why the caller is calling. If it is about an order, transfer to the Orders agent. If it is about a payment, transfer to the Billing agent. Do not try to solve these problems yourself."

Step 2: The LLM recommends a handoff

Let's say the caller is Priya. The Greeter has already asked for her name and her order number, A1234, and has checked her identity. Now, she speaks.

Caller: "Hi, I was charged twice for my order."

The Speech-to-Text part turns this audio into text and gives it to the LLM of the Greeter agent. The LLM reads the text, reads its instructions, and looks at the tools it has.

From the text and the tool descriptions, it finds that this is a payment problem. So, instead of a normal reply, it replies with a tool call like below:

{ "tool": "transfer_to_billing", "arguments": { "reason": "caller was charged twice" } }

The LLM never moves the call itself. It only recommends the handoff. Our code, which runs the agent, reads this recommendation and does the actual switch.

To master Tool use in Agents and Agent Architecture, and build an AI Coding Agent from scratch, check out our AI and Machine Learning Program at Outcome School.

Step 3: Our code swaps the active agent

When our code sees the transfer_to_billing tool call, it does the following:

  • It marks the Billing agent as the new active agent.
  • It loads the instructions of the Billing agent in place of the Greeter's instructions.
  • It loads the tools of the Billing agent, like check_payment and issue_refund, in place of the Greeter's tools.
  • If the Billing agent uses a different voice, it tells the Text-to-Speech part to use that voice.

The Speech-to-Text part and the phone line do not change at all.

Now, the Billing agent has its instructions and its tools. But, it still does not know what Priya has said so far. That is our next step.

Step 4: The context travels with the call

If the Billing agent starts with an empty memory, it can say: "Hello, how can I help you today?" Then, the caller has to explain the problem again, and that is a bad experience.

So, how can we avoid this? The answer is: we pass the context to the new agent along with the call.

There are two common ways to do this:

Way 1: We pass the full history, which means the complete list of messages from the call so far. The Billing agent reads everything the caller and the Greeter said.

Advantage: Nothing is lost.

Disadvantage: In a long call, this history becomes very long. More tokens means more cost and more delay on every turn, and voice cannot afford much delay.

Way 2: We pass a short summary with key facts. Before the switch, our code, or the LLM itself, writes a short note like below:

{ "reason": "charged twice", "order_id": "A1234", "caller_name": "Priya", "verified": true }

Here, verified means that the caller's identity was already checked, so the Billing agent does not ask for it again.

Advantage: It is short, so the new agent stays fast.

Disadvantage: If the summary misses something important, the new agent will not know it.

In practice, many systems mix both: they pass a short summary of the facts plus the last few messages of the conversation. We must choose based on our use case.

We have a detailed blog on how a voice agent manages conversation state across a long call that covers this end to end.

Step 5: The new agent speaks

Now, the Billing agent has its instructions, its tools, and the context. Its LLM reads all of this and writes its first reply.

Billing agent: "Priya, I understand that you were charged twice for order A1234. Let me check the payments for you."

The Text-to-Speech part turns this reply into audio, and the caller hears it.

Here, we can notice that Priya did not repeat anything, not even her name or her order number. The Billing agent continued the same conversation from where the Greeter left it.

This is how a handoff completes.

A quick note for you

No matter which tech domain you work in, get familiar with these topics:

  • LLM
  • RAG
  • MCP
  • Agent
  • Fine-tuning
  • Quantization

We put it all together in one video:

AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization

No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.

Now, let's get back to the topic.

The complete flow in one diagram

Let's put all the steps together in one diagram, like below:

Caller: "I was charged twice."
                ↓
Speech-to-Text turns audio into text
                ↓
Greeter agent's LLM reads the text
                ↓
LLM recommends: transfer_to_billing
                ↓
Greeter says: "Let me connect you."
                ↓
Our code switches the active agent
(new instructions, new tools, same call)
                ↓
Our code passes the context
(full history or a short summary)
                ↓
Billing agent's LLM writes its reply
                ↓
Text-to-Speech speaks the reply
                ↓
Caller hears the Billing agent

Here, we can see that the call never stops. Only the agent in the middle changes, and the history goes along with it.

Making the handoff smooth for the caller

In a text chat, a small pause during a handoff is fine. In a voice call, silence feels like the call has dropped. So, we must design the handoff for a voice call.

A few things help:

  • Say something before the switch. The Greeter can say "Sure, let me connect you to our billing team." while our code prepares the Billing agent. This covers the small delay.
  • Do not make the new agent greet again. We tell the new agent in its instructions to continue the conversation, not to start a new one.
  • Decide on the voice. If all agents use the same voice, the caller hears one assistant. If each agent has a different voice, the caller hears a new person, so the previous agent must tell the caller about the transfer.
  • Keep listening during the switch. If the caller speaks while the switch is happening, our code must keep that audio and give its text to the new agent, so that nothing the caller says is lost.
  • Keep the switch fast. We load the instructions and tools of every agent at the start of the call, so that the switch takes almost no time.

Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.

Handing back and handoff loops

Now, the next big question is: what happens after the Billing agent finishes its job?

The caller can say: "Thanks. Also, where is my other order?" This is not a billing question. So, the Billing agent needs a way to hand the call back. We give it a tool like transfer_to_greeter or transfer_to_orders, and the same five steps happen again.

But, the following issue arises. Suppose the Greeter thinks a question is about billing and sends it to the Billing agent. The Billing agent thinks it is about orders and sends it to the Orders agent. The Orders agent thinks it is about billing and sends it to the Billing agent again. The caller keeps hearing "let me transfer you" and nobody answers the question.

This is called a handoff loop.

We can prevent it in the following ways:

  • Write clear, non-overlapping descriptions for each handoff tool, so that each agent knows exactly what belongs to whom.
  • Set a limit on how many handoffs can happen in one call. After the limit, the current agent must answer, or the call goes to a human.
  • Pass the reason for the handoff in the context, so that the receiving agent knows why the call came to it and does not send it away for the same reason.

If we want to go deep into Multi-Agent Systems, Orchestration and Routing, and Design a Real-Time Voice AI Agent, we have a complete program on this - check out our AI and Machine Learning Program at Outcome School.

Putting it all together in code

Now, let's see the code for a simple handoff. We can write the code as below:

MAX_HANDOFFS = 3

agents = {
    "greeter": Agent(GREETER_PROMPT,
                     tools=[transfer_to_orders, transfer_to_billing],
                     voice="voice_a"),
    "orders": Agent(ORDERS_PROMPT,
                    tools=[track_order, transfer_to_billing, transfer_to_greeter],
                    voice="voice_a"),
    "billing": Agent(BILLING_PROMPT,
                     tools=[check_payment, issue_refund, transfer_to_orders, transfer_to_greeter],
                     voice="voice_a"),
}

active = "greeter"
history = []
handoffs = 0

def handle_turn(user_text):
    global active, handoffs
    history.append({ "role": "user", "content": user_text })

    while True:
        agent = agents[active]
        result = llm.run(agent.instructions, agent.tools, history)

        if result.tool_name and result.tool_name.startswith("transfer_to_"):
            if handoffs >= MAX_HANDOFFS:
                transfer_to_human(history)  # stop the loop, a person takes over
                return
            speak("Sure, let me connect you.", agent.voice)
            active = result.tool_name.replace("transfer_to_", "")
            handoffs += 1
            history.append({ "role": "system", "content": "Handoff reason: " + result.arguments["reason"] })
            continue  # the new agent replies to the same history

        history.append({ "role": "assistant", "content": result.text })
        speak(result.text, agent.voice)
        return

Here, I have kept only the important lines of the code and removed other lines for brevity, like running normal tools such as check_payment.

Here, we have:

  • agents: each agent has its own instructions, its own tools, and its own voice. All three use the same voice here, so the caller hears one assistant.
  • active: the name of the agent that is talking right now. At its core, a handoff is a change of this one value.
  • history: one shared list of messages for the whole call. Every agent reads the same list, so the context travels with the call. This is Way 1 from Step 4.
  • handle_turn: it runs every time the Speech-to-Text part gives us what the caller said.
  • When the LLM recommends a transfer_to_ tool, our code speaks a short line, switches active, adds the reason to the history, and runs the loop again, so that the new agent replies right away.
  • MAX_HANDOFFS: it stops a handoff loop. If the LLM recommends a fourth handoff in the same call, our code sends the call to a human instead.

Now we must have understood how multi-agent handoffs work in a voice AI system, how the context travels with the call, and how to keep the handoff smooth for the caller.

Frequently Asked Questions

Does the phone call drop during a multi-agent handoff?

No. The phone call does not drop during a handoff. The phone line, the Speech-to-Text part, and the Text-to-Speech part stay the same for the whole call. A handoff changes only the instructions, the tools, and sometimes the voice of the LLM part, so the caller stays on the same line.

Is a handoff between AI agents faster than transferring a call to a human?

Yes. A handoff between AI agents takes very less time compared to transferring a call to a human, because nothing is dialled again. Our code only changes the settings of the LLM part, and the call continues. If we load the instructions and tools of every agent at the start of the call, the switch takes almost no time.

Should every agent in a voice AI system use a different voice?

Not necessarily. If all agents use the same voice, the caller hears one assistant. If each agent has a different voice, the caller hears a new person, so the previous agent must tell the caller about the transfer.

Do handoffs work with a speech-to-speech model?

Yes. A speech-to-speech model listens to audio and speaks audio directly, without separate Speech-to-Text and Text-to-Speech parts. The idea of a handoff stays the same there: our code updates the live session with the instructions and tools of the new agent.

That's it for now.

Thanks

Amit Shekhar
Founder @ Outcome School

You can connect with me on:

Follow Outcome School on:

Read all of our high-quality blogs here.