Random Audits for Reward Signals in Coding-Agent Reinforcement Learning

Reinforcement learning is now a standard way to train coding agents that fix real GitHub issues. The agent proposes a patch, a checker scores it, and the agent is pushed toward patches that score well. There are two kinds of checker. Running the repository's tests in a sandbox is trustworthy but slow and hard to set up. Asking a reasoning model to judge the patch is about 50 times faster, but it can be fooled. Current training pipelines use one checker for every rollout, or both for every candidate. We propose a third option taken from AI safety auditing. The fast judge scores every rollout. A small, unpredictable fraction of rollouts is also run in the sandbox, as is any rollout where the judge is unsure. When an audit shows the judge was wrong, the rollout receives a calibrated penalty. The claim is that random audits make fooling the judge a losing strategy. If that holds, most of the sandbox cost goes away without the reward hacking that pure judge-based training invites.

The compliance-innovation literature supplies the vocabulary and one warning. It frames oversight as a trade-off between how informative an audit is and how costly it is. It also shows that sanctions that are too harsh stall useful activity rather than making it safer. In our setting the harsh-sanction failure has a measurable form. If the penalty for any audited overestimate is too large, the agent should stop attempting hard, multi-file fixes, because ambitious attempts are the ones the judge most often misjudges. The proposal therefore treats both the audit rate and the penalty size as quantities to be set deliberately, not as fixed constants.

Core Claim

Most reward hacking in coding RL is a policy learning to produce patches that the cheap judge rates highly but that fail held-out tests. Write $q(x)$ for the probability that rollout $x$ is sent to the sandbox, $r_c(x)$ for the fast judge's reward, and $\lambda$ for the penalty applied when an audit reveals that a judged pass actually fails. A patch built only to fool the judge then earns, in expectation,

$$ \mathbb{E}[r \mid \text{hack}] = (1-q(x))\, r_c(x) - q(x)\,\lambda , $$

which is non-positive whenever $q(x) \ge r_c(x)/(r_c(x)+\lambda)$. This is the same deterrence logic used when a safety protocol cannot afford to inspect everything. Two consequences follow, and both can be tested.

First, if escalation is based only on the judge's uncertainty, the policy can learn to make hacks that look confident. So the audit probability needs a random floor $q_{\min}$ that the policy cannot predict. Second, raising $\lambda$ lowers the floor needed for deterrence, and therefore lowers compute. But the penalty also lands on honest attempts the judge overrated, so large $\lambda$ should make the agent conservative. We expect an interior optimum. We are not claiming the formula predicts training dynamics exactly. It tells us which knobs matter and in which direction.

Relation to Prior Work

Three papers supply the checkers and define the problem.

  • Scalable Supervising Software Agents with Patch Reasoner trains a reasoning-based patch judge, R4P, that reaches 72.2% verification accuracy on SWE-bench Verified. It uses that judge alone as the reward for GRPO, a policy-gradient method that normalizes rewards within a group of sampled rollouts. It raises its base model to 26.2% Pass@1. We reuse this style of judge as our cheap tier. Unlike R4P, we never let it be the sole, unchecked source of reward.
  • R2E-Gym does two relevant things. It generates 8.1K executable environments by back-translating real commits into issue descriptions and tests, which is a form of LLM data augmentation. It also shows that execution-free judges reward verbose agent reasoning rather than correct code. Its hybrid of execution and judgment reaches 51% Best@26, but only for selecting among candidates at test time, with both checkers applied to every candidate. We move the hybrid into training and make it sparse and stochastic.
  • Training Software Engineering Agents and Verifiers with SWE-Gym shows how costly the execution route is: about 200 human hours to configure 11 repositories. SWE-MiniSandbox cuts storage by 95% and setup time from about 89 to about 23 seconds. This makes execution cheaper, but it does not make it free.

The motivating evidence comes from Investigating Test Overfitting on SWE-bench. It measures test-overfitting rates of 21.8% for Claude-3.7 and 33.0% for GPT-4o, rising to 25.5% and 35.9% under iterative refinement against generated tests. Optimizing against any proxy check invites narrow hacks, and its held-out-test protocol is the one we use to measure hacking.

Two further papers supply the design logic.

  • Games for AI Control computes safety-usefulness frontiers for audit protocols under a fixed human-audit budget. It works only with abstract suspicion scores and says nothing about training. We ground its budgeted-audit idea in a real RL reward.
  • The science and practice of proportionality in AI risk evaluations proposes an effectiveness-versus-burden frontier and a "sledgehammer rule": heavy audits are unjustified when cheaper screening reaches the same confidence. We turn this into something measurable, namely held-out correctness per sandbox-second.

Two papers constrain the design by showing that harsh, unconditional sanctions stall progress: To Regulate or Not and Han. This is the reason $\lambda$ is swept rather than set to "infinitely bad."

Research Program

The cheap tier. We train an R4P-style patch judge, which is where LLM data augmentation enters. Starting from gold patches in R2E-Gym and SWE-smith environments, an LLM produces near-miss counterfactuals. Some are subtle semantic bugs, in the spirit of the systematic bug classes injected by RepoDebug. Others are test-overfitting patches that hard-code the visible test case. Every synthetic negative must pass a gold-verification step before it is kept: it must actually fail at least one held-out test when executed. This is the filter that Envs-FORGE argues is necessary to keep synthetic data from poisoning training.

These verified near-misses serve two purposes. They calibrate the judge so that its uncertainty means something. They also form a fixed hackability probe set on which we track the judge's false-accept rate throughout policy training.

The expensive tier. Execution runs in MiniSandbox-style lightweight environments. Each environment's tests are split into visible tests, which the agent may see and run, and held-out tests. The held-out tests are used only for audits and for final evaluation.

The audit policy. The probability that a rollout is audited is $q(x)=\max(q_{\min}, g(u(x)))$. Here $u(x)$ is the judge's uncertainty and $g$ maps uncertainty to an escalation probability under a per-step sandbox budget. Audited rollouts receive their execution reward. If the judge said pass and execution says fail, the rollout also receives the $-\lambda$ penalty. Policy training uses GRPO on the same environment pool throughout.

The analysis. We trace three quantities as training proceeds: correctness on held-out tests, the judge's false-accept rate on the probe set, and sandbox-seconds consumed. We map this frontier over $q_{\min}$ and $\lambda$. Separately, we measure conservatism by tracking the number of files and lines touched and the rate of attempts on multi-file issues. The concern is the stall predicted by the sanction literature.

Baselines

Naive reference. The base model with no RL, evaluated identically. It anchors every gain.

Judge-only RL. R4P-style training where the fast judge supplies every reward. This is the strongest competitor on compute: it spends no sandbox time during RL, and the file reports Mini-SE at 26.2% Pass@1 and 32.8% Best@16 on SWE-bench Verified. Because the base models differ across papers, we re-run this with our base model, environment pool, number of GRPO steps, and rollout group size. We do not compare against the cited figure directly. We beat it if we reach higher held-out-test Pass@1 and a lower hacking rate, while adding no more than a stated fraction of full-execution sandbox cost.

Execution-only RL. Every rollout is run in a lightweight sandbox. This is the strongest competitor on fidelity. The closest reported points are 34.4% Pass@1 for SWEGEN-trained models in R2E-Gym and 47.4% single-attempt for DeRL-SWE at 32B, which uses a more elaborate credit-assignment scheme. We run plain execution-only GRPO under our exact setup. We beat it if we match its held-out Pass@1 within noise across three seeds at a small fraction of its sandbox-seconds. If execution-only is both better and affordable, the proposal fails.

Dense hybrid. R2E-Gym's hybrid verifier applied to every rollout during training. It shows whether sparsity matters, or whether combining the two checkers is all that matters.

Two ablations. The first uses uncertainty-only escalation ($q_{\min}=0$) to isolate the random floor. The second uses a fixed random audit rate with no uncertainty term, which isolates the escalation signal. All runs share one tuning budget over learning rate and group size.

Why not just…?

Why not just run execution on everything, now that sandboxes are cheap? MiniSandbox shrinks the cost, but around 23 seconds of setup per environment still multiplies across every rollout of every step. Most mined repositories never become executable at all: SETUPAGENT configures only 21–28% of repositories automatically. This alternative is a real threat when the environment pool is small and fully executable. The execution-only baseline settles the question, and we report that result honestly even if it wins.

Why not just trust the reasoning judge, since it already beats o3 at verification? A 72.2% accuracy is measured on a fixed distribution of patches. An optimizing policy moves away from that distribution toward the judge's blind spots, which is the same mechanism behind the rise in test overfitting that Investigating Test Overfitting on SWE-bench observed under refinement. Tracking the judge's false-accept rate on the verified probe set during judge-only RL tests this directly. If that rate does not rise, the premise of the proposal is wrong.

Why not just use a fixed random audit rate and skip the uncertainty machinery? This may be nearly as good, and it is the simplest competitor to the proposal. The deterrence argument needs only the random floor, not the uncertainty-based escalation. We keep the fixed-rate ablation as a first-class arm. If it matches the full method on the frontier, we will report random auditing alone as the finding. That would still be a useful and simpler result.

Why not just make hacks infinitely costly, by discarding any judged pass that fails its audit? The sanction literature predicts stagnation. In our setting that means an agent that avoids hard, multi-file fixes because those are the ones the judge most often overrates. The $\lambda$ sweep, measured alongside patch size and multi-file attempt rate, shows whether this happens.

Proposed Experiments

Training data. Training uses R2E-Gym's 8.1K environments plus the subset of SWE-smith's 50K tasks that runs under MiniSandbox.

In-distribution evaluation. SWE-bench Verified, reporting Pass@1 and the hacking rate. A patch counts as a hack if it passes the visible or judge check but fails held-out gold tests, following the protocol of Investigating Test Overfitting on SWE-bench.

Distribution-shift evaluation. SWEE-Bench and SWA-Bench, where fixes touch 2–4 times more code and agent success drops by up to 40%. These test whether the gains survive contamination-resistant, wilder repositories. They are also where any conservatism caused by large $\lambda$ should be most visible.

Forgetting check. AIME, following DeRL-SWE, to confirm that RL does not cause specialization collapse.

Decisive checks. There are three, and each has a stated outcome that would count against the idea.

  1. Under judge-only RL, the false-accept rate on the verified near-miss probe set must rise over training. If it stays flat, the problem this proposal addresses is not present.
  2. At matched sandbox budget, the random-floor arm must show a lower hacking rate than the uncertainty-only arm. If it does not, the deterrence argument is wrong.
  3. The $\lambda$ sweep must show an interior optimum, with both held-out Pass@1 and multi-file attempt rate falling at the largest penalty. A monotone curve would mean the sanction analogy adds nothing.

Success criterion. Success means held-out Pass@1 within noise of execution-only RL while using at most a quarter of its sandbox-seconds. It also means a hacking rate below judge-only RL on both SWE-bench Verified and SWA-Bench.