LangGraph solves the problem that LangChain chains cannot: agents that loop, branch, and maintain state across multiple model calls. It models your agent as a directed graph where nodes are functions and edges control the flow.
The ReAct pattern (Reason + Act) is the most common agent architecture:
State is a TypedDict that flows through the graph. Every node reads from and writes to state. Define all fields upfront.
from typing import TypedDict, Annotated
from langgraph.graph.message import add_messages
class AgentState(TypedDict):
# Messages accumulate — add_messages merges rather than replaces
messages: Annotated[list, add_messages]
# Custom state fields
research_results: list[str]
final_answer: str
iterations: int| Feature | AgentExecutor (legacy) | LangGraph |
|---|---|---|
| Control flow | Black box loop | Explicit graph — full control |
| Custom routing | Limited | Full conditional branching |
| Multi-agent | Not supported | First-class: sub-graphs, handoffs |
| Persistence | No | Checkpointers (memory, Redis, Postgres) |
| Human-in-the-loop | Hacky | Built-in interrupt/resume |
In the next lesson, we explore the different memory strategies available to LangGraph agents: short-term (within-thread), long-term (cross-thread), and episodic memory.