How to Verify AI Agent Code Before Trusting a Green Check
A search-box bug shows how a passing test can mislead. Five habits from Addy Osmani for checking AI agent code: guess first, define done, read the command.
For Engineering and Managers

How do you check that an AI agent's fix is actually correct?
Ask what the passing check proved, then ask what it did not. A green result only tells you that the specific thing tested worked. It says nothing about the paths nobody tested. To close that gap, write down your own guess before the agent answers, define "done" before you see the fix, read the exact command and output before the summary, get a fresh reviewer to hunt for untested paths, and explain the fix in your own words before it ships.
Addy Osmani laid out these habits in an article called "Critical Thinking: When Agents Do the Work" (published November 3rd). This post applies them to one small, common bug so you can see each habit catch something.
TL;DR
- A green check is an answer to a narrow question. Always ask what it proved and what it left untested.
- Write your own guess first. Once you read a polished agent answer, it gets hard to imagine any other cause.
- Define "done" before you see the fix, or you will talk yourself into accepting whatever comes back.
- Read the command and its output before the summary. A name filter on a test command can mean only one test ran.
- Use a fresh reviewer (a new session or sub-agent) that sees only the requirements and the diff, not your assumptions.
- If you cannot explain the fix out loud, you do not own it. You only merged it.
What is the bug we are testing?
Picture a search box. You type "cat", then keep typing until it reads "cats". Two requests go out. The "cat" request starts first but comes back last. The box must show results for "cats", not "cat".
There is a second rule. If you clear the box while a request is still running, the box must stay empty.
This is a classic race condition: two things happen at once, and the result depends on which one finishes first. It is a tiny bug, but it can be fixed halfway, and a green check will still say everything is fine. That makes it a good teaching case.
A note on the example: the three versions of the search box used here (buggy, partially fixed, fully fixed) were written to demonstrate the habits. They are not output from a real agent session. The habits are what matter.
Why write your guess before asking the agent?
Because a confident, well-written answer crowds out every other idea. Osmani's reasoning is that once you have read a polished explanation, it is very hard to see alternatives, so you will not notice when the agent is confidently wrong. Even a bad guess gives you something to compare against.
For the search box, the guess is: the "cat" response arrives after the "cats" response and overwrites the results. Last response wins.
Then write the prompt around it. A template you can copy:
Here is the symptom: [what you see]
Here is my guess at the cause: [your hypothesis]
Here is the behavior I want: [the rule]
Here is what you must not change: [boundaries]
Filled in: the search box shows old results. Show results for the latest query only. When the user clears the box, keep it empty. Do not change the search API.
Notice something. The prompt mentions the clear case, but the guess only talks about response order. That gap matters later.
How do you define "done" before you see a fix?
Decide what proof you will accept before you look at any code. If you wait, you will rationalize whatever you get. "I typed in the box and it looked fine" is not a definition of done.
For this bug, a manual check is especially weak. The problem depends on network timing on your machine, so "cat" might happen to arrive first every time you try it. You can pass by luck.
The better move is a test that forces the bad order on every run. Use a fake server where each request returns a promise (a placeholder for a result that arrives later) that you resolve by hand. Start a search for "cat", start a search for "cats", resolve "cats" first, then resolve "cat". The box must show "cats". Because the test controls the order, the network does not.
A template for this step:
Write a test that fails on the current code.
Control the timing by hand. Do not use sleeps or timeouts.
Show me the test failing before you fix anything.
The "show me it failing" line is the important one. A test that has never failed has never proved it can catch the bug.
What does a green check actually prove?
Less than it appears to. Osmani's advice for when an agent says it is finished: read the command that ran and its output before you read the summary.
Here is what that looks like. Run the test on the buggy version with Node's built-in test runner, filtered by name to the one "older response" test. It fails: expected "cats", got "cat". Pass 0, fail 1. Your guess was right.
Now run the same command on the partial fix. It passes. Pass 1, fail 0, exit status 0. Green.
The partial fix works by giving every search a number from a counter. When a response returns, it checks whether a newer search has started, and if so, drops itself. That sounds like the whole fix.
But look at the command. It has a name filter, so only one test ran. If an agent had run this and written "all tests pass," the sentence would be technically true. You only see how little ran by reading the command.
What did the green prove? That an old "cat" response cannot overwrite "cats." Nothing about clearing the box. A template for when an agent reports it is done:
Before your summary, show me the exact command you ran
and its full output. Tell me which tests ran and which
were skipped or filtered.
Why use a fresh reviewer?
Because you and the agent share the same assumptions. A reviewer with a clean slate does not. Osmani points out that a coding agent can critique work through a sub-agent with fresh context. In practice, open a new session or spawn a sub-agent that sees only the requirements and the diff (the list of code changes).
He also suggests asking what would have to be true for the result to be wrong, then checking it. A reviewer prompt that does this:
Review this diff. Do not trust the summary.
Find one path that the tests do not cover.
Write a test for it.
A fresh reviewer is likely to go straight to the clear path, since it is in the requirements and has no test. (This step is illustrative in the demo, so treat "likely" literally.) The new test: start a search for "cat", clear the box, then let the "cat" response arrive. The box must stay empty.
Now run the whole test file with no filter. One pass, one fail. The box shows "cat" when it should be empty.
The reason is clear once you see it. The partial fix only drops a response when a newer search has started. The "cat" search took number one. Clearing the box did not take a new number. So when the response arrived, number one was still the latest, and it wrote "cat" into a box the user had just emptied.
Remember that the original guess only covered response order. The first test matched the guess, so it missed the clear path too. A test can only check what you thought to check.
The full fix changes one thing: clearing the box also takes a new number. Run the whole file again: two pass, zero fail.
Can you explain the fix without looking at the code?
Try it. If you cannot, Osmani's point is that you have given up ownership of the answer.
Here is the explanation for this fix: every search takes a new number. Clearing the box also takes a new number. When a response comes back, it writes to the box only if its number is still the latest. A late "cat" response finds a newer number and drops itself.
If you can say that out loud, you can defend the change in a code review, debug it at 5 p.m. on a Friday, and spot the next variation of the bug. If you cannot, you have not reviewed it. You have merged it.
Osmani adds one more habit: write some code without an agent each week. Skills you stop using fade faster than you expect, and the agent can do the work only if you can still stand behind it.
What does this mean for you?
You do not need to be a developer for most of this. The habits apply anywhere an AI hands back work that reads well.
- If you code with an agent: copy the three templates above. Make "show me the command and output" a standing instruction.
- If you review other people's AI-assisted work: ask for the guess, the definition of done, and the exact command. These are cheap to provide and expensive to fake.
- If you manage a team: ask what the checks did not cover. That one question surfaces most half-fixes.
- If you use AI for spreadsheets, reports, or analysis: the same logic holds. "The numbers add up" proves the totals match, not that the right rows were included.
None of this needs to be heavy. Five short habits, a few minutes each, applied before something ships.
Could you build a review log instead of tracking this in spreadsheets?
If your team ships AI-assisted changes regularly, the five habits generate things worth recording: the guess, the definition of done, the command that ran, the reviewer's findings, and the plain-language explanation. You could describe that as a small internal tracker to Remy, which builds and deploys full-stack apps from a plain-English description. The result would be a form with a sign-off step and a searchable history, running as your own app rather than another subscription. Remy has limits, so check the details on its site first, but a review log is a simple, well-defined tool to start with.
Frequently Asked Questions
What is Addy Osmani's main advice on checking AI agent work?
When a check goes green, ask what it proved, then ask what it did not. His article suggests writing your own guess first, defining "verified" upfront, reading the command and output before the summary, using a fresh-context reviewer, and explaining the result yourself before accepting it.
Why can a passing test still be misleading?
A test only checks what its author thought to check. In the search-box example, the test matched the author's guess about response order, so it passed on a fix that still broke when the box was cleared. A name filter on the test command also meant only one test ran.
What is a race condition?
It is a bug where the outcome depends on which of two simultaneous events finishes first. In the search box, a slow request for "cat" can finish after a faster request for "cats" and overwrite the newer results.
How do I get an AI agent to show what it actually tested?
Ask it directly. Request the exact command it ran, the full output, and a list of which tests ran and which were skipped or filtered. Ask for this before the summary, so the evidence comes first.
Does a fresh reviewer have to be a different AI?
No. A new session or a sub-agent works, as long as it sees only the requirements and the diff, not your earlier conversation or assumptions. The point is a reviewer that does not share your guess.
Useful for
How we source, write, and correct our articles. Editorial standards
Related articles

What Is the Context Sandwich Prompting Framework?

What Are AI Software Factories? The 5 Types Compared

Is Devin AI Any Good in 2026? Verdict by Task Type
