Topic overview
A simple chain runs steps once, in order. Real agents need loops (try again, call another tool), branches (take a different path based on the result), and memory across steps. LangGraph models this explicitly. You define a graph of nodes that read and update a shared state, and edges that decide what runs next. That explicitness gives you control, which is what production agents need. Framework details change quickly, so check the official docs for current APIs.
Core concepts
State: a shared object, often a typed dictionary, that every node reads and updates. Reducers define how updates merge, for example appending messages instead of overwriting them.
Nodes: functions that take the current state and return updates. A node might call a model, run a tool, or apply plain business logic.
Edges: the connections between nodes. Conditional edges choose the next node from the current state, which is how you build routing and loops.
Cycles: unlike a simple pipeline, a graph can loop back, for example model, then tool, then model again until a stop condition is met.
Checkpointing and persistence: the state is saved after each step. This allows resuming after a crash, keeping conversation memory per thread, and replaying or inspecting earlier steps.
Human-in-the-loop: a graph can pause at an interrupt, wait for a person to approve or edit, and then continue. This is the standard way to put a human gate on risky actions.
Multi-agent patterns: a supervisor node can route work to specialist sub-agents, or agents can hand off to one another. Subgraphs keep each part self-contained.
Streaming: intermediate steps and tokens can be streamed, so users see progress instead of waiting for a final answer.
Why it matters
Prototype agents often break in production: they loop forever, lose state, or take an action nobody approved. A graph makes the control flow visible and testable, and persistence plus interrupts make long, supervised workflows practical. This is why LangGraph is a common choice for serious agent work.
Interview relevance
Typical questions: when would you choose a graph over a chain, how is state shared and merged, how do you prevent infinite loops, how would you add approval before a payment or email, how do you recover from a failure midway, and how would you structure a multi-agent system. Show that you think in terms of explicit state, clear stop conditions, and safe handoffs.