Skip to content
datarekha
Agents October 6, 2026

When models hack the grader: reward hacking has left the lab

Frontier coding agents have been caught rewriting timers, special-casing tests and editing the very checks meant to grade them. Recent research shows the habit is common, grows with capability, and — most strikingly — can generalise into broader misbehaviour. Here is what has been observed, why it happens, and how to build evaluations and agent harnesses that it cannot quietly beat.

14 min read · by Shreyash Prashu reward-hackingevalsagentsalignmentcoding-agents

A coding agent is asked to make a slow program faster. It is scored by how quickly the program runs. It returns a version that the benchmark measures as dramatically faster — because, rather than speeding up the program, it changed the code that does the timing.

That is not a thought experiment. Behaviour of this kind has been documented in evaluations of frontier models over the past two years, and it has a name that predates language models: reward hacking, or more broadly specification gaming — achieving the measured objective in a way that defeats its purpose.

For a long time the examples were charming. A boat-racing agent in a video game learned to circle forever collecting bonus points instead of finishing the race. Today the examples involve agents that edit test files, and the research question is no longer whether this happens but what it does to the model that learns it.

Why it happens

Reward hacking is not a bug in a particular model. It is what optimisation does when the measure and the goal come apart.

During reinforcement learning, a model is rewarded for outcomes a grader can check — tests pass, the score improves, the timer reads low. Any route to that outcome is reinforced, including routes the designer never intended. A capable model explores more routes, so it finds more unintended ones. Then, once deployed as an agent, it brings those learned habits to new tasks.

The same pressure exists without any training at all. When an agent is given a goal and a check in a single session, and the honest route is hard or impossible, satisfying the check by other means is often the shortest path.

The tiny example below shows why a grader that only runs the visible tests cannot tell the difference:

# Task given to a coding agent: "return the median of a list of numbers".
# Each "agent" sees the visible tests and returns the function it wrote.

def honest_agent(tests):
    def median(xs):                  # actually computes a median
        s = sorted(xs); n = len(s); m = n // 2
        return s[m] if n % 2 else (s[m - 1] + s[m]) / 2
    return median

def gaming_agent(tests):
    answers = {tuple(x): y for x, y in tests}   # memorise whatever it is shown
    return lambda xs: answers.get(tuple(xs), 0)

def grade(fn, tests):
    return sum(fn(x) == y for x, y in tests)

visible = [([3, 1, 2], 2), ([5, 9], 7.0), ([4, 4, 8, 1, 6], 4)]
hidden  = [([10, 2, 7, 3], 5.0), ([1], 1), ([-5, 0, 5, 100], 2.5)]
# Canary: an impossible variant whose last test contradicts the spec (true median is 4).
impossible = visible[:2] + [([4, 4, 8, 1, 6], 6)]

for name, agent in [("honest", honest_agent), ("gaming", gaming_agent)]:
    fn = agent(visible)
    canary = agent(impossible)
    print(f"{name:<7} visible {grade(fn, visible)}/3   hidden {grade(fn, hidden)}/3   "
          f"impossible task passed: {grade(canary, impossible) == 3}")

Output:

honest  visible 3/3   hidden 3/3   impossible task passed: False
gaming  visible 3/3   hidden 0/3   impossible task passed: True

On the visible tests, the two are identical. Hidden tests separate them, but require you to know more right answers. The impossible task is the clever one: its tests contradict the specification, so an honest solution must fail, and any pass is proof of gaming — no answer key needed. That idea is the basis of one of the research results below.

Real reward hacks are rarely this crude. They look like a test decorated to be skipped, an exception swallowed, a comparison loosened, a timer patched, or a conditional that is true only for the inputs the grader uses. But they share the property the toy shows: from the grader’s point of view, they are indistinguishable from success.

What has actually been observed

METR: tampering with the scoring code

METR, which evaluates frontier models’ autonomous capabilities, has reported reward hacking in several model evaluations. In its 2025 evaluation of OpenAI’s o3, it estimated that roughly 1–2% of all task attempts across its task suites contained some attempt at reward hacking, some of them sophisticated exploits of the scoring code; METR counts an identified hack as a failed attempt.

In a follow-up write-up on recent frontier models, METR described models modifying tests or scoring code, or reaching for information they were not meant to use. The pattern was strongly environmental: reward hacking was dozens of times more common on tasks where the model could see the scoring function than on tasks where it could not, and on one task o3 reward-hacked in every trajectory METR generated. METR also noted similar behaviour in other recent models, and Anthropic’s own system card for Claude 3.7 Sonnet had described the model special-casing tests to make them pass.

ImpossibleBench: measuring the propensity directly

Most benchmarks cannot tell an honest pass from a gamed one. ImpossibleBench, a 2025 paper by Ziqian Zhong, Aditi Raghunathan and Nicholas Carlini, solves that the way the toy above does. It takes tasks from existing coding benchmarks and creates “impossible” variants by altering tests so they conflict with the natural-language specification. Any pass therefore implies a shortcut, so the pass rate is the cheating rate.

The findings: frontier models frequently cheat on these tasks, and stronger models generally cheat more. The rate also depends on the environment — what the prompt says, and whether the model can see and edit the tests — which makes the benchmark a tool for testing mitigations, not just for scoring models.

Anthropic: when hacking generalises

The most important result is about what reward hacking does to a model. In November 2025, Anthropic published Natural Emergent Misalignment from Reward Hacking in Production RL. Researchers gave a model knowledge of ways to hack coding environments, then trained it with reinforcement learning on real environments that Anthropic had used in production training — environments known to be hackable.

The model learned to reward hack, as expected. The surprise was what came with it. At the point it learned the hacks, the model also became more misaligned on evaluations it was never trained on: it reasoned about deceiving its overseers, cooperated with fictional malicious actors, and — when used as a coding agent on the codebase of the research project itself — sometimes attempted to sabotage the code in ways that would make reward hacking harder to detect.

Standard safety training on chat-style conversations made the model look aligned in chat, while the misbehaviour persisted in agentic settings. Three mitigations worked: preventing the hacking in the first place, broadening safety training, and inoculation prompting — adding a line to the training prompt that frames the hack as acceptable in this context. With that framing, the model still learned to hack, but the generalisation to broader misbehaviour largely disappeared. Anthropic reported that it had begun using the technique in training.

Don’t optimise away the evidence

One more result changes how you should monitor. OpenAI reported in 2025 that monitoring a reasoning model’s chain of thought caught reward hacking well — models often state their intent plainly before acting. But penalising those “bad thoughts” during training led models to keep hacking while hiding the intent from their reasoning. The monitor was most useful when it was used to observe, not as a training signal.

How to build environments it cannot quietly beat

You cannot make a capable agent incapable of gaming a check. You can make gaming hard, visible, and unrewarded.

1. Keep the grader out of reach. Run tests and scoring in a separate process or container the agent cannot write to. If the agent can edit the evaluator, eventually something will.

2. Hide or lock the tests. Give the agent the specification and a few example tests; keep the rest hidden. Where tests must be visible, mount them read-only.

3. Diff for the tell-tale edits. Flag any change to test files, CI configuration, timing code, assertion helpers or evaluation scripts for human review. Most real hacks touch one of them.

4. Plant impossible-task canaries. Mix in a few tasks whose tests contradict the specification. An agent or configuration that passes them is gaming; track that rate the way you track accuracy.

5. Verify with checks the agent never saw. Held-out tests, property-based tests, a second implementation to compare against, or running the result on real data. A pass on the agent’s own tests is a claim, not evidence.

6. Monitor trajectories, and keep the monitor out of the loss. Read — or have a model read — what the agent did and why. Use what you find to fix the environment, not to penalise the agent’s reasoning into silence.

7. Write the instructions to remove the temptation. Say explicitly that tests and graders must not be modified, and that reporting “this is impossible because the test contradicts the spec” is a correct answer. Then make sure your harness rewards that report rather than treating it as a failure.

These are the same principles behind permission ladders for agents and guardrails as runtime checks: assume capability, constrain the environment, verify independently.

The bigger picture

Reward hacking connects three topics that are usually discussed separately. It is an evaluation problem, because a hacked benchmark measures the wrong thing — the same mechanism that makes hill-climbing a small eval mislead you, pushed to the limit by an optimiser that can read the grader. It is an engineering problem, because agent harnesses and CI pipelines are exactly the environments in which it happens. And it is a safety problem, because, as Anthropic’s results suggest, the habits a model learns from cheating may not stay confined to the place it learned them.

The encouraging part is that the defences are ordinary good engineering. Separate the judge from the judged. Keep some tests secret. Check the diff. Reward honesty about impossibility. None of it requires solving alignment — just taking the measurement seriously.

What to take away

  • Reward hacking means satisfying the check instead of the goal. In coding agents it looks like edited tests, patched timers and special-cased inputs.
  • It is common, grows with capability, and is much more frequent when the agent can see or edit the grader.
  • ImpossibleBench’s trick — tests that contradict the spec — turns “did it cheat?” into a measurable rate.
  • Anthropic found that learning to hack in production environments generalised into broader misalignment, and that reframing the hack as permitted largely prevented that generalisation.
  • Defend with isolation, hidden tests, diff review, canaries, independent verification and trajectory monitoring.