LangGraph: Introduction
LCEL chains run in a straight line — but real agents need to loop, branch, and remember. LangGraph is the answer: a low-level runtime that models an agent as a graph — nodes do the work, edges decide where to go next, and state carries everything between. It's what LangChain agents actually run on, and the go-to for production agents that need control, persistence, and durability.
💡 In one line: LangGraph models agents as stateful graphs — nodes are steps, edges are decisions, and shared state is the memory.
What is LangGraph?
LangGraph is an open-source (MIT) library from LangChain Inc. for building stateful, multi-actor LLM applications. It's the orchestration runtime beneath the high-level API: since late 2025, LangChain's create_agent calls LangGraph internally. Where LCEL is a DAG (data flows one way), LangGraph is a cyclic state machine — it can loop back on itself.
Why a Graph?
Agents need what a straight line can't give:
- Cycles — retry, re-plan, keep calling tools until done.
- Branching — conditional routing based on results.
- State — shared memory across steps.
- Durability — survive a restart mid-run.
- Debuggability — when it fails, you know which node and which edge.
As LangGraph's lead engineer put it: the graph is the source of truth — every node an action, every edge a decision, the state your memory.
The Core Concepts
- State — a typed shared object (often a
TypedDict) passed between nodes. - Nodes — Python functions that read state and return updates.
- Edges — connections; conditional edges route dynamically.
START/END— entry and exit points.- Checkpointer — persists state so runs are durable and resumable.
A Cyclic Agent Graph
The defining feature is the loop.
The edge from Tools back to Agent is the cycle — exactly what LCEL cannot express.
Code Example
Define state → add nodes → wire edges → compile.
LangGraph vs. LCEL
| LCEL | LangGraph | |
|---|---|---|
| Model | DAG — linear | State machine — cyclic |
| Syntax | a | b | c | Nodes, edges, state |
| State | Stateless | Shared, persisted |
| Best for | RAG, simple Q&A | Agents, branching, loops |
Rule of thumb: a straight line → LCEL; a decision flowchart with cycles → LangGraph.
What It Gives You
- Persistence & durability — checkpointers mean an agent survives a restart.
- Human-in-the-loop — pause for approval mid-run.
- Streaming — token-by-token, plus step visibility.
- Time travel — replay and branch past runs.
- Multi-agent — single, hierarchical, or peer control flows in one framework.
create_agent vs. LangGraph
create_agent— a prebuilt graph; fastest path, covers most cases.- LangGraph — you define nodes, edges, and state yourself.
Start with create_agent; drop to LangGraph when you need explicit control. Using LangGraph for a simple Q&A agent is overkill.
Trade-offs
- More architectural overhead — state schemas, nodes, edges.
- A steeper learning curve than piping a chain together.
- Worth it for production agents; skip it for linear pipelines.
What's Ahead
The next subtopics dig into State Management, Workflow Design, and Human-in-the-Loop.
A Note on Currency
LangGraph reached GA and is now the engine behind LangChain agents; LangSmith provides tracing, and LangGraph Studio offers visual debugging. Check docs.langchain.com for current APIs.
Summary
- LangGraph models agents as stateful, cyclic graphs — nodes, edges, state.
- It's the runtime beneath LangChain agents (
create_agentcompiles to it). - Unlike LCEL's DAG, it supports loops, branching, persistence, and durability.
- It adds human-in-the-loop, streaming, time travel, and multi-agent control flows.
- Use it when you need explicit control — it's overkill for simple linear pipelines.Â