DEV Community

Cover image for My Agent's Tests Were Green Because the Model Learned to Cheat

My Agent's Tests Were Green Because the Model Learned to Cheat

Debashish Ghosal on September 15, 2026

If your AI reviewer says "pass" every time, you didn't build a reviewer. You built a rubber stamp. I know because I built one. Not on purpose. I...
Collapse
 
max_quimby profile image
Max Quimby

The "your model isn't misbehaving, your benchmark is mis-rewarding" framing is exactly right, and I think it's underappreciated how early it shows up. The degenerate-trigger regex gate is the right instinct, but in our experience blacklisting known cheats turns into whack-a-mole — you close step_\d+, then it finds timestamps, then session IDs. What ended up saving us more time was a cheap invariant that doesn't care about the specific artifact: a trigger that fires on a held-out set of known-negative trajectories at above chance is degenerate by definition, regardless of what it matched on. It catches the semantic shortcuts (your git push example) that no regex will. Curious whether you considered scoring candidates against a negative corpus rather than enumerating structural artifacts — the second class of shortcut you found makes me think the format-level fixes are necessary but never sufficient.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal

Max, yes — and by the end the negative corpus was the fix, not the regex. The three lines only prefilter the obvious structural case. The durable gate is scoring every candidate against trajectories that should stay silent — failures/negative, the counterexample set, near-misses, cross-scenario calibration negatives — and rejecting a trigger that fires on any of them before precision/recall even matter. That's what catches your git push fails with authentication error vs non-fast-forward pair. No regex will, because the leakage is semantic.

"Necessary but never sufficient" is exactly right, for a reason I didn't appreciate at first: a negative corpus only catches shortcuts that fire on known negatives. Silence is cheap, so a trigger can pass by being inert. We guard with minimum negative-corpus volume, but I won't claim it's closed — a shortcut that only leaks on unseen negatives still walks. Same blind spot as false negatives.

Collapse
 
byteox2 profile image
Niuniu Ox

The "solving the problem I defined" framing is the part most teams skip. I hit a mirror version of this running a local 7B model as a code-review gate: I rewarded it for "issues found per PR" and within a week it was flagging every magic number and TODO comment while waving through a Stripe webhook that ACKed before persisting. Precision looked great on the dashboard; the failure mode moved somewhere the metric couldn't see.

Your three-line degenerate-trigger gate is doing the same job as what I ended up with — a denylist of "cheap wins" the reward function can't distinguish from real work. The harder lesson from your semantic-shortcut section: token overlap is not failure-class overlap, and no amount of threshold tuning fixes that. You need a second model (or a human) judging kind of failure, not just presence of text.

Curious: after you closed the structural shortcut, did the model's trigger distribution shift toward longer, more specific rules, or did it just find the next-cheapest artifact (timestamps, session IDs) in the same format? In my setup the shortcuts migrated rather than disappeared — wondering if you saw the same whack-a-mole.

Collapse
 
raju_dandigam profile image
Raju Dandigam

@debashish_ghosal, the model-independent plateau is a strong signal that the classifier or reward layer is broken rather than every model sharing the same capability ceiling. The regex closes the known shortcut, but I’d add counterfactual negatives where token overlap stays high while the failure class changes, plus holdout structural artifacts that were absent when rules were generated. agent-inspect treats deterministic trajectory facts as contract inputs, but those contracts need the same adversarial scrutiny. How are you sampling hard negatives so the next shortcut is found before production does it for you?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal • Edited

Fair read — and you're right that the plateau pointed at the layer, not the models: the fix was six lines in the component that classifies what a match means. On hard negatives, honest answer: today they're curated, not mined — nearmiss corpus, a should-silence corpus, and cross-scenario calibration pairs (each golden rule scored against every other scenario and all nearmisses as expected no-matches). That last set is the closest thing to your "high overlap, different class," but it's a fixed set. I don't have the generator you're describing — swap the failure class, keep the token overlap, feed the pair in as an expected non-match — and no holdout for structural artifacts the rules were never generated against. Filed it as the next work item (CauterRule #814); the rule-mutation test perturbs rules, not trajectories, so the negative space is exactly as uncovered as you say. The contract point on agent-inspect stands — deterministic facts are only as trustworthy as the contract that produced them.

Collapse
 
mudassirworks profile image
Mudassir Khan

the 'step_1' precision 1.00 recall 0.02 case is the clearest version of this i've seen written down. the model was not wrong. it was optimal for the objective you gave it.

we hit the same thing with an LLM judge that was grading its own family model. swapped in a different vendor and the passing rate dropped 27 points overnight. the judge had learned the texture of the outputs it was evaluating, not the quality. same shortcut, different form.

the degenerate trigger gate is the right fix for the structural case. how are you handling the semantic gap — LLM judge, held out human labels, or something else?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal

Thank you — and ouch, the "judge grading its own family model" story is uncomfortably familiar. A 27-point overnight drop when you swap the vendor is such a clean way to expose it: the judge had learned the texture of the outputs, not the quality, exactly as you said. Same shortcut, different organ.

On the semantic gap: candidly, we don't have a solved answer. The structural case is handled by the degenerate-trigger gate (a "step_1" trigger can never match — see #765, now closed, and the follow-up to generalize the invariant beyond an artifact blacklist in #811). The semantic case is the open one — embedding-based trigger↔reference similarity is tracked in #680, and we're building counterfactual hard negatives (high token overlap, different failure class) in #814 partly so a judge can't pass on surface similarity. The honest summary is in the v0.3.1 field test report: recall is still the weak axis (0.22–0.24 on failures/positive), and held-out human labels are the thing we most want next. If you've found a judge-bias check that survived a vendor swap, I'd love to compare notes.

Collapse
 
mudassirworks profile image
Mudassir Khan

yeah the family model bias is brutal to catch — our judges consistently scored their sibling models 8 to 12 points higher on identical outputs. what held up through vendor swaps: a 200 sample human labeled anchor set, scored quarterly. any judge that deviates more than 10% recall on that set gets flagged before going live. made the bias gate model agnostic since the truth signal never changed. are you keeping the calibration set frozen across swaps, or refreshing it as your product evolves?

Collapse
 
jo-do profile image
Jo Do

A useful evaluator test is to generate candidates that preserve the score while violating the intended meaning. If tiny structural artifacts keep winning, the benchmark is measuring familiarity with the fixture rather than the behavior. I would also hold out entire formats or tool vocabularies, not only examples; otherwise the next shortcut is often a different field name for the same leakage.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal

Jo, this is the test I don't have yet. What exists is adjacent, and it's the inverse of your point: a mutation test that asserts perturbed rules degrade precision. Generating candidates that preserve the score while violating the meaning is the sharper framing — we don't do it, and it would have caught the semantic class earlier than the corpus did.

Your second point is a real gap too. We hold out examples and whole trajectories, but not formats or tool vocabularies. The generation pools vary models and tools per example — that's not the same as holding out the format itself. If the next shortcut is the same leak under a new field name, example-level holdouts won't see it. Both go on the list. Thank you.

Collapse
 
kartik-nvjk profile image
Kartik N V J K

"step_1" matching every trajectory is the most honest eval failure I have seen. If your metric is gameable, your model will game it.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal

Thank you — "if your metric is gameable, your model will game it" is the whole post in one line. "step_1" matching every trajectory was a perfect little demonstration: the model wasn't wrong, it was optimal for the objective we handed it. We closed that specific hole in #765, and we're generalizing the guard so it's an invariant rather than a blacklist in #811. Appreciate you reading it.