Theory
A chain is a list of steps. A state machine is a graph of steps with explicit transitions. The difference matters the moment your agent has to do anything other than march forward.
| Capability | Linear chain | State machine (LangGraph) |
|---|---|---|
| Conditional next step | if inside a step (hidden) | Explicit conditional edge |
| Retry a failed tool | Bespoke try/except in glue code | Loop back to the same node |
| Hand off between agents | Awkward (string-passing) | Native (sub-graphs, shared state) |
| Persist & resume | Custom serialization | Checkpointer = one line of config |
| Visualise the flow | Read the source | Render the graph |
LangGraph is, at its core, a thin layer that turns a Python dict of nodes and edges into a runnable graph. Each node is a function state -> state. Each edge picks the next node. That's it — the rest is ergonomics.