LangGraph

agent orchestration · by LangChain · official site

LangGraph (LangChain) – Graph-Based Agent Flows in Production

What it does

LangGraph is an open-source framework for building stateful, multi-actor agentic workflows using a directed graph model. Nodes represent computation steps (LLM calls, tool executions, human input, sub-graphs), and edges define control flow, including conditional branching, cycles, and parallel execution. The graph is compiled and executed by a runtime that manages state persistence, checkpointing, and interrupt/resume semantics.

Key capabilities include:

LangGraph is part of the LangChain ecosystem, sharing primitives like ChatModel, Tool, and BaseMessage.

Who it's for

LangGraph targets developers building production agent systems that require:

It is less suited for simple RAG chains, single‑turn LLM calls, or teams that want minimal abstraction overhead.

What works

State management – LangGraph’s persistence layer is robust. You can resume an agent from any checkpoint, which is critical for production systems where partial failures are common. The built‑in state schema (typed dicts) imposes structure without being overly prescriptive. Human‑in‑loop – Interrupts are clean. You define Node functions that raise a special Interrupt exception; the runtime pauses execution and stores the state. Resuming from a UI or API replays the next edges. This is more explicit than frameworks that hide interruption logic. Cycles and conditionals – Unlike linear DAGs (e.g., LangChain’s old LLMChain), LangGraph genuinely supports loops. For example, a ReAct agent is a simple two‑node graph with a conditional edge back to the LLM node. This eliminates boilerplate while staying inspectable. Streaming – Token‑level streaming works reliably with supported providers (OpenAI, Anthropic, etc.). Combined with the graph’s StreamWriter, you can push intermediate steps to front‑end components without custom async plumbing. Modularity – Nodes are plain Python functions. You can test them in isolation, which lowers the barrier to unit testing compared to monolithic chain implementations.

What breaks

Learning curve – The graph metaphor is powerful but non‑trivial. Building a simple agent requires understanding StateGraph, Node, Edge, CompiledStateGraph, and the persistence configuration. The documentation assumes familiarity with LangChain v0.3+ and async patterns. Debugging – When a graph misbehaves, the stack trace often leads to compiled internals rather than your node code. LangSmith helps, but local debugging with pdb is awkward because the graph runtime swallows exceptions in nested asyncio tasks. Performance overhead – For trivial agents (two LLM calls with no state), LangGraph adds 20–50ms overhead per node due to state serialisation and checkpointing. This is negligible for long tasks but noticeable in high‑throughput, low‑latency scenarios. Dependency on LangChain ecosystem – LangGraph inherits LangChain’s churn and abstraction layers. You often have to import langchain_core for message types, and tool definitions. If LangChain releases breaking changes (which happened frequently in 2024–2025), your graph code may need updates. Graph complexity – As graphs grow beyond 10 nodes, the YAML/JSON representation becomes unwieldy. Programmatic graph assembly (using Python code) is the preferred approach but can still be hard to reason about without a visualiser. LangGraph Studio (a desktop tool) exists but had limited community adoption.

Pricing reality

Open‑source library – LangGraph itself is MIT‑licensed and free. No hidden costs for the core runtime. LangSmith – Observability, tracing, and evaluation are hosted on LangSmith. Free tier: 10,000 spans/month (as of mid‑2026). Paid tiers start at $99/month for 100k spans; enterprise pricing negotiable. LangGraph Cloud – Managed graph execution (persistence, scaling, serverless API). Pricing is usage‑based (per node execution? per request?). LangChain has not published official per‑node pricing publicly; it varies based on contract. As of early 2026, self‑hosting via Docker (using langgraph serve) is production‑ready and free apart from infrastructure costs. LangChain platform overall – If you already pay for LangSmith or Cloud, LangGraph adds no extra license fee. But the full stack (LangGraph Cloud + LangSmith + hosting) can cost $500–$5000+/month for moderate production loads.

Honest comparison

vs. CrewAI – LangGraph is lower‑level. CrewAI provides higher‑level abstractions (roles, tasks, crews) but less control over state and loops. For a fixed set of agents with predefined handoffs, CrewAI is faster to prototype. For a custom, stateful orchestration (e.g., branching based on LLM decisions), LangGraph wins. CrewAI’s persistence is less mature; LangGraph’s checkpointing is production‑grade. vs. AutoGen (Microsoft) – AutoGen v0.2+ also uses graphs, but its core is agent‑centric (conversation rounds). LangGraph is centred on state transitions rather than chat rounds. AutoGen’s two‑agent pattern (sender/receiver) is simpler for chat‑like cooperation. LangGraph is better for workflows where the state is a complex data structure (e.g., an evolving plan) and agents are just one node type. vs. custom code (async Python + pydantic) – For a simple sequential agent, writing a while loop with asyncio and a database session is less code than a LangGraph graph. However, custom code lacks built‑in streaming, checkpointing, and visualisation. LangGraph’s value grows with workflow complexity: cycles, human‑in‑loop, and parallel execution become much harder to implement correctly from scratch. vs. Haystack (deepset) – Haystack’s Pipeline is DAG‑only (no cycles). For RAG pipelines, Haystack is simpler and has native document store integrations. For any agent that loops (e.g., tool calling), LangGraph is required.

When to use

Use LangGraph when:

Avoid LangGraph when: LangGraph is a powerful tool for the subset of production agents where complexity justifies the graph model. For everything else, the overhead outweighs the benefits.

Last verified: 2026-06-08 by kernel.