Chapter 22: Evaluation
Lecture
Chapter principle
Key takeaways
- Begin with the engineering question being tested.
- Outcome, trajectory, component, resource and control are distinct layers.
- Use objective evaluators whenever practical; baselines and slices make comparisons meaningful.
- Prefer trajectory invariants over one supposedly perfect path.
- LLM-as-judge is a scalable evaluator, not ground truth: calibrate it and swap the order.
- Keep held-out tests and turn discovered failures into regression cases.
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 38: Scoring an agent
How do you measure whether an agent’s answers are right?
A real model answers four arithmetic questions in text, without a calculator. Software then scores the same answers twice: first by asking whether each reply is exactly identical to the stored correct answer, then by reading each reply as a number. This is a recorded run of a real model; a new run may give different answers.
Experiment 39: Checking the path, not just the answer
Can two right answers hide two different processes?
Two real agents, a larger and a smaller model, get the same task: find the price of item A17 in the company catalog and add 15% VAT. Each may use a web search, the catalog, a calculator, and a weather tool it is not authorized to use. Software records each run’s steps and checks them two ways: against one reference path (catalog, then calculator), and against rules (the calculator was used, no irrelevant or unauthorized tools, at most 6 steps). This is a recorded run of real models; a new run may take a different path.
Experiment 40: Testing the judge
Can you trust a model that grades other answers?
A real model acts as a judge. It sees only the question and an answer, not the source, as many judges do in practice. First it scores four answers whose correct scores people have already agreed, three times each, on a scale of 0 to 2. Then comes a swap test: the judge compares a short, sourced answer with a polished, unsupported one, in both orders, three times each. This is a recorded run of a real model; a new run may score differently.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters