LEGO-RL Improves Reinforcement Learning for Coding Agents.

Yiming Du, Yuxin Jiang, Tao Yuan, Jianbo Dai, Shaowei Wang, Jierun Chen, Chaofan Tao, Xianzhi Yu, Lifeng Shang, Kam-Fai Wong, Xiaohui Li, Haoli Bai· August 19, 2026 View original

Key takeaways

  • LEGO-RL is a framework for robust reinforcement learning of coding agents.
  • It addresses issues like environmental crashes and reward hacking in agent harnesses.
  • The framework ensures faithful optimization, reliable execution, and observable training.
  • LEGO-RL significantly improves the performance of LLM-based coding agents on benchmarks.

Who benefits

Software DevelopmentAI DevelopmentDevOpsEdTech

Summary

LEGO-RL is a new framework that enables scalable policy-gradient optimization for coding agents within their native execution harnesses. It addresses issues like environmental crashes and reward hacking, significantly improving the performance of LLM-based coding agents across various platforms.

Reinforcement learning (RL) for coding agents, which often involves large language models (LLMs), typically relies on complex agent harnesses to manage tools, repository contexts, and execution feedback. However, the native environments of these harnesses are often misaligned with policy-gradient training, leading to problems like corrupted outcome signals from crashes and reward hacking, as well as discrepancies between training and inference behavior. To overcome these challenges, researchers introduce LEGO-RL, a framework designed to bridge native coding-agent harnesses with scalable policy-gradient optimization without altering their internal control flow. LEGO-RL operates on three core principles: faithful optimization through in-process LLM proxying for accurate token-level alignment; reliable execution via scalable sandbox orchestration with image caching and stage-wise defenses against reward hacking; and observable training with integrated validation, monitoring, and a live UI for granular diagnostics. Evaluations show that LEGO-RL significantly boosts the performance of the Qwen3.5-35B-A3B model across multiple coding agent harnesses, including OpenHands SDK, Claude Code, and OpenCode, on the SWE-bench Verified benchmark, while maintaining high correlation between rollout and training probabilities.

Why it matters

For professionals developing or deploying AI coding agents, LEGO-RL offers a robust framework to train these agents more effectively and reliably. This can lead to more capable and trustworthy AI assistants for software development, reducing debugging time and improving code quality.

How to implement this in your domain

  1. 1Investigate integrating LEGO-RL into existing reinforcement learning pipelines for developing coding agents.
  2. 2Utilize LEGO-RL's sandbox orchestration to create more reliable and secure training environments for coding agents.
  3. 3Leverage the framework's observable training features for better debugging and understanding of agent behavior during development.
  4. 4Apply LEGO-RL to fine-tune or train new LLM-based coding agents for specific software development tasks.

Original post by Yiming Du, Yuxin Jiang, Tao Yuan, Jianbo Dai, Shaowei Wang, Jierun Chen, Chaofan Tao, Xianzhi Yu, Lifeng Shang, Kam-Fai Wong, Xiaohui Li, Haoli Bai

"arXiv:2608.17393v1 Announce Type: new 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…"

View on X

Originally posted by Yiming Du, Yuxin Jiang, Tao Yuan, Jianbo Dai, Shaowei Wang, Jierun Chen, Chaofan Tao, Xianzhi Yu, Lifeng Shang, Kam-Fai Wong, Xiaohui Li, Haoli Bai on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses

More in AI Engineering & DevTools