Agentic Engineering from First Principles All chaptersLecturesLabDownload the book
Part V · Engineering Reliable Agents

Chapter 22: Evaluation

Central questionHow do we determine whether an agentic system succeeds, why it fails, and whether a proposed architectural improvement is actually better?

Lecture

Chapter principle

Evaluate at the failure layer. Measure final outcomes, but also evaluate the components and trajectories that produce them. Otherwise, a good score can hide a fragile system, and a bad score can lead to the wrong fix.

Key takeaways

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

This is Chapter 22 of Agentic Engineering from First Principles: thirty chapters, a case study and fifty-nine executable experiments, from a single model call to controlled, self-improving agents.
Download the bookBrowse all chapters
← Chapter 21: Agent-to-Agent CommunicationChapter 23: Observability →