LangGraph Explained: Stateful Agents That Remember

LangGraph Explained: Stateful Agents That Remember

LangGraph explained in one sentence: it is a low-level, open-source framework for building long-running, stateful agents as graphs of nodes and edges. LangGraph models an agent as a set of steps that read and write a shared state, with explicit control over where the model reasons, where code runs, where loops happen and where a human approves. The central question is when to use it instead of a simple chain, and the short answer is to use it when the workflow needs loops, branching, memory or the ability to resume after a failure.

LangGraph is built by LangChain Inc, the company behind LangChain, and it reached its 1.0 release in October 2025, with a commitment to no breaking changes until version 2.0. It is available in Python and TypeScript, it is licensed under the MIT licence, and it can be used on its own or together with the rest of the LangChain ecosystem. It is also the runtime underneath LangChain’s agent abstraction, so teams can mix high-level agents and hand-built graphs on one persistence and observability stack.

Key takeaways

  • LangGraph explained: a graph-based framework where nodes are steps, edges are control flow, and shared state is what the agent remembers.
  • Durable execution is the defining feature: checkpointing saves state after every step, so a run resumes where it stopped instead of restarting.
  • Human-in-the-loop interrupts are a native primitive, letting a person inspect, approve or edit state before the graph continues.
  • LangGraph 1.0, released in October 2025, stabilised the runtime for production use.
  • Use LangGraph when the path through the workflow is decided at run time; use a simple chain when the path is fixed.

What LangGraph is

LangGraph is an orchestration framework, not a model and not a hosted product. You define a graph: nodes are functions or agents that do work, edges decide which node runs next, and a shared state object carries information between them. Conditional edges let the graph branch on the result of a step, and loops let it retry, ask a clarifying question or escalate to a human.

That graph model fits work where the path cannot be fixed in advance, because the agent decides at run time what to do next.

The framework is deliberately low level. It does not dictate your prompts, your architecture or your model provider, and it does not abstract away the control flow. That is both its strength and its cost: you get explicit control over every step, but you write more code than you would with a high-level agent library.

Teams that want that control, and are comfortable with a steeper learning curve, get an agent they can reason about, test and debug step by step. Best for: production agents with complex, branching or long-running workflows.

Durable execution and checkpointing

Durable execution is the feature that most clearly separates LangGraph from a simple script. A checkpointer saves the graph’s state after every step, so if the server restarts, the process crashes or a deployment interrupts a run, the agent picks up exactly where it left off. There is no lost work and no need to replay steps that already completed, which matters when a step has spent minutes calling a model or a tool.

Checkpointers plug into different storage backends. A lightweight option stores checkpoints in a local database for development, while a production deployment typically uses a durable store such as PostgreSQL. Each run is identified by a thread, so many conversations or workflows can run side by side, each with its own saved state.

For the wider picture of keeping long-running agents safe, see our guide to AI workflow state management and our guide to agent failure recovery. Best for: agents that run for minutes or hours, wait on external systems, or must survive crashes without losing their place.

Human-in-the-loop interrupts

Human-in-the-loop is a native primitive in LangGraph, not an afterthought. The runtime can pause execution at a chosen point, save the state, and wait for a person to inspect it, approve it or edit it before the graph continues. The pause can last seconds or days, because the saved state does not depend on a running process, and the resume is exact: the graph continues from the interrupted step, not from the beginning.

That pattern is essential wherever an agent takes actions with real consequences: sending a message to a customer, changing a record, spending money or publishing content. A well-placed interrupt turns an autonomous agent into a supervised one, with a human decision at exactly the boundary that matters. It also creates a natural audit point, because the state at the moment of approval is recorded.

For the governance side of that decision, see our guide to human oversight of AI agents. Best for: agents that act on the world, where a wrong step costs money, trust or compliance.

Memory: short-term and long-term

LangGraph gives an agent two kinds of memory. Short-term memory is the working context of the current run: the state the graph carries from node to node, including the conversation so far, the tools called and the results received. That state is what makes the agent feel continuous within a single task, and it is saved by the checkpointer after every step.

Long-term memory persists across sessions, letting an agent remember facts, preferences and past outcomes from earlier runs. It is built on persistent stores that plug into the same checkpointer mechanism, so a returning user does not start from scratch. The distinction matters for design: short-term memory is about the current task, long-term memory is about the relationship with the user, and the two need different storage, retention and privacy rules.

For the architecture of agent memory, see our guide to AI agent state management. Best for: assistants and agents that serve the same user repeatedly and should remember what they learned.

Comparing LangGraph with the alternatives

Approach Control flow Durable execution Best for
LangGraph Explicit graph Yes, checkpointing Stateful production agents
LangChain chains Fixed sequence No Simple, fixed pipelines
LangChain agents Model decides Via LangGraph runtime Quick agent builds
Temporal Code as workflow Yes, full durability Long-running business processes
CrewAI Role-based teams Limited Fast multi-agent prototypes

The table shows that LangGraph sits between simple chains and heavyweight workflow engines. A fixed pipeline does not need it, and a multi-hour business process with strict durability guarantees may be better served by a dedicated engine such as Temporal. LangGraph is the right middle ground when the work is agentic, the path is decided at run time, and the run must survive interruption.

For a fuller comparison, see our guide to AI agent frameworks and our guide to AI orchestration architecture.

A laptop on a dark desk showing a branching decision tree diagram on screen, with headphones beside it
A LangGraph agent is a graph, not a script: each node is a step, each edge is a decision about what happens next.

LangGraph Studio and deployment

LangGraph Studio is the visual tool for developing and debugging graphs. It shows the graph as a diagram, lets you step through a run node by node, and supports time travel: replaying or forking execution from any earlier checkpoint. That capability turns debugging a complex agent from a painful reverse-engineering exercise into a systematic inspection, because you can see exactly what the state was at each step and what the model decided.

For deployment, LangGraph Platform became generally available in May 2025 and was later renamed LangSmith Deployment, becoming part of the LangSmith platform. It provides a managed, hybrid or self-hosted runtime for graphs, with threads, runs, durable execution and horizontal scaling. Teams that prefer to self-host can run the same runtime on their own infrastructure with PostgreSQL and Redis.

LangSmith adds tracing and evaluation on top, so a deployed graph can be observed and scored in production. Best for: teams that need visual debugging in development and a managed runtime in production.

How to start: a decision framework

Start with a single graph that models one real workflow, not a toy example. Define the state first, because the state is the contract every node shares: what goes in, what comes out, and what must be remembered. Then add nodes one at a time, with a checkpointer enabled from the beginning, so durability is tested from the first run rather than bolted on later.

Add a human-in-the-loop interrupt at the riskiest step, and test it by interrupting and resuming a run.

Then decide how much of the graph the model should control. A graph where every edge is conditional hands all routing to the model, which is powerful but hard to test; a graph with mostly fixed edges and one or two model-decided branches is easier to reason about and to debug. Keep the graph small at first, measure how often each path is taken, and expand only the branches that real runs actually use.

For multi-agent designs built on graphs, see our guide to multi-agent orchestration.

LangGraph checklist

  • State is defined first, as the contract every node shares.
  • A checkpointer is enabled from the first run, so durability is tested early.
  • Human-in-the-loop interrupts sit at the steps with real consequences.
  • Loops have a maximum iteration count, so an agent cannot spin forever.
  • Every run is identified by a thread, so concurrent runs do not share state.
  • Time travel in LangGraph Studio is used to debug failures from the exact checkpoint where they happened.
  • LangSmith tracing is enabled, so production runs can be observed and evaluated.

Frequently asked questions

What is LangGraph used for?

LangGraph is used to build long-running, stateful agents as graphs: customer support agents that follow branching workflows, research agents that loop between searching and drafting, and multi-agent systems where several agents hand work to each other. It fits any workflow where the path is decided at run time and the run must survive interruption.

What is the difference between LangChain and LangGraph?

LangChain is the general framework for LLM applications, with building blocks for prompts, retrieval, memory and agents. LangGraph is the lower-level library for stateful, graph-based agents with explicit control flow, durable execution and human-in-the-loop interrupts. LangChain’s agents run on the LangGraph runtime, so the two work together rather than competing.

Do I need LangGraph for a simple agent?

No. A single agent with a few tool calls can run as a chain or inside a high-level agent abstraction. Add LangGraph when the workflow needs loops, branching, persistent memory, human approval or the ability to resume after a failure.

What is durable execution in LangGraph?

Durable execution means the graph’s state is saved after every step by a checkpointer, so a run that is interrupted by a crash, a restart or a deployment resumes exactly where it stopped. It is the default behaviour of the LangGraph runtime, and it is what makes the framework suitable for production agents rather than prototypes.

Can I use LangGraph without LangChain?

Yes. LangGraph is a standalone library and can be used without the rest of LangChain, with any model provider. It integrates with LangSmith for tracing and evaluation, and with LangSmith Deployment for hosting, but neither is required to run a graph.

Latest articles

Scroll to Top