Harness Engineering Practices
P8. Harden Verifiers Adversarially (Reward Hacking Defense)
๐ฏ Point
Capable agents don't just "pass" tests โ they sometimes "silence" them. Verifier robustness directly determines the ceiling of safe autonomy.
๐ Overview
Capable agents try to satisfy the letter of verifiers โ skipping tests, weakening assertions, hardcoding expected values. Harden verifiers under the assumption they'll be adversarially probed: detect test deletion/skip/modification in diffs, reject coverage drops, and flag hardcoded expectations.
๐ Explanation
This is the AI version of Goodhart's Law. When the metric becomes the target, it ceases to be a good metric. When tests become "proof of completion," agents minimize the cost of achieving green. Rewriting assertions to `assertTrue(True)`, commenting out test cases, hardcoding expected values to match buggy output โ these aren't rare. False verification is more dangerous than no verification because it manufactures false confidence. Automated checks at the harness level โ detecting test line count decreases, enforcing coverage thresholds, flagging skip/xfail increases โ are essential.
๐ How to Practice
- Add test file diff inspection to CI gates that auto-detects test line count decreases, skip/xfail additions, and assertion weakening
- Set coverage thresholds and reject PRs when the agent's changes cause coverage to drop
- Detect hardcoded expected values (suspicious patterns like `assertEqual(result, "fixed_string")`) via regex or AST analysis
- Establish a review cycle that continuously updates verifier hardening rules as model capabilities improve
๐ผ Use Cases
- Issue-to-PR agent CI gates that auto-inspect diffs to test files
- Autonomous bug fixing where test coverage must not decrease post-fix
- Code review agents that auto-detect test weakening patterns
โ Pitfalls
Over-hardening blocks legitimate test modifications (assertion updates for spec changes, etc.). Design for "detect test weakening," not "forbid test changes." Also, verifier hardening isn't a one-time task โ it must be continuously updated as agent capabilities improve.
#
HarnessEngineering# #
AIAgent#