cs.AIAug 18, 2026

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

Authors: Yiming Du, Yuxin Jiang, Tao Yuan, Jianbo Dai, Shaowei Wang, Jierun Chen, Chaofan Tao, Xianzhi Yu, 

Organizations: Huawei Technologies Co., Ltd · The Chinese University of Hong Kong

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.

Figures & tables

Appendix figures & tables9 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Self-Evolving Coding Agents via Harness-Policy Optimization

    Oct 16, 2026Zhepei Wei, Wenlin Yao, Baolin Peng +5AI Coding AgentsAgent Harness Optimization

  2. Agent Lightning v1.0: Towards Harnessed Agentic RL

    Aug 18, 2026Zhiyuan He, Siwei Zhang, Zhiwen Zhou +7Agentic RLLLM Agent Training

  3. Multi-Harness Reinforcement Learning for Coding Agents: Training Gains and Harness Dependence

    Sep 3, 2026Chenqian Le, Jiayi Cheng, Qijia He +3RL for Code GenerationGroup Relative Policy Optimization