The tests your AI agent writes mostly prove it agrees with itself

When one AI agent reads the ticket, writes the code and writes the tests, a green suite only proves the agent agrees with itself. Banning mocks, mutation testing and TDD don't fix that. The expected value has to come from whoever owns the request.

VerificationCobble team5 min read
A line engraving of reflective glass panels on a building facade, seen at an angle.
Photo by Albert Stoynov on Unsplash

When one AI agent reads the ticket, writes the code and then writes the tests, the tests check the code against the agent's own reading of the ticket. So a green suite of AI-generated tests tells you the agent is consistent with itself, and very little about whether it understood you. Most of the popular fixes for bad agent tests don't change that.

Take a refund, a hypothetical one. The ticket says "refund the order". The order is 100 with 21% VAT. The agent decides a refund means the amount net of VAT, so refundFor returns total / (1 + vatRate), which rounds to 82.64. Then it writes a perfectly respectable test:

1it("refunds the order", () => {2  const order = makeOrder({ total: 100, vatRate: 0.21 });3  expect(refundFor(order)).toBe(82.64);4});

It builds a real order, mocks nothing and asserts an exact value, and it passes. A reviewer skimming the diff would think a careful engineer wrote it. The customer wanted their 100 back.

The code and the test are wrong in the same way, because they're the same opinion written down twice. Making the test better won't help either, since by most measures this one is already good.

One reading of the ticket, written down twice

A hypothetical refund: an order of 100 with 21% VAT

The agent writes both

  1. Ticket"Refund the order"three words
  2. Agent's readingA refund is the amount net of VATone reading
  3. Code and testBoth say 82.64Passes

The request's owner decides first

  1. Ticket"Refund the order"the question
  2. Request's ownerThe customer gets 100 backthe expected value
  3. Test, written firstExpects 100. The agent's code returns 82.64.Fails
When the code and the test come from the same reading of the ticket, they agree, including on the mistake. A value the request's owner decided first is what turns the test red, and here red is the result you want.

Green means the code matches the agent's reading

The lazy version of this is easy to spot. It's a test that mocks the very function it claims to test, then checks that the mock returns what it was told to, so it passes whatever the code does. Plenty of agent tests are closer to that end than you'd hope. A study of agent-written test patches in public repositories found 80.2% had a weak assertion or none at all.1

But the 82.64 test isn't lazy, and it's the one that worries us. Researchers who looked at LLM-written test oracles found they "mainly capture the actual program behavior," which is a polite way of saying the model looks at what the code does and writes that down as what it should do.2 If the code is right, fine. If the code is wrong, you now have a test guarding the bug.

The usual fixes test the test

Ask how to make agent tests better and people suggest banning mocks, adding mutation testing or having the agent do red/green TDD. They're good habits, and none of them would have caught the refund.

Banning mocks doesn't touch it, since the 82.64 test has none. Mutation testing changes the code in small ways and checks that some test fails. Swap the division for a multiplication and refundFor returns 121, so the test fails and the mutant dies. Most mutants will die. The mutation score looks great, and the customer still gets 82.64.

Red/green is the one people find most convincing. Simon Willison's version is to write the test, watch it fail, then write the code, because "If you skip that step you risk building a test that passes already."3 That would have caught the mocked test, which passes whatever the code does. Now run it on ours. The agent writes the 82.64 test first, it goes red, the agent writes the code, it goes green. It's TDD by the book, and it's still wrong.

All three make sure a test can fail. None of them ask where 82.64 came from, which is the thing that went wrong.

A second agent reads the same three words

The obvious next move is to have a different agent write the tests. But give a second agent the ticket "refund the order" and it has exactly the information the first one had. It may well land on net of VAT too. Separating the agents only helps if the second one has something the first didn't.

A September preprint called EXECCRITIC makes the point from the other side.4 One agent wrote tests, they were frozen, and a separate agent fixed the code against them. When the tests came from a second copy of the same model the fixer ran on, they left the fixer worse off than having no tests at all. Tests from a much stronger model made it better. The test writer was separate in both cases, so being separate didn't help by itself. The quality of what the tests expected did.

Weak tests from a separate agent did worse than none

Share of SWE-bench Verified tasks the repair agent solved, by where its frozen tests came from

  1. No tests61.2%
  2. Tests from the same untrained model as the fixer57.3%
  3. Tests from a much stronger model65.3%GPT-5.6-sol
Both test writers were separate from the fixer. Separation alone didn't help. Better tests did.4

And the expected value for a refund isn't something a stronger model can work out from three words. Someone who owns the request has to say whether the customer gets 100 or 82.64. That only helps if the question actually reaches them. Transluce found a session where an agent's tool for asking the user returned an empty acknowledgment on all sixteen calls. The agent wrote the user's decisions into a decisions file anyway, and later admitted "I was effectively making up all the decisions myself."5 That's the refund test one level up. The agent answered its own questions and wrote the answers down as the user's.

The expected value has to exist before the code does

Cobble started as the fix for AI work on our own team that was only as good as whoever happened to be running it. Here, what it does is ask first. Business questions go to the product owner or analyst before any code exists, and technical ones to the engineer after that. In the business requirements interview, the issue then waits, with its goals and acceptance criteria written down, until someone authorizes the build. That's the point where a person can say "100, not 82.64", before the agent that writes the code has a reading of its own to agree with.

Keep the tests, change where the numbers come from

None of this means you should throw out the tests your agent writes. Once a person has confirmed what the code should do, a test that pins that behavior down is exactly what you want guarding it. Agent tests make a decent regression net, as long as you don't mistake them for proof.

So this week, try one thing on your agent pull requests. For every value an agent-written test asserts, ask who decided that number. If the answer is "the agent, while writing the code", the test is checking the agent against itself. For the next ticket that has a number in it, write the expected values down with whoever owns the request before the build starts, put them in a test file the agent can't edit, and see whether its code agrees.

  1. "All Smoke, No Alarm", IEEE AITest 2026, 16 June 2026. 86,156 test patches in 33,596 pull requests from five coding agents, classified statically as having weak or no explicit oracle. The authors: "test file counts substantially overestimate verification strength." https://arxiv.org/abs/2606.18168 Back to text
  2. Konstantinou, Degiovanni and Papadakis, 24 Java projects, first published October 2024, revised 5 October 2026. https://arxiv.org/abs/2410.21136 Back to text
  3. Simon Willison, "Red/green TDD", Agentic engineering patterns, February 2026. https://simonwillison.net/guides/agentic-engineering-patterns/red-green-tdd/ Back to text
  4. Tao et al., EXECCRITIC, 8 September 2026. Preprint. In this comparison both the test writer and the fixer are the untrained Qwen-3.5-35B-A3B, and the stronger test writer was GPT-5.6-sol. Post-trained versions are reported separately. On SWE-bench Verified the repair agent solved 61.2% of tasks with no tests, 57.3% with tests from that same untrained model and 65.3% with GPT-5.6-sol's. GPT-5.6-sol was both a different model and a stronger one, so the study can't tell which helped. It also didn't test one agent writing both code and tests. https://arxiv.org/abs/2609.09133 Back to text
  5. Transluce, "Measuring coding agent misalignment in the wild", 5 August 2026. The sixteen-call session is a worked example in Transluce's overselling rubric, rated severe, and the commit was reverted after the user objected. About 8,600 sessions from the public SWE-chat dataset and Transluce's own traffic, judged by a model. https://www.lesswrong.com/posts/smE9h9RnaK7FWKBZ2/measuring-coding-agent-misalignment-in-the-wild-1 Back to text

Read next

  1. Run the agent harness as it ships

    On a Claude subscription, the agent harness you run is Claude Code, and we think that's the right one to be on. A team gets more from setting down how work reaches the agent and how the result gets checked.

    Delivery2 min read
  2. Most of your coding agent prompt was written for last year's models

    We think most of what engineers put into coding agent prompts is padding left over from last year's models. The part worth writing is a plain description of done, and the person who can write it is usually the one who asked for the work.

    Shaping tickets3 min read
  3. If merging is your AI bottleneck, you're doing well

    Anthropic's merges grew from about 2,500 a day to over 30,000, and git couldn't keep up. We think where AI work piles up shows how far a team has got.

    Delivery3 min read