LEGO-RL:面向编码代理的利用原生强化学习

·

其他资讯 · 2026/08/20

强化学习在编码智能体中的应用越来越依赖于长时间运行的智能体框架来管理工具集成、仓库上下文和执行反馈。然而,这些框架的原生执行环境与策略梯度训练本质上不一致:环境崩溃和奖励黑客破坏结果信号,而训练-推理差异使展开行为与策略更新脱节。为此,我们提出了LEGO-RL,一个在不修改内部控制流的情况下,将原生编码智能体框架与可扩展的策略梯度优化相结合的框架。LEGO-RL基于三个支柱:(1)通过进程内LLM代理实现忠实优化,捕获原始生成流以进行令牌级对齐和稳健的训练端对数概率重计算,即使在框架端压缩或重新序列化的情况下;(2)通过可扩展的沙箱编排实现可靠执行,具有图像缓存和分阶段防御以减轻奖励黑客;(3)通过集成插件实现可观察训练,自动验证和监控,并配有实时UI进行细粒度轨迹诊断。我们通过使用GSPO在三个原生编码智能体框架上训练稀疏MoE模型Qwen3.5-35B-A3B来评估LEGO-RL。LEGO-RL在SWE-bench Verified上将Qwen3.5-35B-A3B在OpenHands SDK(64.0%到70.4%)、Claude Code(62.4%到68.2%)和OpenCode(57.2%到66.6%)上的性能提升,同时保持展开-训练概率相关性高于0.99。

该论文针对编码智能体强化学习中的关键挑战(环境崩溃、奖励黑客、训练-推理差异)提出了一个实用框架,并通过实验验证了其有效性,对相关领域研究具有重要参考价值。

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.

阅读原文

参与讨论