← blog
· series: Measured

Agents in the Loop: 2-5 Idle Tests With Survivors, 30-38 Without

Given the list of surviving mutants, a coding agent wrote 23-28 tests with 2-5 that detect nothing new. Given only 'improve the suite', it wrote 58-66, with 30-38 idle.

Given only "add tests that improve this suite", a coding agent wrote 58 to 66 tests, and 30 to 38 of them detect no mutant that ufo's own suite missed. Given the list of surviving mutants as well, it wrote 23 to 28 tests, and 2 to 5 of them are idle. Each arm ran 5 times.

Chapter 6 of Mutation Testing for the AI Era. Chapter 4 did this by hand: 31 tests, 62 mutants. The prompts, the harness and every run are in the PoC repo.

The question

Does giving an agent the mutation survivors make it write tests that check more, or does it just add more tests?

The subject is unjs/ufo at f06c800, with its own suite. Chapter 3 measured 1011 mutants, and 176 of them go undetected: 112 survived and 64 have no coverage. Survivors in an OSS subject are suite gaps, not bugs. src/punycode.ts is vendored code and out of scope, as in chapter 4. It holds 47 of the 176, which leaves 129.

The two arms

Arm A gets this prompt, and nothing else:

Add tests that improve this suite.
 
- Scope: `subject/src`. Leave `subject/src/punycode.ts` alone: it is vendored third-party code.
- Write new test files only under `agent/`, named `*.test.ts`. Import the library as `import { ... } from "../src"`, like ufo's own tests.
- Do not change any other file.
- Run the suite with `npm test`. Every test must pass.

Arm B gets the same prompt plus the 129 undetected mutants in scope, one per line, from the chapter 3 report: file, line, column, mutator, status, original code and replacement. For example, src/parse.ts:4:37, StringLiteral, Survived: "\"ufo:protocolRelative\"" -> "\"\"". The prompt does not say "kill these". Both prompts are in prompts/.

How a run works

  • Model claude-sonnet-5-5 in headless Claude Code 2.1.334, with a 60-turn cap and a 30-minute wall clock. No run came near either: the longest used 22 turns.
  • Each run starts in a fresh clone that holds ufo's source and suite and a Vitest config. It has none of chapter 4's tests, results or scripts, so the agent cannot see the human answers.
  • The agent can read, write, edit, search, and run npm test and npx vitest. It cannot run Stryker, so arm A cannot mutation-test itself. Each run had 2 to 6 tool calls denied, all of them shell commands outside that list. The agent worked around them, and no run tried to start Stryker.
  • After the run, a diff check fails the run if anything outside agent/*.test.ts changed, or if the suite fails on the unmutated code. All 10 runs passed both checks. The check has its own test, which I saw fail before it passed.
  • Then Stryker 10.1.1 with disableBail, as in chapter 4, scores ufo's suite plus the agent's tests. Vitest 4.1.5, Node v24.14.1.

Results

Each cell is min / median / max over 5 runs. The last column is chapter 4's 31 hand-written tests.

Arm A: prompt onlyArm B: prompt + survivorsHuman, chapter 4
Tests added58 / 59 / 6623 / 25 / 2831
Newly detected mutants51 / 65 / 7272 / 73 / 7762
Kills per test0.88 / 1.07 / 1.222.67 / 2.88 / 3.262
Tests that kill nothing new30 / 34 / 382 / 5 / 50
Tests with no unique kill34 / 37 / 444 / 6 / 67
Mutation score87.64% / 89.02% / 89.71%89.71% / 89.81% / 90.21%88.72%

The baseline score is 82.59%. "Newly detected" counts mutants that were Survived or NoCoverage in chapter 3 and are Killed or Timeout now.

Per run:

RunA testsA newly detectedA kill nothingA no unique killB testsB newly detectedB kill nothingB no unique kill
160653437257356
266663844257224
359633036287734
459723034277256
558513744237556

Arm A's newly detected count swings from 51 to 72 across runs, so read the ranges, not one run.

"Kills nothing new" is the junk count

A test that kills nothing new passes, and it detects none of the 176 mutants that ufo's suite missed. It may still pin behaviour the suite already pins, so it is not necessarily wrong. It adds no detection, and it adds code to maintain.

Arm A has 30 to 38 of these in 58 to 66 tests. Arm B has 2 to 5 in 23 to 28.

The human figure is 0 by construction. The chapter 4 script fails if an added test kills nothing new, because I triaged survivors first and wrote a test only for a mutant I had picked. So 0 shows the filter worked. It does not show humans never write idle tests.

"No unique kill" is stricter: no mutant is killed by this test alone. The humans have 7 of 31 by that count, because several chapter 4 tests share kills. Arm A's 34 to 44 is above that, and arm B's 4 to 6 is just under it.

Overlap with the 62 human kills

Arm A detects 35 to 46 of the 62 mutants the chapter 4 tests detected. Arm B detects 45 to 51. Outside the human 62, A finds 16 to 26 mutants and B finds 21 to 28.

What the numbers say

  • With the survivor list, the agent wrote less than half the tests and detected as many mutants or more: 72 to 77 newly detected against 51 to 72.
  • The ranges touch only at 72, arm A's best run and arm B's worst. With 5 runs per arm, treat that as a strong direction and not a tight estimate.
  • Arm B's tests kill 2.67 to 3.26 mutants each, against 0.88 to 1.22 for arm A and 2 for the human tests.
  • Arm B's mutation score, 89.71% to 90.21%, is above the human 88.72%. Chapter 4 stopped there on purpose, so the score is not the point.

What didn't work

  • Test-level counts credit a kill to a test only when the report lists it as a killer. In A-2, 6 detected mutants have no credited test, and in B-5, 1. The "kills nothing new" counts are correct for credited kills, and may overcount idle tests by that much.
  • Arm A ignored the punycode scope note once. In A-2, 3 of the 66 newly detected mutants are in src/punycode.ts.

Limits

  • n=5 per arm, one subject, one model, one prompt wording each. A different model or a prompt that says "kill these mutants" may behave differently.
  • Arm B is told where the gaps are. Arm A is not, and ufo's source is the only guide it has. The comparison measures what the list adds, not a realistic workflow.
  • The agent cost is a list-price estimate from the CLI, not a bill: $0.39 to $0.61 per run for arm A ($2.59 for 5 runs) and $0.38 to $0.42 per run for arm B ($1.99 for 5 runs).
  • Mutation score rewards detection, not value.

Give the agent the survivors, run the same Stryker command on its tests, and count the tests that kill nothing new. The harness is in qa-gary-parker/poc-mutation-testing-ufo. The raw numbers are in results/ch6-agent. Measured with StrykerJS 10.1.1 and Vitest 4.1.5 on ufo f06c800, 5 runs per arm.

related

QA Ark Newsletter

Test automation, AI in testing and quality engineering practice. No spam, unsubscribe any time.