A Grafana reviewer found the case my agent and I both missed

4 casesthe changed condition affects

1 casenobody tested before the human review

On October 1 I opened a pull request to Grafana to fix a blank label in the table panel. My agent wrote the fix and the tests. An automated review on GitHub said the fix targeted the root cause and was well tested. I read the diff and approved it.

Nineteen days later a Grafana maintainer found a case that the agent, the automated review and I had all missed. This post is about that miss: why three checks failed the same way, what I now ask agent reviewers to do instead, and how you can borrow it.

The bug and the fix

A table panel with several queries shows a selector for which dataset to display. Filter out every value field from one query, and that query’s entry in the selector goes blank.

The label came from a helper with three exits. If the frame has fields, join the names of its non-time fields. Otherwise, if it has a reference ID, return Series (A). Otherwise return Series (index). A query filtered down to its time field still “had fields”, took the first exit, found nothing to join, and returned an empty string.

The fix was one line: take the first exit only when there are non-time fields. The agent added tests that failed without the fix and passed with it. The automated review reported that the fallback was tested “with and without a refId”. All of that was true.

The case nobody listed

The helper takes two optional inputs: a reference ID on the frame, and an index passed by the caller. For a frame with only a time field, that makes these cases:

Reference ID Index Before My first commit After review
A none blank Series (A) Series (A)
A 2 Series (A) Series (A) Series (A)
none 2 Series (2) Series (2) Series (2)
none none blank Series (undefined) Series

My fix moved a whole class of frames from the first exit to the last one, and the last one assumed the index was set. The last row was new behaviour that nobody had looked at.

  • The agent tested frames that had a reference ID or an index.
  • The automated review said “with and without a refId”. True, but the case without one also had an index.
  • I read a one-line diff and a green test summary, and approved it.

The maintainer wrote out the last row, with the note “On main it was blank”, and the guard that fixes it:

return index === undefined ? 'Series' : `Series (${index})`;

All three of us made the same mistake. We checked that the fix did what it was for. Nobody asked who else now goes through the condition it changed.

What it cost

The pull request waited 19 days for that review. While it waited, a regular Grafana contributor opened another pull request with the same one-line change, and it merged a day before mine. When mine merged on October 28, the production code it added was one line: the reviewer’s guard. The other 36 lines were tests.

The merge was real and the tests are worth having. But the record shows the important judgement in this fix came from the reviewer, not from me or my agent.

How I use agents to review now

Agents can review. I had asked the wrong question: “is this fix good?” invites a reviewer to check the case the fix is for. Now I ask for something narrower and harder to fake.

1. Ask for the case table first. For every condition a change touches, list each combination of inputs that reaches each branch, before and after. Two optional inputs make four cases. Writing them down takes a minute, and it is exactly what the Grafana maintainer did without being asked.

2. Count a finding only when it is reproduced. A reviewer’s suspicion goes into the report only with a test that fails on the current code. Anything it cannot reproduce is listed separately as unverified. This keeps the review honest in both directions: no vague worries, and no “looks good” without evidence.

3. Review from several angles, in rounds. One reviewer reading top to bottom finds what that one reader looks for. On Argon, my open-source MongoDB tool, the change that let it follow a live database went through rounds like this. The first used seven angles, each checked against two separate databases, and reproduced 30 problems. After those were fixed, a second round reproduced 26 more, and a third round 10 more. The feature stayed behind an off-by-default switch while the rounds ran.

4. Prove the test can fail. A passing test only matters if it fails when the fix is wrong. The Grafana tests failed with the fix removed, which is good. The review now also asks for one deliberately broken variant and the assertion that catches it.

5. Look again while the pull request waits. The agent searched for overlapping work when it opened the pull request and found none. It did not search again in the 27 days the pull request was open. A look at recent commits to the same files now belongs in every status check.

6. Read the merge commit. After a merge, git show --stat on the merge commit tells you what you actually contributed, which can differ from what you opened.

A review harness you can copy

None of this needs a special tool. Any coding agent that can read a repository and run its tests can do it; I run it with Codex and Claude Code. The harness is three parts: one prompt, several reviewers, and a rule for what counts.

The prompt. I give each reviewer the diff, the issue, and this:

Review this pull request. Do not tell me whether it looks good.

1. For every condition the diff changes, list each combination of
   inputs that reaches each branch, before and after the change.
   Mark the rows the tests cover and the rows they do not.
2. For each problem you suspect, write a test that fails on the
   current code. Report the test, the command and the failing output.
3. Anything you could not reproduce goes in a separate list,
   labelled unverified, with what you would need to check it.
4. Label each finding with its severity and how you know it:
   reproduced, traced through the code, or speculative.

Several reviewers. I start the same prompt more than once, each with one angle to own: correctness of the changed branches, inputs at the edges, concurrency and retries, security and permissions, and what the change does to data that already exists. Separate reviewers disagree, and the disagreements are where the interesting findings are.

The rule for what counts. Only reproduced findings go into the fix. Each fix lands with the reviewer’s test, turned around so it now passes. Then the next round reviews the new code, not the old report. I stop when a round reproduces nothing serious, and the unverified list is something I have read and decided on.

How you can use this

You do not need my setup. If you review pull requests, your own or an agent’s:

  • Before reading the diff, write the case table for the condition it changes. If a row is missing from the tests, that is your first comment.
  • When you ask an agent to review, give it the prompt above: reproduced findings and an unverified list, not an opinion.
  • Run more than one round on anything risky. Each fix changes the code the next reviewer reads.

I wrote the fourth point up as a short regression test review template that you can paste into a pull request.

The maintainer who caught the last row spent a few minutes on it. A list of four rows would have caught it on the first day.

Sources