Comparison · Updated 2026-06-18
OpenAI Agents SDK vs LangGraph
The decision here is not "which framework is better" -- it is whether your workflow needs a run-to-completion agent loop or a resumable state graph. The OpenAI Agents SDK exposes a deliberately tiny primitive set -- Agents, tools, handoffs, guardrails, sessions, and built-in tracing -- and runs the agent loop until the task completes in one process. LangGraph exposes a different set -- a StateGraph of nodes and edges over a typed state object, with a checkpointer that persists every step and an interrupt/resume mechanism that can pause a run and continue it later. Match the primitive set to your workflow shape and the choice makes itself: a single agent that answers in one pass points at the SDK; a workflow that must branch, retry, or wait for a human and resume points at LangGraph.
OpenAI Agents SDK
Opinionated Python SDK from OpenAI. Agent + tools + handoffs + guardrails + tracing -- batteries included for production single-agent workflows.
See alternatives →LangGraph
State-graph agent framework from the LangChain team. Nodes, edges, persistent state, time-travel debugging -- explicit control flow for stateful agents.
See alternatives →The short answer
- Winner for single-agent on OpenAI: OpenAI Agents SDK. Tracing, guardrails, and handoffs are built in.
- Winner for stateful, branchy, resumable workflows: LangGraph. Graph edges, checkpoints, and persistence are first-class.
- Winner for learning curve: OpenAI Agents SDK -- ship in 50 lines.
- Winner for long-running workflows: LangGraph -- checkpoints survive crashes and approvals.
- Best for: OpenAI Agents SDK for production single agents and triage/handoff shapes; LangGraph for plan-and-execute, retries, and human-in-the-loop.
Snapshot comparison
Before the section-by-section breakdown, the one-screen version.
| Dimension | OpenAI Agents SDK | LangGraph |
|---|---|---|
| Execution model | Run-to-completion agent loop (one process) | Graph traversal, resumable from any step |
| State model | Implicit conversation history via sessions | Explicit typed state passed between nodes |
| Resumability / checkpoint | None (loop runs to completion) | Checkpointer persists every step; resume later |
| Human-in-the-loop | Wire it yourself | Native interrupt() then resume |
| Hosted runtime | None official (traces hosted by OpenAI) | LangGraph Platform (managed) |
| Core primitives | Agents, tools, handoffs, guardrails, sessions | StateGraph, nodes, edges, typed state, checkpointer |
| Branching & retries | Via handoffs | Conditional edges and loops |
| Tracing | Built-in trace UI | LangSmith (separate product) |
| Guardrails | First-class input/output guardrails | Node-level, roll your own |
| Model coverage | OpenAI-first; others via LiteLLM | Provider-agnostic |
| License | MIT | MIT |
| Maintainer | OpenAI | LangChain Inc. |
| Best for | Single-agent, run-to-completion on OpenAI | Stateful, branchy, resumable workflows |
Two different mental models
The right framework depends on which of these reads like your workflow.
OpenAI Agents SDK: Agents, tools, handoffs, guardrails, sessions. Per the
official docs, the SDK is built on a deliberately small primitive set. You define an
Agent (an LLM with instructions and tools), turn functions into tools, and
optionally register handoffs so one agent can delegate to another. Input/output
guardrails run validation in parallel with execution and fail fast. Conversation
state is carried by sessions, and a built-in tracing UI records each run. The
built-in loop runs until the task is complete -- one process, start to finish.
LangGraph: StateGraph, nodes, edges, typed state, checkpointer, interrupt/resume.
You declare a StateGraph over a typed state object; nodes are functions
(often LLM calls), and edges -- including conditional edges -- define transitions.
Branching and retries are expressed as edges and loops rather than handoffs. A
checkpointer persists state at every step, so a run can be resumed after a crash
or a long pause, and interrupt() pauses the graph for human input and resumes
from the saved checkpoint. The mental model is a durable workflow engine, not a
single-shot agent loop.
If you find yourself writing "the agent gets a question, calls a search tool, calls a database tool, then answers", that is OpenAI Agents SDK shaped. If you find yourself writing "if the validator passes, continue; otherwise retry with a revised prompt", that is LangGraph shaped.
Use cases -- when each one wins
OpenAI Agents SDK fits when
- Customer support agent with tools. One agent, knowledge base search + order lookup + refund tool + handoff to a human specialist.
- Internal Q&A bot over docs. RAG retrieval as a tool, structured output for citations, guardrails for off-topic queries.
- Triage and routing. Classifies inbound messages and hands off to specialist agents per category.
- Data enrichment agent. Reads a CRM record, calls enrichment APIs, writes structured results back.
- Anything where built-in tracing and guardrails matter more than explicit state.
LangGraph fits when
- Plan-and-execute agents. Planner proposes steps; executor runs them; planner adjusts based on the result.
- Long-running workflows. Agents that pause for hours or days waiting for human approval, then resume from saved state.
- Retries and self-correction. Loops that re-prompt with error context until a tool call succeeds.
- Auditable production agents. Workflows where every transition needs to be inspectable, replayable, and time-travel debuggable.
- Stateful multi-agent. Multiple specialist agents sharing a typed state object, with explicit handoffs between graph nodes.
Learning curve
OpenAI Agents SDK has fewer concepts to learn first. The surface is Agent, function tools, handoffs, and guardrails, with tracing on by default -- the official docs frame the whole SDK as "few enough primitives to make it quick to learn." You can express a working agent without a state schema or graph wiring.
LangGraph asks you to model state up front. Before a run works you define the typed state, the nodes, and the edges (including conditional routing). That cost buys durability: because the checkpointer persists each step, you can inspect the state at any node and resume a run rather than restart it. The trade is explicit -- more structure to learn in exchange for resumability and inspectable state.
Practical rule: if the workflow is a single agent that runs to completion, the SDK's smaller primitive set gets you there with less scaffolding. If the workflow must survive interruptions, branch, or pause for a human and resume, LangGraph's state graph is the model built for it.
Pricing comparison
Both frameworks are MIT-licensed and free. The real bill is model inference and, optionally, hosted observability or runtime services.
| Cost line | OpenAI Agents SDK | LangGraph |
|---|---|---|
| Framework licence | Free (MIT) | Free (MIT) |
| Self-hosting | Your infra (any Python host) | Your infra (any Python host) |
| Model inference | Pay-per-token (OpenAI primary) | Pay-per-token (any provider) |
| Hosted runtime | None official | LangGraph Platform: usage-based |
| Observability | Included with OpenAI usage | LangSmith (paid, generous free tier) |
| Hidden costs | Trace storage at scale | State storage at scale |
The pattern: framework cost is zero for both. Model inference dominates. For a tight single-agent loop, the SDK is competitive on cost and saves engineering time on tracing. For long-running, multi-step workflows, LangGraph's per-node state discipline materially reduces token spend at scale.
Final verdict
These two frameworks are not direct substitutes -- they are competing for the same decision. The right call comes down to one question: does my workflow need explicit state and branching, or is it a single-agent loop that benefits from batteries-included tracing and guardrails?
- Single-agent loop on OpenAI models: OpenAI Agents SDK wins. Smaller surface, lower ceremony, tracing and guardrails included.
- Stateful, branchy, retry-heavy, or resumable: LangGraph wins. The graph model exists for exactly this shape, and persistence keeps long workflows safe.
- Neither feels right: the workflow may be multi-agent shaped instead. See the AI Agent Frameworks pillar for the wider landscape, or the best OpenAI Agents SDK alternatives and best LangGraph alternatives shortlists.
Meta-recommendation: a lot of "we need LangGraph" architectures are actually single-agent loops with one or two retry conditions -- shippable as an OpenAI Agents SDK agent with a guardrail and a handoff. Reach for LangGraph when the workflow genuinely needs explicit state: human-in-the-loop pauses, multi-day runs, or branches the SDK cannot model cleanly.
Next reads
FAQ
- OpenAI Agents SDK vs LangGraph -- which one should I pick?
- If your workflow is "one agent with tools" against OpenAI models and you want tracing and guardrails out of the box, pick the OpenAI Agents SDK. If your workflow has branches, retries, human-in-the-loop pauses, or needs to resume after a crash, pick LangGraph. They are not really substitutes -- one is an opinionated runtime, the other is a control-flow engine.
- Is LangGraph better than the OpenAI Agents SDK for production?
- Only when the workflow is genuinely stateful or branchy. LangGraph gives you persistence, time-travel debugging, and explicit transitions, which matter when an agent has to recover from a failed tool call or wait days for a human approval. For a straightforward single-agent loop, the OpenAI Agents SDK ships faster, costs less, and includes tracing out of the box.
- Is the OpenAI Agents SDK easier to learn than LangGraph?
- The SDK has fewer first concepts: Agent, tools, handoffs, guardrails, and sessions, with tracing built in. LangGraph asks you to declare a typed state, nodes, and edges before a run works. The SDK trades structure for a quicker start; LangGraph trades a steeper start for explicit, inspectable state.
- What is the core difference in how each one runs a workflow?
- The OpenAI Agents SDK runs a built-in agent loop to completion in one process. LangGraph traverses a StateGraph of nodes and edges and, via its checkpointer, persists state at every step -- so a LangGraph run can be resumed after a crash or a pause, while an SDK run is designed to finish in a single pass.
- Is the OpenAI Agents SDK only for OpenAI models?
- It is OpenAI-first but not OpenAI-only. The SDK supports any model that LiteLLM can reach (Anthropic, Google, Bedrock, Azure, local). In practice, tracing, structured output, and tool calling have the smoothest ergonomics on OpenAI models; cross-provider works but loses some polish.
- Can I use the OpenAI Agents SDK and LangGraph together?
- In principle yes -- you can wrap an OpenAI Agents SDK agent as a single LangGraph node, using LangGraph for control flow and the SDK for the agent loop. In practice teams pick one. Mixing both adds a second mental model and a second set of failure modes.
- Which one handles human-in-the-loop and resumable runs?
- LangGraph, natively. Its interrupt() mechanism pauses the graph for human input and resumes from the saved checkpoint, and the checkpointer persists state so long-running or multi-day workflows can continue after a stop. The OpenAI Agents SDK expects the agent loop to run to completion; pausing and resuming across processes is not its built-in shape.
- Are both open source?
- Yes. Both are MIT-licensed. The OpenAI Agents SDK is OpenAI-first (other providers via LiteLLM); LangGraph is provider-agnostic. Both are safe to embed in proprietary products.