LangGraph Agents: Building Stateful Agents That Remember and Recover

LangGraph Agents: Building Stateful Agents That Remember and Recover

—

LangGraph agents are agents built as graphs, where each step is a node, the connections between steps are edges, and a shared state carries information from one step to the next. LangGraph is a low-level orchestration library from LangChain Inc. for building stateful, long-running agents, and it differs from a simple agent loop because the flow of work is written down explicitly instead of being decided entirely by the model at each turn.

If you are choosing between an agent loop and a graph, the short answer is that LangGraph agents suit work that must pause, resume, branch or survive failure, while a plain loop suits short tasks that finish in one pass.

LangGraph was first released in early 2024 and reached its stable 1.0 release in October 2025. It is open source under the MIT licence, available in Python and JavaScript, and it can be used on its own or alongside LangChain.

The library is inspired by Pregel and Apache Beam, and its public interface draws on NetworkX, which will feel familiar if you have worked with graph libraries before. Its three core benefits, in the project’s own description, are cycles, controllability and persistence.

Key takeaways

  • LangGraph agents are graphs: nodes do the work, edges control the flow, and shared state carries context between steps.
  • Unlike fixed pipelines, graphs support cycles, so an agent can loop back, retry a step or refine its output.
  • Checkpointing saves state after each step, which enables pause and resume, human review and recovery from failure.
  • LangGraph is a low-level orchestration runtime: it does not prescribe prompts or a fixed agent architecture.
  • Since LangChain 1.0, LangChain agents run on LangGraph underneath, so the two are complementary rather than rivals.

What makes LangGraph agents different

Most agent frameworks hide the flow of work inside a loop: the model decides what happens next, and the developer sees only the trace afterwards. LangGraph agents turn that flow inside out.

You define the steps as nodes, you define how the steps connect as edges, and you define the state that every node reads from and writes to. The model still does the reasoning inside the nodes that need it, but the shape of the work is yours to design, inspect and test.

That explicitness is the whole point. A graph can loop, which matters because most agentic work is not a straight line: an agent drafts something, checks it, finds a problem and goes back to fix it.

Fixed pipelines cannot express that without awkward workarounds, while a graph treats a cycle as an ordinary edge. A graph can also branch on conditions, so a low-confidence result can go to a human reviewer while a high-confidence result goes straight to the next step.

State, nodes and edges in plain language

State is the shared record that every node can read and update. In practice it is a typed schema, often a Python TypedDict or a Pydantic model, and a common starting point is the prebuilt MessagesState, which holds the list of messages exchanged so far.

Each time a node runs, it returns an update, and the framework merges that update into the state before the next node runs. Nothing is hidden in a single model call’s context unless you put it there.

Nodes are the units of work. A node might call a model, run a tool, query a database or transform data.

A typical small agent graph has two nodes: an agent node that decides what to do next, and a tools node that executes the chosen tool and returns the result. Edges connect the nodes, and conditional edges let the graph choose its next step based on the current state, for example by routing back to the agent node after a tool result or ending the run when the task is complete.

A developer sketching a flowchart with branching paths on paper
Drawing the graph before coding it makes the branches, the retry loops and the human checkpoints explicit instead of leaving them to the model.

Checkpointing, persistence and durable execution

The feature that most separates LangGraph agents from a plain loop is persistence. A checkpointer saves the graph’s state after every step, so execution can be paused and resumed at any point.

If the process crashes, the run can pick up from the last checkpoint instead of starting again. If a step needs human approval, the graph can stop, wait for a person to inspect or edit the state, and then continue from exactly where it left off.

Persistence also enables time travel, the ability to replay a run from an earlier checkpoint. When an agent takes a wrong turn, you can rewind to the state before the mistake, change the input or the instructions, and run forward again.

For debugging, that is far more useful than re-running the whole task from the start and hoping the model makes a different choice. Our article on agent state management explains how this kind of persistence fits into agents that remember, resume and stay safe.

Human-in-the-loop and memory

Human-in-the-loop support is built into LangGraph rather than added on afterwards. Because state is saved after each step, a graph can pause before a consequential action, show a person the current state, and let them approve, edit or reject it before execution continues. That is the right shape for agents that draft contracts, move money or contact customers: the agent does the preparation, and a person takes responsibility for the decision.

LangGraph agents compared with the alternatives

Aspect LangGraph agents LangChain agents CrewAI
Main idea Work as an explicit graph Model in a tool-calling loop Team of agents with roles
Flow control Developer defines nodes and edges Model decides each step Roles and task order define flow
Cycles and branching First-class, built into graphs Limited, loop repeats the same shape Through task order and delegation
Persistence Checkpointing after every step Via LangGraph underneath Crew and task context
Human review Built-in pause, inspect and edit Added with middleware or LangGraph Added at task level
Learning curve Higher, needs graph thinking Lowest for a first agent Low, reads like a team brief

When LangGraph agents are the right choice

Best for: long-running, branching agent work where the flow must be visible, testable and able to pause for a human.

LangGraph agents earn their complexity when the workflow has branches that depend on results, when a step can fail and must be retried, when a human must approve something before the agent proceeds, or when a run can last long enough that a crash would be expensive. Research pipelines, multi-stage document work, customer operations with approval steps and agents that coordinate several tools over time are all natural fits.

LangGraph is less suitable for a first prototype or a short question-answering agent. If the whole task is one model call with one or two tools, the graph adds structure you do not need, and a LangChain agent will get you there faster.

Start with the loop, and move to a graph when the loop starts to hide decisions you need to see. Our guide to agent orchestration covers how to coordinate several agents without losing track of who is doing what.

Designing a LangGraph agent well

Begin by drawing the graph. List the steps, decide which ones need a model and which ones are plain code, and mark the places where the flow can branch, retry or stop for a human. If the drawing has more than a handful of nodes, split it: a graph that tries to do everything becomes as hard to debug as the loop it replaced.

Design the failure paths before the happy path. Decide what happens when a tool returns an error, when the model produces an unusable output, or when a step runs out of retries.

A graph that only handles success will fail in production in exactly the ways you did not plan for, and the retry edge you draw on day one is cheaper than the incident review later. Our article on evaluating agents that take actions sets out how to test those failure paths before users find them.

Common mistakes to avoid

The most common mistake is putting the whole task inside one node and calling it a graph. A single node that does everything gives you none of LangGraph’s benefits, because there is nothing to checkpoint between, no branch to take and no step to inspect. If your graph has one node, you have a loop with extra steps.

LangGraph agent checklist

Use this checklist before building a LangGraph agent for production use.

  • ☐ The graph is drawn on paper first, with nodes, edges, branches and retry paths marked.
  • ☐ Each node does one job, and nodes that need no model use plain code.
  • ☐ The state schema is small, typed and documented, with large data fetched on demand.
  • ☐ A checkpointer is configured, and pause, resume and recovery have been tested.
  • ☐ Human review points sit before consequential actions, not after them.
  • ☐ Failure paths exist for tool errors, bad model output and exhausted retries.
  • ☐ Streaming is used for long runs, so users can see progress.
  • ☐ The graph is tested node by node as well as end to end.

Frequently asked questions

What are LangGraph agents?

LangGraph agents are agents built as graphs of nodes, edges and shared state, using the LangGraph library from LangChain Inc. Each node performs a step of work, edges control the flow between steps, and checkpointing saves state after each step so runs can pause, resume and recover.

Who maintains LangGraph?

LangGraph is built and maintained by LangChain Inc., the company behind LangChain. It is open source under the MIT licence, with Python and JavaScript libraries, and it can be used with or without the rest of the LangChain framework.

Do I need LangChain to use LangGraph?

No. LangGraph does not require LangChain, although the official documentation often uses LangChain for model and tool integrations in its examples. You can use LangGraph with any model provider or tool library, and LangChain’s own agents are built on LangGraph underneath.

What is checkpointing in LangGraph?

Checkpointing is the automatic saving of graph state after each step, using a checkpointer backed by memory, SQLite or Postgres. It enables durable execution, so a run can resume after a failure, and human-in-the-loop workflows, where a person inspects or edits state before the graph continues.

When should I use LangGraph instead of a LangChain agent?

Use LangGraph when the workflow branches, loops, runs for a long time or needs human approval mid-run. Use a plain LangChain agent when the task is a short loop of reasoning and tool use that finishes in one pass. The official overview at docs.langchain.com gives the same guidance: start with a higher-level agent loop, and use LangGraph when you need explicit control over state and flow.

What is the difference between LangGraph and a workflow tool?

LangGraph is a library for building agent workflows in code, with language models as first-class participants in the graph. Traditional workflow tools run fixed sequences of steps; LangGraph graphs can loop, branch on model decisions and pause for humans, which suits agentic work rather than fixed pipelines.

Latest articles

Scroll to Top