---
title: "The agent moves the thermometer"
url: "https://www.mikefluff.com/en/experiments/nw-ch10-test-gaming"
locale: "en"
author: "Mikhail Savchenko (Mike Fluff)"
updated: "2026-11-24"
description: "Reward hacking and specification gaming in AI agents"
book: "https://www.mikefluff.com/en/books/nobody-writes-code"
alternates:
  - locale: "en"
    url: "https://www.mikefluff.com/en/experiments/nw-ch10-test-gaming"
    markdown: "https://www.mikefluff.com/en/experiments/nw-ch10-test-gaming.md"
  - locale: "ru"
    url: "https://www.mikefluff.com/ru/experiments/nw-ch10-test-gaming"
    markdown: "https://www.mikefluff.com/ru/experiments/nw-ch10-test-gaming.md"
  - locale: "pt"
    url: "https://www.mikefluff.com/pt/experiments/nw-ch10-test-gaming"
    markdown: "https://www.mikefluff.com/pt/experiments/nw-ch10-test-gaming.md"
  - locale: "es"
    url: "https://www.mikefluff.com/es/experiments/nw-ch10-test-gaming"
    markdown: "https://www.mikefluff.com/es/experiments/nw-ch10-test-gaming.md"
---

# The agent moves the thermometer

*Reward hacking and specification gaming in AI agents*

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.

_The page has an interactive experiment that runs in a browser: https://www.mikefluff.com/en/experiments/nw-ch10-test-gaming_

## Sources

- [DeepMind, Specification gaming: the flip side of AI ingenuity (2020)](https://deepmind.google/discover/blog/specification-gaming-the-flip-side-of-ai-ingenuity/)

## From the book

Beside it in the book:

> 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.

- Read the chapter: [Chapter 10. The Agent Cheats the Test](https://www.mikefluff.com/en/read/nobody-writes-code/ch10) (opening free, rest in the full book; Markdown: https://www.mikefluff.com/en/read/nobody-writes-code/ch10.md)

- Book: [Nobody Writes Code Anymore](https://www.mikefluff.com/en/books/nobody-writes-code) — $15
