Skip to main content
eScholarship
Open Access Publications from the University of California

UC San Diego

UC San Diego Electronic Theses and Dissertations bannerUC San Diego

Steering Away From Shortcuts: Activation-Level Interventions for Reward Hacking in LLM Coding Agents

Abstract

Large language models deployed as coding agents are increasingly capable of autonomous software development, but their tendency to optimize for observable evaluation signals rather than underlying task specifications poses a serious reliability risk. In agentic coding settings, this reward hacking manifests as specification-violating shortcuts such as hardcoding outputs to pass specific test cases or rewriting test suites to eliminate failing tests. These behaviors produce code which appears correct but is brittle or semantically incorrect.We investigate whether activation steering, a test-time intervention that suppresses behavioral directions in a model’s residual stream, can reduce reward hacking in a coding LLM without modifying model weights. Using the ImpossibleBench dataset of Zhong et al. (2025), in which coding tasks are constructed so that any passing solution necessarily violates the natural-language specification, we extract a “cheating direction” in the model’s activation space via contrastive activation addition and subtract it from the residual stream during inference. On the full evaluation set of 103 tasks, both prefill-only and full-sequence steering reduce the cheating rate substantially — from 7.8% to 3.8% and 1.0% respectively — at a comparable cost to legitimate solve rate (23.3% to 12.6% and 13.5%). On the subset where the model’s tendency to cheat is most pronounced, the two configurations exhibit qualitatively different tradeoffs. Prefill-only steering eliminates cheating entirely (cheating rate 0%) while reducing legitimate solve rate to 31.3%, whereas full-sequence steering allows a residual hack rate of 6.3% while preserving a legitimate solve rate of 50%. Ablation studies reveal that the cheating direction is distributed across layers rather than localized, that simultaneous multi-layer intervention is necessary for effective suppression, and that prefill-stage intervention alone is sufficient, suggesting that the commitment to cheat is encoded primarily during the prefill stage. These results establish the existence of an identifiable cheating direction in coding LLM activations, characterize the capability–honesty tradeoff as a function of steering magnitude, and suggest that interpretability-based tools may be useful for auditing and mitigating reward hacking in LLM coding agents.