DEV Community

Cover image for Correction: the tests did not pass on all 107 wrong AI changes. What I got wrong, and the real numbers

Correction: the tests did not pass on all 107 wrong AI changes. What I got wrong, and the real numbers

Amit Spitzer on November 23, 2026

Correction (Nov 23, a few hours after publishing). This post was first titled "The tests passed on all 107 wrong AI changes. Here is what caught 8...
Collapse
 
rollsolo profile image
Sean Maxwell • • Edited

Proving each generated check actually fails on the pre-fix code before trusting it as a gate is the right filter -- most LLM-generated test suites quietly pass on both the broken and fixed versions and give false confidence.

Your negative result on requiring two checkers to both object is worth having on record: AND-mode did not help here.

One thing I'm curious about on the 3-stop cap in the Claude Code Stop hook: when the hook returns a failing generated check, how often does the coding agent actually fix the underlying bug vs. gaming the specific assertion you just showed it? (And on the good changes that failed because the upstream test was narrower than the task text, that's a classic spec-vs-test-suite gap -- hard to fault the checker there.)

Collapse
 
amit_spitzer profile image
Amit Spitzer •

Thanks Sean, that's the question I can't answer well yet, so here is the honest state: it is unmeasured.

What I have is two anecdotes, not a rate. In a real Claude Code session the hook blocked a wrong change and returned the failing checks, but I had told Claude not to edit anything, so it just kept reporting. In a real Gemini CLI session it was blocked once, then genuinely fixed the code (and added tests).

The gaming risk is real: the hook shows the failing check's expected/actual, so an agent could special-case that input. Partial mitigations exist (a scan that flags special-casing of the task's own example values, --lock-tests which restores the original tests, and the 3-block cap so a wrong check can't trap it) but none is measured against this question.

I opened an issue for the measurement itself: run an agent on the benchmark tasks with the hook on, and use the hidden tests to separate real fixes from "passes only the shown check", with and without showing expected/actual: github.com/apex-engine-dev/apex-ve...

And agreed on the spec-vs-test gap. I audited those 10 after seeing the numbers, so I'm treating the 4% as an estimate, not a result.

Collapse
 
rollsolo profile image
Sean Maxwell • • Edited

Comparing with vs. without expected/actual in the retry feedback on the hidden tests is a clean experimental design for #22.

One diagnostic worth logging alongside that A/B split is shown-check pass rate vs. hidden-test pass rate broken down by retry attempt (1, 2, 3). If the agent's pass rate on the shown check jumps sharply on attempt 2 while the hidden-test pass rate stays flat, you've directly quantified feedback gaming rather than having to infer it by hand.

The same question applies to tool retries in general, so it is worth measuring directly. Curious to see whether withholding expected/actual actually cuts that down or just makes the coding agent burn its 3 retries guessing blind.

Thread Thread
 
amit_spitzer profile image
Amit Spitzer •

That is a better design than mine, thank you. I added the per-attempt breakdown (shown-check pass rate vs hidden-test pass rate at attempts 1, 2, 3) to the issue, credited to you: github.com/apex-engine-dev/apex-ve...

Your point about models narrowing scope or mutating an argument to get a green return is the failure I would most expect, so I also noted it as something to record (an input dropped or flipped between attempts). And I agree the open question is whether hiding expected/actual cuts that down or just makes the agent burn its three retries guessing blind. I do not know yet, and I would rather measure it than guess.

Nothing in the tool itself broke here, so there is nothing to "fix and report back" on this thread; I will post the numbers on the issue when the experiment has run.

Thread Thread
 
amit_spitzer profile image
Amit Spitzer •

Sean, an update as promised: the experiment ran, with your per-attempt breakdown. 120 real Gemini CLI sessions, three arms (no hook, hook as shipped, hook with expected/actual withheld).

Honest result: too few cases to answer you. With the hook as shipped, 12 sessions were blocked on a change that really was wrong; 4 ended with a real fix, 7 still failed, and none went from failing the shown check to passing it while still wrong. 0 of 12 cannot rule out a 20% gaming rate. Withholding the details gave 2 fixes of 17, which points toward your "guessing blind", but it is not a reliable difference at this size.

The run also found a bug: after a block, Gemini CLI calls the hook with an empty prompt, so the hook judged each session only once. That is fixed in 0.2.8, and it means the attempt 2 and 3 rows are not real retries yet. One finding I did not expect: after a false block, 2 of 4 agents broke a correct change.

Protocol, every session and the scripts: github.com/apex-engine-dev/apex-ve...

Collapse
 
checkcraft profile image
Checkcraft •

Respect for the correction, that alone makes the numbers worth reading. The part I like most is proving each generated check can fail on the old code, we do the same with API checks, break one value in the response and the check has to go red or it is dropped. The 13% false stops on good changes look like the real cost here. Do you keep the generated checks that wrongly stopped a good change, or throw them away and regenerate?

Collapse
 
amit_spitzer profile image
Amit Spitzer •

Thank you. We keep them: every run's checks are saved with the results, and that turned out to matter. I re-ran each check that stopped a "good" change against the upstream fix itself. In about 7 of 10 cases the check passes on the upstream fix and the blocked change really does not do what the task says (for example a cookie change that rejects a quoted value the task allows); the hidden test was just too narrow to notice. That leaves about 4 to 5 in 100 as the checker's own mistakes, against 13 by the labels. The lower number rests on my reading of the task texts, so I quote both.

Three attempts to cut the rest did not beat the unchanged tool, and two runs of the same code disagreed on 25 of 200 verdicts, so regenerating does change the answer more than I would like. Details: github.com/apex-engine-dev/apex-ve...

Your "break one value in the response and the check has to go red" is the same idea from the other side. Do you mutate one field at a time, or several?

Collapse
 
checkcraft profile image
Checkcraft •

One field at a time. If I break several at once and the check goes red, I only learn that something reacts, not which rule did the work. One mutation per run maps each rule to the field it guards, and a mutation that stays green shows the gap right away. The 25 of 200 disagreement between two runs of the same code is the number I'd worry about most.

Thread Thread
 
amit_spitzer profile image
Amit Spitzer •

One mutation per run mapping each rule to the field it guards is a cleaner design than what I do, and "a mutation that stays green shows the gap" is the same test I apply to a generated check.

You are right to worry about the 25 of 200, and I do too. It comes from the checker writing a different set of checks on each run: the benchmark throws the drafted checks away on purpose, so every change gets a fresh draft. In normal use the draft is cached per task, so re-running on the same change gives the same answer, but that makes the verdict stable, not right.

What it means for the numbers: a difference of a few points between two single runs is noise, which is why none of my three attempts to cut false alarms could be called a win. From now on I want at least 3 runs per arm before I quote a comparison.

Collapse
 
heinrichneb profile image
Heinrich Neb •

Thanks for posting the correction this openly, and for keeping the old headline in the note.

"unknown" read as "passed" is the failure I keep meeting in other shapes. An agent's report said "Build: pass" three times in six weeks, and each time the server didn't start. Nobody had run it, so the honest status was unknown, and it got written down as green. In my gate a step that can't run now ends as "no verdict", which can never count as a pass.

Would a benchmark run where most rows come back unknown now stop, or does it still produce a total?

Collapse
 
amit_spitzer profile image
Amit Spitzer •

Thank you, and your "Build: pass" story is the same failure exactly: nobody ran it, so the honest status was unknown.

Honest answer to your question: until today, no. The benchmark script still printed a total for a run where every row was unknown. I had fixed the bug that caused it and written the lesson down, but the script itself would have let me do it again.

It stops now. A run where every row has the same verdict, or (with a checker) most rows are unknown or errors, prints "NOT A RESULT", gives no totals and exits non-zero. I tested it by giving it a test command that runs nothing: 12 of 12 unknown, and it refused. The commit, with credit to you in the changelog: github.com/apex-engine-dev/apex-ve...

One limit: it catches the degenerate run, not a quietly wrong one. An arm that is unknown for 40% of rows for a bad reason would still print. Your "no verdict can never count as a pass" is the better rule, and the tool's own verdicts follow it; the benchmark harness around them did not.

Collapse
 
heinrichneb profile image
Heinrich Neb •

Thanks for the changelog line. For the 40% case I'd compare the arms: if one comes back unknown far more often than the others, that gap is a result in itself, and I'd print it next to the totals.

Collapse
 
natureai profile image
Nature AI •

One practical way to detect AI agents gaming verification checks is to introduce randomized inputs or edge cases that differ from the shown assertions, making it harder for the agent to hardcode responses and encouraging genuine fixes rather than superficial passes.

Collapse
 
amit_spitzer profile image
Amit Spitzer •

Agreed on the principle, and thank you. Two things from my runs. First, I tried the nearest cheap version: asking the checker to avoid the task's own example values when it writes checks. It did not help (details in docs/EXPERIMENTS.md in the repo). Second, inputs the agent never sees are exactly how I now measure this: in the new hook experiment every attempt is scored against hidden upstream tests, next to the check the agent was shown. In 12 blocked wrong changes none passed the shown check while failing the hidden ones, but 12 is far too few to call it. Randomizing the inputs inside the shown check itself is something I have not tried; if you have seen it work, I would like to hear how you kept the expected values correct.