Quick answer
In one sentence: LangChain is a component library for assembling LLM powered pipelines; LangGraph is a stateful graph runtime, built on top of LangChain, that adds cycles, branching, and persistent state for agents that reason and act across multiple steps. Use LangChain alone for linear pipelines; use LangGraph when your agent needs to loop or maintain state.
Section 01 · Core difference
Linear pipelines vs. stateful graphs
Most LLM applications start as linear pipelines. Agents are different: they decide what to do next based on their current state. That distinction is the whole reason LangGraph exists.
A linear pipeline takes a user message, retrieves relevant documents, constructs a prompt, calls the model, and returns the output. Input flows through a fixed sequence of steps and exits. That is a chain. LangChain is designed for this.
An agent does not follow a fixed sequence. It decides what to do next based on its current state and the outputs of previous steps. It might call a tool, observe the result, decide the result is insufficient, call a different tool, and try again. It might check a condition after each LLM call and branch to a different subgraph depending on the answer. This kind of flow, with cycles, branching, and state, is what LangGraph was built for.
The technical implementation of LangGraph is a directed graph where nodes are computations (LLM calls, tool invocations, conditional checks) and edges represent transitions. Edges can be conditional, allowing the graph to branch based on an LLM's output. Nodes can loop back to previous nodes. The graph maintains a shared state object that every node can read and update.
LangChain is the component layer. LangGraph uses LangChain's chains, retrievers, tools, and output parsers as nodes inside its graph. They are not competing frameworks. LangGraph extends LangChain.
Section 02 · LangChain
What LangChain is good at
LangChain's core strength is the component library: well tested, interchangeable building blocks for the standard LLM application shapes.
LangChain provides chat models, completion models, embedding models, vectorstore integrations, document loaders, text splitters, output parsers, and a tools interface. The LCEL (LangChain Expression Language) lets you compose these into pipelines with clean syntax.
RAG systems
A retrieval augmented generation pipeline (embed documents, store in a vectorstore, retrieve on query, assemble a prompt, call the model) is a linear chain. LangChain is often sufficient and faster to ship. LangGraph adds complexity without benefit here.
Chatbots with memory
LangChain's conversation buffer memory and message history integrations handle the standard case well. If your chatbot remembers previous messages and responds in turn, LangChain alone is appropriate.
Document processing pipelines
Extract, transform, summarize, classify. LangChain's sequential chain pattern works cleanly without the overhead of a graph runtime.
The common thread: use LangChain when the flow is known in advance, each step runs a fixed number of times, and the pipeline terminates when it reaches the end.
Section 03 · LangGraph
What LangGraph is good at and why it exists
LangGraph was built to solve a specific problem: LangChain's chain abstraction does not support cycles. An agent that needs to retry a failing tool call, iterate toward a goal across multiple LLM calls, or maintain decision state across a long running task cannot be expressed cleanly as a LangChain chain.
Loops and retries
An agent calls a search tool, gets a poor result, calls a different search tool, and evaluates the combined results before responding. Each tool call is a node; the routing logic between them is a conditional edge. LangChain chains cannot express this because they do not support cycles.
Persistent state across steps
A research agent maintains a notes object that accumulates findings across multiple tool calls. A planning agent maintains a todo list that gets updated and checked after each step. LangGraph's state schema defines what gets persisted and how nodes read and write it.
Human in the loop checkpoints
LangGraph's interrupt mechanism lets a graph pause execution at a defined node and wait for external input before continuing. This is how you build agents that require human approval before taking a high stakes action, exactly the pattern that production agentic AI systems need for regulated use cases.
Parallel subgraph execution
LangGraph supports a Send primitive that allows parallel execution of multiple graph branches, collecting results before continuing. A research agent that queries three sources simultaneously and merges the results is a natural fit.
For a deeper look at the orchestration shapes that production agents actually use, see the multiagent design patterns guide.
Section 04 · Decision
LangChain or LangGraph? A decision table
The rule of thumb: if you can describe the application's flow as a flowchart with no cycles and no conditional branches, LangChain is enough. If the flowchart has cycles, branching conditions based on LLM outputs, or state that persists and evolves across calls, use LangGraph.
| Scenario | Use |
|---|---|
| Document Q&A with RAG | LangChain |
| Summarization pipeline | LangChain |
| Chatbot with conversation history | LangChain |
| Single pass document extraction | LangChain |
| Agent that retries on failure | LangGraph |
| Agent with branching logic based on LLM output | LangGraph |
| Multiagent system with coordinator and workers | LangGraph |
| Long running task requiring state persistence | LangGraph |
| Agent requiring human approval at decision points | LangGraph |
| Research agent querying multiple sources | LangGraph |
Section 05 · Failure modes
Production failure modes to avoid
Both directions of the choice have a characteristic failure mode. Recognizing them up front saves a rewrite.
LangChain without LangGraph for an agentic task
The most common version: an agent implemented as a chain calls a tool once, gets an insufficient result, and returns the insufficient result to the user because the chain has nowhere to loop back to. Engineers compensate by adding retry logic inside Python code around the chain, which creates fragile, untestable spaghetti that is impossible to visualize or debug.
LangGraph when LangChain would have been sufficient
LangGraph adds real complexity: you define a state schema, write node functions, define edges, and manage graph compilation. For a document Q&A system that does not need any of this, the overhead delays shipping by weeks and creates a maintenance burden that nobody asked for.
Forgetting that graphs can loop infinitely
Without a loop counter or a convergence condition on your conditional edges, a LangGraph agent that cannot satisfy its goal will call tools indefinitely until it hits your API cost limit. Always add a max steps counter or a convergence check on loops.
Treating state as reliable without a persistence backend
LangGraph's in memory state disappears if the process restarts. For long running agents or agents that need to survive failure, wire LangGraph's checkpointer to a Redis or Postgres backend before shipping to production.
The LLM agent evaluation guide covers how to build evaluation sets for agentic systems, which is the layer that catches these failure modes before they reach users.
Section 06 · Observability
LangSmith and observability
If you are running LangGraph in production, you need tracing from day one. Running a graph runtime without observability is flying blind.
LangSmith is LangChain's observability layer. It traces individual runs, captures inputs and outputs at every node, and lets you debug why an agent took a particular path through the graph.
LangSmith is not the only option. Langfuse, Arize Phoenix, and Helicone all integrate with LangChain and LangGraph via callback handlers. LangSmith has the tightest integration and covers graph specific tracing well, but any of these is a reasonable production choice if it fits the rest of your stack.
A real production setup pairs LangGraph with LangSmith or a comparable observability layer from day one. The cost of adding tracing later, after an agent has already shipped and started misbehaving on edge cases, is much higher than the cost of wiring it in at the start.
Section 07 · Getting started
If you are new to both
Start with LangChain. Reach for LangGraph only when you hit a specific limitation.
If you are building your first LLM application, get a working RAG pipeline or chatbot running with LangChain alone. Understand how the component model works, and reach for LangGraph only when you hit a specific limitation: you need a loop, you need branching, or you need persistent state.
The LangGraph documentation is good. The tutorials section is particularly clear on the core graph concepts. Run the examples locally before building your production system. Understanding how nodes and edges interact in simple cases saves significant debugging time on complex ones.
If you are architecting an agentic system for a production launch and want a senior technical perspective on whether LangGraph is the right foundation, the agentic AI consulting service covers framework selection as part of the discovery phase.
Section 08 · FAQ
Frequently asked questions
The questions engineers ask most before committing to one framework or the other.
What is the difference between LangChain and LangGraph?
LangChain is a component library for building LLM powered applications. It provides chains, retrievers, tools, and output parsers. LangGraph is a stateful graph runtime built on top of LangChain that adds cycles, conditional branching, and persistent state. LangGraph uses LangChain components as nodes inside its graph; they are complementary, not competing.
When should I use LangGraph instead of LangChain?
Use LangGraph when your agent needs to loop (retry on failure, iterate toward a goal), branch based on intermediate LLM outputs, maintain state that evolves across multiple LLM calls, or support human in the loop checkpoints. For linear pipelines where the flow is fixed and each step runs once, LangChain alone is appropriate.
Can I use LangGraph without LangChain?
LangGraph is built on top of LangChain and imports it as a dependency. In practice, you use both: LangGraph provides the graph structure and state management, while LangChain provides the models, tools, and retrievers that become nodes in your graph.
Is LangGraph better than LangChain?
It is not a ranking. They serve different use cases. LangGraph is more capable for complex agentic workflows; LangChain is simpler and faster to use for linear pipelines. Choosing LangGraph for a simple pipeline adds unnecessary complexity. Choosing LangChain alone for an agent that needs to loop creates brittle code. Match the tool to the flow your application requires.
What is LangSmith and do I need it?
LangSmith is the observability and evaluation platform from the LangChain team. It traces runs, captures node level inputs and outputs, and supports evaluation dataset management. For production LangGraph deployments, some form of LLM observability is not optional, and LangSmith is the natural choice if you are already in the LangChain ecosystem.