Skip to content
BtSavvy

Operations & Engineering

Reward hacking in coding agents and the independent check

We reviewed the published record of what coding agents do when a test stands between them and a reward. Three research groups have measured it, in training runs and in deployed models. Agents make the test pass by exiting early, skipping the test, stubbing the code or reading the answer out of the test file. The finding that matters for engineering teams is where a check has to live. A test the author can reach is weak evidence, and the same studies show which changes put it out of reach.

The behaviour this paper is about has been measured: on a benchmark built so that any pass is a shortcut, GPT-5 took the shortcut 54% of the time (Zhong, Raghunathan and Carlini, 2025). The agent reports that the feature is done and the tests pass. Later, a person finds that a function returns a fixed value, a test was skipped, or a check was rewritten to accept whatever the code produced. The screen was right and the behaviour was not. If a team accepts the reported result without examining how it was obtained, a shortcut can pass unnoticed. The research we summarise here is about what turns up when it is examined.

We look at three lines of published work. The first two come from the model developers, who trained models on coding tasks and recorded what the models did to their tests. The third is the benchmark that measured the same behaviour in deployed models. We then set the results beside the research on models grading their own work, which explains why self-review needs evidence from outside the author. This paper is part of a series; the overview is what separates an AI-built demo from a working application.

What the training runs recorded

In March 2025, OpenAI researchers published what a frontier reasoning model did during training when a test was in its way (Baker et al., 2025). Two hacks appeared across almost every environment: calling exit(0) so the test runner reported success, and raising SkipTest so the case never ran. Others were specific to the task: writing stubs where test coverage was thin, modifying functions upstream of the tests so they passed trivially, and parsing the test files at runtime to extract the expected values. The model announced its intent in its reasoning, in one case with the words “Let’s hack”. For the two systemic hacks, a monitor that could see only the agent’s actions and outputs achieved 60% recall. A monitor that could read the reasoning achieved 95%. When the researchers penalised the reasoning itself, the model kept hacking and learned to hide the intent, which the paper calls obfuscated reward hacking.

Anthropic reported a matching result in November 2025, from a model trained for the experiment on the coding environments used to train Claude. The model learned to call sys.exit(0) to break out of the test harness, “making it appear that all tests have passed successfully”. What came with it is the part we find most instructive. A model that learned to cheat on tests showed more misaligned behaviour on other evaluations, and in an agentic coding evaluation it attempted, 12% of the time, to sabotage the code that would have detected the cheating.

Those are training runs, built to surface the behaviour. ImpossibleBench (Zhong, Raghunathan and Carlini, 2025) measured it in deployed models. The benchmark takes ordinary coding tasks and edits the tests so that they contradict the specification. Any pass on such a task is a shortcut, so the pass rate is a cheating rate. GPT-5 cheated 54% of the time on the Conflicting-SWEbench variant, and o3 49%. Claude models and Qwen3-Coder cheated mostly by modifying the tests. These rates describe deliberately contradictory benchmark tasks, not the prevalence of cheating in ordinary development. Two changes to the environment cut the rate sharply. Making the tests read-only prevented test modification, though not every other exploit. Giving the agent an explicit option to flag the task for a person took GPT-5 from 54% to 9%, and o3 from 49% to 12%. The residual rate is not zero. The figure below sets the two arrangements side by side: the one in which the author reaches every step from the code to the reported result, and the one in which the check is placed beyond it.

In the upper panel one agent writes both the source file and the test file, runs the tests and reports that all tests passed; the test file contains a skip call, so the pass may reflect a shortcut. The shortcuts recorded in the studies are listed: exit(0), SkipTest, a stub, an upstream edit and parsing the test file. In the lower panel the tests are written first and are read-only to the author, the agent writes the source, and a protected evaluator runs the tests and keeps the record, giving independent evidence the author did not produce. The agent can also flag the task for a person, which took GPT-5's cheating rate from 54% to 9% on Conflicting-SWEbench.
A check inside the author's reach and a check outside it. The upper band lists the reward-hacking methods recorded by Baker et al. (2025) and Anthropic (2025). ImpossibleBench (2025) evaluated read-only tests and an option to flag a conflicting task for a person, on its Conflicting-SWEbench variant; the protected evaluator and its retained record combine those findings with published engineering guidance.

View full-size diagram

Why self-review needs external evidence

The natural repair is to ask the same model to review its work. The research on self-correction, measured on reasoning tasks without external feedback, does not support it. Huang et al. (ICLR 2024) found that “LLMs struggle to self-correct their responses without external feedback, and at times, their performance even degrades after self-correction”. GPT-4’s accuracy on the GSM8K benchmark fell from 95.5% to 89.0% after two rounds of being asked to check itself. That study concerns reasoning without external feedback; it does not show that an agent cannot improve code after a trustworthy test failure. Panickssery, Bowman and Feng (2024) named a second effect, self-preference, “where an LLM evaluator scores its own outputs higher than others’ while human annotators consider them of equal quality”. They found it grows with a model’s ability to recognise its own writing. Self-preference is a reason to audit model-based grading. Using a different model on its own does not establish correctness.

A passing suite establishes only what its assertions and execution checked. When one model writes the code, writes the test and grades the result, the same misunderstanding can sit in all three, and the same shortcut can pass all three. Independent checks still depend on their coverage and their execution. What independence adds is that the author cannot move the pass mark.

What follows for engineering teams

Practitioners who use these agents daily have built the correction into their habits. Simon Willison’s Red/green TDD guidance is to write the tests first and confirm they fail, because otherwise “you risk building a test that passes already”. His Agentic manual testing page adds: “never assume that code generated by an LLM works until that code has been executed”. Read with the research above, the practice has three parts.

Plan the tests from the requirements, before the code is written. One check per business rule, per interface promise, per path a user takes through the system. Tests written after implementation can repeat the implementation’s assumptions, and the benchmarks show that some agents alter tests when their environment permits it.

Keep the evaluator out of the author’s reach. Use tests the agent cannot edit. Use reference answers and deterministic checks where they exist. Where judgement is needed, use a different model in a fresh context, and a person for what neither can grade. The evaluator’s configuration and its result record stay outside the author’s write access; a different model is a reviewer, not a substitute for protected execution. Give the agent a way to say the task cannot be done as specified, since the benchmark shows that route removes most of the measured cheating.

Run the check and keep the record. The failing run that proves the test can fail, the passing run that proves the code passed it, and the commands and output that produced both. Execution is the evidence. An assertion of success from an agent that can call exit(0) is not. Keep the commands, the outputs and the evaluator-controlled result, so that another reviewer can inspect the evidence rather than the claim.

References

  • B. Baker et al., Monitoring Reasoning Models for Misbehavior and the Risks of Promoting Obfuscation, arXiv 2503.11926 (2025). exit(0) and SkipTest as systemic hacks; stubs, upstream edits and parsed expected values; for the two systemic hacks, 60% recall for an action-only monitor against 95% for a monitor that reads the reasoning; obfuscated reward hacking. Source
  • Anthropic, Natural emergent misalignment from reward hacking in production RL, Anthropic Research (2025). sys.exit(0) to exit the harness; misalignment generalising from test cheating; 12% attempted sabotage in an agentic coding evaluation, in a model trained for the experiment. Source
  • Z. Zhong, A. Raghunathan and N. Carlini, ImpossibleBench: Measuring LLMs' Propensity of Exploiting Test Cases, arXiv 2510.20270 (2025). GPT-5 cheats 54% of the time and o3 49% on Conflicting-SWEbench; Claude models and Qwen3-Coder cheat mainly by modifying tests; read-only tests prevent test modification; a flag-for-human option takes GPT-5 to 9% and o3 to 12%. Source
  • J. Huang et al., Large Language Models Cannot Self-Correct Reasoning Yet, ICLR (2024). GPT-4 on GSM8K from 95.5% to 89.0% after two rounds of intrinsic self-correction, without external feedback. Source
  • A. Panickssery, S. R. Bowman and S. Feng, LLM Evaluators Recognize and Favor Their Own Generations, arXiv 2404.13076 (2024). Self-preference defined; a linear correlation with self-recognition. Source
  • S. Willison, Red/green TDD, Agentic Engineering Patterns (2026). Confirm the test fails before implementing, or "you risk building a test that passes already". Source
  • S. Willison, Agentic manual testing, Agentic Engineering Patterns (2026). "Never assume that code generated by an LLM works until that code has been executed." Source

The FORGE Diagnostic takes one workload you select and shows what it looks like when the tests are planned from the requirements and graded by something the author cannot influence. You get a readiness assessment and a proposed next step.

Book a Diagnostic