Skip to content
Preprint

LEGO-RL: Harness-Native Reinforcement Learning for Coding Agents

Aug 2026 · 3 citations · 36 references
Computer Science

Abstract

Reinforcement learning for coding agents increasingly relies on long-running agent harnesses to manage tool integration, repository contexts, and execution feedback. However, the native execution environments of these harnesses are inherently misaligned with policy-gradient training: environmental crashes and reward hacking corrupt outcome signals, while train-inference discrepancies decouple rollout behavior from policy updates. To address this, we present LEGO-RL, a framework that bridges native coding-agent harnesses with scalable policy-gradient optimization without modifying their internal control flow. LEGO-RL is built upon three pillars: (1) faithful optimization via in-process LLM proxying that captures raw generation streams for token-level alignment and robust trainer-side log-probability recomputation, even under harness-side compaction or re-serialization; (2) reliable execution via scalable sandbox orchestration featuring image caching and stage-wise defenses to mitigate reward hacking; and (3) observable training through an integrated plugin that automates validation and monitoring, paired with a Live UI for granular trajectory diagnostics. We evaluate LEGO-RL by training the sparse MoE model Qwen3.5-35B-A3B with GSPO across three native coding-agent harnesses. LEGO-RL improves Qwen3.5-35B-A3B across OpenHands SDK (64.0% to 70.4%), Claude Code (62.4% to 68.2%), and OpenCode (57.2% to 66.6%) on SWE-bench Verified, while maintaining a rollout-training probability correlation above 0.99.

View source

Similar papers

#machine learning Preprint Jul 2026

Learning to Control LLM Agent Harnesses with Offline Reinforcement Learning

Large language model (LLM) agents are usually improved by changing prompts, models, or hand-written workflows, while the execution harness around the model is treated as fixed infrastructure. We argue that this harness is itself a learnable control layer. We formalize harness operation as a finite-horizon Harness MDP,...

Haiwen Yi, Xinyuan Song · 1 citation
Preprint Aug 2026

ClawGym II: Exploring Black-Box RL on Agent Harness

This work presents a unified black-box RL framework for stable and scalable optimization of general agents through complex harnesses, supporting unified training across heterogeneous execution systems.

Hua-Tong Song, Fei Bai, Ming Yang et al. · 2 citations
#machine learning Preprint Aug 2026

EvoHarness-RL: Learning Self-Evolving Runtime Harness for Long-Horizon LLM Agents

EvoHarness-RL is introduced, which exposes Belief, Progress, and Experience (BPE) as policy-facing harness state and reveals two key dynamics: harness annealing, where training internalizes recurring harness-use patterns into the model policy and shifts the agent from frequent harness calls toward selective external-st...

Xuying Ning, Dongqi Fu, Tianxin Wei et al. · 0 citations
Preprint Aug 2026

Efficient Reinforcement Learning for Long-Horizon Tool-Use Agentic Tasks

SINKFLEX-RL, a modular training system for RL in dual-control tool-use environments that combines a Gymnasium-compatible environment wrapper, a VERL-style rollout dataflow, group-relative policy optimization without a separate value model, and a sink-aware FlexAttention path designed to preserve model-specific sink sca...

Zelei Cheng, Amritansh Mishra, Sambit Sahu et al. · 0 citations
Preprint Aug 2026

Harness-R1: Learning to Edit Executable Runtime Harnesses from Agent Failure Trajectories

This work introduces Harness-R1, the first method, to the authors' knowledge, that makes failure-conditioned, lifecycle-wide editing of an existing executable runtime a learned capability, and post-trains a dedicated harness engineer with online reinforcement learning so that its edits are optimized for the realized ta...

Shuai Shao, Kangning Zhang, Qingyao Li et al. · 10 citations · ⚡2
Preprint Jul 2026

Branching Policy Optimization: Sandbox-Native Language Agent Reinforcement Learning

BPO is instantiate as Branching Policy Optimization (BPO), a sandbox-native RL algorithm that adaptively snapshots the sandbox at high-entropy decision points along a backbone trajectory, and proves this estimator is unbiased and has strictly lower variance than the trajectory-level baseline, with the reduction equal t...

Bowei He, Yankai Chen, Xiaokun Zhang et al. · 1 citation

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.