Lesson 03.10 · Phase 03 · The Agent Loop

The loop as a graph

An agent loop is a graph with two nodes and one conditional edge. Once you see that, adding a step is adding a node.

Learning objectives

  • Express the agent loop as a graph: shared state, nodes that return partial updates, and edges (fixed or conditional) that pick what runs next.
  • Implement a graph runtime with reducers, compile-time wiring checks, super-steps with fan-out, a recursion limit, checkpoints and interrupts.
  • Extend an agent by adding a node (a grounding check) without touching the loop.
  • Map each piece to LangGraph's API, so the framework in Phase 9 reads as familiar code.

Every lesson in this phase added something to the loop: stop conditions, malformed-call handling, retries, streaming, interrupts, budgets. Each one went inside run(). Keep going and run() becomes the function nobody wants to touch: 300 lines of interleaved concerns, every new feature a risk to the others.

Loading the full lesson…