AI Agents · Engineering · Research

What our tests missed when AI agents wrote the code and the tests

We counted nine weeks of bugs in an application built by AI agents. About half or more of those that got through were in code that tests already ran. The tests left out the case that failed.

Vin Lim Founder, Astralab

AI coding agents now write the code and the tests that check it. We had two questions. How much is a passing test run worth when one agent wrote both? And should we delete our unit tests, which seemed to catch little? So we took one application and counted the bugs its tests stopped and the bugs they let through.

The short answers are less than it looks, and no. At least 186 bugs reached the main codebase. In about half to 70% of them, tests already ran that code and left out the case that failed. A separate AI reviewer found many more before they were merged.

What did we count?

Nine weeks of bugs in one commercial web product, late in 2026. We do not name it here, and we have kept the examples general. AI agents write nearly all of its code and its tests. About 300 pull requests were merged in those weeks (a pull request is one set of changes, submitted for review). It has four kinds of test:

  • A unit test runs one function or class by itself.
  • A feature test starts the application with a database and runs several parts together.
  • A browser or front-end test checks what appears on screen and how it responds.
  • A rule test checks everything of one kind, such as every file or every background job, against one rule.

A change normally passes three checks:

  1. The writing agent, Anthropic's Claude, runs tests as it works.
  2. The reviewer, OpenAI's Codex, reads the finished change, and the writing agent fixes the findings it accepts.
  3. The tests run again on the result: the ones the change could affect, or all of them when that cannot be worked out.

Where were the bugs found?

At every check, and after the merge. Each check sees only what the earlier ones let through, so the rows cannot be ranked against each other.

WhenWhat found themBugs
While the agent wroteTests it had not editedAt most 415. We read only the unit tests among them.
ReviewThe reviewerAn estimated 560 to 760
The last test runTests15 confirmed, and up to 10 more we could not settle
After the mergeAnything that came later. Tests found 5.At least 186

The 415 is a ceiling. It counts each test that failed before the agent had edited it, where the agent then changed some code. Many of those were probably not bugs.

The reviewer's figure is an estimate. It raised 1,233 findings at the top two of its four levels of severity, and 1,122 were fixed. We had AI models judge a random 120 of the fixed ones, and they called 117 of them bugs. Of those, 46 needed an unlikely chain of events to happen. The other 71 are 59% of the sample, and a sample that size could be off by about nine points either way. Between 50% and 68% of 1,122 is 560 to 760.

The 186 come from reading the 119 pull requests that looked like fixes. Here we kept the unlikely ones in. We also read 24 of the pull requests we had left out, picked at random, and they had fixed 20 more bugs. If the rest are like those 24, the full number is roughly 260 to 440. Of the 186 bugs, 64 happened to someone in production or while using the product.

Did tests cover the code that broke?

Mostly yes, and they left out the case that failed. For each bug that got through, the judging models said whether tests already ran that code without covering the case. The first judges said yes for 131 of the 186, which is 70%. A second judge repeated 24 of the pull requests and was stricter. It said yes for 18 of 37 bugs (49%), where the first judges had said yes for 27 of 38 (71%). That is where our range of about half to 70% comes from.

Here is one such bug. A record whose end date had passed still counted as active, so nobody could create its replacement. That code had tests. The fix added the case of a date in the past.

In about one bug in eight, a test demanded the wrong behaviour. A long job was marked as stalled and closed after a set number of hours, although part of its work was still waiting in a queue. Closing it would drop that part. A test expected exactly this.

Our explanation is that the agent writes the code and the tests from one understanding of the problem, so a case it did not think of is missing from both. Our count fits that but does not prove it. A study of 24 Java projects found something close: tests that language models generate mostly capture what the code already does, which makes bugs hard to detect.

Should you delete your unit tests?

No, and adding more would not have helped much either. For each bug, the judges named the cheapest kind of test that could have shown it.

Cheapest testFound by the reviewer (the 71 bugs above)Found after the merge (186 bugs)
Feature test69%65%
Browser or front-end test14%16%
Unit test14%3%
The real outside service, AI model or server3%10%
Something else0%5%

The shares are rounded. The reviewer's column leaves out the unlikely bugs, and the other column does not.

So a unit test was the cheapest way to show 3% of the bugs that got through, and 14% of the reviewer's, which is 10 bugs. Unit tests also caught little while agents wrote code. Going back to July, before our nine weeks, 13 unit tests failed that the agent at work had not edited. We read all 13. One was a real bug, and feature tests caught it in the same run.

We kept the unit tests anyway. They are about a tenth of the tests and 2.5% of the running time, so deleting them would save almost nothing.

A feature test could have shown about two thirds of the bugs. The project already has tens of thousands of feature tests, so the number of tests was not the problem. Each of these bugs needed a case that nobody had written.

What did the reviewer find that the tests missed?

Cases nobody had tested, even in work that had been reviewed before. The descriptions of 106 changes say that another agent session had already reviewed the work. The reviewer still found something that had to be fixed in 90 of them (85%). For the other changes it was 175 of 254 (69%). The 106 were about three times the size of the rest, so there was more to find.

The reviewer must not report a preference. Each finding names the behaviour at risk and shows how it fails. Here is the format, filled in with one finding that we shortened:

FieldExample
SeverityIssue
Behaviour at riskThe cost on record matches what was spent.
How it failsSomeone deletes a record while a paid job for it is running. The job finishes and reports its cost. Its claim is gone, so the cost is dropped.
EvidenceThe lines that clear the claim and look it up.
Suggested fixKeep cancelled claims until their cost is booked.

A review took a median of 45 minutes, including the fixes and the last test run, and one in ten took more than three and a half hours. We did not measure the cost in tokens.

We cannot say how much of this comes from using another company's model. When we reviewed the research on that question, no study showed that a second vendor catches more than a fresh session of the same model. It showed that two reviewers find different bugs. Some of the reviews counted here are also in that article's totals.

What did rule tests catch?

Twelve of the 15 confirmed catches in the last test run. We see two likely reasons. By then the agent had already run the other tests it thought of. And an agent works from the files it opens, while a rule test looks at all of them.

Five of the 15 were not caused by the change under review. An earlier change had been merged with the fault in it, and later changes ran into the failing test.

Here is one rule test, in outline. When a new version goes live, jobs created by the old version are still waiting in the queue. If the new version adds an optional field with no default, the waiting jobs do not have it and crash.

for each kind of queued job:
  rebuild it as an older job,
    with no optional values
  for each field of that job:
    fail if it has no value

When it fails, the test says what to do: give this field a default, or jobs queued before this release will crash when they run.

Which bugs need the real service?

For 19 of the 186 bugs, the cheapest way to show the fault was the real outside service, the real AI model or the server itself. Of those 19, 18 happened to someone in production or in use.

One of them began before our nine weeks. For about eight weeks, every recorded request of one kind to an outside service failed, and nothing raised an alarm. The service expects its own format, and the code sent plain text. The tests checked that the feature was available to use. None checked what it sent. One real call would have shown the fault.

How can you run this count on your own project?

You need a record of test failures and the code at each one. We used the logs of our reviews and the transcripts of the agents' sessions. For each failure, look at what changed before the test passed again:

What changedHow to read itWhile agents wrote (621 failures)Last test run (171 failures)
Only the codeA possible catch13531
Code and testCould be either, so read it28025
Only the testThe test was out of date, or was loosened to pass14130
NothingThe test fails at random5436
Could not sortThe record was incomplete, or the review ended first1149

Then read the failures, because the table overstates the catches. Of the 31, 15 held up as real. Reading the others, apart from the 30 and the 36, gave up to 10 more. The 36 random failures outnumber the bugs caught in that run.

Next, list the pull requests that fixed a bug already in the main codebase. For each bug, write down whether tests ran that code and which test would have shown it. If an AI model reviews your code, read a random sample of its findings before you quote a total.

What should you do with this?

Three things. These are our opinions, and they come from one project.

  1. Have a separate reviewer check every change, however well its tests pass. Tests from the agent that wrote the code cover the cases it thought of. Accept only findings that show how the code fails. A fresh session of the same model is the minimum, and a different model finds different bugs.
  2. Write a rule test for each rule that an agent can break without opening the file. One test then checks every file or job of that kind, including the ones added later.
  3. Call each outside service for real before you release, and raise an alarm when every call to one fails. A test that stands in for the service can only repeat what you believe about it.
Sources

The counts come from three records of one application: the run store of review-loop, our open-source review coordinator; the transcripts of the agents' sessions; and the merged pull requests. The paper was read on 1 December 2026.