LangGraph architecture overview
In one sentence
LangGraph is a state-machine-style agent orchestration framework built around a channel + Pregel loop core. At the construction layer, StateGraph compiles nodes and edges into a Pregel executable. At runtime, PregelLoop.tick repeatedly runs "read channels → schedule tasks → write channels → checkpoint" until convergence. Along the way, StreamMux provides multi-mode streaming output, interrupt / Command enable human-in-the-loop collaboration, the BaseCheckpointSaver family handles thread-level persistence, and @entrypoint / @task provide a functionally equivalent API.
Layers
One sentence per layer
- Startup & config:
RunnableConfigcarriesthread_id/store/checkpointer;StateSnapshotis the immutable snapshot returned byget_state. - Graph construction:
StateGraphis the user entry point.add_node/add_edge/add_conditional_edgesdefine the topology;compileproduces aCompiledStateGraph(i.e. aPregelinstance). - Pregel engine:
Pregelis the compiled artifact;stream/invoke/astreamare its entry points.PregelLoop.tickruns a single step,PregelRunnerruns tasks concurrently, and_algohandles task preparation, writeback, and interrupt decisions. - Channel:
BaseChannelabstracts theupdate/consume/checkpointsemantics.LastValueoverwrites by default,Topicis pub-sub, andBinopaggregates via a binary operator. - Checkpoint:
BaseCheckpointSaverexposesput/get/list. There are three implementations —InMemory,Sqlite,Postgres— with sync and async support. - Streaming:
StreamMuxhandles multi-mode mux/demux, and each transformer (values/updates/messages/debug/lifecycle/subgraph/checkpoints/tasks) produces a different view. - Functional API:
@entrypointwraps a function into aPregelexecutable;@taskdeclares a concurrent subtask. - Interrupt & subgraph:
interrupt()triggers a human-in-the-loop pause,Command(resume/goto/update)drives resumption and routing, andSendimplements fan-out.
Layering motivation
LangGraph fully decouples "how the graph is defined" (graph construction), "how it executes" (Pregel), "how state updates" (channel), "how it persists" (checkpoint), "how it is viewed" (stream), "the functional equivalent" (func), "how it talks to a human" (interrupt), and "how it is orchestrated" (subgraph). Swapping the checkpoint backend does not affect execution logic; swapping stream modes does not affect the graph definition; adding interrupts does not change the channels. Pregel is the single hub — every execution path ultimately goes through PregelLoop.tick.
Common misreadings
- "LangGraph is just LangChain's graph wrapper" — No. It has an independent Pregel execution engine and does not depend on LangChain's chain/agent abstractions; it can be used on its own.
- "Channel is just state" — Channel is the update-semantics layer for state. Different channel types (
LastValue/Topic/Binop) determine how state is merged, which is what makes it more capable than an ordinary state machine. - "@entrypoint is syntactic sugar for StateGraph" — Functionally equivalent, but implemented differently. The func API goes through the
FunctionalAPIpath and is ultimately also compiled intoPregel, but its concurrency and join semantics are closer to those of ordinary functions.
Recommended reading order
Start with Startup & config, then StateGraph and Pregel engine, then work through PregelLoop tick → Channel → Checkpoint → Streaming → Functional API → Interrupt & resume → Subgraph orchestration.
See official docs: LangGraph docs · GitHub.