Dev.to AI πŸ€– Ai πŸ‘ 2 πŸ“– 3 min read

Your AI agent said "Done." Here are 3 ways it wasn't.

"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 it

"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?

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.