Build stateful, multi-step AI workflows by defining nodes as Python functions and edges as control flow paths within a directed graph. Use a shared, typed state schema to pass data across steps, enabling loops, branching, and agent patterns without implicit state management.
LangGraph is a Python library built on top of LangChain that lets you design, run, and inspect stateful, multi-step AI workflows as explicit graphs. Instead of writing a linear chain of calls or a tangled nest of conditionals, you define your application as a directed graph — nodes do work, edges decide where control flows next, and a shared state object carries data across every step. The result is a principled way to build AI agents that loop, branch, recover from errors, and collaborate across multiple models or tools.
Early LLM applications were mostly single-shot: send a prompt, receive an answer. As requirements grew more complex — search-then-summarise, plan-then-execute, reflect-and-retry — developers reached for chains (sequential calls) and then agents (LLMs that decide which tool to call). Both approaches run into the same wall: state and control flow are implicit, buried in code that is hard to inspect, test, or modify.
LangGraph makes both explicit:
TypedDict or Pydantic model). Every node reads from it and writes back to it.This design mirrors how engineers already think about complex processes: as flowcharts, decision trees, or pipelines with feedback loops.
The five building blocks you will encounter throughout this course are:
| Concept | One-line description |
|---|---|
| State | A shared data structure passed through every node |
| Node | A Python function that reads state and returns updates |
| Edge | A directed connection that routes execution between nodes |
| Conditional Edge | An edge whose destination is chosen at runtime by a function |
| Graph / StateGraph | The container that wires nodes and edges together |
Together they form a complete programming model for AI workflows.
A minimal LangGraph application: state flows through nodes, a conditional edge decides whether to loop (retry) or continue to the end.
When you compile a StateGraph and invoke it:
This cycle means that loops are first-class citizens. An agent that calls a tool, inspects the result, and decides to call another tool is simply a graph that routes back to an earlier node.
A key distinction in LangGraph is the difference between a stateless pipeline and a stateful agent:
LangGraph also supports persistence (checkpointing state to a database between runs) and human-in-the-loop interrupts, enabling long-running workflows that pause for user approval or external input.
LangGraph sits above LangChain's component layer (LLMs, tools, retrievers) and below your application layer. You can think of the stack as:
You do not need to use LangChain components inside your nodes — plain Python functions work fine — but LangGraph's tooling (tracing via LangSmith, pre-built agent architectures) integrates tightly with the broader LangChain ecosystem.
Throughout this course you will progress from simple linear graphs to sophisticated multi-agent systems:
Each of these patterns builds on the same five primitives introduced above. Mastering state, nodes, and edges is the foundation for everything else.