LangGraph is an open-source framework from the LangChain team for building stateful, multi-step LLM applications as graphs. You define nodes (functions…
Understand LangGraph as a way to build agent control flow as an explicit graph.
LangGraph is a framework from the LangChain team for building stateful LLM applications by modeling them as a graph of steps. Instead of a single opaque agent loop, you draw the control flow: which step runs, what it can decide next, and where it can loop back.
The key difference from a plain chain is that LangGraph allows cycles. A node can route back to an earlier node — call a tool, look at the result, decide to call another — which is exactly the shape of an agent.
LangGraph is deliberately lower-level than a one-line 'create agent' helper. You write more setup, but you get explicit, inspectable control flow, which is what teams want once an agent must be reliable in production.
Learn the three primitives that make up every LangGraph application.
Every LangGraph app centers on a state object — usually a typed dictionary — that flows through the graph. Each node receives the current state and returns a partial update, which LangGraph merges in. Fields can define how updates combine; for example, a messages field can append rather than overwrite.
This explicit, shared state is what makes the app stateful and debuggable: at any step you can see exactly what the graph knows.
Nodes are plain functions that do work — call a model, run a tool, transform data. Edges wire them together: a normal edge always goes A to B, while a conditional edge runs a router function that reads the state and returns the name of the next node.
Conditional edges are how decisions and loops appear: an agent node returns a tool request, a conditional edge routes to the tool node, and another edge routes back to the agent to observe the result.
from langgraph.graph import StateGraph, END g = StateGraph(AgentState) g.add_node("agent", call_model) g.add_node("tools", run_tools) g.set_entry_point("agent") g.add_conditional_edges("agent", needs_tool, {"yes": "tools", "no": END}) g.add_edge("tools", "agent") # loop back to observe app = g.compile()
Two nodes, one loop: the agent decides, a conditional edge routes to tools or to END, and the tools node always returns to the agent. Compiling turns the definition into a runnable app you invoke with an initial state. This little cycle is a complete tool-using agent.
See how checkpointing gives LangGraph memory, resume, and safe pauses.
Attach a checkpointer and LangGraph saves the full state after every step to a store such as memory, SQLite, or Postgres. Each run is keyed by a thread id, so the same conversation resumes with its history intact — this is how LangGraph gives agents persistent memory across turns.
Because state is durable, a crashed or long-running graph can resume from the last checkpoint instead of starting over.
Checkpointing also enables human-in-the-loop control. You can tell the graph to interrupt before a sensitive node — say, one that sends an email — so execution pauses with its state saved. A human reviews or edits the state, then resumes the graph, which continues from exactly where it stopped.
This is the safe way to keep a person in control of irreversible actions without rewriting the agent's logic.
Judge when LangGraph's explicit control earns its extra setup.
Use LangGraph when an agent needs reliable, inspectable control flow: multiple steps, branching, loops with clear stop conditions, persistent memory, human approvals, or multi-agent coordination. Its graph makes that behavior explicit and testable.
For a one-shot prompt or a single tool call, LangGraph is overkill — a direct model call is simpler. The value shows up when the workflow is complex enough that a hidden loop becomes hard to debug and trust.
LangGraph builds stateful LLM apps as graphs: a shared state flows through nodes (functions returning updates), while edges and conditional edges route control and allow loops — the shape of an agent. A checkpointer persists state per thread, giving memory, resume, and human-in-the-loop pauses before sensitive actions. Use LangGraph when control flow must be explicit and reliable; skip it for one-shot calls.
Sketch a support agent as a LangGraph: name the state fields, the nodes (classify, retrieve, answer, escalate), and one conditional edge that loops back to retrieve when the answer is unsupported — then say where you would interrupt for human approval.
What is LangGraph?
LangGraph models agent control flow as an explicit graph with a shared state, and unlike a linear chain it supports cycles — the shape of an agent loop.
What are nodes and edges in LangGraph?
Nodes do the work and return partial state updates; edges (including conditional ones) route control, which is how branches and loops are expressed.
What does a checkpointer enable in LangGraph?
Durable, thread-keyed state is what powers memory, resuming, and interrupting the graph for human approval before sensitive actions.
When should I use LangGraph instead of a simple agent loop?
LangGraph's explicit graph pays off for complex, production workflows; a one-shot call or single tool use does not need it.