Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Blog
- /
- LangChain vs LangGraph: Differences, Code & When to Use Each
LangChain vs LangGraph: Differences, Code & When to Use Each (2026)
LangChain or LangGraph? How the 1.0 releases changed the answer, with runnable code for both, the create_agent vs StateGraph trade-off, and how to test agents.
Published on:
Use LangChain when you want a working agent fast: create_agent gives you a tool-calling agent in a few lines, with middleware for human approval, summarization, PII handling and retries. Use LangGraph when you need explicit control: custom state, branching and loops you define yourself, durable long-running workflows, and multi-agent systems. Since the 1.0 releases (October 2025), this is less an either-or choice. LangChain agents run on the LangGraph runtime, so you can start in LangChain and drop down to LangGraph when you need to, without switching ecosystems.
LangChain vs LangGraph at a Glance
| LangChain | LangGraph | |
|---|---|---|
| What it is (official wording) | "The easiest way to start building agents": a "highly customizable harness" | "A low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents" |
| Level of abstraction | High: one function builds an agent | Low: you define nodes, edges and state |
| Main API | create_agent(model, tools, system_prompt, middleware) | StateGraph, add_node, add_edge, add_conditional_edges, compile() |
| Control flow | Built-in agent loop (model, tools, model…) | Anything you can draw: branches, cycles, parallel steps, subgraphs |
| State | Messages plus optional custom state | Any typed state you define, with reducers |
| Persistence and memory | Via the LangGraph checkpointer you pass in | Checkpointers, threads, time travel, durable execution |
| Human-in-the-loop | HumanInTheLoopMiddleware (approve, edit, reject, respond) | interrupt() anywhere in the graph, resumed with Command |
| Multi-agent | Subagents as tools, handoffs, router | Any topology: supervisor, swarm, hierarchical, custom |
| Integrations | Hundreds of model, vector store and tool integrations | Uses LangChain integrations, but doesn't require LangChain |
| Deployment | Through LangSmith Deployment (it's a LangGraph graph) | LangSmith Deployment (formerly LangGraph Platform), or self-host |
| Learning curve | Low | Moderate: you think in graphs and state |
| GitHub stars (Oct 11, 2026) | ~147.6k | ~43.1k |
| PyPI downloads (last month) | ~170 million | ~45 million |
| Best for | Standard tool-calling agents, RAG agents, fast prototypes and production agents with middleware | Complex, stateful, multi-step or multi-agent systems where you need to own every transition |
What Changed in LangChain 1.0 and LangGraph 1.0?
LangChain announced both 1.0 releases on October 22, 2025, with a promise of "no breaking changes until 2.0." Most comparison articles were written before this and are now out of date.
- create_agent replaced create_react_agent. LangChain's new standard agent lives in langchain.agents and "uses LangGraph under the hood". It returns a compiled LangGraph graph. langgraph.prebuilt.create_react_agent is deprecated and slated for removal in 2.0.
- Middleware is the defining feature of create_agent. You can hook in before and after the model call, wrap model or tool calls, or run at the start and end of the agent. Built-in middleware covers:
- Human-in-the-loop
- Summarization
- PII handling
- Model and tool call limits
- Model fallback and retries
- Tool retries and error handling
- Context editing
- To-do lists
- Legacy code moved to langchain-classic - old chains (LLMChain, ConversationChain), legacy retrievers, the indexing API and hub. If a tutorial imports these from langchain, it predates 1.0.
- Standard content blocks - messages expose .content_blocks with the same shape across providers, covering reasoning, citations and server-side tool calls.
- LangGraph 1.0 was a stability release. State, nodes, edges and the runtime model didn't change.
LangChain's docs now describe three levels:
- Deep Agents for a "batteries-included" agent.
- LangChain for a customizable agent harness.
- LangGraph, the "low-level orchestration framework, for advanced needs combining deterministic and agentic workflows."
Difference Between LangChain and LangGraph: How Each Is Built
LangChain gives you an agent loop that's already designed: the model decides whether to call a tool, the tool runs, the result goes back to the model, and so on until it answers. You customize it with a system prompt, tools and middleware, but you don't redraw the loop.
LangGraph gives you the parts to draw any loop:
- A typed state object that every step reads and updates.
- Nodes - Python or JS functions that do work, such as calling a model, running a tool, or calling an API.
- Edges, including conditional edges that route to different nodes based on state.
- A compiled graph you can run, stream, pause and resume.
Which Handles State and Memory Better?
Both use the same LangGraph persistence layer, since create_agent is a LangGraph graph.
- In LangChain, you pass a checkpointer (for example InMemorySaver, or a database-backed saver in production) and a thread_id. The agent then remembers the conversation across calls.
- In LangGraph, you get the same checkpointing plus full control of what goes in state: counters, retrieved documents, approvals, partial results.
- You also get time travel: replay or fork a run from any earlier checkpoint.
- And durable execution: long-running workflows resume where they stopped after a failure.
How Does Human-in-the-Loop Work in Each?
- LangChain - add HumanInTheLoopMiddleware(interrupt_on={"issue_refund": True}), and the agent pauses before that tool runs. You resume with a decision: approve, edit, reject or respond.
- LangGraph - call interrupt() inside any node to pause the graph with a payload for a human, then resume with Command(resume=...). Interrupts need a checkpointer, because the graph's state is saved while it waits.
Use LangChain's middleware when approval is about tool calls. Use LangGraph's interrupt() when approval sits anywhere else in your process, such as reviewing a plan, a draft or a classification.
LangGraph vs LangChain: Which Is Better for Multi-Agent Systems?
LangGraph, when you need a specific topology.
- LangChain supports common patterns from its documentation: subagents as tools (a main agent calls specialists), handoffs, skills and routers.
- LangGraph lets you compose compiled graphs as nodes (subgraphs) and wire any structure, such as supervisor, swarm, hierarchical or pipeline.
Library status:
- The Python langgraph-supervisor library was archived in September 2026. LangChain now recommends building the supervisor pattern directly with tools.
- langgraph-swarm is still available.
- The JS versions of both libraries are still maintained.
How Do You Deploy LangChain and LangGraph Agents?
The same way, because a LangChain agent is a LangGraph graph:
- LangSmith Deployment, renamed from LangGraph Platform in October 2025. It offers cloud, hybrid, self-hosted and standalone (Docker/Kubernetes) options. Pricing (October 2026):
- Developer - free, with 5,000 base traces a month and 1 seat.
- Plus - $39 per seat per month, with 10,000 base traces and one free small deployment.
- Enterprise - custom.
- Deployments are metered in LangChain Standard Units (LSUs).
- LangSmith Studio - a visual IDE for inspecting and debugging graphs.
- Self-hosting - run the graph in your own service. LangGraph doesn't require LangSmith.
Who Uses LangGraph in Production?
LangChain's published case studies include:
- LinkedIn - an AI recruiting assistant.
- Uber - agents that generate unit tests during code migrations.
- Klarna - a support assistant serving 85 million active users, with an 80% cut in resolution time.
- Elastic - agents for security threat detection.
- AppFolio - the Realm-X copilot.
LangChain create_agent vs LangGraph: The Same Agent Both Ways
One weather tool, one agent, built both ways. Both examples were run against langchain 1.4.4 and langgraph 1.2.14.
LangChain: create_agent
from langchain.agents import create_agent
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
@tool
def get_weather(city: str) -> str:
"""Get the weather for a city."""
return f"It's always sunny in {city}!"
agent = create_agent(
model="openai:gpt-5", # any "provider:model" string or chat model instance
tools=[get_weather],
system_prompt="You are a helpful assistant.",
checkpointer=InMemorySaver(),
)
config = {"configurable": {"thread_id": "1"}}
result = agent.invoke({"messages": [{"role": "user", "content": "Weather in Paris?"}]}, config)
print(result["messages"][-1].content)LangGraph Tutorial: The Same Agent as an Explicit Graph
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.graph import StateGraph, MessagesState, START
from langgraph.prebuilt import ToolNode, tools_condition
from langgraph.checkpoint.memory import InMemorySaver
@tool
def get_weather(city: str) -> str:
"""Get the weather for a city."""
return f"It's always sunny in {city}!"
tools = [get_weather]
model = init_chat_model("openai:gpt-5").bind_tools(tools)
def call_model(state: MessagesState):
return {"messages": [model.invoke(state["messages"])]}
builder = StateGraph(MessagesState)
builder.add_node("agent", call_model)
builder.add_node("tools", ToolNode(tools))
builder.add_edge(START, "agent")
builder.add_conditional_edges("agent", tools_condition) # to "tools" or END
builder.add_edge("tools", "agent")
graph = builder.compile(checkpointer=InMemorySaver())
config = {"configurable": {"thread_id": "user-42"}}
graph.invoke({"messages": [{"role": "user", "content": "Weather in Paris?"}]}, config)What the side-by-side shows: the LangChain version is 16 lines and hides the loop. The LangGraph version spells out the loop (model, then tools if needed, then back to the model), which is exactly the part you'd change to add a validation step, a second model, a retrieval node or a human checkpoint.
Adding a Human Approval Step in LangGraph
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.types import interrupt, Command
from langgraph.checkpoint.memory import InMemorySaver
class State(TypedDict):
draft: str
approved: bool
def write_draft(state: State):
return {"draft": "Refund $40 to customer #123"}
def human_review(state: State):
decision = interrupt({"question": "Approve?", "draft": state["draft"]})
return {"approved": decision == "yes"}
builder = StateGraph(State)
builder.add_node("write_draft", write_draft)
builder.add_node("human_review", human_review)
builder.add_edge(START, "write_draft")
builder.add_edge("write_draft", "human_review")
builder.add_edge("human_review", END)
graph = builder.compile(checkpointer=InMemorySaver()) # interrupts need a checkpointer
config = {"configurable": {"thread_id": "review-1"}}
graph.invoke({"draft": "", "approved": False}, config) # pauses at human_review
graph.invoke(Command(resume="yes"), config) # resumes with approvalHow to Migrate Older LangChain Code
| If your code uses… | Change to… |
|---|---|
| from langgraph.prebuilt import create_react_agent | from langchain.agents import create_agent. Rename prompt to system_prompt, and pass tools as a list, not a ToolNode |
| AgentExecutor, LLMChain, ConversationChain | create_agent for agents, or a LangGraph graph for custom flows. To keep old code running temporarily, import it from langchain-classic |
| Custom callback logic for approvals or retries | Built-in middleware (HumanInTheLoopMiddleware, ModelRetryMiddleware, ToolRetryMiddleware, and others) |
| Python 3.9 | Python 3.10 or later (required by LangChain 1.x) |
When to move from create_agent to a hand-built StateGraph:
- When the logic you need doesn't fit the model-tools loop. For example, a mandatory validation step after every tool call, two different models for planning and answering, or branching on custom state.
- When middleware starts carrying business logic it wasn't meant for.
How Do You Test LangChain and LangGraph Agents?
Testing is the same for both, because both produce LangGraph graphs. LangChain's own docs describe three layers:
- Unit tests. Swap the real model for a fake one (GenericFakeChatModel from langchain_core) and use InMemorySaver. With LangGraph you can also test each node on its own, which is one practical advantage of an explicit graph.
- Integration tests that call real models and tools.
- Evaluations:
- Trajectory evaluators from the agentevals package check which tools the agent called and in what order (strict, unordered, subset or superset match), or use an LLM judge.
- openevals adds LLM-as-judge graders for answer quality.
- The LangSmith pytest plugin (@pytest.mark.langsmith) logs runs and results to LangSmith.
Those tests answer "did the agent take the expected path?" Before production you also need to answer three more questions:
- Did it actually do the right thing in your systems? An agent can call the right tool with the wrong amount, or report success when the write failed.
- Does it hold up against real, messy users? That means hundreds of conversations: confused, angry, off-topic and adversarial.
- Does it work on the real channel? If your LangGraph agent sits behind a chat widget, a phone number or a voice assistant, the channel itself has to be tested.
For a step-by-step walkthrough, see how to test a LangChain or LangGraph agent.
How TestMu AI Fits
LangChain and LangGraph help you build the agent. TestMu AI (formerly LambdaTest) tests it from the outside, the way users and other systems meet it:
- Agent Assurance, delivered by Rook, grades what your agent actually changed in tools, files and APIs, not what it says it did.
- It builds test scenarios from your repo, PRD or policy documents.
- It generates adversarial tests (prompt injection, instruction override, tool misuse).
- It reports Pass, Fail and Unable to Verify separately, so unverifiable results never inflate your pass rate. CI gating is built in.
- Install with npm install -g @testmuai/rook. Its /rook skill also works inside Claude Code and Codex CLI. Rook is pre-alpha and publicly installable.
- Agent Testing puts your agent in front of autonomous AI evaluators across chat, voice, IVR/phone and video.
- It generates 60-100+ scenarios from your docs, scores conversations on 9 quality metrics, and returns a go-live verdict.
- Voice and phone tests add 200+ voice profiles, 50+ accents, background noise and real calls.
- Run it from the terminal with pip install testmu-a2a-cli.
- KaneAI and Kane CLI test the app around your agent: the chat UI, the dashboard, the checkout the agent touches. KaneAI writes end-to-end tests in plain English. Kane CLI is a testing agent that drives a real browser from the terminal and returns a pass or fail with evidence, which your coding agent can call after each change.
Author
Saurabh Prakash is an Engineering Manager at TestMu AI (formerly LambdaTest), where he leads engineering on agentic AI development and scalable system architecture for the quality engineering platform. He has also contributed to Test at Scale, the company's open-source test intelligence platform. He brings over 9 years of experience across Node.js, Java, Spring, MVC, data structures, algorithms, and scalable system design, with earlier roles as SDE 2 at Zomato, Senior Software Engineer at LogicHub, and Software Development Engineer at Directi. Saurabh holds a B.Tech in Computer Science and Engineering from Delhi Technological University.
Reviewer
Anubhav Singhmaar is an AI Product Manager at TestMu AI driving Kane CLI, the command-line tool that brings browser automation to the terminal, turning natural-language flows into runs in a real Chrome browser that return pass or fail with shareable proof. He owns the roadmap and prioritization and works with engineering to ship developer-facing features. Before TestMu AI, he spent over four years at Sprinklr owning enterprise voice AI across APAC and EMEA. A mechanical engineer turned product manager, he grounds guidance in real QA workflows.
LangChain vs LangGraph FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests




