What Is LangGraph?
LangGraph is a Python and TypeScript library for building stateful, graph-based LLM applications. It is developed by the LangChain team and is now the recommended framework for any agent workload that needs to go beyond a single LLM call or a simple ReAct loop.
The core abstraction is a StateGraph. You define a State (typically a TypedDict), register nodes that receive state and return partial updates, and connect nodes with edges — some static, some conditional on state. When you invoke the graph, LangGraph threads state through nodes, calls LLMs or tools as each node requires, and returns the final state.
Crucially, LangGraph separates state from code. This means you can checkpoint state at every step, rewind to any prior checkpoint, branch off into alternate timelines, and interrupt execution for human approval. These capabilities are what turn an agent demo into a production workflow.
LangGraph also ships high-level helpers. create_react_agent gives you a tool-using agent with one line. Prebuilt patterns exist for supervisor-based multi-agent systems, hierarchical teams, and swarm coordination. You can start simple and gradually expose more of the graph as your needs grow.
How to Calculate Better Results with langgraph langchain stateful agent framework graph orchestration production
Install with pip install langgraph. Optionally add a checkpointer: pip install langgraph-checkpoint-postgres for production, or use the default MemorySaver for development. Import StateGraph and your preferred LangChain chat model.
Define your State. For a simple chat agent, from langgraph.graph import MessagesState is enough — it provides a messages list with append semantics. For a custom workflow, define a TypedDict with the fields you need to thread through the graph.
Build the graph. Create a StateGraph(State), add nodes with graph.add_node("name", node_fn), connect with graph.add_edge("a", "b") or graph.add_conditional_edges("a", router_fn, {"yes": "b", "no": "c"}). Compile with graph.compile(checkpointer=saver).
Invoke and iterate. graph.invoke({"messages": [HumanMessage("...")]}, config={"configurable": {"thread_id": "123"}}) runs the graph with a thread id that identifies the checkpoint stream. Stream with graph.stream for token-level UI updates.
Treat this page as a decision map. Build a shortlist fast, then run a focused second pass for security, ownership, and operational fit.
When a team keeps one shared selection rubric, tool adoption speeds up because evaluators stop debating criteria every time a new option appears.
Worked Examples
Human-in-the-loop refund approval agent
- Build a graph with three nodes: lookup_order, propose_refund, execute_refund
- Configure the graph to interrupt before execute_refund using interrupt_before
- User reports "I want a refund on order 12345" — agent runs lookup and composes a refund proposal
- Graph pauses with state containing the proposed refund amount and reason
- Support manager reviews proposed refund in a dashboard, optionally edits the amount, and approves
- Graph resumes from execute_refund node with updated state and performs the actual Stripe refund
Outcome: A production-safe agent that cannot take irreversible financial actions without human approval, while still automating 90 percent of the refund workflow.
Resumable long-running research agent
- Build a graph that plans a research task, searches N sources, summarizes each, and composes a final report
- Use Postgres as the checkpointer so every node completion is persisted
- User kicks off research at 10am with thread_id=research-abc
- At noon the user closes the laptop — the agent has completed 7 of 15 source summaries
- At 3pm the user resumes: graph.invoke(None, config={"configurable": {"thread_id": "research-abc"}})
- LangGraph restores state and continues from source 8, eventually producing the full report
Outcome: A durable research agent that survives session interruptions, crashes, and deploys — behavior impossible to achieve with stateless ReAct-style agents.
Frequently Asked Questions
What is LangGraph?
LangGraph is a library for building stateful, multi-step LLM applications as directed graphs. Each node is a function (or LLM call), edges define flow, and a shared State object threads through the graph. Unlike the classic LangChain Agent, LangGraph gives you explicit control over state transitions, cycles, branching, and checkpointing — making it the preferred framework for production agents that need reliability and observability.
How is LangGraph different from LangChain?
LangChain provides chains, tools, and the original AgentExecutor. LangGraph is a separate library (built by the same team) that focuses on stateful orchestration. You can use LangChain components (LLMs, tools, retrievers) inside LangGraph nodes, but the control flow is a graph rather than a linear chain or a ReAct loop. For anything beyond a simple agent, LangGraph is the recommended path forward from the LangChain team itself.
How do I install and start with LangGraph?
pip install langgraph (Python) or npm install @langchain/langgraph (JS/TS). Define a State type (usually a TypedDict), create a StateGraph, add nodes with graph.add_node, connect them with graph.add_edge or conditional edges, compile with graph.compile(), and invoke with graph.invoke({initial state}). A prebuilt create_react_agent helper gets you a tool-using agent in a few lines.
What is the checkpointer and why does it matter?
Checkpointers persist graph state at every step to SQLite, Postgres, or Redis. This unlocks three production features: (1) durable execution — resume an agent after a crash or a user leaves and returns, (2) human-in-the-loop — pause for approval and resume from the exact node, (3) time travel — rewind the graph to any prior state and branch off. Without a checkpointer you have a stateless agent; with one you have a resumable workflow.
Can LangGraph run in production?
Yes. LangGraph Cloud (now LangGraph Platform) offers a managed deployment with horizontal scaling, task queues, and monitoring. Self-hosted, you wrap the compiled graph in a FastAPI or Express service, use Postgres as the checkpointer, and deploy like any other backend. The framework is explicitly designed for long-running, durable agent workflows — not just demos.
When should I choose LangGraph vs CrewAI vs AutoGen?
Choose LangGraph when you want explicit control over state, branching, and persistence — it scales from single agents to complex multi-agent systems. Choose CrewAI for role-based multi-agent teams with a simpler mental model. Choose AutoGen when you want a research-grade multi-agent conversation framework with Microsoft's backing. LangGraph is the most production-oriented of the three in 2026.