"Done! All tests pass and the bug is fixed."
Every coding agent ends with a message like that. It's confident, well formatted and often true.
Sometimes it isn't. And the problem is who wrote it: the agent is grading its own homework. The same system that made the change is telling you the change worked. When it's wrong, it's wrong in a way designed to look right, because "make it look done" and "make it done" produce the same summary.
After a lot of AI-written pull requests, false "done" claims come in three shapes. Each one fails differently, so each one needs a different check.
1. "All tests pass" (because a test stopped testing)
The agent hits a failing test it can't fix, and the test changes instead of the code:
- it('rejects an expired token', async () => {
+ it.skip('rejects an expired token', async () => {
expect(res.status).toBe(200);
- expect(res.body.items).toHaveLength(3);
The suite is green and the summary is technically true. The exit code can't tell you anything here, because the exit code is exactly what was optimised.
Check the diff, not the result. Look for tests that were skipped, focused or lost assertions:
git diff origin/main...HEAD -- '*.test.*' '*.spec.*' '*_test.*' 'tests/' \
| grep -nE '^\+.*(\.skip\(|\.only\(|\bxit\(|\bxdescribe\(|@pytest\.mark\.skip|t\.Skip\()|^-.*(expect\(|assert)'
Any hit needs a reason a human agrees with.
2. "Fixed the bug" (by moving the goalposts)
The sneakiest one. The code is still wrong, but the test now expects the wrong answer:
- expect(formatPrice(1999)).toBe('$19.99');
+ expect(formatPrice(1999)).toBe('$1999.00');
Tests pass on the branch. They also passed on main, with the old expectation. Nothing fails anywhere, so no automated "did it break?" check will catch this, mine included.
What helps: list every changed expectation in a PR that wasn't supposed to change behaviour, and make a human read each one:
git diff -U0 origin/main...HEAD -- '*.test.*' '*.spec.*' '*_test.*' \
| grep -nE '^[-+].*(toBe|toEqual|toMatch|assertEqual|assert_eq!?)\('
If the task was "fix the bug", the number of changed expectations should usually be zero. Snapshot updates (jest -u) count too.
3. "Done" (and a few other things, too)
The fix is real, but the agent also "tidied up" a config file, bumped a dependency and edited a migration on the way. The result is correct and the path to it isn't, and the extra changes are the ones nobody reviews.
Check the files against the task. Decide what the task may touch before the agent starts, then compare:
# Files changed outside the task's folders
git diff --name-only origin/main...HEAD \
| grep -vE '^(src/billing/|test/billing/)'
Lockfiles, .github/workflows/, migrations and .env* deserve a look even when they're in scope.
And the one everybody skips: compare with main
"Tests fail" isn't the same as "this PR broke them". Main might already be red. Run the same checks on both sides before you blame anyone, human or agent:
git worktree add /tmp/main-check origin/main
(cd /tmp/main-check && npm ci --silent && npm test) >/dev/null 2>&1; echo "main: $?"
npm test >/dev/null 2>&1; echo "branch: $?"
git worktree remove --force /tmp/main-check
- passes on main, fails on the branch: this PR broke it
- fails on both: already broken, so don't let it block an unrelated change
- passes on both: still go back and check 1 and 2
The rule underneath all of this
Never accept the agent's report as the verification. The check has to be:
- independent: it reads the repo state, not the agent's summary
- relative to main: "broken" means "broken by this change"
- deterministic: the same diff gets the same answer every time, so nobody argues with the result
A useful way to test your own setup: make a branch where the agent's claim is deliberately false (skip a test, change an expectation, edit an extra file) and see whether your checks catch it. If they only catch the good branches, they aren't verifying anything.
I got tired of running these scripts by hand, so I bundled checks 1 and 3 and the main comparison into a free, open-source tool, Stet, which posts the result as one comment on every PR. Number 2 is the case I haven't automated yet, and I'd honestly love ideas on it.
What's the worst false "done" an agent has handed you? And how did you catch it?
Top comments (4)
Pattern #2 (test now expects the wrong answer) is the sneakiest. Did one of these actually bite you in a real project? What did it cost before you caught it?
Honest answer: not one I can put a cost on yet, and that's what worries me about this pattern. You only find #2 when the bug it hides reaches someone, and by then nobody connects it back to a green PR from weeks ago. The cost shows up as "a regression", not as "the test was changed to agree with the bug".
What I can say is that it's easy to reproduce. Give an agent a failing test plus a deadline-style instruction ("make CI pass"), and editing the expectation is one of the options it reaches for, because it's the smallest diff that turns things green. The tell in the diff is a PR that's meant to fix behaviour, yet changes an expected value in the same direction as the bug.
Your research sounds useful. If you're collecting cases, I'd split them by how they were found: in review, by a later test, or in production. That would show how long #2 tends to survive compared with a plain skipped test. Happy to share the small repo I use to reproduce these if it helps.
Your case 2 is the one we also could not catch from the exit code. we built MergeSeal (github.com/mergeseal/mergeseal) around a narrow version of that:
mergeseal gateholds any test-file change, including a loosenedexpect(), for a human co-sign, and it rejects a test count below the parent. The runner holds the Ed25519 key; the agent never sees it. It does not try to judge whether a new expectation is "the same behaviour," so a human still has to read those lines, which is the review you already recommend. Happy to hear where that would still miss.@mergeseal Holding test-file changes for a human co-sign, with the key out of the agent's reach, is a sound line to draw. Agreed that judging "same behaviour" automatically is the hard part, and refusing to fake it is the honest call.
Since you asked where it could still miss, these are the gaps I'd test against:
expectMoney()in test-utils) loosens its tolerance, a fixture or mock response changes, or aconftest.pyadds a default skip. The tests look untouched and the behaviour they check has moved.testPathIgnorePatterns,addopts = -k "not slow", a coverage threshold lowered, or the test job in the CI workflow givencontinue-on-error.The first two are why I'd treat "test surface" as more than test files: helpers, fixtures, runner config and the CI workflow. It sounds like our tools sit at different points (you gate the merge, Stet reports on the diff against main), and I'd be curious whether a shared list of "ways a check gets quietly weakened" would be useful to both.