Study Guide · Chapter 3: Execution Loop · 7 min read

How Planning and Self-Correction Work Under the Hood

Underneath every capable agent is a control system: checkpoints that save progress, budgets that cap effort, and escalation paths for failures it cannot fix alone.

Anatomy of the LoopPlan state, actions, reflection, rollbackPLAN STATEExplicit machineStep status, dependencies,rollback pathsACTExecute stepTool calls and retrieval, resultsrecordedREFLECTGrade the stepSuccess criteria checked againstevidenceDECIDEContinue or replanResume safely after interruptionschosen actionoutcomereplan from updated state

Checkpoints make loops resumable

Each completed subtask is committed as a checkpoint — the plan state, tool outputs so far, and remaining steps. If a process crashes or a model call times out, work resumes from the checkpoint instead of starting over.

Checkpoints also enable inspection: reviewers can see exactly which step produced which decision, which turns debugging from archaeology into reading.

Reflection turns failure into signal

When a step fails, well-built agents do not simply retry identically. A reflection step asks: why did this fail — bad input, wrong tool, wrong order, or an impossible request?

The answer changes the strategy: reformat and retry, pick a different tool, reorder the plan, or escalate to a human. Escalation is not failure; it is the loop knowing its own limits.

Budgets prevent runaway loops

Every loop runs under explicit limits: maximum iterations, wall-clock time, token spend, and cost. Hitting any limit triggers a defined behavior — summarize progress, save state, hand off to a person.

This is what separates production agents from demos. Demos assume success; production systems define exactly what happens when the twentieth attempt still fails.

Key Points

  • Persist plan state at each step so runs are resumable and reviewable.
  • Classify failures before retrying — identical retries of a doomed step just burn money.
  • Escalation paths are a feature, not an admission of defeat.
  • Iteration, time, and cost budgets convert infinite risks into bounded ones.


All study guides for this chapter: Execution Loops, Explained Simply · How Planning and Self-Correction Work Under the Hood · Execution Loops in the Real World · How AI Learns From Trying, Made Simple