OpenAI Agents SDKopenai-agents 0.22 · Python 3.10+
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.

python
by_handoff = Agent(name="Triage", instructions="Route it.",
                   model=PretendModel([call("transfer_to_billing")]),
                   handoffs=[billing])
python
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.")])
Example
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

HandoffAgent as a tool
Who answers the customerthe new agentthe original agent
Comes backnoyes
Good fora different department taking overborrowing one skill
Several at onceno, one takes overyes, call as many as you like
Costthe same conversation continuesa 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.name for both, which is the whole lesson in one field.

Every expert started right here.