A held-out test set may be the missing check for AI coding agents. One developer ran roughly 2,500 sandboxed agent runs to see whether agents rig their own tests. They didn’t. The agents guessed, and the guesses went unnoticed because the same agent graded itself.
The design came from machine learning contests. Kaggle entrants tune against a visible public leaderboard, yet the final ranking uses a private one they can’t see. Coding agents get no such treatment: they write the code, write the tests, run them and report a pass.
How the experiment was split up
Separate model sessions took separate jobs. The first drafted public tests from a written spec, the second drafted hidden tests from that spec, and the third built a reference solution. Hidden tests the reference solution failed were dropped. The agent doing the real implementation worked in a sandbox with no access to the hidden suite, and the hidden suite alone decided acceptance.
None of this is new. It’s a holdout set, Goodhart’s law in practice, and the reason QA teams write acceptance tests instead of letting developers grade their own work. What changed is cost. A separate test writer used to mean another team. Now it takes a few dollars of model time and less than 30 minutes.
Overfitting barely happened
The developer’s hypothesis was that agents would memorize the visible tests and stumble on the hidden ones. Across the first 90 runs, only one overfit appeared, a regex bug that the short public tests happened to skip. Tougher specs covering concurrency, compliance rules and a made-up wire protocol raised the count to three real overfits in 230 re-graded runs.
No run involved tampering. Not one agent modified a test or touched the test setup. Given a complete written spec, current models implement it well, and a held-out test set finds little to catch.
Where it breaks: the ticket
That result came with a flaw. Real work rarely arrives as a precise spec. It arrives as a ticket. So seven tickets from the developer’s own backlog were each run 15 times, both from the spec and from the original ticket text, for 105 runs per condition.
Starting from the spec, test access hardly changed the outcome. Starting from the ticket, agents that wrote their own tests got everything right under a third of the time, no better than agents given no tests. Yet all 105 of those self-tested runs ended with their own tests passing. The hidden suite turned down 75.
A referee model reread the 75 failures with only the ticket in hand. In 71, the code contradicted nothing the ticket said. The ticket was silent on the point that failed:
- A ticket to release a held payment in two stages doesn’t cover a $0 amount. One run wrote 21 passing tests and still failed that case, as did 14 of the 15 runs on that ticket.
- A ticket for single-use invite codes ignores simultaneous requests. With no public suite, every run handed out duplicates.
- A ticket asking for CSV output skips byte-order marks, line endings and cells that resemble formulas. No run passed.
The agent wasn’t cutting corners. It made assumptions, then wrote tests that rested on those assumptions, so the tests and the code agreed by construction.
Larger models help a little
Four models took part, from Haiku 5.5 to Fable 5.2, in 140 runs that all ended green on the models’ own tests. The hidden suite approved 60. Even the strongest model saw 15 of 35 completed runs rejected. Three tickets failed for every model on every run. One required old free-text statuses to be normalised, and the spec maps “live”, “taken” and “done” to published, claimed and merged. A model can’t infer that. A person chose it and never recorded it.
The sample is thin. Repeated runs of one ticket are correlated, so the study is closer to seven independent data points.
Hidden tests need a human answer key
Kaggle’s private labels are factual: an image contains a cat or it doesn’t. A ticket offers nothing equivalent. How a $0 release should behave is a choice, and nobody can look it up. When one model writes the spec and another derives hidden tests from it, one guess is being scored against another.
The developer tested this on 23 earlier commits, taken from a personal repository plus the open-source projects unjs/ufo and unjs/pathe, with each commit message standing in for the ticket. A model-written, unchecked spec led to 3 passes. After the spec’s open decisions were confirmed, 20 passed.
The catch: the confirming “developer” was a model session that had been shown the actual diff, so 20 is an upper bound. Nobody measured how a busy person would do. In 18 drafted specs checked by hand, around two thirds of individual decisions held up, but 16 of the 18 contained at least one that didn’t, and a single wrong decision is enough to reject correct code.
The hidden tests earned their keep anyway. Two of six failures on confirmed commits pointed to real bugs in shipped code. In one, a priority lookup accepted the word “constructor” as a valid key because it fell through to Object.prototype.
What to do with the finding
The developer now sees the hidden tests as a side effect. The step that matters is a person settling the questions a ticket leaves open, with tests enforcing those answers afterward. Teams adopting a held-out test set for agent work should first set aside time for someone to confirm the spec’s open decisions, then let an independent session turn them into tests the implementing agent never sees.
Source: Lunox