Comparison · Agent frameworks

OpenAI Agents SDK vs LangGraph

One is a small agent loop with handoffs, guardrails and tracing. The other is a graph runtime for long-running, stateful workflows. They overlap, but they optimise for different kinds of complexity.

Short answer. Use the OpenAI Agents SDK when your agent is a loop: a model, a set of tools, optional handoffs to specialists and guardrails on input and output. Use LangGraph when the workflow is a graph with explicit state, branches, retries, pauses for humans and durable checkpoints. The first is faster to ship; the second is easier to reason about when the control flow becomes the product.

Side by side

DimensionOpenAI Agents SDKLangGraph
AbstractionAgents, handoffs, guardrails, sessionsState graph, nodes, edges, checkpoints
Default model pathOpenAI Responses APIAny model through LangChain or direct SDKs
OrchestrationAgent loop and handoffsExplicit graph, conditional edges, subgraphs
DurabilitySessions for conversation stateCheckpointers and resumable runs
Human in the loopBuilt-in mechanismsInterrupt and resume at any node
TracingBuilt-in OpenAI tracingLangSmith or OpenTelemetry
DeploymentLibrary; you host the runtimeLibrary; LangSmith Agent Server optional
Best forSingle-agent and handoff patternsLong-running, branching, stateful workflows

Sources: OpenAI Agents SDK documentation, LangGraph overview and LangSmith docs, checked 20 November 2026. Both projects ship frequently; confirm APIs against the installed version.

Orchestration model

The Agents SDK has a deliberately small set of primitives. An Agent has instructions, tools and guardrails. A Runner executes the loop until the model stops calling tools. A handoff transfers control to another agent, which is how the SDK expresses triage, escalation and specialist routing. Sessions keep conversation state across turns.

LangGraph makes the control flow explicit. You define a state schema, add nodes that read and write that state, and connect them with edges. Conditional edges choose the next node based on state. A checkpointer persists state after each step, so a failed run can resume instead of restarting. Subgraphs let you compose a larger workflow from smaller ones.

Tools and handoffs

In the Agents SDK, a Python function becomes a tool with automatic schema generation and Pydantic validation. MCP servers can expose remote tools alongside local functions. Hosted tools cover web search, file search and computer use where available. Handoffs are themselves a tool-like mechanism: the model can choose to transfer to a billing agent, a refund agent or a human escalation queue.

LangGraph treats tools as ordinary nodes or as a prebuilt tool node. You can call a LangChain tool, a plain function or an external API. The graph decides when a tool runs and what happens to its output. That makes it easy to add a validation node after a tool call, or to route a failed tool result back to a retry node with a different strategy.

Memory and state

The Agents SDK's session layer stores conversation history for an agent loop. It ships SQLAlchemy, SQLite, Redis, Mongo and encrypted session options, so you can keep memory in the store you already operate. That is enough for a chat assistant that needs continuity across turns.

LangGraph separates short-term thread state from long-term memory. The checkpointer persists the graph state at every step; a store holds facts that outlive a thread. Because the state is explicit, you can inspect it, edit it during a human pause and resume from a known point. That is the feature that makes long-running approvals practical.

Observability

The Agents SDK includes tracing that shows the agent loop, tool calls and handoffs. It is designed to feed OpenAI's evaluation and fine-tuning tools. If you already use OpenAI's platform, the trace is available with little setup.

LangGraph pairs with LangSmith for traces, evaluation, prompt management and deployment. LangSmith is a separate commercial product with its own plans, so budget for it if you want the managed experience. You can also route OpenTelemetry traces to Datadog, Grafana or another backend, which teams with an existing observability stack often prefer.

Either way, trace the same things: model, prompt version, retrieved document IDs, tool arguments, latency, token counts and the final answer. A trace without prompt and retrieval versions is hard to act on.

Deployment

The Agents SDK is a library. You run it in your own service, container or serverless function, and you own scaling, secrets, retries and queues. That is straightforward for a synchronous API; it becomes more work when a run lasts minutes and must survive a restart.

LangGraph is also a library, but the LangSmith Agent Server adds a managed runtime for stateful agents, with Studio for visual prototyping. If you deploy elsewhere, you still need a durable store for checkpoints and a worker model that can resume runs. The framework does not remove the operational work; it gives you a state model that makes the work possible.

Migration and cost

Migration is a rewrite of the control plane, not the prompts. Start by mapping the Agents SDK loop to a graph: the agent becomes a model node, each tool becomes a tool node, and each handoff becomes a conditional edge. Move session history into a checkpointer. Convert guardrails into validation nodes that can route to a rejection or retry path.

# OpenAI Agents SDK: a triage agent that hands off to a specialist
from agents import Agent, Runner

billing = Agent(name="Billing", instructions="Resolve billing questions.")
triage = Agent(
    name="Triage",
    instructions="Route billing questions to Billing. Answer everything else.",
    handoffs=[billing],
)
result = Runner.run_sync(triage, "Why was I charged twice?")
print(result.final_output)

# LangGraph: the same flow as an explicit graph
from langgraph.graph import StateGraph, MessagesState, START, END

def triage_node(state: MessagesState):
    return {"messages": [{"role": "ai", "content": "route:billing"}]}

def billing_node(state: MessagesState):
    return {"messages": [{"role": "ai", "content": "I found the duplicate charge."}]}

g = StateGraph(MessagesState)
g.add_node("triage", triage_node)
g.add_node("billing", billing_node)
g.add_edge(START, "triage")
g.add_conditional_edges("triage", lambda s: "billing", {"billing": "billing"})
g.add_edge("billing", END)
app = g.compile()
print(app.invoke({"messages": [{"role": "user", "content": "Why was I charged twice?"}]}))

Both are open source, so there is no licence fee. The bill is model tokens, tracing retention and hosting. LangGraph can save money by resuming after a failure; the SDK saves money with fewer model calls. Measure cost per completed task, not per token.

FAQ

Is LangGraph harder than the OpenAI Agents SDK?

LangGraph asks you to define state, nodes and edges explicitly, so the first working graph takes more code. The payoff is control over branching, retries and checkpoints. The Agents SDK hides the loop and is faster to start for a single agent or a handoff pattern.

Can the OpenAI Agents SDK use non-OpenAI models?

Yes, through model adapters and OpenAI-compatible endpoints. The SDK defaults to the Responses API for OpenAI models, but its model interface and provider adapters let you point it at other providers. Test tool calling and structured output against the exact model.

Does LangGraph include observability?

LangGraph itself is the runtime. Tracing, evaluation and deployment are provided by LangSmith, which is a separate product with its own plans. You can also export OpenTelemetry traces to your existing backend.

Which is cheaper?

Both frameworks are open source, so licence cost is zero. Model tokens dominate the bill, followed by tracing retention and hosting. The real cost difference comes from how many model calls each architecture makes and how often a failed run must restart from the beginning.

Can I migrate between them?

Yes, but not by swapping an import. Map the Agents SDK loop and handoffs to graph nodes, move session state into a checkpointer, and rewrite guardrails as graph edges or validation nodes. Run both implementations against the same evaluation set before cutting over.

Reviewed 20 November 2026. The Agents SDK primitives were checked against the OpenAI Agents SDK docs; graph, persistence and deployment behaviour against the LangGraph overview and LangSmith docs. Framework APIs change; pin versions.