CodeMidas:从代码本身扩展智能体编码强化学习环境
研究论文 · 2026/09/21
通过强化学习训练编码智能体需要多样化的任务和可靠的验证器。开源代码库提供了丰富的任务来源,但现有方法通常依赖问题和提交等开发产物,限制了可提取任务的范围。为更好地扩展强化学习环境,我们提出 CodeMidas,一个智能体流水线,仅以源代码作为任务特定输入,将现有代码库中已实现的功能转化为可执行的强化学习环境。CodeMidas 在环境构建的每个阶段分配智能体计算:智能体探索已实现功能以制定行为规范,基于原始代码的执行构建测试,并通过执行检查和重复解决方案推演来验证和筛选候选任务。所得数据集包含来自 3,185 个开源代码库的 5,545 个训练任务,涵盖 23 种编程语言和 15 个技术领域。使用 GRPO 在这些任务上训练 MiMo-V2.5,在五个多样化基准上均取得性能提升,涵盖问题修复(DeepSWE +11.7%)、全程序构建(ProgramBench +17%)和终端工作(Terminal-Bench v2.1 +8.5%)。消融实验表明,增加高质量训练任务的数量可提升性能。轨迹分析显示,经强化学习训练的智能体表现出更好的行为,如增加代码库探索和更多样化的自我验证。这些结果确立了源代码作为构建强化学习环境的可扩展基础,能够跨多样化软件任务改进编码智能体。
该工作提出了一种仅依赖源代码即可大规模构建强化学习环境的方法,显著扩展了编码智能体训练任务的来源,并在多个基准上验证了有效性,对推动编码智能体的强化学习训练具有实用价值。
Training capable coding agents via reinforcement learning (RL) requires diverse tasks with reliable verifiers. Open-source codebases offer a rich source of such tasks, while existing methods typically rely on development artifacts such as issues and commits, limiting the range of tasks that can be extracted. To better scale RL environments, we present CodeMidas, an agentic pipeline that turns implemented functionality in existing codebases into executable RL environments using source code as its only task-specific input. CodeMidas allocates agentic compute to every stage of environment construction: agents explore implemented functionality to formulate behavioral specifications, construct tests grounded in execution of the original code, and validate and filter candidate tasks through execution checks and repeated solution rollouts. The resulting dataset has 5,545 training tasks from 3,185 open-source codebases spanning 23 programming languages and 15 technical domains. Training MiMo-V2.5 on these tasks with GRPO improves performance on all five diverse benchmarks, covering issue repair (DeepSWE + 11.7%), whole-program construction (ProgramBench +17%), and terminal work (Terminal-Bench v2.1 +8.5%). Ablations show that increasing the number of high-quality training tasks improves performance. Trajectory analysis shows the RL-trained agent demonstrates better behaviors like increasing codebase exploration and more diverse self-verification. These results establish source code as a scalable foundation for constructing RL environments that improve coding agents across diverse software tasks.