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 Runner-centered agent loop or an explicit, checkpointed state graph. The OpenAI Agents SDK exposes a deliberately tiny primitive set -- Agents, tools, handoffs, guardrails, sessions, RunState, and built-in tracing -- and runs the agent loop until it produces final output; approval-gated tool calls can pause and resume through a serialized RunState. 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 Runner loop with tools, handoffs, and occasional approvals points at the SDK; a workflow whose application logic is explicit graph state, branching, and checkpointed transitions points at LangGraph.

Published 2026-06-18 · ~6 min read · Independent, no paid placements (disclosure)

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.
  • Lower initial scaffolding for a simple Runner-centered agent: OpenAI Agents SDK.
  • Winner for long-running workflows: LangGraph -- with a durable checkpointer configured, checkpoints support recovery after process failure and approval interrupts.
  • Best for: OpenAI Agents SDK for Runner-centric agents, triage/handoff shapes, and tool approvals; LangGraph for plan-and-execute, graph-level retries, and checkpointed state transitions.

Snapshot comparison

Before the section-by-section breakdown, the one-screen version.

Dimension OpenAI Agents SDK LangGraph
Execution modelRunner agent loop; tools and handoffs feed the next turnExplicit graph traversal over nodes and edges
State modelConversation sessions plus serializable RunState for paused runsExplicit typed graph state scoped to a thread
Resumability / checkpointPause/serialize/resume RunState; application stores the serialized stateConfigured checkpointer persists thread-scoped graph checkpoints
Human-in-the-loopBuilt-in tool approvals surface interruptions through RunStateinterrupt() pauses graph execution; resume with the same thread state
Hosted runtimeNone official (traces hosted by OpenAI)LangGraph Platform (managed)
Core primitivesAgents, tools, handoffs, guardrails, sessions, RunStateStateGraph, nodes, edges, typed state, checkpointer
Branching & retriesVia handoffsConditional edges and loops
TracingBuilt-in trace UILangSmith (separate product)
GuardrailsFirst-class input/output guardrailsNode-level, roll your own
Model coverageOpenAI-first; others via LiteLLMProvider-agnostic
LicenseMITMIT
MaintainerOpenAILangChain Inc.
Best forRunner-centric agents on an OpenAI-first stackStateful, branchy workflows built around graph checkpoints
Decision tree for choosing OpenAI Agents SDK, LangGraph, or a prototype of both based on explicit graph state, branches and loops, checkpoint inspection, Runner-shaped flows, guardrails, and tracing.
Choose LangGraph when graph state and transitions define the application; choose OpenAI Agents SDK when Runner primitives fit; prototype both when the critical failure or approval path remains uncertain.

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. Guardrails can validate inputs, outputs, or tool behavior; input guardrails can block before the main run or execute in parallel, depending on configuration. Conversation state is carried by sessions, and a built-in tracing UI records each run. The built-in loop runs until final output, a turn limit, or an interruption. For approval-gated tools, the SDK surfaces interruptions through RunState; that state can be serialized by the application and restored to resume the same run. This is resumability around the Runner lifecycle, not a graph-wide node/checkpoint model.

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. With a durable checkpointer configured, graph checkpoints support recovery after process failure 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.

Execution model comparison between the OpenAI Agents SDK Runner loop with tools, handoffs, guardrails, sessions, tracing, and serializable RunState, and LangGraph StateGraph with typed state, checkpointer, interrupt, and Command resume.
Both frameworks can pause and resume; the key difference is Runner-lifecycle state versus checkpointed graph state and transitions.

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 model graph state explicitly, inspect checkpoints by thread, or make branching and resumed transitions the core application structure, LangGraph's state graph is the model built for it.

Pricing comparison

Both frameworks are MIT-licensed and free. Total cost can include model inference, infrastructure, observability, persistence, and optional hosted runtime services.

Cost line OpenAI Agents SDK LangGraph
Framework licenceFree (MIT)Free (MIT)
Self-hostingYour infra (any Python host)Your infra (any Python host)
Model inferencePay-per-token (OpenAI primary)Pay-per-token (any provider)
Hosted runtimeNone officialLangGraph Platform: usage-based
ObservabilityBuilt-in tracing; model/API usage billed separatelyLangSmith is a separate product; verify current plan terms
Operational cost driversModel calls, infrastructure, and trace retentionModel calls, infrastructure, and checkpoint/state retention

The pattern: both frameworks are MIT-licensed. Total cost depends on model choice, call frequency, context strategy, observability, persistence, and hosting. LangGraph checkpoints can avoid recomputing some completed graph steps after failures, but token usage still depends on the workflow's model calls and context strategy.

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?

  1. Single-agent loop on OpenAI models: OpenAI Agents SDK wins. Smaller surface, lower ceremony, tracing and guardrails included.
  2. Stateful, branchy, retry-heavy, or resumable: LangGraph wins. The graph model exists for exactly this shape, and persistence keeps long workflows safe.
  3. 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 graph state: inspectable thread checkpoints, complex conditional transitions, or long-running graph workflows whose structure 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, guardrails, handoffs, and tool-approval pauses out of the box, pick the OpenAI Agents SDK. If explicit graph state, conditional edges, graph-level checkpoints, and resumable control flow define the application, pick LangGraph. They are not really substitutes -- one is a Runner-centered agent runtime, the other is a graph 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 requires less explicit graph scaffolding 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 until it produces final output, handing off or executing tools as needed. It can pause for tool approval and serialize a RunState for later resumption. LangGraph traverses an explicit StateGraph of nodes and edges and uses a configured checkpointer to persist thread-scoped graph state, making resumable graph control flow the central model rather than a pause path around a Runner loop.
Is the OpenAI Agents SDK only for OpenAI models?
It is OpenAI-first but not OpenAI-only. The SDK supports other providers through LiteLLM. Feature behavior for tracing, structured output, and tool calling depends on the provider and integration.
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?
Both support human-in-the-loop pauses, but at different layers. The OpenAI Agents SDK can surface tool-approval interruptions, serialize the resulting RunState, and resume the Runner later. LangGraph interrupt() pauses an explicit graph and resumes it from thread-scoped state saved by a configured checkpointer. Choose LangGraph when checkpointed graph state and transitions are the application model, not merely when one tool call needs approval.
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.
Best OpenAI Agents SDK alternatives → Best LangGraph alternatives → AI Agent Frameworks pillar →