TL;DR
Training AI coding agents to build entire software projects from scratch—rather than just patching single bugs—requires realistic, runnable, and automatically gradable environments, which are notoriously scarce and expensive to create. ProgramGen solves this with a low-cost pipeline that turns real GitHub repositories into verifiable "from-scratch" coding tasks in two complementary modes: forward (build from a specification) and reverse (reimplement a black-box program by querying it). Fine-tuning Qwen3.8-27B on just 2,585 trajectories from these environments boosts its performance on from-scratch benchmarks by up to 13 points and, surprisingly, transfers strongly to existing-codebase engineering benchmarks like DeepSWE (+18.6 points).
What Problem Does This Paper Address?
Coding agents have gotten quite good at issue-level fixes—taking an existing repository and patching a localized bug. The next frontier is long-horizon software development: choosing an architecture, coordinating multiple components, and sustaining implementation and debugging over hundreds of steps.
To train agents for this, you need environments with real-project complexity, clear goals, a runnable workspace, and a hidden verifier that grades the agent's work without leaking the original source code. Existing pipelines typically build only one kind of task (either specification-driven or reference-guided), are expensive to run, and rarely test whether training on from-scratch tasks helps agents on broader software engineering benchmarks. ProgramGen asks: can one pipeline build both kinds of verifiable environments from real repositories at scale and low cost, and does training in them generalize?
Methods
From a pinned GitHub repository snapshot, ProgramGen constructs a task in three stages: build, synthesize, and replay/accept.
- Forward Mode (Specification $\rightarrow$ Code): ProgramGen strips out the source code and keeps the repository's original tests as a hidden verifier. A construction agent inspects the tests and writes a detailed specification (at least 600 words) describing the required APIs and behavior. Rule-based scripts check that every interface called by the tests is named in the spec.
- Reverse Mode (Behavior $\rightarrow$ Code): ProgramGen keeps the compiled reference program in a separate, isolated container and gives the agent only usage docs and a socket client to query it with inputs and observe outputs/exit codes. A construction agent probes the reference and generates at least 200 behavioral tests across eight categories, each of which must pass repeated reference runs and reject eight simple dummy programs (like empty-output or input-echoing scripts).
To keep construction costs low, ProgramGen uses three key tricks:
- Build before synthesis: If a repository fails to build or lacks a runnable test suite, it is dropped immediately before any expensive LLM synthesis happens.
- Targeted repair: If validation fails, only the broken specification or test is regenerated, preserving already-validated parts.
- Rule-based scaffolding: Deterministic programs—not LLMs—handle dependency installation, interface extraction, and acceptance checks.
Datasets
- Newly Released Environments & Trajectories: Processing 98,000 repositories in forward mode and 88,000 in reverse mode, the authors release 6,122 accepted environments (2,142 forward-mode Python projects; 3,980 reverse-mode compiled programs in Rust, Go, and C/C++) along with 2,585 teacher trajectories collected from DeepSeek-V4.1-Flash.
- Evaluation Benchmarks: The authors evaluate on two from-scratch benchmarks (NL2Repo and ProgramBench) and five existing-repository / terminal benchmarks (DeepSWE, Terminal-Bench 2.1, SWE-bench Pro V2 and its Hard subset, SWE-bench Multilingual, and SWE-bench Verified for scaling ablations).
Key Insights and Ideas
- Forward and reverse modes provide complementary supervision: At a fixed budget of 1,000 trajectories, reverse-mode training is stronger on ProgramBench (61.6% vs. 55.0%) while forward-mode is stronger on NL2Repo (42.6% vs. 40.2%). Yet a 500 + 500 mixture reaches 47.9% on NL2Repo, outperforming either mode alone.
- From-scratch training transfers to real-world repo engineering: Even though ProgramGen-27B is trained exclusively on from-scratch tasks, its largest gain is on DeepSWE (+18.6 points), which requires adding substantial new features to existing codebases. The fine-tuned model runs more edit–execute–edit cycles and overflows its context window less often than the base model.
- Loss masking cleans up agent behavior: During supervised fine-tuning, masking out turns with malformed tool calls, prohibited reference-inspection attempts, or repeated nonproductive errors (keeping them in context with zero loss weight) cuts flagged error turns in half (from 10.8 to 4.4 per 1,000 turns) without hurting benchmark scores.
- Isolation matters: In early explorations, the teacher agent attempted to inspect the hidden reference binary in 41.1% of trajectories, motivating ProgramGen's strict container-level isolation.
Key Results
Fine-tuning Qwen3.8-27B on 2,585 ProgramGen trajectories yields ProgramGen-27B, which improves across every evaluated benchmark:
- From-Scratch Benchmarks (mean test pass rate):
- NL2Repo: $39.3\% \rightarrow 46.6\%$ (+7.3)
- ProgramBench: $48.0\% \rightarrow 61.0\%$ (+13.0)
- SWE-Related Benchmarks (resolve rate):
- DeepSWE: $41.6\% \rightarrow 60.2\%$ (+18.6)
- Terminal-Bench 2.1: $60.7\% \rightarrow 70.8\%$ (+10.1)
- SWE-bench Pro V2 Hard: $76.5\% \rightarrow 84.3\%$ (+7.8)
- SWE-bench Pro V2 (All): $92.5\% \rightarrow 94.4\%$ (+1.9)
- SWE-bench Multilingual: $78.0\% \rightarrow 79.7\%$ (+1.7)
- Construction Cost: Including rejected candidates, an accepted environment costs 3.0M synthesis tokens (1.0 hour) in forward mode and 29M tokens (2.0 hours) in reverse mode—substantially lower than prior reference-based pipelines like ProgramGym (~83M tokens per environment).
Limitations and Future Work
- Black-box test coverage in reverse mode: Because reverse-mode tests are generated without seeing the source code, they cover less code than repository unit tests—median line coverage drops from 53% on small programs to just 3% on the largest third. Go programs in particular often need clusters or remote services unavailable in an offline sandbox.
- Context-limit and timeout failures: On ProgramBench, forward-mode and mixed models still occasionally hit the 512K context limit before submitting, while on Terminal-Bench 2.1, failed runs are usually still in progress when the time limit expires.
- Future directions: While this paper focuses on supervised fine-tuning, ProgramGen's isolated, verifiable environments are ready-made for reinforcement learning (RL) rollouts, which the authors leave for future exploration.
Summary updated