Comparisons / OpenAI Agents SDK
OpenAI Agents SDK vs Building from Scratch
OpenAI's Agents SDK (evolved from Swarm) provides Agent, Runner, handoffs, and guardrails. It's intentionally minimal — closer to plain Python than most frameworks. Here's how the concepts map.
The verdict
The Agents SDK is the thinnest framework on this list — it barely abstracts beyond what you'd write yourself. Use it when you want OpenAI's conventions and auto-schema generation. Skip it when you want full control or use non-OpenAI models.
| Concept | OpenAI Agents SDK | Plain Python |
|---|---|---|
| Agent | Agent(name, instructions, model, tools) | A function with a system prompt, model name, and tools dict |
| Tools | Python functions with type hints, auto-converted to schemas | A dict of callables + manually written JSON schema |
| Agent Loop | Runner.run() handles the loop internally | A while loop: call LLM, execute tool_calls, repeat |
| Handoffs | Handoff between Agent objects for multi-agent routing | Call a different agent function based on the LLM's tool choice |
| Guardrails | InputGuardrail and OutputGuardrail with tripwire pattern | Two lists of rule functions checked before and after the LLM |
| Context | Typed context object passed through the agent lifecycle | A state dict updated inside the loop |
What the OpenAI Agents SDK does
The Agents SDK (formerly Swarm) is OpenAI's opinionated take on agent architecture. It provides four primitives:
Agent(system prompt + tools + model)Runner(the agent loop)- handoffs (routing between agents)
- guardrails (input/output validation)
The key feature is auto-schema generation — write a Python function with type hints and the SDK converts it to a JSON tool schema automatically. Runner.run() handles the loop: call the model, check for tool calls, execute them, repeat. Handoffs let one agent transfer control to another by returning a special tool call.
It's deliberately thin. OpenAI designed it as a reference implementation showing how agents should work with their API, not as a batteries-included framework.
The plain Python equivalent
The Agents SDK is already close to plain Python, which says something. Agent is a function that takes messages and returns a completion — the system prompt is the first message, tools are a dict. Runner.run() is a while loop: call openai.chat.completions.create(), check if the response has tool_calls, execute the matching functions from your tools dict, append results to messages, repeat until the model responds without tool_calls.
Handoffs are an if statement: if the model calls a "transfer_to_research" tool, call the research agent function instead. Guardrails are two lists of validation functions — run the input rules before calling the LLM, run the output rules after. The auto-schema generation is the only piece that takes more than a few lines to replicate.
When to use the Agents SDK
The Agents SDK makes sense when you're already committed to OpenAI's API and want clean conventions without building them yourself. Auto-schema generation from type hints saves boilerplate and reduces bugs — you change the function signature and the schema updates automatically. The handoff pattern provides a clean multi-agent routing model that's well-tested.
Guardrails with the tripwire pattern give you a standard way to validate inputs and outputs without ad-hoc if statements scattered through your code. If your team is building multiple agents on OpenAI and wants consistent patterns, the SDK provides a lightweight standard. It's also a good learning tool — read the source code to understand how agents work.
When plain Python is enough
Since the Agents SDK is already minimal, the gap between "with framework" and "without framework" is smaller than any other option on this page. The main reasons to skip it:
- you use non-OpenAI models (the SDK is tightly coupled to OpenAI's API)
- you want to understand every line of your agent loop (the 60-line version is fully transparent)
- you need custom behavior the SDK doesn't support (unusual termination logic, streaming with custom processing, non-standard tool patterns)
Auto-schema generation is nice but not essential — writing JSON schemas by hand takes a few extra minutes and gives you full control. For a single-agent, single-provider setup, the plain Python version is barely longer than the SDK version.
Frequently asked questions
What is the OpenAI Agents SDK?
The OpenAI Agents SDK (evolved from Swarm) provides Agent, Runner, handoffs, and guardrails for building AI agents with OpenAI models. It's the thinnest framework available — closer to plain Python than LangChain or CrewAI, with auto-schema generation from Python type hints.
What is the difference between OpenAI Agents SDK and Swarm?
Agents SDK is the production evolution of Swarm, which was an experimental framework. Both use the same patterns: Agent objects with instructions and tools, a Runner that handles the agent loop, and handoffs for multi-agent routing. Agents SDK adds guardrails and is officially supported.
Should I use OpenAI Agents SDK or LangChain?
Use the Agents SDK if you're committed to OpenAI models and want minimal abstraction with auto-schema generation. Use LangChain if you need multi-provider support, vector store integrations, or the LangSmith ecosystem. Use plain Python if you want full control and transparency.
Worth reading
- Agents SDK guide — OpenAI Platform docs
Official platform guide explaining the SDK's primitives and tracing.
- Introducing AgentKit — OpenAI
OpenAI's follow-up announcement expanding the Agents SDK into a broader toolkit.