Passing tests prove little when code and tests share an author
Code and tests can agree on the same wrong assumption. We'd never let an engineer verify their own work alone, and AI agents shouldn't either.


When the same author writes the code and the tests, a green build doesn’t tell you much. If they get something wrong, the mistake ends up in both places and the tests pass anyway.
None of this is new. In a team, we’d never let an engineer be the only one to check their own work, which is why we have code review.
What’s changed is how often it happens. An agent can write the code, make up the test data and test against it in one sitting, quickly and confidently. It’s also easy to accept an agent’s green build as done in a way we’d never accept from a person. With AI writing more of our code, verification is now the slow part, and it has to come from somewhere the author didn’t control.
What went wrong
We ran into this three times in one week, and each one looked a little different.
The first was on a task board in an internal tool. An agent was adding custom columns, and its frontend expected a status name the API never sends. Its test data used the same made-up name, so all 65 tests passed. In the real app, the Todo column would never have appeared and every column reorder would have been refused.
The second was about access. A change gave a record’s owner access whenever the owner field changed, which sounds harmless until you realise an ordinary member could make themselves the owner and pick up access they shouldn’t have. Every happy-path test passed, because none of them tried to misuse it.
The third was performance. A user said card moves felt slow, so we made the interface optimistic and added indexes, fewer queries and a query-count test. Everything passed and the board felt instant. Once it was deployed, though, a card move still took four seconds, because the test used cards that had never run and so never hit the expensive lookup that real cards do.
In each case the tests showed the code did what the author believed. None of them checked whether the belief was right.
How we caught it
Each fix came from evidence outside the author’s own checks, which is the same rule we already hold engineers to.
A separate reviewer agent caught the board bug before a pull request was opened. Instead of reading the spec, it checked the frontend against the API’s real response and the API’s own code.
A security review caught the access bug before release. We moved the grant behind the same permission check as a direct grant, and added a test where a low-privilege user tries to trigger it.
For the slow board, we stopped trusting the test and timed the deployed endpoints. Batching the lookup halved the board load, and it showed us that lookup wasn’t the only cost.
The board bug was caught by another agent, so AI can do a lot of this checking as well as the writing, as long as it starts with fresh context and something real to check against.
What I do now
None of this means trusting AI less. It means building checks that let us trust it more, matched to the risk, and fixing the system around the agent when something slips through.
Whether a person or an agent wrote the change, I now build test data for other services from their real output rather than from memory. I treat “all tests pass” as weak evidence when one author wrote both the code and the test data. Someone else reviews the work with fresh eyes, pointed at the real code on the other side, and there’s one end-to-end pass against the real system before the pull request goes up. For performance, the test data has to look like production, and a speed fix isn’t done until the deployed numbers show it. Anything that controls access goes through a security review that actively tries to break it.
So when a build goes green, the first thing I ask is where the expected values came from. If the answer is the same person, or the same agent, that wrote the code, I don’t count it as verified yet.
