Research

What is LangGraph? Stateful Agent Graphs Explained in 2026

LangGraph is an MIT library for stateful agent graphs. Learn what LangGraph is and how StateGraph, nodes, edges, reducers and checkpointers work in version 1.x.

· Updated
· 12 min read
langgraph langchain agent-framework stateful-agents agent-orchestration python open-source 2026
Wireframe state-machine graph with five nodes in a cycle beside the headline What is LangGraph.
Table of Contents

A team needs an agent that researches a topic, drafts a report, asks the user for approval before publishing, and routes to either a “publish” or “revise” branch based on the response. The LangGraph version is a small graph with an interrupt node and a conditional edge that reads the resume payload. The graph maps cleanly onto the workflow, and LangGraph’s primitives match it one to one.

This is the niche LangGraph fills in 2026: it is opinionated about state machines. You declare nodes and edges, share a typed state, and let the framework execute the graph until it terminates. This guide covers what LangGraph is, how its primitives work, how it compares to alternatives, and when to pick it.

TL;DR: What LangGraph is

LangGraph is an open-source, MIT-licensed Python and TypeScript library from LangChain Inc. for building stateful agents as graphs: nodes do work, edges choose the next step, and a typed state object is shared and updated across the run. The Python repo, langchain-ai/langgraph on GitHub, has more than 43,000 GitHub stars as of October 2026, and the current release is 1.2.16 (October 16, 2026).

You build a graph with StateGraph, add nodes and edges, then call .compile() to get a runnable graph with invoke and stream. The primitives are nodes, edges, a typed state schema, checkpointers for persistence, and interrupts for human-in-the-loop.

The library is independent of LangChain proper but interoperates with LangChain’s model wrappers and tool abstractions. The hosted product, LangSmith Deployment (formerly LangGraph Platform), layers managed deployment, persistent state storage, and admin features on top of the open-source library.

How Is LangGraph Different From LangChain?

LangChain is the framework of model integrations, tools and agent building blocks, and LangGraph is the lower-level runtime that executes stateful agent graphs with loops, branches, persistence and interrupts. LangChain Inc. maintains both as separate libraries.

Since LangGraph 1.0, the prebuilt create_react_agent is deprecated in favor of create_agent in the langchain package, which runs on LangGraph underneath. Start with create_agent for a standard tool-calling agent, and drop down to StateGraph when you need a custom topology, such as the approval loop above. For the LangChain side, see what LangChain is and how it works.

What Is LangGraph Used For?

LangGraph is used for agent workflows that need state, branching or a human in the loop. Each use maps to a primitive:

  • Research and report agents with sign-off. An interrupt pauses before publishing, and a checkpointer holds the state until someone approves.
  • Multi-agent supervisors. A supervisor node uses conditional edges to route work to specialist subgraphs and back.
  • Map-reduce document processing. A conditional edge returns one Send per document, and the results merge through a reducer.
  • Support flows with a human handoff. A checkpointer keyed by thread ID lets the conversation resume after a person steps in.
  • Recovery from failures. A run that stops can resume from its last checkpoint instead of starting over.

Why Does LangGraph Matter in 2026?

Three shifts explain why graph-based orchestration matters.

First, agent workflows outgrew linear chains. An agent that branches, loops, retries, persists state and waits for human sign-off needs graph semantics, which a linear chain abstraction cannot express.

Second, long-running agents need persistence. A workflow that fails halfway and restarts from scratch wastes the work already done. Checkpointing at each super-step turns failure recovery from a debugging exercise into a resume-from-last-good-state operation, and LangGraph’s checkpointer gives you that without custom storage code.

Third, agents that act need human approval. An agent that takes irreversible actions (wires money, sends emails, modifies infrastructure) needs an approval pause. LangGraph’s interrupt primitive pauses the graph mid-execution, persists state, and waits for an external resume signal.

When Did LangGraph Come Out?

LangGraph’s first PyPI release (0.0.8) shipped on January 8, 2024, about five months after LangChain Inc. created the GitHub repository in August 2023. Version 1.0 shipped on October 17, 2025, 1.1 on March 10, 2026 and 1.2 on May 12, 2026; the current release is 1.2.16 (October 16, 2026).

What Makes Up a LangGraph Application?

LangGraph’s primitives map closely to graph theory.

StateGraph. The builder. You instantiate StateGraph with a state schema, add nodes, add edges, set an entry point, and compile.

Node. A function that receives the current state and returns a partial update to it. Nodes can be plain Python functions, LangChain Runnables, or compiled subgraphs. The node’s return value is merged into the state by reducers defined on the schema.

Edge. A transition. Edges can be unconditional (after node A, go to node B) or conditional (after node A, evaluate a routing function and pick the next node from a set). Conditional edges are how branching works.

State. A typed dictionary (TypedDict or Pydantic model) shared across all nodes, where each field can declare a reducer that controls how multiple updates are merged. If a key has no reducer, each update overwrites it. Annotate a key with a reducer such as operator.add to append, or use the prebuilt add_messages reducer (and MessagesState) for chat history, which appends new messages and updates existing ones by ID.

Checkpointer. A persistence layer attached to the compiled graph. When you compile with a checkpointer, LangGraph saves a checkpoint at each super-step boundary, not in the middle of a node. If a run stops and resumes (after an interrupt or a retry), the interrupted node runs again from the start of its function, so side effects before the pause must be idempotent.

The InMemorySaver ships in langgraph-checkpoint for testing; install langgraph-checkpoint-sqlite for single-process SQLite persistence and langgraph-checkpoint-postgres for production Postgres. LangSmith Deployment offers a managed Postgres backend.

Interrupt. A primitive that pauses graph execution mid-node. Code calls interrupt(value) and the graph blocks; an external caller resumes with Command(resume=...). The state is checkpointed on pause, so the resume can come hours or days later.

Send. A primitive for parallel fan-out. A conditional edge returns a list of Send(node_name, state) objects, and LangGraph runs the target node once per Send, each with its own input state. This is the map-reduce pattern.

Command. Return Command(update=..., goto=...) from a node to update state and route in one step, use graph=Command.PARENT to jump from a subgraph to its parent, and Command(resume=...) to resume after an interrupt.

What Is StateGraph in LangGraph?

StateGraph is the LangGraph builder class you use to define an agent as a graph: you give it a state schema, register nodes and edges, then compile it into a runnable graph. You import it with from langgraph.graph import StateGraph, START, END.

StateGraph diagram of an approval agent: START to research to draft to an approval node with an interrupt, then a conditional edge to publish and END or to revise and back to draft, with the shared state beside it

The state schema can be a TypedDict, a dataclass (when you want default values) or a Pydantic model. Add work with add_node, fixed transitions with add_edge, and branching with add_conditional_edges. START and END are special nodes that mark where a run enters and leaves the graph.

Calling .compile() runs basic structural checks, such as rejecting a graph with no entry point or an edge to an unknown node, and is where you attach a checkpointer and breakpoints. The compiled graph exposes invoke, stream, ainvoke and astream. In the approval workflow from the opening, research, draft and approval are nodes, and a conditional edge after approval routes to publish or back to revise.

How Does State Work in LangGraph?

LangGraph state is one shared object that every node reads, and each node returns only the keys it changed. LangGraph then calls the reducer for each updated key to merge that partial update into the state.

Each key has its own reducer. A key with no reducer is overwritten by each update. Annotate a key with operator.add to append to a list instead, or use the prebuilt add_messages reducer (or MessagesState) for chat history. Keys a node does not return stay unchanged.

A quick example: the state is {"draft": "v1", "notes": ["sources found"]} and notes uses operator.add. The revise node returns {"draft": "v2", "notes": ["tightened intro"]}. The new state is {"draft": "v2", "notes": ["sources found", "tightened intro"]}: draft was overwritten and notes was appended.

LangGraph StateGraph Example With add_node, add_edge and compile

from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langchain_openai import ChatOpenAI

class State(TypedDict):
    question: str
    answer: str

def research(state: State) -> dict:
    # Return a partial state update; LangGraph merges it into State via reducers.
    return {"answer": f"researched: {state['question']}"}

def write(state: State) -> dict:
    model = ChatOpenAI(model="gpt-6-luna")
    response = model.invoke(f"Polish this draft: {state['answer']}")
    return {"answer": response.content}

builder = StateGraph(State)
builder.add_node("research", research)
builder.add_node("write", write)
builder.add_edge(START, "research")
builder.add_edge("research", "write")
builder.add_edge("write", END)

graph = builder.compile()
result = graph.invoke({"question": "What is OpenTelemetry?", "answer": ""})

The graph compiles into a runnable that accepts a partial state, executes the nodes in topological order with the typed state flowing through, and returns the final state. To watch each node’s update as it finishes, call graph.stream(inputs, stream_mode="updates") instead of invoke.

How Does LangGraph Compare to CrewAI, AutoGen, and Agent SDKs?

FrameworkPrimitiveBest forMaintainer
LangGraphStateful graph (nodes, edges, conditional routing)Arbitrary state machines, persistence, human-in-the-loopLangChain Inc. (MIT)
CrewAIRole + task + crewRole-decomposable workflowsCrewAI Inc. (MIT)
AutoGen (legacy)Conversational agent in a GroupChatExisting AutoGen stacks; new builds should start with the Microsoft Agent FrameworkMicrosoft (MIT code, archived and no longer maintained as of October 2026)
OpenAI Agents SDKAgent loop with tools, handoffs, guardrails, and HITLSingle- or multi-agent workflows on OpenAIOpenAI (MIT)
Claude Agent SDKSingle-agent loop with tool use and subagentsAnthropic-native single-agent workflowsPython SDK MIT; SDK use governed by Anthropic Commercial Terms

LangGraph’s flexibility is its strength and its tax. In return for a lower-level API, you get explicit control over state transitions, parallel fan-out, conditional loops and pause-and-resume.

The procurement question is whether your workflow needs that control. If yes, LangGraph. If not, a higher-level framework from the table above may be simpler.

Production patterns with LangGraph

Three patterns to know.

Pattern 1: ReAct agent with create_agent. A prebuilt starting point. Pass a model, a list of tools, and a system prompt to langchain.agents.create_agent (the modern replacement for the deprecated create_react_agent). The compiled graph loops between LLM and tool calls until the model emits a final answer.

Pattern 2: Multi-agent supervisor. A supervisor node receives the user request and conditionally routes to one of several specialist subgraphs (research, code, summarize, etc.). Each specialist is a compiled subgraph with its own state. The supervisor’s routing function reads the request, picks a specialist, and the graph loops back to the supervisor after each specialist completes.

Pattern 3: Long-running workflow with human approval. A graph with a node that calls interrupt(payload) before an irreversible action. The checkpointer persists state to Postgres. An admin UI reads the pending interrupt and resumes the graph with an approval or rejection.

Common mistakes when adopting LangGraph

  • Skipping the typed state schema. Untyped state is a debugging nightmare. Use TypedDict or Pydantic for the state schema and define reducers explicitly.
  • Using InMemorySaver in production. It is for tests. PostgresSaver is the production checkpointer; SqliteSaver works for low-volume single-process services.
  • Building everything as one giant graph. Subgraphs are first-class. Compile each specialist into its own subgraph and compose them.
  • Forgetting to set recursion limits. A buggy conditional edge can loop until it hits the limit. Pass recursion_limit at run time via the config to invoke or stream (e.g. graph.invoke(inputs, {"recursion_limit": 100})); set it to a reasonable upper bound for your workflow. Since version 1.0.6 the default limit is about 10,000 super-steps (it was 25 before); hitting it raises GraphRecursionError. Pass it as a top-level config key, not inside configurable.
  • Ignoring the streaming API. Graph execution can stream node-level updates as they happen. For real-time UIs, use the stream method instead of invoke.
  • Hand-rolling state persistence. The checkpointer abstraction is LangGraph’s built-in way to persist state. Rolling your own database writes inside nodes can lead to drift between graph state and your custom store.
  • Non-idempotent side effects before interrupt(). The node re-runs from the top on resume, so a database insert before the pause runs twice.
  • Using LangGraph for trivially-linear workflows. A three-step sequential pipeline does not need a graph. Use a small Python function and skip the orchestration overhead.

How to Trace a LangGraph Agent With Future AGI

traceAI’s LangChainInstrumentor traces LangGraph automatically through LangChain’s callback handler, with no LangGraph-specific setup (see the LangGraph tracing guide). Set FI_API_KEY and FI_SECRET_KEY to send traces to Future AGI.

pip install traceAI-langchain
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_langchain import LangChainInstrumentor

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="research-agent-graph",
)
LangChainInstrumentor().instrument(tracer_provider=trace_provider)

traceAI-langchain 0.2.0 needs Python 3.10 to 3.13 and installs cleanly next to LangChain and LangGraph 1.x. The resulting trace tree shows per-node spans named after each graph node, with tool and LLM spans nested under their node. For branching and retries, see tracing conditional edges and retried nodes in LangGraph.

How to Evaluate and Guard LangGraph Agents With Future AGI

Future AGI is an observability and evaluation platform for LangGraph agents built around one reliability loop. Future AGI’s Apache-2.0 core is self-hostable with Docker Compose or a signed Helm chart, and rule-based gateway guardrails are free on every plan.

  • Graph tracing, traceAI (Apache-2.0) records per-node spans named after each graph node, tool and LLM spans nested under their node, the node name and ID on the node’s span (gen_ai.agent.graph.node_name, gen_ai.agent.graph.node_id), session grouping when you bind session.id to the LangGraph thread_id, and human-in-the-loop interrupts recorded as OK (not ERROR) and marked langgraph.interrupt.
  • Node and edge evals, Future AGI has custom evals: write your own grading rule, choose an LLM judge or a deterministic check, set a pass threshold and run it as a CI gate. Built-in agent checks include Task Completion, Tool Call Accuracy, Evaluate Function Calling, Instruction Adherence, Groundedness and Detect Hallucination, and scores attach to whole traces or single spans. BYOK lets any LLM serve as the judge at zero platform fee. For a walkthrough, see a deeper LangGraph agent evaluation tutorial.
  • Simulation, Simulation runs your agent through realistic conversations, built from a scenario and a persona, as chat or voice, and scores every conversation with the same evals you use on production traces.
  • Gateway and guardrails, the Agent Command Center gives every node’s model wrapper one OpenAI-compatible endpoint across 100+ providers with routing, failover, caching and budget limits, and Agent Command Center guardrails run checks such as PII detection, prompt injection, secret detection and tool permissions, and can block a request, log it, or mask PII before it reaches the model.

Beyond the four axes, Future AGI also ships six optimizer algorithms (Random Search, Bayesian Search, ProTeGi, Meta-Prompt, PromptWizard, GEPA) that rewrite and score prompt variations with evals as the judge, so production traces feed back into versioned node prompts. Pricing starts free; beyond the free allowances you pay for usage, with optional Boost, Scale and Enterprise add-ons from $250/month.

Future AGI puts tracing, evals, simulation, gateway and guardrails on one platform, so the loop from trace to fix closes in one place. For a deeper walk-through of the tracing model, read What is LLM Tracing?.

Ship the Research, Approve, Publish Agent With Confidence

The agent from the opening (research, draft, ask for approval, then publish or revise) is one StateGraph with an interrupt before publishing and a conditional edge that reads the reviewer’s answer. A checkpointer keeps the run paused for as long as the review takes.

Once it runs, trace every node with traceAI, score each draft with evaluators such as Task Completion and Groundedness before the approval pause, and replay the runs that failed as simulation scenarios so the next version is tested against them.

Trace your first LangGraph run free on Future AGI.

Related: What is CrewAI?, What is AutoGen?, Best Multi-Agent Frameworks in 2026

Frequently Asked Questions

What is LangGraph?

LangGraph is an open-source, MIT-licensed library from LangChain Inc. for building stateful AI agents as graphs of nodes, edges and a shared state object, in Python and JavaScript. Nodes do the work, edges decide what runs next, and the state carries context between steps. Graphs can loop, branch, pause for approval and resume.

What is LangGraph used for?

LangGraph is used to build AI agents and workflows that need memory across steps, conditional routing, retries, human approval or recovery from a saved checkpoint. Examples include tool-calling agents, multi-agent systems that hand work to each other, and long-running review flows where a person signs off on an action before the agent continues.

What is the difference between LangGraph and LangChain?

LangChain is the broader framework of model integrations and agent building blocks, while LangGraph is the lower-level runtime that runs stateful agent graphs with loops, branches and checkpoints. Since LangGraph 1.0, the create_agent factory in langchain replaces create_react_agent and runs on LangGraph underneath. Use create_agent for standard agents and StateGraph for custom control flow.

Is LangGraph paid or free?

LangGraph is free: the Python and JavaScript libraries are MIT-licensed open source, so you pay no LangGraph license fee to install them and run graphs yourself. Your own infrastructure and model API calls still cost money. LangChain Inc. charges for managed hosting through LangSmith Deployment, formerly LangGraph Platform, which comes with paid LangSmith plans.

When was LangGraph founded?

LangChain Inc. created the LangGraph repository in August 2023 and published the first LangGraph release on PyPI on January 8, 2024. Version 1.0 followed on October 17, 2025, and 1.2 on May 12, 2026. As of October 2026 the current release is 1.2.16, and the GitHub repository has more than 43,000 stars.

What are the alternatives to LangGraph?

LangGraph alternatives include CrewAI, the OpenAI Agents SDK, the Claude Agent SDK and Microsoft Agent Framework, four agent frameworks you can use instead of LangGraph. CrewAI, the OpenAI Agents SDK and Microsoft Agent Framework are MIT-licensed. AutoGen is now archived and no longer maintained, and Microsoft points new users to Agent Framework instead.

How does LangGraph state work?

LangGraph state is a shared typed object, defined as a TypedDict, dataclass or Pydantic model, that every node reads and updates as the graph runs. Nodes return partial updates, and LangGraph calls each updated key's reducer to merge them. Keys without a reducer are overwritten, and keys a node does not return stay unchanged.

What is a LangGraph checkpointer?

A LangGraph checkpointer is the persistence layer that saves graph state at each super-step boundary, so a run can pause for human approval, survive a failure and resume later. You attach it when you compile the graph. Available backends include langgraph-checkpoint-postgres and langgraph-checkpoint-sqlite, and an interrupted node reruns from its start.
Related Articles
View all