LangGraph is an open-source orchestration library for building stateful, multi-step applications around large language models, in which the control flow is expressed as a graph of nodes and edges that read and update a shared state. Among AI frameworks & tools, it occupies the low-level orchestration layer: it does not wrap a model or define prompts, but decides which step runs next, what data each step sees, and how a long-running process pauses, resumes and recovers.
The library was released by the team behind LangChain and is available for Python and JavaScript/TypeScript. It can be used with or without LangChain components, and it is most often chosen for agent loops, human-in-the-loop approval and multi-agent systems where a simple linear chain is not enough.
How LangGraph executes a graph
A LangGraph application is defined as a StateGraph: a state schema, a set of nodes that are ordinary functions, and edges that connect them between the special START and END markers. Each node receives the current state and returns a partial update, which the runtime merges into the state before the next step.
Execution follows a model inspired by Pregel and bulk synchronous processing. The graph advances in discrete super-steps: all nodes scheduled for a step run, possibly in parallel, their updates are applied together, and the edges then decide which nodes run in the next step. Because routing is evaluated after every step, the graph may contain cycles, which is what allows an agent to call a tool, inspect the result and decide to call another one.
The following table lists the core building blocks and the role each one plays at runtime.
| Component | What it is | Role at runtime |
|---|---|---|
| State schema | TypedDict, dataclass or Pydantic model | Defines the shared data every node reads |
| Reducer | Merge function attached to a state key | Combines updates, for example appending messages |
| Node | Python or JavaScript function | Performs one unit of work and returns an update |
| Normal edge | Fixed connection between two nodes | Always routes to the same next node |
| Conditional edge | Routing function over the state | Chooses the next node or ends the run |
| Checkpointer | Persistence backend | Saves a snapshot after every super-step |
Reducers are a frequent source of confusion. Without a reducer, a node update overwrites the key; with a reducer such as add_messages, the update is appended or merged into the existing value. Choosing the wrong behavior is a common cause of lost conversation history or duplicated messages.
Persistence, interrupts and memory
LangGraph treats persistence as a first-class feature rather than an add-on. When a graph is compiled with a checkpointer, the runtime writes a checkpoint of the full state after every super-step and groups those checkpoints under a thread_id, so a conversation or job can be continued later from exactly where it stopped.
This mechanism enables several capabilities that are difficult to build by hand. The table summarizes them.
| Capability | How it works | Typical use |
|---|---|---|
| Durable execution | Resumes from the last saved step after a failure | Long jobs that call slow or unreliable APIs |
| Human-in-the-loop | The interrupt function pauses and waits for input | Approving a payment or an email before it is sent |
| Time travel | Replays or forks from an earlier checkpoint | Debugging a wrong decision in an agent run |
| Short-term memory | Thread-scoped state reloaded on each call | Multi-turn chat with full message history |
| Long-term memory | Separate key-value store shared across threads | User preferences remembered between sessions |
Checkpointers exist for in-memory, SQLite and PostgreSQL backends, among others. The in-memory saver is suitable only for tests, because all state disappears when the process stops. For production, a database-backed checkpointer is the expected choice, and its storage growth must be planned, since every step of every thread produces a snapshot.
LangGraph compared with related frameworks
LangGraph is a low-level, explicit orchestration framework, whereas many neighboring agent tools offer higher-level abstractions with less control. The table contrasts it with frequently compared options in the same category.
| Framework | Main abstraction | Control over flow | Best fit |
|---|---|---|---|
| LangGraph | Explicit graph with shared state | High | Custom agents with branching and approvals |
| LangChain | Components and prebuilt agents | Medium | Model, tool and retriever integrations |
| CrewAI | Role-based crews and tasks | Lower | Quick multi-agent prototypes |
| AutoGen | Conversing agents | Medium | Research on agent dialogue patterns |
| OpenAI Agents SDK | Agents with handoffs | Medium | Lightweight agents on one provider |
The relationship with LangChain is complementary, not competitive. Current LangChain agent constructors run on the LangGraph runtime, while LangGraph itself can call any model client. Observability is usually added through LangSmith or an open alternative such as Langfuse, which record each node, model call and token count as a trace.
Common patterns and when to use them
Most LangGraph applications are built from a small set of recurring patterns, and choosing the simplest one that fits the problem keeps the graph readable and testable. The decision table below maps typical situations to a pattern.
| Situation | Recommended pattern | Reason |
|---|---|---|
| Model must call tools until done | ReAct-style tool loop | A conditional edge returns to the model after each tool call |
| Fixed sequence of known steps | Linear workflow | No routing logic is needed |
| Many independent subtasks | Map-reduce with Send | Fans out parallel nodes, then aggregates results |
| Specialized agents for different jobs | Supervisor with subgraphs | A router delegates to compiled child graphs |
| Risky or irreversible actions | Interrupt before the action | A person approves or edits the pending step |
A practical rule is to start with a deterministic workflow and add model-driven routing only where the decision genuinely requires judgment. Graphs in which every edge is chosen by a model are harder to test and costlier to run than graphs that combine fixed edges with a few well-defined decision points.
Limitations and common mistakes
LangGraph gives precise control at the cost of more code and a steeper learning curve than higher-level agent frameworks. Teams that need only a single prompt or a short retrieval chain gain little from a graph runtime.
- Unbounded loops: a cycle without a clear exit hits the recursion limit, which defaults to 25 super-steps in many versions and raises an error rather than stopping silently.
- Oversized state: storing large documents in state inflates every checkpoint; storing references or identifiers is safer.
- Side effects before an interrupt: when a run resumes, the interrupted node runs again from its start, so non-idempotent calls placed before the
interruptmay execute twice. - Missing thread identifiers: invoking a checkpointed graph without a
thread_idbreaks conversation continuity. - Version drift: APIs changed noticeably before the 1.0 release, so older tutorials may use deprecated imports.
A plain-language summary
LangGraph is a tool for programmers who want an AI assistant to work through a task in clear, controlled steps. Instead of asking a model one question and hoping for a good answer, the developer draws a kind of flowchart: one box gathers information, another calls a calculator or a database, another checks the result, and arrows decide what happens next.
The key benefit is that the process remembers where it is. It can stop and wait for a person to approve something, survive a crash, and continue later without starting over. In short, LangGraph turns an unpredictable chatbot into a reliable, step-by-step worker.
An example from practice
An insurance company builds a claims assistant that handles about 2,000 small property claims per week. The LangGraph application has five nodes: one extracts details from the claim form, one retrieves the policy terms, one asks a language model to assess coverage, one drafts the decision letter, and one sends it. A conditional edge routes any claim above a set amount, for example 5,000 dollars, to an interrupt that waits for a human adjuster.
Because every step is checkpointed in PostgreSQL, adjusters can open a paused claim days later and continue it with one click, and engineers can replay a disputed decision from the exact state the model saw. After rollout, the team reports that routine claims are processed in minutes rather than days, while every high-value payout still receives human approval, which satisfies the internal audit requirement.