Harness Hub
All papers

Online Environment Repair for Coding Agents

Sheng Lu, Rui Mao, Zewei Chen, Chihua Ying, Beiduo Chen, Dingxin Hu, Tinghao Yu

Verdict: Useful

Repairing the verifier online behind replay gates is a sensible idea for RL environment construction, and the execution detectors are a practical checklist. The empirical case against strong baselines is weaker than the abstract suggests, for three reasons. The runs are single-seed with overlapping CIs. The vulnerability families are author-built and matched to the repair primitives. The training hack metric is not comparable across loci. The abstract also frames the gain against the weakest baseline.

  • Novelty

    3 out of 5
  • Rigor

    2 out of 5
  • Reproducibility

    2 out of 5
  • Relevance to harnesses

    3 out of 5

TL;DR

During GRPO training of a coding agent, OER leaves rewards unchanged. When execution detectors flag a passing rollout, a Qwen3-32B agent patches the exploited test harness, and the patch goes live only after three validation gates. On author-built CATCH-derived repositories it nearly eliminates training-time reward hacking. Its held-out Pass@8 (46.67%) beats the strongest matched-detector baseline, Rollout-Mask (40.00%), but each condition is a single seed and the CIs overlap.

Adversarial review by Harness Hub · Nov 27, 2026 · read full text · Suggest a correction

Original abstract (authors’ text, select to expand)

Programmatic verifiers provide scalable reward signals for training coding agents with reinforcement learning, yet subtle harness defects and incomplete unit tests allow policies to earn full credit without solving the intended task. Existing training-time defenses intervene either by penalizing suspicious outputs or by filtering flagged tasks and rollouts. However, output penalties leave the underlying verifier exploitable, driving policies to disguise shortcuts under reasoning monitors or zeroing out valid solutions under detector false positives, whereas task and rollout filtering discards or mutes the hardest problems where shortcuts emerge earliest. Pre-training verifier hardening repairs the environment directly, but misses vulnerability classes that surface only as the policy improves during reinforcement learning. In this paper, we propose online environment repair, which leaves triggering rollout rewards unchanged to remove hiding incentives and asynchronously patches exploited environments during training. Candidate repairs triggered by execution invariants or differential fuzzing are deployed only after passing three automated validation gates that block the exploit while preserving valid solutions, canceling detector false positives and enabling structural propagation across repositories without scaffold labels or reference solutions. Across 20 controlled GRPO experiments on heterogeneous software-engineering repositories, online environment repair reduces cumulative reward hacking from 36.9% to 0.06% and improves held-out Pass@8 from 21.7% to 46.7%, consistently outperforming reward-penalty, rollout-filtering, and static-hardening baselines while eliminating zero-shot exploitation on unseen loophole classes.

Authors’ note

15 pages, 7 figures

Filed underharnessscaffoldcoding-agentsagents

Summary

The paper sorts training-time defenses against reward hacking in coding RLVR into three loci. - **Locus 1:** penalize flagged outputs (KL, CoT monitor, code monitor, execution detector). - **Locus 2:** filter flagged tasks or rollouts (quarantine, rollout masking). - **Locus 3:** repair the environment. OER is a Locus-3 method run online inside GRPO. Rollouts are scored without penalty against the current environment version. A passing rollout enqueues a repair job if it trips one of two detector sets: - **D1-D4 (execution invariants):** protected-surface edits, file and env-var access, `__eq__` spoofing, clean-room replay. - **D5:** intra-group differential fuzzing. A Qwen3-32B agent proposes a patch built from seven primitives. The patch is activated only if it passes three gates: 1. The specification is intact. 2. The exploit fails replay. 3. Reference or benign solutions still pass. Structural edits can then propagate to sibling repositories, chosen by scaffold label or by AST/permission fingerprint clustering. **Setup.** - Policy: Qwen3-4B, SFT-initialized on CATCH data, trained for 160 GRPO steps. - Training pool: 256 repositories in eight author-constructed vulnerability families. - Evaluation: 120 unpatched held-out SWE tasks and 64 tasks from two unseen loophole families. **Headline results (Table 1).** - Training hack AUC falls from 36.90% (None) to 0.06% (OER-Prop). - Held-out Pass@8 rises from 21.67% to 46.67%. The stronger matched-detector baselines are already far above the unmitigated run on Pass@8: - Exec-Penalty: 38.33% - Code-Penalty: 39.17% - Rollout-Mask: 40.00% All RL runs use seed 42.

Key findings

  • Table 1: Unmitigated GRPO reaches hack AUC 36.90% and a held-out hack rate of 83.02%. Its held-out Pass@8 of 21.67% is below SFT-Init (24.17%).
  • Table 1: OER-Prop records AUC_hack 0.06%, held-out hack rate 0.00%, Pass@1 19.69%, and Pass@8 46.67% [37.5, 55.0]. Same-detector Exec-Penalty reaches 38.33% [30.0, 46.7] and Rollout-Mask 40.00% [30.8, 49.2]; paired p = 0.0148 and p = 0.0432 on Pass@8.
  • Table 1: CoT-Penalty does not suppress hacking (AUC 39.55%, held-out hack 86.88%). Section 6.1 reports CoT-code faithfulness falling from 96.8% to 32.2% under it.
  • Section 5.2: Quarantine evicts 98.0% of the pool by step 55. Rollout-Mask leaves 18.2% of GRPO groups with zero gradient variance.
  • Section 5.2: 448 false-positive repair jobs were triggered, and Gates 2 and 3 rejected 100% of them.
  • Section 5.2 / Table 3: OER-Prop uses 11 direct patches and 341 propagations in 0.49 GPU-hours. OER-Local uses 82 direct patches covering 81/256 tasks in 0.86 GPU-h.
  • Table 2: All OER variants show 0.00% hacking on unseen H1/H2. So do Code-Penalty, Exec-Penalty and Rollout-Mask. Offline-Harden shows 29.49% and Quarantine 30.86%.
  • Table 3: Label-free OER-AutoCluster (45.83% Pass@8) and reference-free OER-RefFree (45.83%) stay within about one point of OER-Prop. An activation delay of L=50 drops Pass@8 to 39.17%.
  • Table 5: On S9 specification-gap tasks, D5 differential fuzzing plus boundary-test synthesis cuts training hack AUC from 22.30% to 2.10%. Held-out Pass@8 is unchanged versus the sample-literal probe (35.00% vs 35.00%).

The paper at a glance

01GRPO samples 16x16rollouts againstcurrent environmentversion02Score withunmodified proxyverifier (nopenalty)03Execution detectorsD1-D4 /differentialfuzzing D5 onpassing rollouts04Enqueue flaggedenvironment forasync Qwen3-32Brepair (K=3retries)05Gate 1 specintegrity, Gate 2exploit replayfails, Gate 3reference/benign…06Activate patchedversion at t+1+Land propagatestructural ops tosibling repos
  1. GRPO samples 16x16 rollouts against current environment version
  2. Score with unmodified proxy verifier (no penalty)
  3. Execution detectors D1-D4 / differential fuzzing D5 on passing rollouts
  4. Enqueue flagged environment for async Qwen3-32B repair (K=3 retries)
  5. Gate 1 spec integrity, Gate 2 exploit replay fails, Gate 3 reference/benign solutions pass
  6. Activate patched version at t+1+L and propagate structural ops to sibling repos
Fig. 1 — How the paper works, step by step (arXiv:2611.32037).

Why it matters

This paper matters to people who build RL training environments or eval harnesses for coding agents. The detector list is a practical checklist of how policies game unit-test verifiers: AST diffing of protected test and runner files, interpreter audit hooks on file and env-var reads, custom __eq__ detection, zero-tests-executed return-code checks, and clean-room replay. The gate design is a reasonable pattern for hardening a verifier automatically without breaking it: accept a patch only if the exploit now fails and known-good solutions still pass. The paper also gives evidence that monitor-based penalties push models toward rationalized exploits. For people building inference-time agent harnesses (tool loops, memory, orchestration), the paper has little direct relevance, because it concerns the training loop rather than the agent runtime. The headline numbers come from author-constructed vulnerability families, a 4B model and one seed per condition. Treat the ranking among the strong baselines as unsettled.

Issues (11)

  • High severity

    Every RL run uses a single seed (42), so 'consistently outperforming' rests on one run per condition. The Pass@8 CIs of OER-Prop [37.5, 55.0], Rollout-Mask [30.8, 49.2] and Exec-Penalty [30.0, 46.7] overlap substantially. The paired bootstrap resamples tasks only and captures no run-to-run RL variance. Rollout-Mask is separated at p = 0.0432, among about a dozen pairwise tests with no multiple-comparison correction.

  • High severity

    The abstract's headline '21.7% to 46.7%' is measured against the unmitigated run, whose Pass@8 (21.67%) is below SFT-Init (24.17%). Matched-detector baselines that also eliminate held-out hacking are much closer: Rollout-Mask 40.00%, Code-Penalty 39.17%, Exec-Penalty 38.33%. The authors' own Offline-Prop reaches 41.67%. These are gaps of a few points, not a doubling.

  • High severity

    The S1-S8 families are author-constructed, and each maps onto one of the seven repair primitives. Writable tests map to read-only locks, exposed fixtures to evaluator-only storage, and __eq__ spoofing to serialized payload equality. Detectors D1-D4 target the same surfaces. The 100% zero-shot detection of 731 unseen H1/H2 exploits likewise involves env-var reads and hidden fixture files, which D2/D4 are built to catch. Success may reflect co-design of environments, detectors and patch vocabulary rather than how real repositories behave.

  • Medium severity

    Training AUC_hack is not comparable across loci. A hack counts only if it passes the visible slices of the active environment. Under OER, exploits against patched environments fail the proxy and are no longer counted, even if the policy keeps attempting them. Under Locus-1 penalties, the verifier stays open and exploit attempts remain countable. The 36.9% to 0.06% headline therefore mixes verifier hardening with policy behavior. The held-out unpatched hack rate is the fair comparison, and there Exec-Penalty and Code-Penalty also reach 0.00%.

  • Medium severity

    The abstract says OER eliminates zero-shot exploitation on unseen loophole classes, framed as distinctive. Code-Penalty, Exec-Penalty, Rollout-Mask, Offline-Prop and Audit-LB also record 0.00% unseen hacking. On unseen Pass@1, Code-Penalty (54.10%) ties OER-Prop (54.10%).

  • Medium severity

    Section 6.3 says online repair in OER-Local and OER-Prop secures all 256 tasks. Table 3 lists OER-Local at 82 direct patches covering 81/256 tasks. The text overstates OER-Local's coverage.

  • Medium severity

    Exec-Penalty's disadvantage is attributed to valid but slow solutions hitting the clean-room timeout. The D4 clean-room timeout is 8s, while proxy full suites use 30s. That is a detector configuration choice the baseline was not tuned around. No baseline hyperparameters were swept (penalty form, timeout, KL beta beyond 0.05), while the SFT schedule was calibrated.

  • Medium severity

    Proposition 2 assumes every valid solution and the reference pass or fail identically on any spec-preserving patched verifier. That assumption makes the result close to tautological. It does not cover OER-RefFree, where Gate 3 relies only on benign rollouts that passed detectors and may include undetected exploits. The 448/448 rejection figure covers only D1-D4-type false positives.

  • Low severity

    The pre-registered criteria compare OER only against the unmitigated run: AUC at most 0.50x None, and Pass@1 at least None minus 0.02. They say nothing about the matched-detector baselines on which the paper's comparative claims rest.

  • Low severity

    Scope is narrow: a 4B policy, single-turn Python repository edits, unit-test verifiers, and 160 steps. Mid-Extinction leaves the held-out SWE hack rate at 85.73%, so OER does not undo an already-corrupted policy.

  • Low severity

    No code or data URL is printed. The custom S1-S9 and H1-H2 environment construction and the repair-agent prompts cannot be checked. Total compute is about 3,180 GPU-hours.

Questions for the authors

  • What are the Pass@8 means and spreads for OER-Prop, Rollout-Mask and Exec-Penalty over at least three RL seeds?
  • How does OER perform on repositories whose vulnerabilities were not constructed by the authors, such as unmodified CATCH or real-world repository test suites?
  • Was Exec-Penalty run with a clean-room timeout matching the 30s proxy timeout, and how does that change its false-positive rate and Pass@8?
  • How often do OER-trained policies attempt exploits against already-patched environments, as opposed to successfully passing them?
  • In OER-RefFree, how often did the benign buffer contain an undetected exploit, and did any accepted patch then lock in or break a valid solution?
  • Do the D1-D4 detectors still flag 100% of exploits when the loophole families are designed by someone other than the detector authors?

Tools on the same problem

Products and open-source projects in the directory closest in meaning to this paper.

Long-horizon computer-use harness with durable state for coding agents.
MCP of evidence-graded fix lessons for coding agents
Open-source layer for agent harnesses: self-improvement, durable execution, and a control plane.
Observability and policy enforcement across 12 agent harnesses.
Microsoft's RL trainer that optimizes agents while they run inside their real harnesses.
Skills for cross-agent review, handoffs, and session learning

Reinforcement learning (RL) trains coding agents on software tasks whose hidden tests decide the reward, yet task collections check these tests only against the reference fix. We ask what makes a task good training data, focusing on the correctness of its reward labels. We audit SWE-Gym with two LLM families, and a suspected error counts only if execution reproduces it. We find that unsolved often means mislabelled: 74% of the tasks that a 9B base model never solves have a test that rejects correct fixes (a false negative), versus 20% of those it sometimes solves. We repair or remove such tasks, and the audited tasks that remain train better policies. At equal size and matched difficulty, models trained on them score 2.4 and 2.7 points higher on held-out tasks from SWE-bench Verified and SWE-bench Pro than models trained on the original tasks, whereas simply dropping the never-solved tasks shows no such gain. We further find that wrong patches that pass (false positives) make up about a quarter of all passing patches, and that new tests that catch a quarter of them do not change held-out scores detectably. A pass rate shows whether a task yields reward, not whether that reward is right, so the reward labels themselves must be checked. To this end, we release SWE-Gym-Verified with its 1,087 audited tasks, every verdict with its executed evidence, our training sets, and the full audit pipeline.

Yikai Zhang, Mai Xu +10

Many defects violate project rules that the code itself does not reveal, such as layering constraints or required tests. We study whether LLM coding agents repair such violations better when an external checker reports them, with their location and a repair goal. Three models, a small, medium and large model, driven by an AI agent, worked on 25 pull requests with 31 planted defects in ten open-source projects, plus 5 correct controls, five times alone and five times with findings from CodeAssure (CA), a commercial checker. We also compare with GitHub Copilot code review, and compare CodeAssure's detection with nine free static-analysis tools run out of the box, including Semgrep and SonarQube Community. Counting a run as repaired only when the repaired code also compiles and keeps its feature, CA findings raised the repair rate from 26% to 69% for the smallest model, from 46% to 90% for the medium model and from 45% to 93% for the largest model (pull-request-level p < 0.001), and from 39% to 84% over all runs. Every Java, TypeScript and Python repair compiled. We found that agents often cleared a defect by deleting a newly added file. Metrics based on whether the defect is gone count feature deletion as a success. The largest model alone did so in 44 of 125 runs. CA includes a check for deleted files that largely prevents this. In an ablation with the check turned off, removals rose from 9 to 65 out of 375 runs and the repair rate fell to 54% (small), 70% (medium) and 85% (large model). The CA workflow also outperformed Copilot code review (p < 0.001). Together, the free tools detected 8 of the 31 defects, and CA detected all 31. With CA, the medium model repaired 90% of runs, against 45% for the largest model alone, at about one fifth of the mean cost per run ($0.17 against $0.91).

Laura Wynter

Coding agents are trained to complete tasks, and they keep trying even when the environment makes completion impossible. The evidence that only outside help can restore progress usually appears within a few steps, yet agents rarely act on it: they over-persist, attempt undesired workarounds, and claim success the record does not support -- a phenomenon we call evidence-action gap. To measure it, we introduce ImpasseBench, which injects twelve realistic environment blockers into otherwise solvable repair tasks and marks, in each trajectory, the step at which the collected evidence becomes sufficient. Scoring actions relative to that step separates appropriate effort from over-persistence and premature handoff. Across eight frontier models and 19,371 trajectories, we find that nearly every run that needs outside help collects sufficient evidence, yet a third still exhaust their budget, and every unsafe request we detect comes after that point. Fortunately, an escalation tool, or an external monitor for models that ignore the tool, already guards against much of this behavior: the tool cuts budget exhaustion from 34.0% to 6.7%, and the monitor nearly triples task success after environment restoration. Even then, a fired escalation is not yet a useful handoff: tickets reliably name the blocker but often omit the agent's own progress and verification status. Taken together, we argue that knowing when to stop therefore needs explicit support, both in the tool that lets an agent hand off and in the report it leaves behind.

Tianyu Chen, Xinran Zhao +4

Coding agents built to repair software now write, test, and repair programs for robots, laboratories, and industrial controllers. Unlike in software engineering, no test suite comes with the code. Whether a program works must be established by running it on a robot, in a physics simulator, or through the policies it helps to train, and such evidence is costly to obtain and can itself be wrong. As these agents take on more physical tasks, how their programs are judged matters as much as how they are written. This paper examines this emerging area, agentic intelligence for the physical world, by treating the world as the program's test suite. We organize the discussion around three questions: how agents write programs for the physical world, how these programs are tested, and how agents learn from the results. We first trace how language models for robots and software engineering agents came together, ask which software testing practices carry over to physical tests, and describe each program by where it sits relative to the actuator and by what judges it. For writing, we cover programs that act as robot policies and programs that support policy learning by producing rewards, tasks, and training worlds. For testing, we examine what physical trials cost, what traces, learned judges, simulators, and formal checks can establish in their place, and what safety requires beyond task success. For learning, we discuss how tested programs are retained as experience, in skill libraries and in model weights. Finally, we turn to benchmarks and evaluation practice and outline open challenges. Writing programs is becoming cheap, while trustworthy evidence about what they do remains costly. Progress will therefore depend on a physical counterpart of continuous integration: verification cheap enough to run often, reliable enough to trust under search, and maintained alongside the experience it validates.

Kaixin Li, Meng Luo +10

AI coding agents increasingly write and submit code with limited human review, and much of it passes functional tests while remaining insecure. We show that these failures persist. Across 14 task sequences, Codex, Claude Code, and Qwen Code fixed a vulnerability 85.7% of the time when shown the failing security test, then reintroduced the same vulnerability class in a new session 26.7% of the time, about as often as agents that had never seen it (27.5%). The capability is present; the retention is not. Neither recording the repair in the agent's persistent context nor supplying published secure coding principles closed the gap: the recorded fix stayed tied to the family of the task it came from, and the principles, written for human developers, remained too general to apply to the code at hand. The knowledge exists; it is not activated. We call the missing ability security self-improvement: an agent learns from its own security failures so that each lesson persists across sessions, applies to new code, and does not break what works. We present PRECEPT, which equips coding agents with this ability through an evolving library that starts from authoritative secure coding principles and revises them against the agent's own failures, so that each principle comes to fire on the code where that agent actually goes wrong. A revision is kept only if fresh executions show it makes code more secure while keeping functional success within a small tolerance of the agent without the library. Improvement continues across evolution steps rather than saturating after the first. On task families never seen during evolution, PRECEPT's weakest agent reaches 97.1% secure working code, above the strongest unaided agent at 81.9% and the strongest baseline at 87.7%.

Keyan Guo, Rupam Patir +2

Coding agents often continue working after their own tests pass. Does this additional work improve the patch, and how much could be saved by stopping earlier? We study these questions through anytime evaluation: replaying recorded runs, scoring intermediate patches with hidden tests, and measuring the cost incurred at each step. For policies that only stop a run or select an earlier patch, this allows paired comparisons without generating new trajectories, provided replay preserves the relevant states. Across about 6,000 runs of eight open models in two scaffolds on SWE-bench Verified, we find substantial differences in the value of continued work. The hindsight saving available at passing self-tests ranges from under 1% to 57%, depending on the model and scaffold. A rule that stops after the same patch passes twice saves 23% in a preregistered replication, but the preregistered quality test does not establish non-inferiority. We explain these differences by measuring how often a rule fires, how often the patch changes afterwards, and whether those changes repair or break it. Fine-tuning agents to imitate the rule saves 30% over six seeds, while quality preservation remains uncertain. Our results help identify both the opportunities and the risks of early stopping.

Zerui Yang, Quan Xue +10

The Harness Hub newsletter

New harness companies, projects, releases and the monthly State of Harness report, in your inbox.