Why state machines beat chains

Loops, retries, and conditional routing — none of which a linear chain handles cleanly.

0/3 done

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.

CapabilityLinear chainState machine (LangGraph)
Conditional next stepif inside a step (hidden)Explicit conditional edge
Retry a failed toolBespoke try/except in glue codeLoop back to the same node
Hand off between agentsAwkward (string-passing)Native (sub-graphs, shared state)
Persist & resumeCustom serializationCheckpointer = one line of config
Visualise the flowRead the sourceRender 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.

Analogy

A linear chain is a conveyor belt: every item passes the same stations in the same order. A state machine is a train network: the same carriage can loop back, switch lines, or wait at a junction depending on what's inside it. Production agents are trains, not conveyor belts.

Reading in progress · 0 of 3 activities done