LangGraph
Type: full-code · Vendor: LangChain Inc. · Language: Python, TypeScript · License: MIT · Status: active · Status in practice: mature · First released: 2024
Provide low-level orchestration infrastructure for long-running, stateful agents with durable execution, persistent memory, and built-in human-in-the-loop interrupts.
Description. LangGraph is the MIT-licensed orchestration framework from LangChain Inc. that models an agent as a graph of nodes operating over a shared, checkpointed state object. Production users (Klarna, Replit, Elastic) build durable agents that resume from failures, pause for human approval via interrupt(), and share short-term thread-scoped memory plus long-term cross-session memory in a Store. LangGraph draws structural inspiration from Pregel and Apache Beam; it can be used standalone or paired with LangChain, LangSmith for observability, and LangGraph Platform for hosted runs. Multi-agent topologies (supervisor, swarm, hierarchical) ship as separate prebuilt libraries.
Agent loop shape. Graph of nodes with explicit state edges; the runtime checkpoints state after every super-step so any node can be paused, resumed, or restarted, and Command-typed return values can re-route control between nodes or subgraphs.
Primary use cases
- long-running stateful agents resilient to failures
- multi-agent supervisor / swarm / hierarchical topologies
- agents with mid-run human-approval steps
- agents needing both working memory and cross-session persistent memory
Key concepts
- StateGraph (docs) — The core abstraction: a graph whose nodes read from and write to a typed state object the runtime checkpoints.
- Checkpointer → agent-resumption (docs) — Persistence layer that saves state at each super-step so executions are durable and resumable.
- interrupt() → human-in-the-loop (docs) — Pauses graph execution at a node and waits indefinitely for external (human) input before continuing.
- Command → handoff (docs) — Return value from a node combining a state update with a goto routing decision; Command.PARENT crosses subgraph boundaries.
- create_react_agent → react (docs) — Prebuilt tool-calling ReAct-style agent that loops over tool calls until the model emits a final answer.
- Subgraphs → hierarchical-agents — Nested graphs that let a node delegate to a complete inner graph (the basis for hierarchical agents).
- Store (long-term memory) → cross-session-memory (docs) — Cross-thread persistence of long-term memories under custom namespaces and keys.
- recursion_limit / GraphRecursionError → step-budget (docs) — Cap on total super-steps (default 25); exceeding it raises GraphRecursionError.
Patterns this full-code implements —
- ★★Agent Resumption
Checkpointer persists graph state at each super-step; on restart the agent resumes from where it left off, even after failure.
- ★★Human-in-the-Loop
interrupt() pauses the graph and waits indefinitely until an external caller resumes it; state can be inspected and modified before resume.
- ★Handoff
Multi-agent handoff is expressed by a node returning Command(goto=<target>, update=...) with optional state updates; Command.PARENT scopes the goto across subgraph boundaries.
- ★★Session Isolation
Short-term memory is thread-scoped: each thread holds its own checkpointed state and message history; thread_id is required to scope persistence per session.
- ★★Cross-Session Memory
LangGraph provides a Store for long-term memory keyed by namespace+key, shared across threads/sessions.
- ★★Supervisor
langgraph-supervisor prebuilt library exposes create_supervisor; a central supervisor agent picks which worker agent runs next.
- ★★Hierarchical Agents
Subgraphs let a node delegate to a complete inner graph; langgraph-supervisor markets itself as 'hierarchical multi-agent systems'.
- ·Swarm
langgraph-swarm provides create_swarm: agents dynamically hand off control to one another and a shared 'messages' state.
- ★★ReAct
create_react_agent is the prebuilt tool-calling ReAct-style agent constructor in langgraph.prebuilt; its docstring describes a graph that loops over tool calls until a stopping condition is met.
- ★★Tool Use
create_react_agent and the underlying StateGraph wire tool nodes that the model can invoke through LangChain tool bindings.
- ★★Step Budget
recursion_limit caps total super-steps (default 25); exceeding it raises GraphRecursionError.
- ★★Replay / Time-Travel
Per-super-step checkpoints expose a state history; graph.get_state_history(config) returns the full execution history and the graph can be invoked with a prior checkpoint_id to replay.
- ★★Approval Queue
interrupt() at a tool-call boundary lets the caller review and accept/reject/modify the proposed action; this is LangGraph's documented HITL approval shape.
- ★★Orchestrator-Workers
Supervisor-with-workers is the canonical orchestrator-workers topology in LangGraph, shipped via langgraph-supervisor.
- ★Interruptible Agent Execution
interrupt() + checkpointer is the canonical pattern: graph execution pauses, state is durable in the checkpointer, and the caller resumes by re-invoking with the same thread id.
- ★★Plan-and-Execute
Plan-and-execute is documented as an idiomatic LangGraph shape (planner node → executor nodes → replan), built on the StateGraph; the canonical LangChain Inc. blog post on planning agents describes i…
- ★★Model Context Protocol
LangGraph integrates MCP through LangChain's langchain-mcp-adapters (MultiServerMCPClient), which converts MCP tools into LangChain tools usable by create_react_agent.
- ★Composable Termination Conditions
interrupt() pauses graph execution and returns to the caller; interrupt_before / interrupt_after pin pause points on specific nodes. Composes naturally with the checkpointer to preserve state across…
- ★Subagent Isolation
Subgraphs scope state per inner graph; isolation is achieved by giving the subgraph a different state schema (no shared keys) or by transforming state between parent and child.
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.