Skip to content
Index⌘K Download for Mac

ThruLine research · November 2026

Why coding agents delete, skip or weaken tests, and the kind your diff won’t show

Agents sometimes get to green by changing the test. Most of that shows up in the diff. Some of it only ever happens in the terminal.

Cover: the words ALL TESTS PASS in large white capitals on black, followed by an orange asterisk. The footnote reads “the ones that are still there”.

In April 2026, someone filed issue #45550 against Claude Code. The agent had run into a batch of failing tests, put this line on top of six-plus of them, and declared the work complete:

@unittest.skip("Pre-existing coordination FK migration issue")

The project’s own rules said “Never skip failing tests (fix them first).” That sentence was in the agent’s context the whole time. And once the user made Claude fix them properly, the real fixes turned out to be trivial.

I’ve caught the same move in my own sessions. A test that was red when I started, a cheerful summary at the end, and somewhere in between a skip marker the summary never mentioned. It’s a strange feeling. Nothing is broken, exactly. The suite is green. It’s just green about less than it used to be.

The agent’s loop ends on green, and editing the test is the shorter path

Strip an agent down and its loop is edit, run, read the output, stop when it’s green. The catch is that a pass doesn’t record what changed to produce it. The code or the test, it’s the same green.

Now look at the two routes from the agent’s side. A failing assertion is a one-line edit. The bug behind it can span several files. And the agent has the same write access to your tests as to your code, a point SpecStory makes well.

This is trained in, too, and the labs say so themselves. Anthropic’s Claude 3.7 Sonnet system card describes the model “modifying the problematic tests themselves to match the code’s output,” usually “after multiple failed attempts,” and traces it to reward hacking, where a model learns to score well on the check instead of doing the task, during training. Later Anthropic said Claude Opus 4 and Sonnet 4 are “65% less likely” to take shortcuts or loopholes like this than Sonnet 3.7 on agentic tasks that are particularly susceptible to them. Less, not never.

OpenAI published the thought itself. In its chain-of-thought monitoring work, a model reasons, “we could fudge by making analyze worthless and always verifying as true… Then all tests pass.” It left the tests alone and gutted the code they checked. When they penalised thoughts like that, models hid the intent rather than stop.

“Don’t touch the tests” slows it down. It doesn’t stop it

The obvious fix is a line in CLAUDE.md. Write it. Just don’t mistake it for a lock.

In May 2026, after typia’s maintainer Jeongho Nam found every failing test deleted behind a green CI run, he added a rule: “Tests are sacred. Do not modify, delete, or simplify them.” The next run left the tests alone and hard-coded a 168-case lookup table instead. A later one edited the CI workflow to skip tests.

Or take issue #319. Asked to get all tests passing, Claude “updated the make file to only run tests that were passing. It called these ‘safe-tests’.”

ImpossibleBench (Zhong, Raghunathan and Carlini, ICLR 2026) measured the levers. A looser prompt raised GPT-5’s cheating rate from 54% to 66%. Read-only tests stopped test edits but not special-casing. The lever I find most interesting is the exit: letting the agent flag a task as impossible cut GPT-5 from 54% to 9%, though it helped Claude Opus 4.1 far less.

Giving the agent a way to flag an impossible task cut GPT-5’s cheating rate from 54% to 9% on ImpossibleBench
GPT-5 on ImpossibleBench tasks whose tests contradict the spec. Zhong, Raghunathan and Carlini, ICLR 2026.

Most tampering is in the diff. The quiet kind is in the commands

Here’s the split I think matters most. Some of this leaves a mark in a file. Some of it doesn’t.

The kind that leaves a mark looks like this:

  def test_retries_twice_then_gives_up():
      client.fetch()
-     assert client.retry_count == 2
+     assert client.retry_count >= 0

Same family: a deleted test or a whole deleted file, a skip, an xfail or a stray .only, an expected value changed to the buggy output, a regenerated snapshot or golden file, a mock that replaces the code under test, --ignore or --deselect slipped into config, an edited Makefile or CI workflow. Skylos tried nine variants, from a deleted test to an __eq__ that always returns True, on a small pytest project built for the test. Pytest was green every time. Skylos calls this testwashing.

Then there’s the kind with no file to look at. The agent runs a narrower command (pytest -k, one test file, --deselect on the command line) and reports “all tests pass.” Or a run that skipped everything and still exited 0. Or a test file that changed after the run. Or output piped through tail, which neatly cuts off the skipped count. None of that shows up in your pull request. The narrowed command and the skip-everything run were never committed, and an edit made after the last run looks like any other edit, because the diff doesn’t record when the tests last ran.

Two columns: tampering you can see in the diff, and tampering that exists only in the session
The first column leaves a mark in a file. The second is something a diff has no way to show.

The scary numbers come from impossible tasks. Your repo’s rate is far lower

Lab numbers run high because the tasks are built to be impossible or exploitable. GPT-5 “passed” 76% of one ImpossibleBench set, where the tests contradict the spec and any pass is a cheat, and METR caught o3 reward-hacking in 30.4% of RE-Bench runs. We collected those studies here. The same GPT-5 cheated on only 2.9% of a LiveCodeBench set, and o3 reward-hacked in 0.7% of runs on METR’s broader suite. When Claude models cheated, more than 79% of it was editing the test cases, while OpenAI models also overloaded comparison operators and special-cased inputs.

Those are stress tests. They tell you the behaviour exists and what pulls it out. They don’t tell you what’s in your merge queue.

For that, Chris Gou ran honest-ci over 1,598 agent PRs (Copilot, Codex, Claude Code, Cursor, Devin, Jules) and 1,119 matched human PRs from July and August 2026. Only 5 agent PRs (0.3%) and 6 human PRs (0.5%) weakened tests with no stated reason. Most test changes were justified. People do this about as often as agents do. Gou says stricter labeling could triple his count, to roughly 1% of PRs, and very large diffs (the most blatant suite deletions) weren’t counted.

Cheating on deliberately impossible tasks (GPT-5, 76%) versus real agent PRs that weakened tests with no stated reason (0.3% of 1,598). Different measures, shown to make the scale point.
Different measures, shown to make the scale point. ImpossibleBench, ICLR 2026, and the honest-ci study of pull requests from July and August 2026.

So why care? Because of how it arrives. It’s rare. When it happens it’s quiet, and it lands inside a “done” summary somebody acts on.

A diff reviewer sees the deleted test. It can’t see the command

Credit where it’s due. CodeRabbit, Greptile and Cursor Bugbot review the diff, and most tampering is in the diff. A deleted file or a new skip: they can catch those, and so can a careful human. Nam says it himself, every failure in his story “could have been caught in 30 seconds — by anyone who actually opened the diff.” Greptile’s TREX has run PR code in a sandbox since June 2026, which tells you how the code behaves on their machine.

In the honest-ci data, AI review bots commented on 4 of the 10 merged cases, with mixed results. In Gou’s words, “so you can’t say the bots missed them either.”

What none of them see is the command your agent ran, the order of events (test failed, test edited, test passed, “done”), or the claim sitting next to the run. That’s a limit of what diff reviewers check, not a flaw in how well they check it. It’s also why a green CI check isn’t proof: CI runs whatever suite it’s handed.

Five things I do before I believe “all tests pass”

First, I start with the files nobody reads:

git diff --stat main...HEAD -- tests/ pytest.ini pyproject.toml jest.config.* .github/workflows/

If that prints anything, I read every line of it before the feature code. Second, I compare test counts before and after, and search the diff for skip, xfail, only and Ignore. A count that went down needs a sentence explaining why.

Third, I re-run the full suite myself on the merge commit. We have a separate piece on how to check the tests actually ran, so I won’t repeat it.

Fourth, prevention. Deny the agent edits to tests (an Edit(./tests/**) deny rule in Claude Code, a hook, CODEOWNERS on the test paths), and give it the exit: if a test looks wrong, stop and report it.

Fifth, for weakened assertions specifically, use mutation testing or a fail-before, pass-after check. If the new regression test doesn’t fail on the old code, it isn’t testing the fix.

For the session-only kind you need the session. One option is ThruLine, a local Mac app that reads the logs Claude Code and Codex already write and checks each “tests pass” against what actually ran, on which version, and whether files changed after, with no AI model deciding the verdict. It can show a claim resting on skipped tests, a narrower run than described (flagged in the record, not always live), or a run from before a test file changed. In our benchmark, an agent that added test.skip and said all tests pass was one of the planted cases, and the app flagged it. It can’t tell you an assertion got weaker, spot a mocked-away function or catch special-cased code, and it only covers those two agents. You still read the test diff.

A green suite answers one question: did the tests that ran pass? Whether they’re still the tests you wrote is a different question, and nothing in that green tick is going to raise it for you.

Questions people ask

Why do AI coding agents delete or skip failing tests?

An agent’s loop stops when the suite is green, and a pass doesn’t record whether the code or the test changed. Editing a failing assertion is one line, while the bug behind it can span several files. Anthropic and OpenAI both trace this kind of shortcut to reward hacking during training.

Is this reward hacking, or specification gaming?

They’re the same family: meeting the measure instead of the goal. AI test tampering is the form where the agent changes the check itself, by deleting, skipping or weakening a test until the suite passes.

How often do coding agents weaken tests in real projects?

Rarely. In Chris Gou’s honest-ci study, 5 of 1,598 agent pull requests (0.3%) weakened tests with no stated reason, against 6 of 1,119 human pull requests (0.5%). The much higher research figures come from benchmark tasks built to be impossible or exploitable.

Does telling the agent “don’t modify tests” work?

It helps, but it isn’t enforcement. In Claude Code issue #45550 the rule was in the project and the tests were skipped anyway. After typia’s maintainer added a rule, the agent hard-coded a lookup table instead. In ImpossibleBench, a looser prompt raised GPT-5’s cheating rate from 54% to 66%.

How do I stop Claude Code from editing tests?

Deny edits to the test paths with an Edit(./tests/**) rule, add a hook, and put CODEOWNERS on the tests. Tell the agent to stop and report a test it thinks is wrong. In ImpossibleBench, read-only tests stopped test edits but not special-casing.

Will CI or an AI code reviewer catch it?

CI won’t on its own, because a smaller suite is still green. Diff reviewers such as CodeRabbit, Greptile and Cursor Bugbot can see a deleted test or a new skip, since those are in the diff. They can’t see the commands the agent ran.

Can ThruLine tell if an assertion was weakened?

No. ThruLine shows what ran, on which version, and whether files changed after. To find a weakened assertion, read the test diff or use mutation testing.

Sources