LangChain vs LangGraph is not really a choice between rivals: LangChain is the high level way to build an agent, and LangGraph is the lower level runtime it runs on. Start with LangChain's create_agent if your app is a model calling tools in a loop, which covers most agents. Use LangGraph directly when you need to define the steps yourself: fixed branches, several agents with a set handoff order, loops with your own exit rules, or long running work that must pause and resume. Both are free, open source under the MIT license, and you can mix them in the same app. Together they are also the most popular AI agent framework by survey use, downloads and stars.
This comparison explains where the line sits in 2026, shows the same support workflow built both ways, and covers when to use each. Code was run on October 21, 2026 with langchain 1.4.6, langchain-core 1.6.12 and langgraph 1.2.16 from PyPI. The descriptions follow the official LangChain overview, the LangGraph overview and LangChain's own page on runtimes, frameworks and harnesses.
LangChain vs LangGraph at a glance
| Item | LangChain | LangGraph |
|---|---|---|
| What it is | Agent framework with a prebuilt agent loop | Low level orchestration framework and runtime |
| Main entry point | create_agent(model, tools, ...) | StateGraph(...) with nodes and edges |
| Who controls the flow | The model decides which tool to call next | You define the steps; the model decides inside them |
| Customization | Middleware hooks around model and tool calls | Any Python function as a node, any routing logic |
| Durable execution, streaming, human review | Yes, inherited from LangGraph | Yes, built in |
| Needs the other one? | Runs on LangGraph underneath | No, works without LangChain |
| License | MIT | MIT |
The key fact is the second to last row. Since LangChain 1.0, every agent made with create_agent is a compiled LangGraph graph. On our test install, type(agent) returned CompiledStateGraph. You get LangGraph's checkpointing and streaming without writing a graph, and LangChain's docs say you don't need to know LangGraph to use it.
What LangChain is now
The old LangChain of chains, LLMChain and dozens of agent types is gone from the main package. LangChain 1.x is centered on one function, create_agent, which the docs describe as a model plus a harness: a system prompt, tools and middleware. Middleware is the extension point. LangChain ships prebuilt middleware for retries on model and tool errors, model fallback, conversation summarization, call limits per thread or per run, PII detection and human in the loop approval. Here is a refund agent that pauses before it moves money. Install langchain plus the integration package for your provider, here pip install langchain langchain-openai (LangGraph comes along as a dependency):
from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.types import Command
@tool
def send_refund(order_id: str, amount: float) -> str:
"""Refund an order."""
return f"refunded {amount} on {order_id}"
agent = create_agent(
model="openai:gpt-5.6-terra",
tools=[send_refund],
system_prompt="You handle refunds.",
middleware=[HumanInTheLoopMiddleware(
interrupt_on={"send_refund": {"allowed_decisions": ["approve", "reject"]}}
)],
checkpointer=InMemorySaver(),
)
config = {"configurable": {"thread_id": "ticket-42"}}
result = agent.invoke({"messages": [{"role": "user", "content": "Refund order A12"}]}, config)
# result["__interrupt__"] holds the pending tool call for a person to review
result = agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config)
The human in the loop docs list four decisions (approve, edit, reject and respond) and note that it needs a checkpointer, because the agent's state has to survive between the two calls. In our test, the first call stopped with an __interrupt__ and the refund only ran after the resume. We ran it with a scripted test model, so swap in any provider string you have a key for.
That is roughly a dozen lines for an agent with tools, memory per thread and an approval gate. For a lot of products, that is the whole agent.
What LangGraph is
LangGraph is the layer underneath: a framework for building your app as a graph of steps over shared state, plus the runtime that runs it with durable execution, streaming, persistence and interrupts. You describe the state as a typed dict, write each step as a plain function that returns updates, and connect the steps with edges. Conditional edges let your own code pick the next step. Here is a support router where a classifier sends refund tickets to an agent and everything else to a person:
from typing import Literal, TypedDict
from langgraph.graph import StateGraph, START, END
class Ticket(TypedDict, total=False):
text: str
category: str
reply: str
def classify(state: Ticket):
return {"category": "refund" if "refund" in state["text"].lower() else "other"}
def refund_agent(state: Ticket):
return {"reply": "handled by refund agent"}
def human_queue(state: Ticket):
return {"reply": "sent to a person"}
def route(state: Ticket) -> Literal["refund_agent", "human_queue"]:
return "refund_agent" if state["category"] == "refund" else "human_queue"
graph = StateGraph(Ticket)
graph.add_node("classify", classify)
graph.add_node("refund_agent", refund_agent)
graph.add_node("human_queue", human_queue)
graph.add_edge(START, "classify")
graph.add_conditional_edges("classify", route)
graph.add_edge("refund_agent", END)
graph.add_edge("human_queue", END)
app = graph.compile()
print(app.invoke({"text": "Please refund me"})["reply"]) # handled by refund agent
None of those nodes call a model, which is the point: LangGraph lets you mix deterministic steps with agentic ones, so a keyword check, a database lookup or a policy rule can be a normal function instead of a prompt. In a real app, classify might call a small model and refund_agent would be the LangChain agent above.
How to use LangChain and LangGraph together
You don't have to pick. Because a create_agent agent is itself a graph, you can add it as a node in a bigger LangGraph graph. In our test, this ran as expected:
from langgraph.graph import StateGraph, MessagesState, START, END
workflow = StateGraph(MessagesState)
workflow.add_node("agent", agent) # the create_agent agent from earlier
workflow.add_edge(START, "agent")
workflow.add_edge("agent", END)
app = workflow.compile()
This is the pattern most teams end up with: LangGraph owns the overall process (intake, routing, approvals, retries, final checks) and LangChain agents do the open ended parts inside it. Our RAG pipeline with LangGraph tutorial builds exactly this, from a fixed two step pipeline to a graph with a grader loop to a full create_agent agent.
When to use LangChain
Pick LangChain's create_agent when:
- The job is "answer or act using these tools", and the model can decide the order.
- You want a working agent today, with retries, summarization, call limits and approvals as one line of middleware each.
- You're swapping models often. Model strings such as
"openai:..."or"anthropic:..."switch providers, and local models work too, as our LangChain with Ollama guide shows.
Most first agents belong here. If you later need something middleware can't do, you can wrap the agent in a graph without throwing it away.
When to use LangGraph
Go to LangGraph directly when:
- The process has a known shape that the model shouldn't be allowed to skip, such as a required review step, a compliance check or a fixed order between agents.
- You need branches and loops with your own exit rules, like "retry the search at most twice, then escalate".
- Work runs for minutes or days and must pause for people, survive restarts and resume from a checkpoint.
- Several agents share state and you want to control who acts when.
The cost is more code and more concepts: state schemas, reducers, nodes, edges and checkpointers. For simple agents, that is overhead with no payoff.
Where Deep Agents and LangSmith fit
Two other names show up in the same docs. Deep Agents is a third option, a ready made harness built on LangGraph that adds planning, subagents, a filesystem and context management for long tasks, closer in spirit to a coding agent. LangSmith is LangChain's tracing and evaluation platform, a separate commercial product that works with both libraries but isn't required. For more on what a harness is, see what is an agent harness.
LangChain's own products page also lists other frameworks in the same category, including Vercel AI SDK, CrewAI, OpenAI Agents SDK, Google ADK and LlamaIndex, and other durable runtimes such as Temporal and Inngest. If you're comparing LangGraph with those rather than with LangChain, our LangGraph vs CrewAI vs OpenAI Agents SDK guide and the best AI agent framework for Python roundup cover that, and the agent frameworks category lists every framework we track.
FAQ
Is LangChain built on LangGraph?
Yes. Since LangChain 1.0, agents created with create_agent run on LangGraph's runtime, which is where they get persistence, streaming and human in the loop support. You don't need to learn LangGraph's graph API to use them.
Is LangChain or LangGraph free?
Both are free and open source under the MIT license, for personal and commercial use. You pay only for the models you call and any hosting. LangSmith, the tracing platform, is a separate commercial product. Our LangChain commercial use guide covers where costs start.
Can I use LangGraph without LangChain?
Yes. LangGraph's docs say you don't need LangChain to use it. Nodes are plain Python functions, so you can call any model SDK inside them.
Should beginners learn LangChain or LangGraph first?
Start with LangChain's create_agent, since it gets you a working agent with tools and memory in a few lines. Learn LangGraph when you hit a flow that a single agent loop can't express.
Is LangGraph replacing LangChain?
No. They are layers of the same stack. LangGraph is the runtime and low level framework, LangChain is the high level agent framework on top, and both are actively released.
What about JavaScript?
Both have official JavaScript and TypeScript versions with the same split. If you work in TypeScript, also look at the options in our TypeScript AI agent frameworks guide.



