
Seven ways AI agents cheat on tests. Three of them got me.
My coding agent is a lot like a very eager intern who's been told they'll get a gold star when the tests go green. Not when the feature works. When the tests go green.
Spots 

My coding agent is a lot like a very eager intern who's been told they'll get a gold star when the tests go green. Not when the feature works. When the tests go green.

Most of the time those are the same thing. When they aren't, the agent will still find a way to get the star, and it gets weirdly creative about it. I don't think it's being sneaky. It's doing exactly what I asked, and what I asked for was green.
So here's the list. Three of these actually happened to me. The other four I've learned to watch for, because once the first three burn you, you start seeing the shape of the whole family. 1. It changed the assertion This is the one that started it.
A test was failing, so I asked the agent to fix it. Thirty seconds later, it was fixed. It had changed the expected value in the assertion to match whatever the broken code was now returning. Suite green. Feature still broken.
What makes this one dangerous is how innocent the diff looks. One line, in a test file. You could approve that half asleep, and I very nearly did. The tell: a fix for broken behaviour that only touches test files. If the code didn't change, nothing got fixed. 2. It decided the tests were "outdated" Same idea on a bigger scale, and this one is fully on me.
The agent needed a new library, which meant bumping another one we already depended on. Fair enough. It even adjusted some of our older code so nothing would break. Honestly good work up to that point.
Then a few tests went red. Its reasoning went something like: the library changed, so these tests must be out of date, so I'll update them. It rewrote them until they passed, and the logic underneath was now wrong.
The part that still gets me is that it told me. It was right there in the summary: "updated tests as required." I looked at a green suite, thought it looked fine, and pushed. CI caught it. I didn't.
The tell: the word "outdated" anywhere near a test change. Sometimes a test really is out of date, but I want to be the one who decides that, not the thing whose whole job right now is making tests pass. 3. It added sleep() until the race went quiet I actually respect this one a little.
We had a request going out twice. The first response came back and got handled, then the second one showed up for work that was already done, and the system panicked and marked the whole job as failed. The agent traced every bit of that correctly. Found the duplicate, explained the collision clearly, probably better than I would have at 2 am. Then it fixed it by putting sleep(1) in three places.
My coding agent is a lot like a very eager intern who's been told they'll get a gold star when the tests go green.
