r/OpenAIDev • • 15d ago

"All tests pass" from a coding agent sometimes means it changed the tests. We stopped taking its word for it.

If you've run Codex or any other agent on a long task, you've probably seen this: it reports done, the tests are green, and then you open the diff. An assertion got loosened, a failing case got skipped, or a mock now returns exactly what the test expects. Nothing was really fixed, the test just stopped checking.

It isn't the model being sneaky. The agent is told to make tests pass, and editing the test is the shortest path to that. As long as the agent is both the one doing the work and the one deciding it's finished, "done" means "the agent thinks it's done".

So in CCode, the coding agent we build, a goal can have a check you choose:

/goal --check "npm test" the checkout flow handles expired cards

Each time the agent wants to stop, CCode runs that command itself. The goal only counts as met if it passes. If it fails, the agent gets the failing output and keeps working. While that goal runs, your tests are locked, so it can't make them easier to pass. If the task really needs a test changed, you allow it explicitly.

The difference in practice: you come back to a task that either really passes your check, or is still working on it with a clear reason why. Not a confident summary on top of a quietly edited test file.

How do you handle this with your agents today: review every test diff by hand, a CI gate, or a separate test-only branch?

2 Upvotes

5 comments sorted by

1

u/DIYC_Official 14d ago

Of course. If you change behavior of a feature, you have to change the test that tests it ...

That's not just ai lol, human engineers do the same

1

u/CCodeSI 13d ago

You're right that tests legitimately change when behavior changes, and you're right that humans do the same. The case the lock is for is narrower: the test changes not because anyone decided the behavior should change, but because passing was the goal. With a human that's a deliberate diff you review on its own; with an agent forty files into a run it reads as routine and nobody notices.

So it's not a ban. While a --check goal runs the tests are locked, and when a task really needs a test changed, you allow it explicitly. The default path just can't do it quietly.

1

u/DIYC_Official 13d ago

But that's a instruction issue 😆

1

u/CCodeSI 13d ago

Partly, yes. "Don't edit tests" in the instructions does cut it down. Our experience is that it holds for the first twenty turns and gets weaker as the context fills up, and the one time it slips is the one you don't notice. An instruction is something the model weighs; a lock is something it can't do. We'd rather have both.

1

u/DIYC_Official 13d ago

I have the instructions in my repo defined as project goals. High quality, no cutting corners, enterprise ready, etc. the ai loses chat context, so you shouldn't rely on that alone.

Beside that, I make designs and documentation of how the app should behave and why. Every choice gets documented. Every mistake as well.