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

FeatureSwarm (experimental)OpenAI Agents SDK
Support statusExplicitly not production-readyOfficially supported
Handoffs between agentsYes, basicYes, with richer context passing
Guardrails / input-output checksNot built inBuilt in
Session/state persistenceManualBuilt in
Tracing and observabilityMinimalBuilt-in tracing dashboard support

When it's a good fit

Model provider flexibilityOpenAI-focusedDesigned 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

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