Modern AI Engineering

Lesson 12.6 · 28 min · video lesson

LangGraph: Graph-Based Agent Orchestration Explained

How do we build an agent that can loop, branch, remember a customer across sessions and pause for a manager's approval, without it turning into a tangle of if-statements?

In short: LangGraph is an open-source library from the LangChain team for building agents as graphs. We define a typed state, nodes that update it, and edges (fixed or conditional) that decide what runs next; cycles are allowed, so agent loops are natural. A checkpointer saves the state after every step per conversation thread, which gives memory, crash recovery, time travel and human-in-the-loop pauses. It is graph engineering, packaged as a library.

What you will learn

  • What is LangGraph?
  • Why do we need LangGraph?
  • What is a Graph in LangGraph?
  • What is State in LangGraph?
  • Nodes and Edges
  • Conditional Edges
  • A complete example
  • Tools and who calls them
  • Memory and persistence
  • Human-in-the-loop
  • When to use LangGraph

In this lesson

  1. What is LangGraph?
  2. Why do we need LangGraph?
  3. What is a graph and what is state in LangGraph?
  4. Nodes, edges and conditional edges
  5. A complete example
  6. Tools and who calls them
  7. Memory and persistence
  8. Human-in-the-loop
  9. When to use LangGraph
  10. Worked example, step by step
  11. Practice: try it yourself

Key terms in this lesson

StateGraph
LangGraph's builder for a graph whose nodes share and update a typed state.
Reducer
A function that merges a node's update into a state field, such as appending messages.
Conditional edge
An edge that calls a router function on the state to choose the next node.
ToolNode
A prebuilt node that executes the tool calls requested in the last AI message.
Checkpointer
A component that saves state snapshots after each step, keyed by thread id.
Interrupt
A pause inside a node that waits for external (usually human) input before resuming.

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 12.5 LangChain: Composable Components for LLM Applications · 12.7 Claude Code: AI-Powered Software Engineering at the CLI →