DEV Community

Cover image for I Planted 20 Bugs for Three AI Reviewers. Being Right Wasn't Enough.
Self-Correcting Systems
Self-Correcting Systems

Posted on Edited on AI-assisted

I Planted 20 Bugs for Three AI Reviewers. Being Right Wasn't Enough.

Reviewer Planted bugs caught (of 20) False alarms (of 20 clean functions)
ChatGPT 20 0
Grok (possible contamination: same account as the key reviewer) 20 0
DeepSeek V4 Pro 17 0
llama3 8B (local) no answer no answer

That is round 1 of a small test I ran this week. I wanted to know which AI reviewer I should trust to check changes to my agents, so I stopped asking them and started measuring them.

The setup

My coding agent, Claude, wrote 40 short Python functions, each with a plain-English spec. Twenty were correct. Twenty had exactly one planted bug, in five kinds: an off-by-one boundary, a wrong comparison, a bad fallback, a quiet change to what the spec asks for, and a wrong default. For every buggy function it kept a hidden copy with the bug fixed.

Each reviewer got the same instruction and the same 40 functions in a fresh session, with no hints about how many were broken. For every function it had to answer OK or DEFECT. A DEFECT also needed a concrete input where the function breaks its spec.

How each one ran, as recorded:

  • ChatGPT: web Temporary Chat, set to Unpersonalized, reasoning High. The exact model name was not shown.
  • Grok: web Private chat, Expert mode. I found no memory setting to turn off.
  • DeepSeek V4 Pro: one call through an agent tool with every tool disabled, not a direct API call.
  • llama3 8B: local, through ollama. Three attempts, no answer.

A catch has to be proven

This is the rule that matters. A reviewer's explanation is saved and never scored. What gets scored is the input they gave: we run it through the buggy function and through the fixed copy. If the two behave differently, the reviewer caught the bug. If they behave the same, the reviewer said DEFECT for a reason their own evidence does not show.

Here is a simplified version of that check:

def outcome(fn, args):
    try:
        return ("value", fn(*args))
    except Exception as e:
        return ("raise", type(e).__name__)

def same(x, y):
    if x[0] != y[0]:
        return False
    a, b = x[1], y[1]
    if isinstance(a, float) and isinstance(b, float) and a != a and b != b:
        return True   # NaN never equals itself; treat two NaNs as the same result
    return a == b

def judge(answer, item, reference, has_bug):
    if not isinstance(answer, dict):
        return "invalid"
    if answer.get("verdict") not in ("OK", "DEFECT"):
        return "invalid"
    if answer["verdict"] == "OK":
        return "missed" if has_bug else "ok"
    args = answer.get("failing_input")
    if not isinstance(args, list):
        return "invalid"
    if not has_bug:
        return "false_alarm"   # any DEFECT on correct code is a false alarm
    different = not same(outcome(item, args), outcome(reference, args))
    return "caught" if different else "wrong_reason"
Enter fullscreen mode Exit fullscreen mode

On a correct function there is nothing to fix, so any DEFECT on it is a false alarm. The real scorer also adds a timeout, compares floats with a tolerance (including inside lists), and rejects code outside an allowed subset of Python before running anything. It is not a sandbox.

One assumption sits under all of this: the hidden fixed copy is treated as the truth. A demonstrated difference counts as a catch within the test's own rules. It is not independent proof that the fixed copy itself is correct, which is why every function was reviewed against its spec before the test was sealed. And a difference is only meaningful when the input falls within what the spec allows; this scorer does not check that, so a reviewer could in principle earn a catch with an input the spec never covered.

Right words, no proof

One function, get_nested, follows a list of keys through nested dicts and should return None when a key is missing. The planted bug returned the half-finished value instead.

All three reviewers flagged it, and all three explanations were right. ChatGPT and Grok gave the input [{"a": 1}, ["b"]]. The buggy version returns {"a": 1}, the fixed one returns None. Caught.

DeepSeek wrote: "On a missing key it returns the partially-traversed dict instead of None." Correct. But its input was [{"a": 1}, ["a", "b"]]. On that input the code reaches 1["b"], which raises a TypeError, and both versions return None. Same output, so no catch.

If I had scored explanations, DeepSeek gets that one. Scoring the evidence, it doesn't. That gap is the whole reason the test runs the input instead of reading the sentence.

DeepSeek's other two misses: it called one buggy function correct, and on another it wrote Python's None instead of JSON's null, so that single answer could not be read. The other 39 of its answers were still scored.

These scores use cleaned captures: copy and paste escapes were removed from ChatGPT's response, and a launcher warning line from DeepSeek's. Answer values were preserved, and invalid answer content stayed invalid.

What this result does not say

It does not say ChatGPT and Grok are equal, or perfect. This round didn't separate the two highest-scoring sessions. Bugs that were too easy is one explanation; for Grok's row, possible contamination is another. On 20 bugs, the 95% Wilson interval for a perfect score runs from 84% to 100%, and DeepSeek's 17 of 20 (64% to 95%) overlaps it.

One model wrote every bug. The functions are short and use only builtins. Nothing here measures review of real agent code, with state, timing and network payloads.

The local model never answered. llama3 8B on my 8 GB MacBook Air pushed the machine into swap so hard the laptop slowed to a crawl. My last attempt measured about 4 bytes every 90 seconds, a projection of roughly 37 hours for one complete answer. It is recorded as no answer on all 40.

Grok's memory state is unknown. The AI that reviewed the answer key before it was sealed is also Grok, on the same account. The Grok reviewer ran in a private chat, but if Grok's memory crosses chats, its 20 of 20 could be contaminated. I can't rule that out from here.

What does hold: across 60 checks of correct code, none of the three raised a false alarm. On this set, when they said "bug," there was one.

Constraining the planter's influence over the grading

The agent that planted the bugs knew the answers, so it never graded. Encryption can't erase what the planter already knows. It restricts access to the saved key; comparing files against the recorded fingerprints makes later changes detectable. Independent review covers the rest.

The answer key was encrypted with a passphrase only I typed, and it stayed locked until the three completed responses and the local model's no-answer record were locked. Before any reviewer saw the test, the fingerprints of the key, the functions, the instruction and the scorer were written down on paper and logged. After the answers arrived and before the key was opened, every answer file was fingerprinted too.

A second AI, from a different company than the one that planted the bugs, tried to break the scorer before it ran. After the answers arrived, one of them turned out to contain a single unreadable row, so the scorer's answer reader had to change. The second AI broke the first version of that change: one malformed answer shape could keep a wrong verdict, and another could silently drop a row. The reader was rebuilt, the second attempt to break it did not land, and the new scorer's fingerprint was logged before the key was opened.

Round 2

Round 2 is already sealed: 40 new functions, longer, with bugs that often show only when two conditions meet, like page counts that divide exactly or intervals that touch without overlapping. The AI that checks the work blocked the question set three times before it was sealed, including one "correct" function that accepted Arabic-Indic digits in an IP address. Results go up when the reviewers finish.

If you've measured AI code review yourself: how did you keep the reviewer's explanation from getting credit its evidence didn't earn?

Top comments (11)

Collapse
 
iictp profile image
IICTP •

The get_nested example is the one that sold me on the evidence rule — DeepSeek's explanation was right, but the input it gave produced the same output from both versions, so there was nothing to catch. Scoring only the demonstrated input/output pair, and never the prose around it, is exactly the discipline that keeps a review honest. For round 2, with bugs that only show when two conditions meet, will a single demonstrating input still be enough, or will the scorer need a pair of inputs to pin the interaction down?

Collapse
 
kenielzep97 profile image
Self-Correcting Systems •

One input should still be enough, because the two conditions live inside the same input. Round 2 was built so many of the bugs need two conditions at once, and both still fit inside a single call. Where I think it breaks is code with state, where the bug only shows on the second call after the first one changed something. How would you score a catch that needs a sequence of calls instead of one input?

Collapse
 
sherotree profile image
Sherotree •

I'd keep llama3's "no answer" out of the catch-rate column. A local model that falls into swap and never returns is a harness failure, not 0/20 bugs caught, and folding it in makes a runtime problem look like weak review. Same for DeepSeek's unreadable row: that's a parse miss, which you already scored separately, and it should stay that way in the table. For round 2, I'd also be wary that one model planted every bug — the reviewers may be getting measured on that model's style of off-by-one, not on the ones a different author would write.

Collapse
 
kenielzep97 profile image
Self-Correcting Systems •

Agreed, and the table keeps it that way: llama3 shows "no answer," not 0 of 20, and DeepSeek's unreadable row was scored separately. The one planter worry is fair too. Round 2 has the same author, so it continues that author's column, and the next step is a test where a different model plants the bugs. Would you split a round between two authors, or give each author a round of their own?

Collapse
 
reidmarlow profile image
Reid Marlow •

For the input-domain gap, a useful next step would be to give each spec a small executable input validator and score a counterexample only if it passes that validator. Keep those validators separate from the planted fix: otherwise an overly narrow validator could hide a real bug by excluding the failing case.

Collapse
 
kenielzep97 profile image
Self-Correcting Systems •

That's the right fix for the gap I left open, and your warning is the part I'd have missed. If the same person writes the validator and the planted fix, they control what counts as a fair input. I'd want a different model to write the validators from the spec alone. Would you trust a validator written that way, or would you want people to review those too?

Collapse
 
reidmarlow profile image
Reid Marlow •

I'd have a person review the validator, especially the boundary cases. A second model may independently make the same assumption or narrow the domain in a different way. A small set of human-checked valid and invalid examples, including cases near each boundary, gives you something to test the validator against before it judges the reviewers.

Collapse
 
jaypateldev profile image
Jay Patel •

Really interesting experiment! It highlights an important point: catching bugs isn't enough if the reviewer can't explain why something is wrong. I'd argue confidence, context, and actionable feedback matter just as much as detection accuracy. AI code reviews need to build trust, not just flag issues.

Collapse
 
kenielzep97 profile image
Self-Correcting Systems •

Explanation matters for the person fixing the bug, I agree. The test is about the opposite risk though. DeepSeek explained get_nested perfectly and its own input still didn't show the bug, so a score that rewards explanation would have given it credit it didn't earn. How would you score explanations without rewarding the ones that sound right but aren't backed by anything?

Collapse
 
_komachi-jp profile image
Komachi | AI on a Budget •

Your rule that a catch has to be proven is the part I will steal first. I split my work so Claude Code writes and ChatGPT reviews with a short diff-only checklist, but my reviewer still mostly argues in words — your get_nested example, where DeepSeek's explanation was right and its test input still proved nothing, shows me exactly what to ask for instead: a failing input, not a paragraph. The local-model footnote hit home too: llama3 8B pushing an 8 GB MacBook Air into swap is a real data point as I shop for a used desktop to run a local model. Do you plan to keep the same 'prove it' scoring in round 2, or will longer functions force a different kind of evidence?

Collapse
 
kenielzep97 profile image
Self-Correcting Systems •

Same rule in round 2: a catch only counts if the failing input proves it, the functions just got longer. A failing input instead of a paragraph is exactly the ask, and it also makes your reviewer's answers cheaper to check. On the desktop, the swap was the lesson for me too, the model and everything else just didn't fit in 8 GB, so I'd want 16 GB or more. What are you hoping to run locally first?