Agent-Written Tests Beat Humans on Small Projects and Trail on Large Ones
How good are agent-written unit tests?
Quick answer: Agents write better tests than humans on small projects — a 0.863 mutation score against 0.674 — and much worse on large ones, where Codex drops to 0.546 against 0.566. Most of the advantage is test volume, not sharper assertions. Treat agent-written tests as drafts with a review gate.
Code Metal's team took 240 open-source repositories with passing human test suites, stripped the tests, had three agents rewrite them, then graded both with mutation testing.
Every team shipping agent-written code faces the same gap: the agent says it wrote tests, the pipeline says they pass, and nobody has checked whether those tests can fail.
What the 240-project benchmark measured
The corpus was 80 Python, 80 C++ and 80 Rust projects, split by size: 30 small (0–1,000 lines), 30 medium (1,000–5,000), 20 large (5,000–10,000). Every project was anonymised — renamed, documentation stripped — so agents could not replay memorised tests. Claude Code ran on Opus 5, Codex on GPT-5.6 Sol, Cursor on Grok 4.6, at high reasoning effort with no network access.
Four instruments graded them: line coverage; mutation score, with up to 120 injected bugs per project and the share the suite catches counted; vacuous-test rate, where each function body is stubbed and the tests that still pass are counted; and a judge model that listed each project's behaviours and edge cases once, as the yardstick for every suite.
The headline number is real, and it is not the whole story
| Author | Mutation score | Line coverage |
|---|---|---|
| Claude Code (Opus 5) | 0.818 | 0.926 |
| Cursor (Grok 4.6) | 0.776 | 0.913 |
| Codex (GPT-5.6 Sol) | 0.724 | 0.873 |
| Human baseline | 0.625 | 0.762 |
Across all 240 projects, the agent mean beats the human baseline by +0.147 mutation score, 95% CI [0.120, 0.174], and +0.142 line coverage, CI [0.116, 0.168]. Both intervals exclude zero.
The first finding is uncomfortable: agent suites are, on average, better than what humans wrote. The second applies to your repository.
Why does test quality collapse as the project grows?
The advantage belongs to the repository, not the agent, and decays as the repository grows.
The gap halves between 1,000 and 10,000 lines
| Project size | Claude Code | Cursor | Codex | Human | Agent mean − human |
|---|---|---|---|---|---|
| Small (0–1k LOC) | 0.863 | 0.852 | 0.837 | 0.674 | +0.176 [0.134, 0.218] |
| Medium (1–5k LOC) | 0.817 | 0.786 | 0.731 | 0.616 | +0.162 [0.116, 0.208] |
| Large (5–10k LOC) | 0.752 | 0.647 | 0.546 | 0.566 | +0.083 [0.029, 0.137] |
Human suites also decay, 0.674 to 0.566, but agents fall faster: the gap halves. On a 1,000-line utility an agent suite is a clear upgrade; at 10,000 lines it is marginal, [0.029, 0.137].
Codex lands below the human baseline at 5k–10k lines
Codex scores 0.546 against the humans' 0.566; the paper's strongest claim is that it "essentially matches" human suites on large projects, not beats them. Claude Code holds at 0.752, which is why the agent mean still clears the baseline by 0.083 — the average hides a split, and your repository decides which harness you pay for.
A benchmark on a 500-line toy repository does not transfer to your monorepo: it describes the one setting where agents look strongest.
Are agents writing better tests, or just more of them?
Mostly more. The paper says much of the advantage "lies in a greater number of written tests", and the per-test numbers show the trade.
A tester's real unit is mutants per test
| Author | Mutants killed per test | Production lines covered per test |
|---|---|---|
| Human | 8.40 | 8.5 |
| Codex | 1.59 | 11.6 |
| Cursor | 0.48 | 3.7 |
| Claude Code | 0.33 | 2.2 |
A human test kills 8.40 mutants' worth of behaviour; a Claude Code test kills 0.33, about a twenty-fifth as much, while reaching the highest score by writing a very large number of them. Codex sits opposite: the most economical tests in the study at 11.6 production lines each, better than the human 8.5, yet the lowest score. Few broad tests reach less behaviour than many narrow ones.
Volume is also where the vacuous tests hide
Tests that still pass after their subject is stubbed run at 0.135 for Claude Code, 0.123 for Cursor, 0.107 for humans and 0.081 for Codex. Roughly one in seven Claude Code tests validates nothing, and the rate climbs from Python to Rust.
What the coverage costs per bug caught
Per mutant killed, Claude Code spends 7.3× the input tokens, 6.4× the output tokens and 8.5× the wall-clock time of Codex; Cursor sits at 2–5× on all three. Two suites can report 92% line coverage while one costs eight times the wall-clock time for a quarter of the fault detection. If you normalise on cost per solved task, the equivalent is cost per mutant killed — and it varies by an order of magnitude between tools grading within 0.1 of each other.
Why do agent tests look fine in C++ and fail in Rust?
Language moves the score the same way for all three agents.
Same model, different language, different score
| Language | Claude Code | Cursor | Codex | Human |
|---|---|---|---|---|
| Python | 0.891 | 0.841 | 0.791 | 0.706 |
| Rust | 0.816 | 0.804 | 0.730 | 0.632 |
| C++ | 0.746 | 0.682 | 0.651 | 0.537 |
Every agent drops at least 14% relative from its Python score when it moves to C++. Humans drop too, so the ordering holds — but the numbers on a C++ codebase sit far below the Python demo that sold you the tool. Python is the easy case, and nearly every public benchmark uses it.
Translation is graded like generation, and that hides the failure
The authors transpiled the C++ sources to Rust, then asked each agent to translate the native suite:
| Metric | Human C++ source | Claude Code | Cursor | Codex |
|---|---|---|---|---|
| Mutation score | 0.559 | 0.514 | 0.513 | 0.489 |
| Line coverage | 0.747 | 0.651 | 0.638 | 0.612 |
| Edge-case coverage | 0.340 | 0.297 | 0.289 | 0.287 |
Every aggregate regresses, most sharply on line coverage. Point by point it is worse: translated suites lose edge-case coverage in 58% of projects, with absolute dropoffs to 45 points; 55% lose mutants outright; the worst loses nearly 70% relative coverage.
The ceiling nobody advertises
Generating a fresh Rust suite from the transpiled source alone — C++ withheld — almost always beats the translated suite. The agent is not really translating; it interpolates between translation and fresh authoring, sometimes beating the source and sometimes falling below both.
C++→Rust modernisation is where teams accept "the tests were translated" as evidence of parity. A suite that regresses on edge cases in 58% of projects is not that evidence.
What actually goes wrong inside the agent?
The trace analysis covers 675 Codex trajectories across 225 projects, three runs each. Three failure modes explain the weak suites, and each is attackable.
It does not read the repository (15.3%)
In 103 trajectories, the agent either never read relevant source files — files in the build and directly connected to the public behaviour under test — or knowingly dropped an objective it had identified. It did not fail to understand the code. It failed to open it.
It anchors the oracle to the implementation (11.1%)
Seventy-five trajectories kept a badly formed oracle: preserving behaviour the agent had itself flagged as erroneous, accepting output from malformed input, weakening assertions until they no longer established the property they were meant to check.
This is the failure your CI cannot see. A test anchored to current behaviour cannot tell the specification from the bug. The suite goes green, coverage is high, and the defect now has a test that will defend it in the next refactor.
It never measures coverage (55.7%)
In 376 trajectories — more than half — no coverage measurement was recorded at all. The traces show tests run and repaired repeatedly, establishing that the suite passes, never asking which paths stayed untested. Execution feedback is not coverage feedback: an agent optimising on "tests pass" stops at the first green run.
How do you gate agent-written tests this week?
- Gate on mutation score, not coverage. The study's budget calibrates well: up to 120 mutants per project, discarding the ones that do not compile. On a large codebase, mutate the diff rather than the whole tree.
- Stub the subject and re-run. Replace the function under test with a no-op and confirm the test fails. This catches the vacuous class — 13.5% of Claude Code's suite — for almost no compute.
- Set a mutants-per-test floor, then read the assertions. A suite an order of magnitude below the human baseline on the same module is volume without precision. Then check whether each test asserts the contract or the value the function happens to return today — the only check that catches a bug-bound oracle.
The prompt change worth 3.6 mutation points
| Metric | Standard prompt | Failure-aware prompt | Difference |
|---|---|---|---|
| Line coverage | 92.21% | 96.43% | +4.22 pp |
| Mutation score | 69.98% | 73.61% | +3.63 pp |
| Redundancy | 18.01% | 20.80% | +2.79 pp |
| Vacuous-test rate | 3.86% | 3.62% | −0.24 pp |
Three and a half mutation points for editing a prompt, at the cost of three points more duplication. Take the trade, but not as a fix: a prompt cannot make an agent read a file it decided to skip.
Where the study stops
- Open-source only. Not enterprise codebases, whose suites are often more mature and would narrow the advantage.
- Harness and model are bundled. Each agent ran its native frontier model, so harness and model are not separated.
- Traces come from one system. The failure-mode percentages are GPT-5.6 inside Codex; whether they hold elsewhere is open.
- No remedy proposed. The authors document the C++→Rust regressions and argue the fix needs stronger harnesses and verifier loops. They demonstrate none.
Read it as evidence about the shape of the problem, not a settled scorecard: the direction held across three independent agents.
Where AutoCoder fits
AutoCoder runs a task as a chain of specialist agents, not one assistant that writes and then grades its own work. A verifier checks the result independently, and the reviewer reads the diff against the task, not against the tests the same agent wrote — the cheapest structural fix for the 11.1% oracle failure.
See how the agent chain runs a task end to end, and the pricing page states the full cost, not the subscription alone. For the review half, what a passing suite can and cannot certify is the companion read; for a guarantee rather than a test, proofs are the other instrument; and per-language accuracy covers which toolchain catches what on C++ or Rust.
FAQ
Do agent-written tests actually beat human-written tests?
On average, yes: +0.147 mutation score and +0.142 line coverage across 240 projects. But the margin shrinks from +0.176 under 1,000 lines to +0.083 at 5,000–10,000, and Codex fell slightly below humans on large projects.
Why does agent test quality drop as the codebase grows?
The advantage comes largely from writing many tests, and volume stops paying when the agent must first find the code. The traces show agents skipping relevant files and never measuring coverage — 55.7% of runs recorded none. Both failures worsen as surface area grows.
What is mutation testing and why use it for AI-generated tests?
It injects small bugs into production code and counts how many the suite catches, measuring fault detection rather than execution. Agent suites keep high coverage while assertions weaken or bind to current behaviour, so the distinction matters. The study used up to 120 mutants per project.
Are agent-written tests more expensive than human ones?
Per test, in two of three cases. Per mutant killed, Claude Code uses 7.3× the input tokens, 6.4× the output tokens and 8.5× the wall-clock time of Codex. A human test kills 8.40 mutants on average, against 0.33 for Claude Code and 1.59 for Codex.
Can coding agents translate a test suite from C++ to Rust reliably?
Not on this evidence. In 58% of projects the translated suite had worse edge-case coverage than the C++ source, in 55% it killed fewer mutants, and the worst lost nearly 70% of relative mutant coverage. Fresh generation from the Rust source usually beat the translation.
Sources
Related reading
The Containment Stack: The Three 2026–2028 AI Skills That Make Agent Output Safe to Run
The AI wage premium is now 62%, but it is not paid for calling a model. It is paid for being answerable for what the model does. Three skills produce that answer: execution isolation, OpenTelemetry GenAI telemetry, and deterministic replay. Here is the evidence, the tools and a shipping roadmap for each.
AI Code Generation Is Not Language-Neutral: 56% of Rust Errors Caught, 0% of Python
A November 2026 study ran one model through six language setups. Rust's compiler caught 56% of its wrong first attempts for a semantic reason; Python's caught none. The lesson is not that Rust is safer — it is that your language sets the error floor and the token bill before the model writes a line. Here are the numbers, the caveats, and a per-language acceptance gate you can run in CI today.
The Metered Three: The 2026–2028 AI Skills That Decide What Your Tokens Cost and Whether They're Correct
Four earlier posts on this site named eighteen skills that sit in front of the model. None covered the three seams where an LLM product actually bleeds: the prefix it re-reads on every turn, the contract its output must satisfy, and the route the request travels. Here they are, with the failure modes, the 2026 pay evidence, roadmaps and starting prompts.