The OpenAI Agents SDK gives you two ways to split work between agents. With a handoff, a triage agent passes the conversation to a specialist, and that specialist becomes the active agent and writes the reply. With agents as tools, a manager agent calls the specialist through Agent.as_tool(), gets its output back as a tool result, and writes the reply itself. The SDK's orchestration guide puts the choice in one line: use agents as tools "when a specialist should help with a bounded subtask but should not take over the user-facing conversation," and handoffs "when routing itself is part of the workflow." The rest of this post shows what that means in practice: what each specialist sees, who answers, how guardrails and turn limits apply, and how to mix the two.
Every snippet was run with openai-agents 0.26.0 on Python 3.13, using a scripted fake model in place of a real one. The fake records what each agent's model received, which is how the history differences below were checked. No request went to the OpenAI API.
The same task, both ways
Take a support bot where a refund specialist should handle refund requests. As a handoff:
from agents import Agent, Runner
refunds = Agent(
name="Refund agent",
instructions="You issue refunds for duplicate or wrong charges.",
handoff_description="Handles refund requests.",
)
triage = Agent(
name="Triage agent",
instructions="Route the user to the right specialist.",
handoffs=[refunds],
)
result = Runner.run_sync(triage, "I was charged twice for order 1042, refund one.")
print(result.last_agent.name) # Refund agent
print(result.final_output) # the refund agent's own words
As a tool:
refunds = Agent(
name="Refund agent",
instructions="You issue refunds for duplicate or wrong charges.",
)
manager = Agent(
name="Support manager",
instructions="Help the user. Use issue_refund for refunds, then confirm to the user.",
tools=[
refunds.as_tool(
tool_name="issue_refund",
tool_description="Refund a charge. Input: what to refund and why.",
)
],
)
result = Runner.run_sync(manager, "I was charged twice for order 1042, refund one.")
print(result.last_agent.name) # Support manager
print(result.final_output) # the manager's reply, written after the tool returned
The Handoffs docs say "Handoffs are represented as tools to the LLM," so in both cases the model sees a function it can call. In the test, the triage agent's model was offered one handoff named transfer_to_refund_agent and no tools; the manager's model was offered one tool, issue_refund, and no handoffs. The difference is what happens after the call.
What each specialist sees
This is the difference that matters most, and it is easy to miss.
A handoff passes the whole conversation. The docs say "it's as though the new agent takes over the conversation, and gets to see the entire previous conversation history." In the test, the refund agent's model received three items: the user's message, the transfer_to_refund_agent function call and its output, {"assistant": "Refund agent"}. With a long chat, the specialist gets all of it, including earlier tool calls and results.
A tool call passes only the arguments. By default, as_tool() exposes a schema with one required string field, input. In the test, the refund agent received exactly one item: a user message holding the string the manager wrote, Refund the duplicate charge on order 1042. It did not see the user's original words. The Tools docs state the rule: "the parent run's conversation state is not inherited automatically." If the specialist needs shared history, pass the same session to both runs.
So the manager's model has to write a good brief. If a detail isn't in the tool arguments, the specialist doesn't have it. That is a feature when you want specialists to stay focused or to see less data, and a bug when you assumed they could read the chat. It is the same tradeoff covered in budgeting the context window: less context is cheaper and cleaner, until something needed is missing.
You can shape both sides:
- For handoffs, an
input_filterchanges what the next agent receives. Withhandoff(refunds, input_filter=handoff_filters.remove_all_tools)fromagents.extensions, the refund agent in the test received only the user message, with the function call items gone. The docs warn thatremove_all_tools"does not redact tool arguments or results already copied into ordinary messages," so it is not a privacy filter. - For tools,
parameterstakes a Pydantic model or dataclass in place of the singleinputstring, andinclude_input_schema=Trueadds the schema to the nested input.
from pydantic import BaseModel, Field
class RefundRequest(BaseModel):
order_id: str = Field(description="Order to refund.")
reason: str = Field(description="Why, in the user's words.")
refund_tool = refunds.as_tool(
tool_name="issue_refund",
tool_description="Refund one order.",
parameters=RefundRequest,
)
Who writes the reply
With the handoff, final_output was the refund agent's message and result.last_agent was the refund agent. The triage agent's model was called once, and never saw the specialist's answer.
With the tool, the manager's model was called twice: once to call issue_refund, and again with the tool result appended as a function_call_output item holding the refund agent's text. The manager then wrote the final reply. last_agent stayed the manager.
That second call is the cost of agents as tools: one more model call per delegation, and a manager that may reword or drop what the specialist said. What you get in return is one place that owns the user-facing answer, which can combine several specialists' outputs. If you only need part of the nested result, custom_output_extractor lets you return, say, a JSON payload instead of the specialist's full final text.
For the next user turn, the two patterns differ again. The Results docs say last_agent "is often the best agent to reuse for the next user turn after handoffs." So after a handoff, continue with the specialist:
next_input = result.to_input_list() + [{"role": "user", "content": "How long until I see it?"}]
result = Runner.run_sync(result.last_agent, next_input)
With agents as tools, last_agent is the manager, and you keep calling the manager.
Guardrails, approvals and turn limits
Guardrails. A note in the Handoffs docs says: "Input guardrails still apply only to the first agent in the chain, and output guardrails only to the agent that produces the final output." With handoffs, an input guardrail on the triage agent does not run again for the specialist, and an output guardrail on the triage agent does not see the specialist's reply. The orchestration table lists enforcing "shared SDK guardrails in one place" as a reason to pick agents as tools, since the manager is both the first agent and the one that answers.
Approvals. as_tool(needs_approval=...) uses the same pause and resume flow as function tools: the run stops with pending items in result.interruptions. The Results docs say these can come from direct tools, "tools reached after a handoff," or nested as_tool() runs, so both patterns work with the approval flow in human in the loop agents.
Turn limits. A handoff stays in the same run, so the specialist's turns count against the run's max_turns. An agent used as a tool starts a nested run with its own limit: in the 0.26.0 source, as_tool(max_turns=None) resolves to DEFAULT_MAX_TURNS, which is 10. A looping specialist then fails as a tool error the manager can see, not as an exception. In the test, a sub-agent that searched on every turn stopped after 10 model calls, and the manager received the tool output "An error occurred while running the tool." MaxTurnsExceeded in the OpenAI Agents SDK covers how to set that limit and surface the real error.
Pass data with a handoff
A handoff can carry a small structured payload the model fills in. input_type defines the arguments of the handoff tool, and on_handoff receives the parsed value:
from pydantic import BaseModel
from agents import Agent, RunContextWrapper, handoff
class EscalationData(BaseModel):
reason: str
async def on_escalate(ctx: RunContextWrapper[None], data: EscalationData) -> None:
print(f"escalating: {data.reason}") # log it, open a ticket, page someone
escalation = Agent(name="Escalation agent", instructions="Tell the user a human will follow up.")
triage = Agent(
name="Triage agent",
handoffs=[handoff(escalation, on_handoff=on_escalate, input_type=EscalationData)],
)
In the test, the triage model called transfer_to_escalation_agent with {"reason": "legal threat"}, on_escalate received "legal threat", and the escalation agent answered. Two limits from the docs: input_type "does not replace the next agent's main input," so the specialist still sees the full history, and it "does not choose a different destination." To route to several specialists, register one handoff each.
How to choose
Pick handoffs when:
- The specialist should talk to the user directly, such as a billing or refunds desk.
- Later turns should stay with the specialist.
- The specialist needs the full conversation.
Pick agents as tools when:
- One agent should own the answer, or combine several specialists' outputs.
- The subtask is bounded: summarize, classify, translate, look something up.
- The specialist should see less than the whole chat.
- You want input and output guardrails to run once, around everything.
The two combine. The SDK docs say a triage agent "might hand off to a specialist, and that specialist can still call other agents as tools for narrow subtasks." And the orchestration guide on OpenAI's developer site adds a caution worth keeping: "Start with one agent whenever you can." Split only when a branch needs different instructions, tools or policy. Each new agent is another prompt to test, and routing mistakes need their own evals, as in multi agent evaluation.
Checklist
- Decide who writes the user-facing reply. That usually settles it.
- Set
handoff_descriptionon handoff targets; it is appended to the handoff tool's description. - Always pass
tool_descriptiontoas_tool(). In 0.26.0, leaving it out gave the tool an empty description. - Remember a tool-agent sees only its arguments. Use
parametersfor structured briefs. - Use
input_filterwhen a handoff target should see less history. - Continue with
result.last_agentafter a handoff. - Put guardrails where they will actually run.
- Set
max_turnsandfailure_error_functiononas_tool()for sub-agents.
FAQ
What is the difference between a handoff and an agent as a tool?
With a handoff, the specialist takes over the run and writes the reply. With as_tool(), the specialist runs as a nested call, returns its output as a tool result, and the calling agent writes the reply.
Does an agent called with as_tool see the conversation history?
No, not by default. It receives the tool's arguments, a single input string unless you pass parameters. Pass the same session to both runs if it needs the shared history.
Does the agent receiving a handoff see the conversation history?
Yes. It sees the full history, including the handoff call itself, unless you set an input_filter or the opt-in nested handoff history setting.
Do guardrails run after a handoff?
Input guardrails run only for the first agent in the run, and output guardrails only for the agent that produces the final output.
Can I use handoffs and agents as tools together?
Yes. A triage agent can hand off to a specialist, and that specialist can call other agents as tools.
Sources
- OpenAI, Agent orchestration (Agents SDK documentation: patterns table, when to use each, combining them)
- OpenAI, Handoffs (Agents SDK documentation: handoff(), input_type, input filters, guardrails note)
- OpenAI, Tools (Agents SDK documentation: agents as tools, structured input, approvals, output extraction)
- OpenAI, Results (Agents SDK documentation: last_agent, interruptions)
- OpenAI, Running agents (Agents SDK documentation: to_input_list, conversation state)
- OpenAI, Orchestration and handoffs (developer guide: choosing a pattern, starting with one agent)
- OpenAI, openai-agents (package source, version 0.26.0)