OpenAI Agents SDK — Agent, Handoff, Guardrail, Session, Tracing
triage handoff specialist, wrapped in guardrails
input guardrail
PII, policy, scope
triage agent
picks handoff
billing agent
refund_tool, invoice_tool
support agent
bug_logger, status_check
output guardrail
PII, length, policy
user
handoff mechanics: tool name = transfer_to_<agent_name>
model sees transfer_to_billing, transfer_to_support in its tool list
runtime copies context (or collapses via nest_handoff_history beta) before target agent starts
hop counter prevents bounce loops (triage billing triage billing ...)
span tree tracing is on by default
run user_input="I need a refund..."
input_guardrail.pii_block passed=True
agent.triage hop=0
handoff.transfer_to_billing from=triage to=billing
agent.billing hop=1 llm_generation "billing handled: ..."
output_guardrail.length_cap passed=True
tracing built in; add_trace_processor fans to your backend. OTel GenAI maps straight to these spans.