Training coding agents for long-horizon tasks requires environments with verifiable feedback. Existing pipelines often follow a linear process that ends with validation, establishing usability but providing little guidance on improving training value. Recursive self-improvement (RSI) often requires model rollouts or model training followed by downstream evaluation, with costs and feedback delays amplified on long-horizon tasks. How can we use timely, reliable proxy signals to improve training value and synthesize environments at scale? We present RepoFactory, an automated pipeline that converts real repositories into verifiable environments where agents build complete projects from scratch given a language specification. Its Environment Evolution Loop optimizes a multiplicative objective combining validity, structural coupling, and implementation scope through proxy feedback. RepoFactory produces 10,159 environments across 17 software domains. Training Qwen3.5-35B-A3B on these environments yields RepoHorizen-35B-A3B, which achieves gains of 22.6 percentage points on NL2Repo-Bench and 8.5 points on average across five benchmarks covering long-horizon coding and agentic tasks in real-world production settings, compared with 17.5 and 6.4 points without environment evolution. These results highlight the training value of RepoFactory environments and the additional gains from the Environment Evolution Loop.
Figures & tables
Figure 1: Overview of RepoFactory. The pipeline searches for repositories, reconstructs their runtimes, and synthesizes task specifications from repository evidence. The Environment Evolution Loop uses low-cost feedback to improve environment reliability and training value.
Figure 2: Statistics of RepoFactory environments and SFT data.
Model
Params
NL2Repo Bench
SWE-bench Verified
SWE-bench Pro
SWE-bench Multilingual
Terminal- Bench 2.1
Avg.
Frontier Closed-Source Models
GPT-5.6-sol
-
56.8
96.2
64.6
-
88.8
76.6
GPT-5.5
-
45.1
82.6
58.6
77.8
73.8
67.6
Claude Opus 5
-
75.3
96.0
79.2
89.5
89.1
85.8
Gemini-3.1 Pro
-
33.4
80.6
54.2
44.0
70.3
56.5
Open-Weight Models ( > 200B)
Table 1: Main results on five agent benchmarks.
Figure 3: Average accuracy as a function of the number of RepoFactory training environments.
Figure 4: NL2Repo performance across model sizes.
Figure 5: Statistics of the four difficulty levels and the corresponding NL2Repo results.
Figure 6: Cumulative number of validated environments over wall-clock time, sampled every 30 minutes.
Training Data
Open
N2R
Ver.
Pro
ML
TB
Reported by prior work (varying harnesses)
DeNovoSWE
✗
27.1
–
–
–
–
MindForge
✗
23.5
73.8
51.3
67.8
–
Refact-92B
✗
28.9
–
–
–
–
TrajLong
✗
13.8
51.1
34.3
–
12.4
Ours (Claude Code harness)
Table 2: Performance of models trained on different SWE data sources, in percent. N2R = NL2Repo, Ver. = SWE-bench Verified, Pro = SWE-bench Pro, ML = SWE-bench Multilingual, TB = Terminal-Bench 2.1. Best result among our runs in bold .
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
Hyperparameter
Value
Number of epochs
3
Rollout / global batch size
64 / 64
Per-device micro-batch size
1
Dynamic token batching
Enabled
Token budget per GPU
80,000
Optimizer
AdamW
Appendix
Table 3: Supervised fine-tuning hyperparameters for Qwen3.5-35B-A3B.
Figure 7: Estimated Python ecosystem coverage across RepoFactory’s 10,159 environments. Categories may overlap. Other denotes environments without an ecosystem match.
Figure 8: Development operations in the collected trajectories. Each bar shows the percentage of trajectories containing the operation. Categories may overlap.
Coding agents are increasingly used to build programs from scratch as software engineers do rather than to resolve issues within a repository or to generate a repository from a given requirements document. However, scalable verifiable training environments that force agents to discover what is required and to decide how the system should be designed remain scarce. Moreover, existing agent workflows also cannot sustain long-horizon development in which the agent explores the reference program before implementation. To address these challenges, we introduce ProgramGym, a framework consisting of Program-Env and Program-Agent for scalable training environments of long-horizon program reproduction agents. Specifically, Program-Env constructs verifiable training environments from repositories through a feedback-driven loop that repairs runtime sandbox builds and the quality of black-box tests. Using this novel pipeline, we obtain 1,648 training environments spanning C, C++, Go, and Rust. Program-Agent combines a role-isolated workflow of analysis, implementation, and review with revision management for compilation checks and failure recovery. Experiments on ProgramBench show that both Program-Env and Program-Agent improve performance on program reproduction. Fine-tuning on trajectories with these constructed environments raises the performance of Qwen3.8-27B from 34.87% to 42.84%. Program-Agent further raises the base and SFT models to 55.71% and 56.25%, both exceeding some flagship models. We will release the ProgramGym to support further research on coding agents that build programs from scratch.
Chengyi Yang, Renxu Bao, Jue Hou +10
Xiamen University · Washington University in St. Louis · Institute of Automation, Chinese Academy of Sciences +1
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.
Bowen Ye, Lei Li, Shicheng Li +16
LLM Core, Xiaomi · Peking University · University of Hong Kong +1
Reinforcement learning (RL) has driven substantial progress in coding agents by relying on verified successful trajectories as learning signals. However, such trajectories are scarce in long-horizon software engineering tasks, where a minor error can invalidate the entire rollout. Repeatedly restarting from the initial state is commonly used yet inefficient, and resetting only the context with working directory misses state changes such as installed dependencies. Therefore, branching from intermediate steps to preserve earlier progress requires restoring both the agent context and execution environments. In this paper, we present SPROUT (SnaPshot-based RollOUT), an agentic RL rollout framework that scales long-horizon coding tasks by resuming and branching from intermediate states. Specifically, SPROUT was built on top of a lightweight infrastructure that checkpoints both the filesystem and the agent context after each assistant turn. A verifier-guided backtracking policy then selects where to resume a failed attempt and how to proceed. Extensive experiments on long-horizon coding tasks show that SPROUT achieves up to 23.6% improvement over pass@k across various LLMs, while using 32--52 of their tokens. For RL training of Qwen3.8-27B, SPROUT stably outperforms standard GRPO by 13.9 points on three long-horizon coding benchmarks while cutting the time per training step by 39.5. SPROUT thus makes RL on long-horizon coding tasks both more effective and cheaper to scale.
Mengyang Liu, Weiming Wang, Haixin Nan +6
Shanghai Jiao Tong University · Amazon · Nanjing University +2