1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
25 small wins to finish your pathNext lesson →
Handoff or tool, which one
Both put a second agent to work. The difference is who is left holding the conversation.
The same billing agent, wired both ways in one file, so the difference is the only thing left to look at.
by_handoff = Agent(name="Triage", instructions="Route it.",
model=PretendModel([call("transfer_to_billing")]),
handoffs=[billing])by_tool = Agent(name="Triage", instructions="Ask billing, then reply.",
model=PretendModel([call("ask_billing", input="refund"),
"Billing say the refund has started."]),
tools=[billing.as_tool(tool_name="ask_billing",
tool_description="Ask the billing team.")])for agent in (by_handoff, by_tool):
result = await Runner.run(agent, "I was charged twice")
print(f"{result.last_agent.name:<8} said: {result.final_output}")Read the two lines carefully. In the first, Billing is the last agent and the words are Billing's. In the second, Triage is still the last agent and the words are Triage's, informed by what Billing said.
Choosing
| Handoff | Agent as a tool | |
|---|---|---|
| Who answers the customer | the new agent | the original agent |
| Comes back | no | yes |
| Good for | a different department taking over | borrowing one skill |
| Several at once | no, one takes over | yes, call as many as you like |
| Cost | the same conversation continues | a full extra run per call |
A support desk is usually handoffs, because a refund question really should become Billing's problem. A writing or checking step is usually a tool, because you want the answer back.
They mix
Nothing stops an agent having both. The capstone in lesson 24 hands off to Billing and Billing owns the refund tool, which is the shape most real systems end up with.
Try it yourself
- Give the tool version a second scripted reply and see Triage keep control.
- Swap which one runs first and confirm nothing else changes.
- Print
last_agent.namefor both, which is the whole lesson in one field.
Every expert started right here.