4 of 5 held-out bugs, 1 false finding in 123
Our review agent read diffs for style. The bugs users hit were a different kind. So I built a bug hunter that learns from past fixes, and a second agent whose only job is to prove the first one wrong.
Our review agent checks every diff against the coding standards. It’s good at it. The bugs that reached our users were a different kind.
A date that moved by a day for users in another timezone. A second click that sent a request twice. A new screen that lost a check the old one had. Each of those diffs read well and followed the standards.
So I built a bug hunter with a narrow definition. A bug is a concrete input or state that produces a wrong result for a user. Style, naming and docs stay with code review. The hunter changes no files. You run it on a branch and get a report.
Thirteen questions from past fixes
A generic review prompt asks “is anything wrong here?” That finds generic problems. I wanted the mistakes this codebase keeps making.
So the hunter starts from history. I read the fix commits and asked one thing about each: what change let this bug in? Each answer became a bug class, written as the question that finds the next one. There are 13.
| Bug class | The question |
|---|---|
| Money | Does the amount use its currency’s decimals, not 2? Does a sum mix currencies? |
| Business dates | Does a date picker value convert through the browser timezone, so the day shifts? |
| Repeated action | Can a second click send the request again before the first settles? |
| Legacy parity | Does the new screen keep every check of the old screen it replaces? |
The list grows by one rule. When a bug reaches users after a hunt passed its diff, the checklist missed a class, so we add it.
The first version was one instruction file. A lead agent read the diff, listed suspects, checked them and wrote the report. It found real bugs. It also failed in four ways.
One agent that finds and judges
The scoring agent scored everything the same. The first version ended with an agent that rated each finding. Nearly every finding got the same score, so the score ranked nothing. Now every confirmed finding gets an impact class instead: data, crash, wrong display or cosmetic.
The lead wrote the report too early. In one run it stopped before its checkers came back, and an engineer had to tell it to wait.
The session had no subagents. In the same run, the lead had no tool to start them, so it launched its checkers as separate processes by hand.
Only a prompt protected the files. A checker writes a small test to prove a bug, and only the instructions told it to delete the test afterwards.
The fix for all four was the same. The agents kept their instructions, and the coordination moved into a script. The script fans out the hunters, merges duplicate suspects, starts the checkers in batches and waits for every verdict before the report. The checkers lost their write tool, and one helper writes, runs and deletes each test. An agent decides whether a suspect is a bug. Code decides everything else.
That fixed the plumbing. It didn’t fix the bigger problem: a hunter that judges its own suspects agrees with itself.
A second agent that tries to say no
A hunter has to give each suspect a failure scenario: what the user does, the code path line by line, and the wrong result. No scenario, no suspect.
Then a verifier takes over. It didn’t do the hunting. It sees the suspect and the code, not the hunter’s reasoning, and its job is to throw the suspect out. It uses the cheapest tool that settles the question: follow the code and cite every line, write a test that fails on the current code, or read the server’s code when the scenario depends on what the server sends.
Date suspects get my favourite trick. The test runs twice, once in a timezone west of the business zone and once east of it. The author never sees the bug because their own machine is on the safe side. One red run is the proof.
Only CONFIRMED suspects reach the report, worst impact first. PLAUSIBLE ones, likely but resting on a fact the code doesn’t hold, go to a short “not proven” list. REFUTED ones are counted and hidden. A verifier that crashed returns UNVERIFIED, which is not a refutation.
On 21 October the hunt ran on a real pull request. It took 12 minutes.
The top finding was a repeated action. One failed call made several waiting requests record the same event. The verifier’s test failed on the pull request’s code with:
expected to be called 1 times, but got 5 times
The author fixed two findings the same day and accepted the two cosmetic ones. Two disproved suspects were behaviour the pull request description asked for, and the verifier read it. One assumed an event is lost on a redirect, and the verifier found the library sends pending events on unload.
A person still makes the last call. The verifier ranked one finding as cosmetic. The lead raised it, because the wrong label defeated the purpose of the change.
Tested on bugs it never saw
I tuned the hunter over several rounds, replaying past bugs each time. False findings fell from 5 in one round, to 2 after the scoring agent went, to 1 in 123 across the last two rounds.
A good score on the bugs you tuned on proves the tuning worked on those bugs. So I kept 5 past bugs apart, and no round used them. The hunter ran on each one’s original pull request, with only what a reviewer had that day. It found 4.
Five is a small sample. 4 of 5 shows the approach works on bugs it wasn’t tuned on, not that it catches 80% of them. And 1 in 123 only counts what the hunter said, never what it missed.
The miss is the price of the verifier. A weak suspect gets dropped, and sometimes a real bug goes with it. I take that trade, because a person reads and acts on every line of the report.
I want each new class the hunter finds to end up as a rule that makes the mistake impossible to write.
Lesson
An agent that judges its own findings agrees with itself. Give the judging to a fresh agent whose job is to say no, and let code do the waiting.