> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Handoffs

> Split a workflow across specialized agents and switch control between them.

Agent handoffs let you split complex workflows across specialized agents. The primary agent detects intent and calls a `function_tool` to hand control to the right agent, which completes the request.

## Handoff vs Transfer

"Handoff" and "transfer" are easy to confuse. They differ in who receives the conversation and whether context is passed along.

| Term                               | Conversation moves to                                      | Context passed                  | Covered in                                      |
| :--------------------------------- | :--------------------------------------------------------- | :------------------------------ | :---------------------------------------------- |
| **Agent Handoff**                  | Another **AI agent** in the same session                   | Optional, via `inherit_context` | This page                                       |
| **Agent Transfer** (Call Transfer) | A **human or another phone number**, connected immediately | No                              | [Call Transfer](/build/telephony/call-transfer) |

In short: a **handoff between agents** keeps the conversation with the bot and only switches which agent is in control. A **transfer** hands the live call to a person. A transfer is **cold** when the person is connected with no briefing, and **warm** when they receive context before the call connects.

## Context Sharing

When switching agents, the `inherit_context` flag controls whether the new agent is aware of the previous conversation.

| Value                             | Behavior                                      | When to Use                                                     |
| --------------------------------- | --------------------------------------------- | --------------------------------------------------------------- |
| `inherit_context=True`            | The new agent receives the full chat context. | Maintaining continuity so the user does not repeat information. |
| `inherit_context=False` (default) | The new agent starts with a fresh state.      | Switching to a completely unrelated task.                       |

## Example

A travel agent hands off to a booking specialist from a function tool, passing the
conversation context along. The handoff is driven by the tool's **return value**: return the
next `Agent` instance (constructed with `inherit_context=True`).

<CodeGroup>
  ```python title="main.py" Python theme={null}
  from zrt import Agent, function_tool

  class TravelAgent(Agent):
      def __init__(self):
          super().__init__(
              agent_id="travel",
              instructions="You are a travel assistant. Help with travel questions and guide users to booking.",
          )

      @function_tool()
      async def transfer_to_booking(self) -> Agent:
          """Transfer the user to a booking specialist."""
          # Returning an Agent instance performs the handoff;
          # inherit_context=True passes the existing chat context.
          return BookingAgent(inherit_context=True)

  class BookingAgent(Agent):
      def __init__(self, inherit_context: bool = False):
          super().__init__(
              agent_id="booking",
              instructions="You are a booking specialist. Help users book or modify reservations.",
              inherit_context=inherit_context,
          )
  ```
</CodeGroup>

`inherit_context` controls whether the receiving agent starts with the full chat context
(continuity) or a clean slate (unrelated task).

## What's Next

<CardGroup cols={2}>
  <Card title="Context Window" icon="window-maximize" href="/build/context-management/context-window">
    Manage conversation history automatically.
  </Card>

  <Card title="Context Management" icon="brain" href="/build/context-management/access-context">
    How ChatContext records conversation memory.
  </Card>
</CardGroup>

## References

#### Examples

<CardGroup cols={2}>
  <Card title="Multi-Agent Switch" icon="github" href="https://github.com/ZeroRuntimeAI/zrt-python-sdk-examples/blob/main/features/agent_handoff.py">
    Switch control between multiple agents.
  </Card>
</CardGroup>

#### SDK Reference

<CardGroup cols={2}>
  <Card title="Function Tool" icon="wrench" href="/api-reference/python/core/tools-and-mcp#functiontool">
    Function Tool in the Python API reference.
  </Card>
</CardGroup>
