Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

RepoFactory Evolves Coding Agent Environments with Cheap Proxy Metrics

RepoFactory introduces an environment evolution loop that uses three proxy metrics—validity, implementation scope, and structural coupling—to recursively improve training environments for long-horizon coding agents without costly model rollouts, boosting model performance on benchmarks like NL2Repo-Bench and SWE-bench.

Introduction

Software development is a core application scenario for coding agents, with requirements expanding from bug fixes and single features to longer-horizon, more complex development tasks. Training solely on short-horizon tasks focused on local modifications cannot cover such complete processes, necessitating long-horizon training environments for full project development.

Real software repositories provide rich material for these tasks. However, existing environment construction pipelines often stop at execution and verification, lacking further optimization of the training value a task can provide and how it can be improved. While runnability and scorability are basic requirements, tasks must also supply sufficient implementation and component collaboration experience.

Methods for continuously improving task environments during construction typically rely on model rollouts or downstream evaluations after model training to judge modification effectiveness. For long-horizon programming tasks, a complete solution involves extensive implementation and debugging, increasing feedback computation cost and latency. Researchers from Beihang University, Shanghai Jiao Tong University, and IQuest Lab propose RepoFactory, which introduces a feedback-driven iterative loop from recursive self-improvement (RSI) into environment construction. The central question: can reliable, low-cost, immediate proxy metrics replace high-cost, long-cycle downstream feedback to guide continuous environment improvement?

RepoFactory Pipeline and Environment Evolution Loop

Figure 1: RepoFactory pipeline and environment evolution loop
Figure 1: RepoFactory pipeline and environment evolution loop

Three Evolution Objectives

RepoFactory defines three objectives for environment evolution:

Validity : Requires the reference implementation to achieve a perfect score while the unmodified initial workspace scores zero, enabling the evaluation to distinguish between completed and unimplemented task states.

Implementation Scope (S) : Combines code scale and direct runtime dependencies to reflect the implementation workload required by the task.

Structural Coupling (C) : Based on function-call reachability relationships, reflecting structural connections between implementations.

The agent first satisfies validity, then jointly modifies the reference implementation, task description, and tests based on feedback from implementation scope and structural coupling. Implementation scope guides tasks to include more substantial development work, while structural coupling encourages more connections between implementations. Both serve as proxy metrics for training value, jointly guiding task content improvement.

After each modification, execution verification and code analysis are re-run to provide results for the next iteration. This loop does not require waiting for a full solver model rollout nor depend on downstream training evaluations after each change, enabling recursive environment improvement at lower feedback cost.

Training Gains from Environment and Evolution

The team used RepoFactory environments to supervise fine-tune Qwen3.5-35B-A3B, yielding RepoHorizen-35B-A3B. On NL2Repo-Bench, the score rose from 23.8 to 46.4 , an increase of 22.6 percentage points . Across five benchmarks—NL2Repo-Bench, three SWE-bench benchmarks, and Terminal-Bench 2.1—the average improvement was 8.5 percentage points . Gains covered full repository generation, repository issue fixing, and long-horizon terminal tasks, indicating transferability of such development experience to diverse software engineering tasks.

Environment evolution provided additional gains. Compared to models trained on unevolved environments, evolved environments improved NL2Repo-Bench by 5.1 percentage points and the five-benchmark average by 2.1 percentage points , with improvements on every benchmark. These modifications, guided by proxy metrics, ultimately yielded downstream training gains, providing empirical evidence for using low-cost, immediate feedback to improve environment training value.

Figure 2: Full evaluation results on five benchmarks (part 1)
Figure 2: Full evaluation results on five benchmarks (part 1)
Figure 2: Full evaluation results on five benchmarks (part 2)
Figure 2: Full evaluation results on five benchmarks (part 2)

Proxy Metrics' Impact on Environment Improvement

Beyond overall training results, the study separately examined the roles of validity, implementation scope, and structural coupling to verify whether these objectives help expand environment supply and guide task content improvement.

Validity Feedback Expands Usable Environment Supply

In an experiment with 500 candidate repositories, environment evolution increased the number of environments passing verification from 169 to 347 while maintaining the same validity requirement, raising the yield from 33.8% to 69.4% . By correcting construction defects through feedback, originally discarded candidate repositories can be retained, yielding more usable environments from the same pool and supporting environment scaling.

Figure 3: Impact of environment evolution on valid environment yield (part 1)
Figure 3: Impact of environment evolution on valid environment yield (part 1)
Figure 3: Impact of environment evolution on valid environment yield (part 2)
Figure 3: Impact of environment evolution on valid environment yield (part 2)

Controlled Experiments: Optimizing S and C Separately

To further test the proxy metrics for training value, the researchers started from 1,000 randomly sampled environments and separately optimized only implementation scope (S) or structural coupling (C), while retaining validity checks. Both experiments sampled at iterations 3, 6, 9, and 12, forming four evolution stages. Each stage collected 2,000 training trajectories, and downstream performance was compared using the same base model and training settings.

Implementation Scope (S): More Substantial Implementation and Debugging

After optimizing S, interaction rounds, context length, and supervised token counts increased across evolution stages. NL2Repo accuracy rose steadily from 30.2% in stage 1 to 32.9% in stage 4 . With the same number of trajectories, expanding implementation scope let models experience more thorough implementation and debugging processes, yielding better repository reconstruction performance.

Structural Coupling (C): More Connections Between Implementations

Optimizing C showed a different pattern. Accuracy fluctuated in intermediate stages but ultimately improved from 30.2% to 32.5% ; interaction rounds decreased, while context length and supervised token counts only slightly decreased. Performance improvement did not accompany longer trajectories or more supervised tokens, supporting structural coupling as a signal for task content improvement. Compared to expanding implementation scope, it offers another direction for environment evolution, focusing on inter-implementation connections and the collaboration requirements they entail.

Figure 4: Ablation experiments optimizing implementation scope and structural coupling separately (part 1)
Figure 4: Ablation experiments optimizing implementation scope and structural coupling separately (part 1)
Figure 4: Ablation experiments optimizing implementation scope and structural coupling separately (part 2)
Figure 4: Ablation experiments optimizing implementation scope and structural coupling separately (part 2)

Initial Release: 200 Unevolved Environments

The full RepoFactory environment set contains 10,159 environments across 17 software domains , primarily targeting Python projects. The figure below shows statistical distributions of the full environment set and training data.

Figure 5: RepoFactory environment and training data statistics
Figure 5: RepoFactory environment and training data statistics

The project initially releases 200 unevolved environments with corresponding pre-built Docker images, using the Harbor task format. Each task includes a requirement description, run configuration, reference implementation, and verifier, suitable for collecting long-horizon coding trajectories, training coding agents, and researching environment evolution and training data value.

Resources

Paper: From Repositories to Training Environments: Scaling Long-Horizon Coding Agents with Environment Evolution Loop

GitHub: https://github.com/IQuestLab/RepoFactory Dataset:

https://huggingface.co/datasets/IQuestLab/RepoFactory
About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

software engineeringcoding agentsRecursive Self-Improvementlong-horizon programmingenvironment evolutionproxy metricsRepoFactorytraining environments

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion