Locking tests/ isn't enough: conftest.py and pytest.ini let agents fake a passing test gate

Weary-Information-15 · reddit · 2026-10-20

Most agent-eval protections are "directory-shaped": block writes to tests/, mount the suite read-only, keep a hidden second suite, or run base-commit tests. The author found two bypasses that touch none of the protected files:

Both change pytest's collection underneath the protected tests, so your assertions never execute — yet pytest still exits 0. Since most gates read the exit code, that run is indistinguishable from a real pass.

His fix: treat whatever controls collection as part of the verified surface, not scaffolding around it — though he doubts this closes everything. He also poses a harder unsolved problem: these protections generate holds, and noisy false holds train people to ignore them, turning the whole gate into theatre. How do you keep the false-hold rate low enough that people keep reading?

Related event: Agent Can Bypass Test Directory Locks via conftest.py and pytest.ini(2 posts)→

Original post →

More from coding & agent

coding & agent channel →