Chains (LCEL) are perfect for straight-line flows: A → B → C. But real agents aren't straight lines — they loop ("call a tool, check, maybe call another"), branch ("if the answer is complete, stop; else keep going"), and remember state across steps. That's where LangGraph comes in.
The core idea: your app is a graph
LangGraph models your app as a graph of:
- State — a shared data object every step can read and update (usually the list of messages).
- Nodes — functions that do work and update the state (call the model, run a tool).
- Edges — arrows deciding which node runs next. Conditional edges branch based on the state — and edges can point backward, creating loops.
If a chain is an assembly line, a graph is a flowchart — with decision diamonds and loops. That flowchart shape is exactly what an agent needs.
LangChain vs LangGraph — when to use which
| Use LangChain (LCEL) when… | Use LangGraph when… |
|---|---|
| The flow is linear: prompt → model → parse | The flow loops or branches (agents, tool loops) |
| RAG Q&A, summarization, extraction | Multi-step reasoning, human approval, multiple agents |
| No long-lived state needed | State must persist across steps and sessions |
They're not rivals — LangGraph uses LangChain models, prompts, and tools inside its nodes. You build the pieces with LangChain and orchestrate them with LangGraph.
Why "stateful" is the key word
In a chain, data flows through and is gone. In a graph, there's a state object that lives for the whole run — every node reads it, adds to it, and passes it on. That shared memory is what lets an agent accumulate a conversation, tool results, and decisions over many steps. And because LangGraph can checkpoint that state, it can pause, wait for a human, resume tomorrow, or survive a crash (see the advanced post).
Why control matters
The one-line create_react_agent from the tools post is a black box. LangGraph makes the loop explicit and inspectable: you see every node, can add a step in the middle, cap the number of loops, stream progress, or require human approval before a risky action. For anything beyond a demo, that visibility is essential.
Next: we build your first graph from scratch — nodes, edges, and state, running end to end.
← All Articles