LangGraph

raw JSON →
1.0.x verified Tue May 12 auth: no python install: verified quickstart: verified

LangGraph is a low-level agent orchestration framework providing graph-based execution with durable state, built-in persistence, and human-in-the-loop patterns. As of v1.0 it is the foundational runtime for LangChain agents. Use LangChain for high-level agent abstractions, LangGraph for fine-grained control.

pip install langgraph
error AttributeError: 'StateGraph' object has no attribute 'compile'
cause You are attempting to use a `StateGraph` object directly for execution (e.g., calling `invoke()`, `stream()`) without first compiling it into an executable `CompiledStateGraph`.
fix
Call the .compile() method on your StateGraph instance before attempting to invoke or stream from it.
from langgraph.graph import StateGraph, END

workflow = StateGraph(State)
# ... add nodes and edges ...
app = workflow.compile() # Add this line
# app.invoke(...)
error ModuleNotFoundError: No module named 'langgraph.prebuilt'; 'langgraph' is not a package
cause This error often occurs when you have a local Python file or directory named `langgraph.py` or `langgraph` in your project's working directory, which shadows the installed `langgraph` package.
fix
Rename your local langgraph.py file or langgraph directory to something else (e.g., my_langgraph_app.py) to avoid conflicts with the installed library. Then, try your import again.
error No checkpointer set
cause You are attempting to use state persistence features (like resuming an interrupted graph run) without configuring a checkpointer when compiling your `StateGraph`.
fix
Provide a checkpointer instance (e.g., SqliteSaver) to the compile() method of your StateGraph.
from langgraph.graph import StateGraph
from langgraph.checkpoint.sqlite import SqliteSaver

memory = SqliteSaver(conn='sqlite:///graph.sqlite')

workflow = StateGraph(State)
# ... add nodes and edges ...
app = workflow.compile(checkpointer=memory)
error Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.
cause This error occurs when the sequence of messages in your agent's state doesn't correctly follow the tool-calling protocol, specifically when a tool output message (`role='tool'`) is not immediately preceded by an AI message containing `tool_calls`.
fix
Ensure that your graph's state updates maintain the correct conversational turn structure: an AI message with tool_calls must be followed by one or more tool messages responding to those specific tool calls before any other AI or human messages are added.
error ImportError: cannot import name 'ServerInfo' from 'langgraph.runtime'
cause This error typically indicates a version incompatibility, where `langgraph-prebuilt` or another `langgraph` extension package is trying to import a symbol (`ServerInfo`) from `langgraph.runtime` that does not exist in your currently installed `langgraph` core library version.
fix
Ensure that all langgraph related packages (langgraph, langgraph-prebuilt, etc.) are updated to their latest compatible versions. Use pip install -U langgraph langgraph-prebuilt (or specific versions if a known compatible set exists).
deprecated langgraph.prebuilt module deprecated in 1.0. All prebuilt functionality moved to langchain.agents.
fix Replace from langgraph.prebuilt import create_react_agent with from langchain import create_agent
breaking langgraph-prebuilt==1.0.2 introduced a breaking signature change to ToolNode.afunc adding a required runtime parameter. langgraph==1.0.1 does not pin this dependency.
fix Pin langgraph-prebuilt==1.0.1 explicitly or upgrade to latest langgraph
gotcha MemorySaver is in-memory only. State is lost on process restart. Not for production.
fix Use langgraph-checkpoint-postgres or langgraph-checkpoint-sqlite for persistence
gotcha LangGraph requires a compiled graph before invocation. Always call graph.compile() before graph.invoke().
fix app = graph.compile() then app.invoke(...)
gotcha State TypedDict must be defined before StateGraph instantiation. Missing keys raise KeyError at runtime not at definition time.
fix Define all state keys in your TypedDict schema upfront
gotcha Test output contains warnings and notices from the 'pip' package manager that are unrelated to the langgraph library's functionality or application-specific failures. These messages typically pertain to environmental setup (e.g., running pip as root) or general system information (e.g., pip updates).
fix Review pip warnings for environmental issues relevant to your setup. If they do not impact the application's functionality, they may be ignored or suppressed. This is not a langgraph-specific issue.
npm install @langchain/langgraph
python os / libc status wheel install import disk
3.10 alpine (musl) - - 2.10s 66.7M
3.10 slim (glibc) - - 1.49s 74M
3.11 alpine (musl) - - 2.63s 72.2M
3.11 slim (glibc) - - 2.17s 80M
3.12 alpine (musl) - - 2.54s 63.2M
3.12 slim (glibc) - - 2.48s 71M
3.13 alpine (musl) - - 2.35s 62.8M
3.13 slim (glibc) - - 2.31s 71M
3.9 alpine (musl) - - 1.86s 64.2M
3.9 slim (glibc) - - 1.63s 72M

Minimal single-node StateGraph in LangGraph 1.0.

from langgraph.graph import StateGraph, END
from typing import TypedDict

class State(TypedDict):
    messages: list

def call_model(state: State):
    # your LLM call here
    return {"messages": state["messages"]}

graph = StateGraph(State)
graph.add_node("agent", call_model)
graph.set_entry_point("agent")
graph.add_edge("agent", END)

app = graph.compile()
result = app.invoke({"messages": [{"role": "user", "content": "hello"}]})