Does telling an AI code reviewer what the code should do help?
Paper: When Postconditions Help or Mislead: An Empirical Study of LLM Code Review
Preprint. It has not yet been peer reviewed.
The short version
AI code reviewers see what code does but not what it is supposed to do, so they flag correct code and miss real bugs. I gave three AI reviewers 210 real Java methods, each in its original form and with three planted bugs, sometimes with a statement of what the method should guarantee, called a postcondition. Checked postconditions cut false alarms by more than half for two of the three reviewers. Postconditions written by an AI helped one reviewer find more bugs, but when that reviewer was told to treat them as the specification, it missed many more.
What I found
- Three AI reviewers from three companies produced 17,640 reviews of 210 real Java methods, each reviewed in its original form and as 3 versions with a planted bug.
- For two of the three reviewers, adding the benchmark's checked postconditions cut false alarms by more than half, while adding the whole source file did not significantly change them.
- When one reviewer was told to treat AI-written postconditions as the specification, it found 16 percentage points fewer bugs. On bugs those postconditions did not cover, its rate fell from 82 percent to 21 percent.
- Without that instruction, the same AI-written postconditions helped that reviewer find more bugs than with none: 89.5 percent against 86.3 percent.
- Some of one reviewer's false alarms were real: in 19 of the 23 cases checked, the code breaks its reference postconditions on an input the benchmark's tests never try.
Why it matters
Teams adding an AI reviewer may cut false alarms by giving it checked statements of what the code is meant to do. The wording matters: give the statement as information, not as an order to treat it as the specification.
How the study was done
The study used a public benchmark of 210 Java methods from 60 open-source projects with checked postconditions. Each method was reviewed alone, with its whole source file, or with either the checked or the AI-written postconditions, and every review was scored against the benchmark. A follow-up experiment removed the instruction to treat the postconditions as the specification, to measure its effect.
How to cite
Thapa, S. J. (2026). When Postconditions Help or Mislead: An Empirical Study of LLM Code Review [Preprint]. Zenodo. https://doi.org/10.5281/zenodo.23956986