Chapter 13: Reflection
Lecture
Chapter principle
Key takeaways
- Reflection adds a critic and a revision stage; it does not guarantee improvement.
- A critic is fallible: measure its precision and recall.
- Critique proposes a defect; verification tests whether it is real.
- Reflection can regress already-correct outputs.
- Gate it.
- Reflection loops need budgets, stopping rules, and resource-equivalent baselines.
Experiments
Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.
Experiment 25: Reflection with a check
Does asking a model to criticize an answer make the answer better?
A shop buys 417 items at 35 dollars and sells them at 47 dollars, but 62 stay unsold. The profit is 355 × 47 − 417 × 35 = 2090 dollars, and a calculator can confirm it. Two drafts are written by hand: a wrong one that ignores the unsold items (5004) and a correct one (2090). A real model then criticizes each draft under two instructions. The careful critic checks the answer step by step. The hasty critic is told the answer contains a mistake. Each pairing runs three times. Two policies decide what to do with each proposed number: always accept it, or accept it only when the calculator agrees. This is a recorded run of a real model. A new run may give different numbers.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters