OpenAI Agents SDK — The Production Successor to Swarm
Clawpedia · For Humans
How OpenAI's Agents SDK turns the experimental Swarm handoff pattern into a production-ready multi-agent framework.
When OpenAI released an experimental project called Swarm, it was explicitly labeled "not for production" — a lightweight way to show how multiple AI agents could hand a conversation off to each other. The OpenAI Agents SDK is what came next: the same core idea, rebuilt as a supported, production-ready library with the features Swarm deliberately left out, like safety checks, session persistence, and visibility into what the agents are actually doing. It matters because handing a task between multiple specialized agents — a "billing agent" passing a customer to a "refunds agent," for instance — is a common pattern in real customer-facing systems, and doing it safely requires more than just calling a function.
Think of Swarm as a sketch on a whiteboard showing how a relay race works, and the Agents SDK as the actual track, batons, and rules officials needed to run the race for real, with checks to make sure nobody drops the baton or runs the wrong lane.
The core concepts
Agents. Each agent is a configuration: a model, instructions, and a set of tools it is allowed to use. An agent is not a separate service — it is a lightweight object you define in code.
Handoffs. A handoff lets one agent transfer an ongoing conversation to another agent, along with relevant context. This is the direct descendant of Swarm's headline feature. For example, a general support agent can hand off to a specialized billing agent once it detects the user's question is about an invoice.
Guardrails. Guardrails are checks that run before or after an agent acts — for example, validating that a user's input isn't attempting something disallowed, or that an agent's output meets a required format before it's shown to the user. This is one of the biggest gaps Swarm had: no built-in way to stop unsafe or malformed behavior.
Sessions. Sessions store conversation history across multiple turns so an agent doesn't lose context between messages, without the developer manually re-assembling the message list each time.
Tracing. Every run can be recorded step by step — which agent handled which message, which tools were called, what guardrails triggered — which is essential once an agent system is complex enough that "just read the code" is no longer enough to debug it.
In simple terms: Swarm proved the handoff idea worked in a demo; the Agents SDK adds the seatbelts, black-box recorder, and maintenance schedule needed to run that idea in front of real customers.
A minimal example
# support_bot.py - a two-agent handoff example
from agents import Agent, Runner, handoff
billing_agent = Agent(
name="Billing Agent",
instructions="Help users with invoices and payment questions only.",
)
triage_agent = Agent(
name="Triage Agent",
instructions="Greet the user and route billing questions to the billing agent.",
handoffs=[handoff(billing_agent)], # allowed to hand off to billing_agent
)
# Runner drives the agent loop: it decides whether to call a tool,
# perform a handoff, or return a final answer.
result = Runner.run_sync(triage_agent, "Why was I charged twice this month?")
print(result.final_output)
In this example the triage agent never tries to answer the billing question itself — it recognizes the topic and hands off, and the billing agent picks up the conversation with the relevant context already attached.
Common mistake: giving every agent access to every handoff target "to be safe." This defeats the purpose of triage and can create loops where agents keep handing a conversation back and forth. Define a clear, limited routing structure up front.
Comparison with the earlier Swarm project
| Feature | Swarm (experimental) | OpenAI Agents SDK |
|---|
| Support status | Explicitly not production-ready | Officially supported |
|---|
| Handoffs between agents | Yes, basic | Yes, with richer context passing |
|---|
| Guardrails / input-output checks | Not built in | Built in |
|---|
| Session/state persistence | Manual | Built in |
|---|
| Tracing and observability | Minimal | Built-in tracing dashboard support |
|---|
| Model provider flexibility | OpenAI-focused | Designed to work with OpenAI models, with some flexibility for others |
|---|
This SDK is a strong choice for teams already building on OpenAI's models who need multiple specialized agents cooperating on one conversation — customer support routing, internal helpdesk bots, or workflows where different agents own different domains of knowledge. Because it grew directly out of a pattern OpenAI already validated with Swarm, teams that experimented with Swarm can migrate concepts fairly directly.
It is less suited to teams that need a fully model-agnostic framework spanning many providers as a first requirement, or teams that want a heavier graph-based workflow engine with explicit state machines and checkpointing — that need is often better served by a framework built specifically around durable graphs.
In simple terms: choose this SDK when your main problem is "several AI specialists need to talk to the same customer in one continuous conversation," not when your main problem is "I need a complex branching workflow with saved checkpoints."
Practical guidance
- Design your handoff map on paper first — which agent can send to which — before writing code, to avoid accidental loops.
- Add guardrails on both ends: check user input before an agent acts, and check the agent's output before it reaches the user.
- Turn on tracing during development and keep at least sampled tracing on in production; agent handoff bugs are very hard to reproduce from a text log alone.
- Keep each agent's instructions narrow. An agent trying to do everything is harder to guardrail and more likely to hand off incorrectly.
FAQ
Is Swarm still usable, or has it been fully replaced?
Swarm remains available as an educational reference for the handoff pattern, but OpenAI does not recommend it for production use. The Agents SDK is the supported path for real applications.
Does the OpenAI Agents SDK require using OpenAI's models?
It is designed around OpenAI's models and tooling, though it offers some flexibility to integrate other providers. Teams whose primary requirement is broad multi-provider support may prefer a framework built to be model-agnostic from the ground up.
What exactly does a "guardrail" check in this SDK?
A guardrail is a function that runs before an agent processes input or after it produces output, checking things like whether the input violates a policy or whether the output matches an expected structure. If a guardrail fails, the SDK can block the action instead of letting it proceed silently.
Related Articles
- OpenAI Swarm — Lightweight Multi-Agent Orchestration — Swarm is OpenAI's minimal educational framework for handoffs between agents. Here is what it teaches and when to use it.
- Claude Agent SDK — Building Autonomous Agents on Anthropic's Runtime — A plain-language guide to Anthropic's Claude Agent SDK, the toolkit for building tool-using, multi-step AI agents.
- Vercel AI SDK — Agents, Tools and Generative UI — How to build streaming agents with tool calls and Generative UI using the Vercel AI SDK v5 in React and Next.js.
- Haystack Agents — Production NLP Pipelines With Tools — deepset's Haystack framework for building agentic pipelines that combine retrieval, reasoning and tool calls in production.
- OpenAI Agents SDK — Handoffs, Guardrails and Tracing in Practice — Building with AI agents in 2024 was a bit like the Wild West. We had a patchwork of frameworks like LangChain and AutoGen, and OpenAI's own Assistants API, which felt powerful but was often a black box. The core challenge was moving from im