LangGraph
v1.1The execution engine for agents. State machines, persistence, human-in-the-loop, streaming, and graph-based control flow.
Nodes, edges, and the state machine model. Why LangGraph over plain chains.
Designing state: TypedDict, Pydantic, reducers, and the add_messages pattern.
Nodes as functions, async nodes, tool nodes, and the Command API for routing from inside a node.
Normal edges, conditional edges, path maps, cycles, and add_sequence() for linear flows.
DEPRECATED in LangGraph v1. Use create_agent from langchain.agents instead — simpler interface, middleware support, and the same LangGraph runtime under the hood.
Checkpointers save state after every super-step. InMemorySaver for dev, PostgresSaver for prod.
Thread IDs isolate conversations. One graph, many users, each with their own state history.
LangGraph Store is a key-value store that persists across threads and sessions. Use it to remember user preferences, learned facts, and past interactions — things that should survive beyond a single conversation.
Replay from any checkpoint, fork-and-rerun, and debugging agent decisions step by step.
Auto-persistence of execution state, crash recovery, resumability across server restarts. How LangGraph guarantees exactly-once execution semantics.
The Runtime object and context_schema replace config['configurable'] as LangGraph's dependency injection system — typed access to state, store, context, and stream writer from any node or tool.
Encrypt checkpoints at rest with AES, configure TTL policies for automatic cleanup, and choose from 8 checkpointer backends for production persistence.
Pause execution for human approval, collect user input mid-run, and resume with Command.
Unified StreamPart protocol, type-safe output modes, and real-time token streaming.
Custom logic before/after model calls for context management, guardrails, token tracking.
Complex routing logic in LangGraph. Conditional edges with multiple targets, LLM-based dynamic routing, parallel branches with merge, nested conditions, and the router node pattern for specialized sub-graphs.
Structured error handling in LangGraph: RetryPolicy for transient failures, error taxonomy for routing errors to the right handler, and CachePolicy for avoiding redundant computation.
Compose graphs from smaller graphs. Parent-child state communication, shared keys, and encapsulation.
Fan out to parallel node executions with Send(), then collect and reduce the results.
Edgeless graphs where nodes dynamically choose the next node. Command(goto=, update=). Building flexible agent flows without static edges.
Nodes that wait for all upstream paths to complete before executing. Essential for map-reduce and consensus patterns. @defer decorator.
Cache results of individual nodes to skip redundant computation. cache_policy on compile(). Cache invalidation strategies.
Alternative to Graph API using @entrypoint and @task decorators. When to use Functional API vs StateGraph. Simpler syntax for common patterns.
LangGraph has two APIs: the Graph API (StateGraph with nodes and edges) and the Functional API (@entrypoint + @task). Both share the same runtime. This article helps you pick the right one for your use case.
Visual IDE for debugging and interacting with graphs. Real-time state inspection, step-through execution, breakpoint debugging.