← Blog

· 4 min read

OpenAI Agents SDK: Handoffs, Guardrails and a Small Multi-Agent Demo

Most teams I talk to want "agents" before they have a clear job for one. The OpenAI Agents SDK is a good place to learn what a second agent is actually for, because it has very few moving parts.

It is a Python library, MIT licensed, built on four ideas: agents, handoffs or agents as tools, guardrails, and tracing. Its stated aim is enough features to be worth using, but few enough primitives to make it quick to learn (OpenAI, 2026).

1. The pieces you need to know

The SDK's building blocks
PieceWhat it doesUse it for
AgentA model with instructions and toolsOne clear job each
HandoffPasses the conversation to a specialistTriage: billing, refunds, support
Agent as toolCalls a specialist and keeps controlA manager that combines answers
GuardrailChecks input and outputBlocking off-topic or unsafe requests
SessionKeeps history across runsMulti-turn chats

2. A small demo: triage with two specialists

Install with pip install openai-agents and set OPENAI_API_KEY.

import asyncio
from agents import Agent, Runner

history = Agent(name="History Tutor",
    handoff_description="Specialist agent for historical questions",
    instructions="You answer history questions clearly and concisely.")
maths = Agent(name="Math Tutor",
    handoff_description="Specialist agent for math questions",
    instructions="You explain math step by step.")
triage = Agent(name="Triage Agent",
    instructions="Route each question to the right specialist.",
    handoffs=[history, maths])

result = asyncio.run(Runner.run(triage, "Who was the first president of the United States?"))
print(result.final_output, result.last_agent.name)

The triage agent reads the question and hands it to the right tutor. Swap the tutors for your own billing and refund agents and you have the skeleton of a support desk. For single-call samples, see our OpenAI code recipe.

3. Where it fits, and where it doesn't

The docs are honest about the trade-off. Letting the model route is great when the task is open-ended; orchestrating in code is more deterministic and predictable in speed, cost and performance (OpenAI, 2026). My rule: if you can draw the flowchart, write it in code and use agents only for the steps you cannot.

Two things to check before production. Tracing is on by default, so decide what leaves your servers. And tracing is unavailable under a Zero Data Retention policy (OpenAI, 2026), which matters to Indian banks and insurers that negotiated one.

Is a multi-agent setup right for you?

Score each 0 (no), 1 (partly) or 2 (yes):

  • Distinct jobs: each agent has a job you can name in one line.
  • Routing is fuzzy: you cannot write the routing as simple rules.
  • Guardrails: input and output checks are defined.
  • Data rules: you have decided what tracing may send.
  • Test set: twenty real questions with expected routes.
What your score means (my recommendation)
ScoreNext move
8–10Build the pilot with handoffs.
5–7Start with one agent and code routing.
0–4A single prompt is probably enough.

Your next step

Run the demo this week, then replace the tutors with two real queues from your support inbox and test it on twenty past tickets.

Sources

  1. OpenAI (2026). OpenAI Agents SDK documentation. Overview, quickstart, handoffs and multi-agent pages, read 20 November 2026.
  2. OpenAI (2026). Tracing. Read 20 November 2026.
  3. PyPI (2026). openai-agents 0.25.0. 18 November 2026.

NEW CODE EVERY MONTH.

Get a note when new Claude Code templates, code recipes or tools go live.

No account required

We email once to confirm. Unsubscribe anytime — it deletes your address.

New drops, every week

Free tools & Claude templates, landing regularly.

We keep shipping new free tools, code recipes and Claude Code templates. Follow @freeyantra on Instagram or join the newsletter so you never miss one.

Follow @freeyantra

or get them by email

Double opt-in. Unsubscribe any time. Privacy