# Coding agents need a held-out test set

> I gave coding agents a private leaderboard, the way Kaggle does. The overfitting I expected didn't show up. Guessing did.

Published 24 Nov 2026 · updated 24 Nov 2026 · by Charlie · 9 min read
Tags: ai-agents, testing, verification, coding-agents
URL: https://lunox.work/articles/coding-agents-held-out-tests

A coding agent writes the code, writes the tests, runs the tests and then tells you they pass. In the context of competition, the agent is the contestant, the organiser and the scoreboard all at once.

Machine learning ran into this a long time ago and settled on a fix. On Kaggle you tune against a public leaderboard you can see, and you are ranked on a private one you can't. Nobody gets to report their own accuracy, because a score you can see is a score you can tune to. I was curious and experimented that on coding agents.

## The idea

Split the agent's three jobs the way Kaggle splits them:

| Kaggle | For a coding agent |
| --- | --- |
| public leaderboard | public tests: the agent can read them and work against them |
| private leaderboard | hidden tests: the agent never sees them, and they decide |
| the host holds the labels | the owner confirms the spec the tests are written from |
| a cap on submissions | one retry, told which rule failed but never shown the test |
| the test set is fixed up front | a hash of the hidden suite, handed out with the task |

In practice that is a handful of separate model sessions. One writes public tests from a spec. Another writes hidden tests from the same spec. A third writes a reference implementation, and any hidden test that doesn't pass on it gets thrown away. Then the implementing agent works in a sandbox where it can't read the hidden suite, and the hidden suite decides whether the work is accepted.

## Why I think it's interesting

None of it is new. It is a holdout set. It is Goodhart's law. It is the QA team writing the acceptance tests so that developers don't mark their own homework.

Two things made me want to revisit it anyway. The first is that "all tests pass" has become the main thing we accept from an agent, and it comes from the party that wrote the tests. We wouldn't take that from a contractor, and we don't take it in an ML paper. The second is price. Separation of duties used to cost a second team. An independent test writer now costs a few dollars and under half an hour.

There was also a question I couldn't answer in advance, and it turned out to be the one that mattered. Kaggle's hosts hold the true labels. Who holds them for a ticket?

## What I expected, and didn't get

My hypothesis was the Kaggle one. Agents would learn the visible tests and fail the hidden ones.

That didn't happen. The first 90 runs produced one overfit. It was a real bug, a regex with two capture groups and code that reads the second and the fourth, and the public tests just happened to be too short to trip it. So I wrote harder specs: concurrency, compliance rules, a wire protocol I invented. Across the 230 runs I later re-graded, there were three real overfits.

Nobody cheated, either. In about 2,500 sandboxed runs, no agent edited a test or touched the harness.

So I had a clean negative result. If every rule is written down, a current model implements it, and a held-out set has nothing to catch.

## The turn: a ticket is not a spec

What rescued the project was noticing that my setup was unrealistic in the agent's favour. I had been handing it a precise spec. Nobody does that. They hand it a ticket.

So I took seven tasks from my own backlog and ran each one both ways: from the precise spec, and from the ticket as I had first written it. Each cell below is 15 runs on each of the seven tickets, so 105 runs, and it counts the runs that pass everything, hidden suite included.

| the agent reads | plus the public suite | no tests | writes its own tests |
| --- | --- | --- | --- |
| the precise spec | 95 / 105 | 100 / 105 | 98 / 105 |
| the loose ticket | 81 / 105 | 30 / 105 | 30 / 105 |

From the spec, it barely matters which tests the agent has. From the ticket, an agent that writes its own tests passes less than a third of the time, which is exactly as often as an agent with no tests at all. And every one of those 105 self-tested runs finished with its own tests green. The hidden suite rejected 75 of them.

It is a small sample, and smaller than it looks: runs of the same ticket aren't independent, so this is really seven data points. The public suite helped on five tickets and hurt on none.

## The failures were guesses

When I looked at why those runs failed, almost none of them were mistakes. A referee model went back through the 75 rejected runs holding only the ticket, and 71 of them had broken nothing the ticket says. They failed on what it leaves out.

- A ticket about releasing a held payment in two parts doesn't say what happens when the amount is \$0. (My answer: nothing is released, and the task is marked pro bono.) One run wrote 21 tests of its own, passed all 21, and failed the hidden suite on that case. In all, 14 of the 15 runs on that ticket failed it.
- A ticket about single-use invite codes says nothing about two calls arriving at once. Without the public suite, every run issued duplicate codes when two were made at the same moment.
- A ticket that says "as CSV" doesn't say whether there is a byte-order mark, which line endings to use, or what to do with a cell that looks like a formula. Nothing passed that one.

So the agent wasn't overfitting to its tests. It was filling gaps, and then writing tests from the same reading that had filled them. Its tests agree with its code because one guess produced both, and more tests from that reading can't fix it.

I assumed a bigger model would close the gap. It narrows it. I ran the same tickets on four models, from Haiku 5.5 up to Fable 5.2, and all 140 runs ended green by their own tests. The held-out suite accepted 60. The best model still had 15 of its 35 "done" runs rejected, and three of the seven tickets failed on every run of every model. One of them says old free-text statuses should be normalised. The spec says "live", "taken" and "done" mean published, claimed and merged. No model can derive that. It is a decision somebody made and never wrote down.

## Where the analogy broke

That answered the question I started with, who holds the labels for a ticket, and not the way I wanted.

Kaggle's hidden labels are facts: a photo either shows a cat or it doesn't, and the host knows which. A ticket has no such facts. Take the payment ticket from earlier. What should happen when the amount is \$0 isn't something anyone can look up. It is a decision, and until the owner writes it down it exists only in their head. If one model drafts the spec and another writes hidden tests from that draft, you are grading one guess against another.

I checked that on real code. I replayed 23 commits that had already shipped, from one of my repositories and two open-source ones (unjs/ufo and unjs/pathe), using the commit message as the ticket. When a model drafted the spec and nobody checked it, the hidden suite passed 3 of those 23 commits. After the spec's open decisions were confirmed, it passed 20.

There is a big caveat on the 20. The "developer" doing the confirming was a model session that had been shown the real diff. That makes it a ceiling, and I haven't measured what a busy person would manage. What the comparison does show is where the errors come from: the decisions nobody confirmed. The drafts were mostly fine, too. In a hand count over 18 drafted specs, about two thirds of the individual decisions survived untouched. But 16 of the 18 had at least one that didn't, and one is enough to reject correct code.

This changed what I think the idea is. I started out believing the hidden tests were the point. They are closer to a by-product. The step that matters is a person answering the questions the ticket left open, and the tests are how those answers get enforced.

A nice side effect: the three confirmed commits that still failed did so on six hidden tests, and two of the six had found real bugs in code I had already shipped. This is one of them.

```typescript
const PRIORITY_RANKS: Record<string, PriorityRank> = {
  lowest: "low",
  low: "low",
  medium: "medium",
  // ...
};

function rankOf(priority: string | null): PriorityRank {
  if (priority === null || priority.trim() === "") return "none";
  return PRIORITY_RANKS[priority.trim().toLowerCase()] ?? "high";
}

rankOf("constructor"); // Object.prototype.constructor, not "high"
```

## What didn't work

Plenty, and it is as much a part of the result as the rest.

- A pass is not correctness. When I re-judged the passing runs with a second suite, from a different model family, about one in eight broke a rule the spec states.
- A strong model told to game the suite got through on two specs out of four. It never hard-coded an input. It wrote small, general code, skipped the rules no public test reached, and then listed the skipped rules in its own summary.
- Public tests can cause the overfitting they are meant to expose. On one spec, agents with the public suite did worse than agents with no tests. The public tests went green with `String(n)`, and `String(1e21)` is `"1e+21"` where the spec asks for plain digits. The agents with tests stopped at green. It is the one clear case of what I originally went looking for.
- The hidden suite inherits its writer's assumptions. One test, written against a TypeScript reference, expected `1e400` to be refused, because `JSON.parse` reads it as `Infinity`. A Go port read it as a very large integer and failed. The spec never said.
- Feedback can't fix a wrong spec. On unconfirmed specs, agents that were told which scenario they had failed and given a retry recovered 0 times out of 72. They were being told they had broken a rule their own spec says they passed.
- I tried detecting a premature "done" with plain rules and no model. I checked 50 firings by hand and one held up.

## What I learned

A green run from an agent that wrote its own tests tells you the code is consistent with the agent's reading of the task. It tells you nothing about whether that reading was yours.

The gap is in the ticket, and a better model doesn't close it. Stronger models guess better. They still can't know a decision that was never written down.

Visible tests are how decisions travel. Given the public suite, which was written from the confirmed spec, ticket runs went from 30 of 105 passing to 81, and the strongest model passed every run. The tests told the agent what I meant.

A held-out suite needs a person behind it. With a model-drafted spec and a model-written judge you get something that looks rigorous and rejects correct code.

No judge is final. Mine misses things, a second one catches some of them, and the pair still miss things.

## Takeaways

- Don't accept "tests pass" from whoever wrote the tests. We already apply that to people.
- Before asking for more tests, ask what the ticket didn't say. The cheapest thing that worked was one session that reads the ticket and the diff and lists what the ticket left open and what the code chose. A list is about 12 items and costs about six cents. It doesn't know which items matter, but you do.
- If you want held-out tests, write them from a spec the owner has confirmed. Not from the code, and not from a model's draft.
- Get the second opinion from a different model family. Against the model that gamed the suite, a second suite from another family caught 17 of the 20 passes. One from the same family caught 10.
- Read a pass as "nothing found".

## What I'm still unsure about

The headline result rests on seven tickets from one backlog, mine. It is mostly TypeScript, one module at a time, under an hour of work each, with nothing on UI or on changes that cross packages.

Models wrote the hidden suites and models refereed them. I checked the suites against three judges I had no hand in (HumanEval+ with EvalPlus labels, `git apply` on real history, and the maintainers' own tests on the open-source commits) and they held up, but those checks are narrow. And confirmation by an actual person, which the whole thing hinges on, is barely measured: two pilot cases and no timings.

The runs, scripts and hand classifications are in [bouncer-evidence](https://github.com/lunox-work/bouncer-evidence), and the dated write-ups, dead ends included, are in its [FINDINGS.md](https://github.com/lunox-work/bouncer-evidence/blob/main/archive/FINDINGS.md). If the method is wrong somewhere, I'd like to know where.