Mapping LangChain Knowledge into LangGraph
Explore the transition from LangChain's linear chains to LangGraph's graph-based workflows. Understand what remains the same, such as model calls and tools, and what changes, including control flow, shared state management, branching, and inspectability. This lesson helps you recognize when to use each approach and guides you to extend workflows with conditional routing for efficiency in AI agent design.
If you have used LangChain before, you have already built the foundation this course relies on. You know how to wrap a language model, write a prompt template, parse a model’s output, and chain a few steps together. Those skills carry forward into LangGraph without modification.
LangGraph is not a replacement for LangChain. It is built on top of it. Every model call, retriever, tool, and prompt template you know from LangChain still works inside a LangGraph node. What changes is the layer above: how we connect those calls, how we pass data between them, and how we control which steps run.
This lesson is about making that handoff clear. We will look at what stays the same, what changes, and how to recognize which tool to reach for when starting a new project.
What stays the same
The core building blocks of LangChain work inside LangGraph nodes without any modification. The following table maps familiar LangChain patterns to their role in a LangGraph workflow.
LangChain concept | What you do with it | Where it lives in LangGraph |
Model wrapper ( | Call the language model | Inside a model node function |
Prompt template | Build structured prompts | Inside a model node function |
Output parser | Extract structured data from model output | Inside a model node, or a dedicated parsing node |
Retriever | Fetch relevant documents | Inside a retrieval node |
Tool function | Call external APIs or search engines | Inside a tool node |
Chain ( | Sequence of steps | Replaced by nodes and edges |
The key difference in that last row is intentional. In LangChain, a chain is the glue that sequences steps together. In LangGraph, that job moves to edges. The steps themselves, the model calls, the retrievers, and the tools remain unchanged. Only the connective tissue is different.
A side-by-side comparison
The clearest way to see the shift is to build the same workflow in both styles. We will use a simple retrieval-and-answer assistant: given a user question, retrieve relevant content, then generate a response.
The LangChain approach
In LangChain, this is a sequential chain. Each step feeds directly into the next. The retriever returns documents, those documents become part of the prompt, and the model generates a response.
Lines 1–3: Import LangChain components.
ChatPromptTemplatestructures the prompt.StrOutputParserextracts the text from the model's response object.Line 5: Create the Groq model wrapper.
Lines 7–11: Define ...