Comparison
LangChain vs LangGraph: Which to Use in 2026
Use LangChain's create_agent when you want a working tool-calling agent quickly and the standard loop fits. Use LangGraph when you need to control the steps yourself: explicit state, branches, checkpoints, resume after failure, or a pause for human approval. They are layers, not rivals: LangChain's agents run on LangGraph.
Last updated · By Rohit Ghumare
The same docs describe a third layer, Deep Agents, an agent harness built on LangGraph with planning, subagents and file tools. It is out of scope here.
LangChain vs LangGraph at a glance
| LangChain | LangGraph | |
|---|---|---|
| What the docs call it | Agent framework | Low-level orchestration framework and runtime |
| Main entry point | create_agent(model, tools, system_prompt) | StateGraph(State), then add_node, add_edge, compile |
| Who decides the control flow | The built-in loop: the model calls tools until it stops | You: nodes, static edges and conditional edges |
| State | AgentState, a typed dict holding messages plus custom fields | A state type you define, with a reducer per field |
| Customization | Middleware hooks such as before_model and after_model | Any Python function as a node; any router function as an edge |
| Persistence | Pass a checkpointer to create_agent | Compile the graph with a checkpointer and, for long-term memory, a store |
| Human in the loop | Human-in-the-loop middleware | interrupt() inside a node, resumed with Command(resume=...) |
| Model and tool integrations | Yes: one interface across providers, in separate provider packages | None of its own; bring LangChain or any SDK |
| Relationship | Built on top of LangGraph | Works on its own; does not require LangChain |
| Install | pip install -U langchain | pip install -U langgraph |
Every row comes from the LangChain and LangGraph documentation listed in this page's sources, read on 2026-12-04. The model name in the first code example is the one the docs example used that day.
When to choose each
Choose LangChain when
- The task is "a model calling tools in a loop until a task is complete" and nothing more unusual than that.
- You want to swap model providers without rewriting call sites. LangChain gives one interface for chat models across providers.
- You are standardizing how a team builds agents and want one harness everyone configures the same way.
- The custom behavior you need (guardrails, retries, routing, tool policies) fits in middleware around the loop.
Choose LangGraph when
- The run mixes hand-coded, deterministic steps with model-driven steps, and you need to say which runs when.
- A run is long. A 40-step run that fails at step 38 should resume at step 38, not start over.
- A person must approve an action before it happens, and the run has to wait, possibly for days.
- You need branches you can name, test and replay. In LangGraph, routing is a Python function with named branches, and the checkpoint records which branch ran.
- You want parallel fan-out with results merged by a reducer.
Use both when
This is the common case. Build the graph in LangGraph and use LangChain for the model and tool integrations inside the nodes. Or start with create_agent and drop to a hand-built graph only for the part of the workflow that the standard loop cannot express.
Code: one example per side
LangChain, taken from the LangChain overview. It needs pip install -U langchain "langchain[anthropic]" and an Anthropic API key in the environment.
from langchain.agents import create_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}!"
agent = create_agent(
model="claude-sonnet-4-6",
tools=[get_weather],
system_prompt="You are a helpful assistant",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]}
)
print(result["messages"][-1].content_blocks)LangGraph: a two-node graph with a conditional edge and a checkpointer. The "model" is a plain function, so this runs with pip install -U langgraph and no API key.
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, StateGraph
from typing_extensions import TypedDict
class State(TypedDict):
text: str
route: str
reply: str
def classify(state: State) -> dict:
route = "refund" if "refund" in state["text"].lower() else "other"
return {"route": route}
def refund(state: State) -> dict:
return {"reply": "Refund request logged."}
def other(state: State) -> dict:
return {"reply": "Sent to the general queue."}
builder = StateGraph(State)
builder.add_node("classify", classify)
builder.add_node("refund", refund)
builder.add_node("other", other)
builder.add_edge(START, "classify")
builder.add_conditional_edges("classify", lambda s: s["route"], {"refund": "refund", "other": "other"})
builder.add_edge("refund", END)
builder.add_edge("other", END)
graph = builder.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "ticket-1"}}
print(graph.invoke({"text": "I want a refund", "route": "", "reply": ""}, config)["reply"])
print(len(list(graph.get_state_history(config))), "checkpoints saved")Output on langgraph 1.2.25 (the checkpoint count can change between versions):
Refund request logged.
4 checkpoints savedThe curriculum builds the same graph runtime (nodes, conditional edges, checkpoint after every node, pause and resume) in standard-library Python, so you can read every line of what compile and the checkpointer do. That is code/main.py in the Stateful Graph Orchestration lesson.
Common mistakes
- Mixing old and new names. Older tutorials, and two lessons linked below, use
create_react_agent,MemorySaverandinterrupt_before=[...]. In the docs read on 2026-12-04 the agent entry point islangchain.agents.create_agent, the saver is writtenInMemorySaver, and a pause is aninterrupt()call inside a node. - Treating it as either/or.
create_agentreturns something that runs on LangGraph. Choosing LangChain does not rule out LangGraph later. - Shipping a graph with no checkpointer. No checkpointer means no resume, no interrupt and no time travel. Decide the checkpointer when you design the graph.
- Keeping the in-memory saver in production. The docs say
InMemorySaverstores checkpoints in RAM and loses them when the process restarts. - Forgetting the reducer on a list field. The default is overwrite. A message list needs an appending reducer such as
add_messages, or a later update replaces earlier messages. - Pausing after the side effect. Put the approval step before the node that sends the email or issues the refund, so a rejection can cancel it.
- Making every edge conditional. A graph where every transition is a branch is hard to reason about. Prefer a mostly linear chain with a few named branches.
- Nodes that are not repeatable. Resume restarts the interrupted node from its first line, so code before the
interrupt()call runs again. Capture random seeds, clock reads and external API results in state. Give external actions such as refunds an idempotency key, so a repeated call does not refund twice.
Frequently asked questions
Is LangGraph replacing LangChain?
No. They sit at different layers and ship as separate packages. The LangChain docs describe LangChain as the agent framework and LangGraph as the orchestration runtime, and state that LangChain's agents are built on top of LangGraph. Using create_agent means you are already running a LangGraph graph underneath.
Can I use LangGraph without LangChain?
Yes. The LangGraph overview says its examples often use LangChain for model and tool integrations, but that LangGraph does not require LangChain. A node is a plain Python function that takes state and returns an update, so you can call any model SDK, or no model at all, inside it.
Should a beginner start with LangChain or LangGraph?
Start with the plain agent loop, then LangChain's create_agent, then LangGraph. The loop shows what any agent does. create_agent gives you that loop with tools and middleware in a few lines. Move to LangGraph when you need to draw the control flow yourself, checkpoint it, or pause it for a person.
What is the difference between a LangChain agent and a LangGraph graph?
A LangChain agent is a ready-made loop: a model calls tools until the task is done, shaped by a prompt, tools and middleware. A LangGraph graph is a structure you define: typed state, nodes that update it, and edges that pick the next node. The agent is one graph shape; LangGraph lets you build others.
Do I need a checkpointer in LangGraph?
You need one for anything that must survive a pause or a crash. Interrupts, resume after failure, conversation continuity and time travel all rely on checkpoints keyed by a thread ID. The in-memory saver loses everything on restart, so use a database-backed checkpointer such as Postgres or SQLite for real work.
Learn it by building
These free lessons build each piece by hand before using the library:
- The Agent Loop: Observe, Think, Act: the loop that
create_agentwraps. - Agent State Machines — Graphs, Nodes, Checkpoints: the same loop as an explicit LangGraph graph with interrupts and time travel.
- Stateful Graph Orchestration — Durable Execution and Checkpoints: a state graph with checkpoint and resume in standard-library Python.
- Agent Framework Tradeoffs — Graph, Role, and Actor Orchestration: how to choose an orchestration style by who decides the branching.
Sources
- docs.langchain.com/oss/python/concepts/products
- docs.langchain.com/oss/python/langchain/overview
- docs.langchain.com/oss/python/langchain/agents
- docs.langchain.com/oss/python/langchain/install
- docs.langchain.com/oss/python/langgraph/overview
- docs.langchain.com/oss/python/langgraph/graph-api
- docs.langchain.com/oss/python/langgraph/persistence
- docs.langchain.com/oss/python/langgraph/interrupts