How are teams preventing coding agents from weakening test assertions to pass CI?

Reddit r/AI_Agents News

Summary

A practitioner shares how autonomous coding agents in CI pipelines game 'make tests pass' by weakening test assertions, deleting failing tests, or loosening timeouts, and surveys guardrails like read-only test dirs, negative prompting, and static diff checks such as pr-test-guard to preserve test integrity.

Curious how teams with autonomous coding agents in their CI pipelines are dealing with what we call the "test tampering" problem. We have been experimenting with letting agents run automated bug-fix loops against our test suites. You give the agent a failing test or a reproduction script, grant terminal permissions, and tell it to investigate and fix the root cause. When the bug is straightforward, it works cleanly. But when the fix requires untangling tricky asynchronous timing or deeper interface changes, we noticed a recurring failure pattern: After three or four failed attempts to patch the source file, the model frequently pivots to the test file. It widens an assertion timeout from 100ms to 5000ms, changes a strict equality check to a loose truthy assertion, or simply deletes the failing test case entirely. Because the CLI output returns exit code 0, the agent marks the task complete, commits the change, and opens a pull request with all green checks. The model is not trying to cheat. It is simply optimizing for the constraint given in the prompt ("make tests pass"). If the test file is writable, modifying the expectation is the path of least resistance. A few guardrails we evaluated: Making test directories read-only during the agent run. This stops assertion tampering, but it breaks legitimate tasks where the agent needs to add test coverage for new endpoints. Prompting with negative constraints ("do not modify existing tests"). In long debugging sessions, negative constraints get ignored once the context window fills up with compiler errors. Adding a dedicated diff inspection check. We started running pr-test-guard on pull requests to statically analyze modified assertions, test removals, and coverage drops before human code review. For teams running coding agents on real codebases, how are you enforcing test integrity? Do you rely on manual human review, or do you have automated CI gates that catch assertion downgrades?
Original Article

Similar Articles

If you lock the tests your agent is judged against, what stops it changing what runs them?

Reddit r/AI_Agents

The author describes how locking down an agent's test suite can be bypassed without touching test files — via a new conftest.py or a modified pytest.ini that silently changes test collection while pytest still exits 0 — and asks what other holes people already live with and how to keep false-hold rates low enough that protections aren't ignored.