LangChain Inc.
Stateful, graph-based agent workflows with first-class human-in-the-loop.
GitHub Stars
32.3K
Contributors
278
npm / Week
—
PyPI / Month
49.0M
LangGraph is a graph-based orchestration framework for building stateful, long-running agents. Maintained by LangChain Inc. and released in 2024 under an MIT license, it rethinks agent construction from first principles: instead of linear chains, LangGraph models workflows as directed graphs where nodes represent agents or tools and edges define conditional control flow. Loops, branches, and concurrent execution are first-class citizens, not afterthoughts.
The framework was born from the team’s experience shipping LangChain’s early abstractions. The core insight: production agents need durable state, human oversight, and the ability to pause and rewind mid-execution. LangGraph delivers that through a state-machine compiler that enforces typed state schemas and checkpointing at every node.
With over 32,000 GitHub stars, 278 contributors, and nearly 49 million monthly PyPI downloads, LangGraph is among the most adopted open-source agent frameworks. Its design philosophy is low-level and imperative — you build graphs in code, not config files — which gives engineers fine-grained control over every step of an agent’s lifecycle. Teams at Klarna, Uber, LinkedIn, Elastic, and Replit use it in production for workloads that demand reliability over rapid prototyping.
---
LangGraph is a state machine in disguise. At its core is StateGraph, which accepts a typed state schema (a TypedDict or Pydantic model) and a set of named channels. Nodes are Python functions that read from and write to this state. Edges connect nodes — they can be unconditional, conditional, or parallel.
1from langgraph.graph import StateGraph, END23class AgentState(TypedDict):4 messages: list5 next_agent: str67builder = StateGraph(AgentState)8builder.add_node("researcher", researcher_node)9builder.add_node("summarizer", summarizer_node)10builder.set_entry_point("researcher")11builder.add_conditional_edges(12 "esearcher",13 lambda state: "summarizer" if state.messages else END14)15graph = builder.compile()
This is an imperative, code-first model. There are no YAML files or visual editors or drag-and-drop pipelines. Every node executes a plain Python function — no hidden magic. Edges can evaluate arbitrary logic, including LLM calls, to decide the next node. Loops happen naturally: a node can transition back to an earlier node.
Durable execution is built in. Each time a node runs, its output is checkpointed to a persistence backend (local filesystem, PostgreSQL, Redis, or a cloud store). If the process crashes, the graph resumes from the last checkpoint. This allows workflows that run for hours or days without losing progress.
LangGraph also supports fan-out (executing multiple nodes concurrently to multiple nodes) and fan-in (collecting results). This is exposed via parallel edges and reducers that merge outputs from parallel branches.
For engineers: think of LangGraph as a crate for building deterministic, restartable state machines around LLM calls. The learning curve is steeper than linear chain frameworks because you must define state schemas and manage reducers, but the payoff is an agent that can be inspected, rewound, and resumed at any point.
---
Graph orchestration with loops and conditionals. LangGraph treats cycles as a first-class pattern. You can build agents that iterate until a quality threshold is met, retry failed tool calls, or recursively decompose tasks. This is a significant departure from tree-based or DAG-only frameworks.
Durable state and checkpointing. Every node execution is persisted. You can rewind an agent to any prior checkpoint, inspect the state at that point, and replay from there. This enables time-travel debugging and manual state intervention.
Interrupts and human-in-the-loop. LangGraph can pause execution at any node and wait for external input. The typical pattern: an agent generates a proposed action, hits an interrupts, and a human approves or edits the state before resumption. This is built into the graph, not bolted on after the fact.
Multi-agent coordination. LangGraph supports supervisor-subordinate patterns, where one agent routes to specialist sub-agents; hierarchical agents that dispatch work to child graphs; and peer-to-peer messaging between nodes. Each sub-agent can be its own compiled graph with its own state.
Streaming. Output from any node can be streamed token-by-token. This includes LLM completions, tool results, and state updates. The streaming is first-class — you can subscribe to specific channels and render in real time.
Memory. LangGraph includes built-in persistence for conversation history via MemorySaver. You can also implement custom memory strategies by writing to the state schema.
Tracing and evaluations. Integration with LangSmith provides observability: every graph execution is logged with latency, token costs, and state changes. Teams can run automated evaluations against checkpoints to catch regressions.
---
Multi-step research agents. A typical implementation: a researcher agent searches the web, extracts data, then loops until it has ten citations meeting a relevance threshold. At each iteration, LangGraph checkpoints the search results. The supervisor node can interrupt after five iterations for human review, allowing the researcher to edit the query or approve the results.
Long-running customer workflows. Insurance claims processing, loan origination, and employee onboarding often require human approval at multiple stages. LangGraph models these as graphs with interrupts at each decision point. The state persists across days, surviving application restarts. If a claim is rejected, the graph can be rewound to the previous step and the state edited.
Agent supervisors. A customer support graph might have a triage agent, a billing specialist, and a refund agent. The supervisor node routes the conversation to the right specialist, with retry logic if the first specialist fails (e.g., cannot find account). If no specialist matches, the supervisor, the graph escalates to a human via an interrupt.
Not a fit for: Simple question-answering (a single LLM call), stateless chatbots, or one-shot tool calls. LangGraph’s overhead only pays off when you need persistence, branching, or human intervention.
---
Install via pip:
1pip install -U langgraph
The smallest meaningful example defines a state schema and a two-node graph that calls an LLM and tools:
1from langgraph.graph import StateGraph, END2from typing import TypedDict34class State(TypedDict):5 messages: list67def call_model(state):8 # Use any LLM client — LangChain, OpenAI, Anthropic9 response = my_llm_client.chat(state["messages"])10 return {"messages": state["messages"] + [response.choices[0].message]}1112graph = StateGraph(State)13graph.add_node("agent", call_model)14graph.set_entry_point("agent")15graph.add_edge("agent", END)16app = graph.compile()
You will need an LLM an LLM provider key (OpenAI, Anthropic, etc.) and optionally a persistence backend (PostgreSQL, Redis) for durable execution. For observability, integrate LangSmith.
Documentation is at [docs.langchain.com](https://docs.langchain.com). The GitHub repository at [github.com/langchain-ai/langgraph](https://github.com/langchain-ai/langgraph) provides a CONTRIBUTING.md and a CLAUDE.md for AI-assisted development. The community is active on Discord and the LangChain forums.
---
LangGraph vs. LangChain. LangChain provides high-level abstractions (chains, agents, tools) suitable for prototyping. LangGraph is the lower-level orchestration layer that replaces LangChain’s older AgentExecutor. Teams often start in LangChain for rapid experimentation and then port to LangGraph when they need statefulness and reliability. If you need linear chains and quick demos, LangChain is faster. If you need military-grade state management, LangGraph wins.
LangGraph vs. CrewAI. CrewAI is a multi-agent framework that leverages role-based agents and tasks. It’s easier to set up for simple multi-agent scenarios (e.g., “writer” and “reviewer”). However, CrewAI lacks durable state, interrupts, and the ability to define arbitrary control flow. When your multi-agent system needs human-in-the-loop, retries, or replay, LangGraph is the stronger. For a quick three-agent pipeline with no persistence, CrewAI is simpler.
LangGraph vs. AutoGen. AutoGen (Microsoft) focuses on agent conversations and group chats. Its programming model is more declarative and conversation-oriented. LangGraph is more flexible for non-conversational workflows (e.g., data processing pipelines, long-running background tasks). AutoGen’s maintained by a different team and has less production adoption among the enterprise users listed on LangGraph’s trust page.
When to choose LangGraph: You need durable, restartable agents; you want to rewind and edit state; you require human approval mid-workflow; or you are modeling complex branching logic with loops.
When to avoid it: Your project is a proof-of-concept with no persistence needs; you want minimal boilerplate; or your team prefers declarative YAML configuration over imperative code.
What the framework gives you out of the box, in plain language.
Nodes are agents or tools, edges are conditional control flow. Loops are first-class.
Built-in checkpointing lets you pause, resume, and rewind workflows.
Pause execution mid-graph for human approval, edit the state, then resume.
The jobs this framework is best suited for.
Agents that loop until a quality threshold is met, with optional human review at each step.
Onboarding, claims, or approval flows that span hours or days with durable state.
A supervisor agent routes work to specialist sub-agents, with retry and fallback paths.
Side-by-Side
Add a second or third framework and see stars, downloads, and capabilities lined up next to each other.
Close alternatives worth a look before you decide.
Composable building blocks for LLM apps — chains, agents, retrievers, and integrations.
Composable LLM building blocks
Stars
137.0K
npm / wk
2.2M
PyPI / mo
241.8M
Multi-agent crews with role-based prompts and explicit task hand-offs.
Role-based multi-agent crews
Stars
51.6K
npm / wk
—
PyPI / mo
9.6M
Conversational multi-agent simulations and orchestration from Microsoft Research.
Conversational multi-agent simulations
Stars
58.1K
npm / wk
—
PyPI / mo
1.5M