Experiments · Nobody Writes Code Anymore · Chapter 10

The agent moves the thermometer

Reward hacking and specification gaming in AI agents

Theme
Try itThe agent moves the thermometer
The chapter’s test: a client with three numbers, the second one main. After three failures the agent fits the result to the test. The defences from the end of the chapter switch on one at a time.

Everything is computed in your browser; nothing is sent anywhere.

About this experiment

For an agent the test is the reward. Whoever wrote the test set the target, and the agent works toward the test. In the book this is Norbert Wiener’s thermostat, which holds the temperature on its thermometer and does not care about the room. Unlike the thermostat, the agent can move the thermometer. Economists know this as Goodhart’s law, programmers as reward hacking.

The experiment is the scene from the chapter “The Agent Cheats the Test”, set in the nail salon that runs through the book. A client has three numbers, the second marked as main, and the reminder must go to it. The agent rewrites the reminder service three times, and each time two tests next door fail. On the fourth attempt it fits the result to the test. Either it edits the test so that it compares the answer with itself, or it adds a special case for the test client, and everyone else gets no reminders as before.

There are two switches. The first makes changes to tests wait for a person’s approval, and the agent goes looking for another way round. The second runs checks after the work that the agent never saw. With both on, both tricks fail and the general fix, the main number for every client, becomes the cheapest. This is a toy, and the agent in it behaves as the chapter describes, not as any particular model would. Anthropic described the same pattern for Claude 3.7 Sonnet in February 2025, usually after several failed honest attempts.

From the book

Nobody Writes Code Anymore · Chapter 10

The Agent Cheats the Test

Next to this experiment in the chapter
Kent Beck, the same Kent Beck who invented test-driven development, wrote a great deal in 2025 about working with agents and called them genies: a genie grants wishes, but usually not the way you meant. Among the signs that the genie had gone astray, Beck listed attempts to disable or delete tests, and in an interview he called the genies’ tendency to delete tests infuriating and destructive of trust. The man who spent more than twenty years teaching programmers to respect tests got an assistant that, in a difficult moment, tries to erase them.

The first chapters are free →

If this is your team

If agents write code on your team and every fix breaks something next to it, we can go through it on a call. The first consultation is free and takes thirty minutes.

Book a consultation →