Ch 6 — LangGraph Under the Hood
Pregel execution engine, channels, supersteps, reducers, checkpoint serialization, and interrupt mechanics
Under the Hood
-
Click play or press Space to begin...
Acompile() → Pregel EngineWhat graph.compile() actually produces
1account_tree
StateGraphGraph definition:
nodes, edges, state
compile
memory
PregelExecution engine
(a Runnable)
contains
2tune
ChannelsOne per state key
with reducer logic
3arrow_downward Supersteps: the execution model inside Pregel
BSupersteps & Execution ModelEach node execution is one superstep
looks_one
Superstep 0Read input →
write to channels
→
looks_two
Superstep 1agent node reads
channels, writes back
→
4looks_3
Superstep 2tools node reads
channels, writes back
→
more_horiz
RepeatUntil no more
nodes to execute
5arrow_downward Reducers: how state updates are merged
CReducers & State MergingHow node outputs get merged into the shared state
output
Node Output{"messages": [new]}
partial update
reduce
merge
add_messagesAppend new msgs
to existing list
vs
6swap_horiz
Default ReducerLast-writer-wins
replaces value
7arrow_downward Conditional edges: the routing function internals
DConditional Edge InternalsHow routing decisions are made between supersteps
output
Node FinishesState updated
after superstep
eval
function
Route Functiontools_condition(state)
→ "tools" or "__end__"
map
route
Path MapString → node name
{"tools":"tools",...}
8arrow_downward Checkpoint serialization: what gets saved and how
ECheckpoint SerializationFull state snapshot after every superstep
data_object
State SnapshotAll channel values
at this superstep
serialize
save
Checkpointid, ts, channel_values
pending_sends
store
9database
Storage BackendMemory, SQLite,
or PostgreSQL
10arrow_downward Interrupt mechanics: how pause/resume works internally
FInterrupt & Resume MechanicsHow the graph pauses, waits, and picks up again
front_hand
InterruptSave checkpoint
before target node
wait
person
Human ReviewInspect, approve,
or modify state
resume
play_arrow
ContinueLoad checkpoint
→ execute next node