ProgramGen: Forward & Reverse Repository Environments for Coding Agents

ProgramGen (arXiv:2612.03336) is an automated pipeline that transforms real open-source repositories into runnable forward-engineering and reverse-engineering training environments for long-horizon coding agents. With only 2,585 curated trajectories, ProgramGen boosts Qwen3.8-27B from 39.3% to 46.6% on NL2Repo, 48.0% to 61.0% on ProgramBench, 41.6% to 60.2% on DeepSWE, 60.7% to 70.8% on Terminal-Bench 2.1, and 76.5% to 84.3% on SWE-bench Pro V2 Hard.
ProgramGen: Forward & Reverse Repository Environments for Coding Agents: ProgramGen (arXiv:2612.03336) is an automated pipeline that transforms real open-source repositories into runnable forward-engineering and reverse-engineering training environments for long-horizon coding agents. With only 2,585 curated trajectories, ProgramGen boosts Qwen3.8-27B from 39.3% to 46.6% on NL2Repo, 48.0% to 61.0% on ProgramBench, 41.6% to 60.2% on DeepSWE, 60.7% to 70.8% on Terminal-Bench 2.1, and 76.5% to 84.3% on SWE-bench Pro V2 Hard. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Dual-Mode Repo Synthesis: Trains agents both to build projects from a spec (forward mode, graded by repo tests) and to reimplement reference programs blind to source (reverse mode, graded by generated tests).
- Massive Cross-Benchmark Generalization: Lifts Qwen3.8-27B from 41.6% to 60.2% on DeepSWE (+18.6 pp), 60.7% to 70.8% on Terminal-Bench 2.1 (+10.1 pp), and 76.5% to 84.3% on SWE-bench Pro V2 Hard.
- Low-Cost Selective Regeneration: Uses rule-based dependency installers and AST interface extractors, regenerating only failing task components instead of whole repositories.
- Turn Masking Cuts Format/Wasteful Errors by 59%: Masking 5,334 noisy rollout turns drops flagged turns per 1,000 from 10.8 to 4.4 while raising ProgramBench average to 61.7%.
import { createAgent } from '@smoke-monkey/harness';// Long-horizon repo synthesis agent operating inside a ProgramGen-validated sandboxconst agent = createAgent({agentId: 'programgen-repo-builder',provider: 'openai-compatible',baseUrl: 'http://127.0.0.1:8000/v1',model: 'Qwen/Qwen3.8-27B',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function main() {const result = await agent.run('Implement the module interfaces defined in SPEC.md, install missing dependencies, and pass all pytest suites.');console.log('Repo Build Summary:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
Coding Agents Hit 70% on SWE-bench With Native Reinforcement Learning
Evaluate agents on SWE-Bench
What Is ProgramGen and How Does Dual-Mode Synthesis Work?
ProgramGen (Xiong et al., arXiv:2612.03336) is an open-source environment construction pipeline that turns real software repositories into verified long-horizon workspaces for coding agents. Rather than relying solely on single-issue bug patches, ProgramGen trains agents across two complementary tasks: forward mode (building a full repository from a specification and grading with native repo tests) and reverse mode (reimplementing a reference program without seeing its source code, graded by synthesized tests).
Using just 2,585 curated trajectories, Qwen3.8-27B matches or surpasses far larger proprietary baselines across five major software engineering benchmarks.
| Benchmark | Qwen3.8-27B Baseline | Qwen3.8-27B + ProgramGen | Absolute Gain |
|---|---|---|---|
| ProgramBench (200 tasks) | 48.0% | 61.0% (61.6% reverse / 61.7% masked) | +13.0 pp |
| NL2Repo (104 tasks) | 39.3% | 46.6% (47.9% 500+500 mix) | +7.3 pp |
| DeepSWE | 41.6% | 60.2% | +18.6 pp |
| Terminal-Bench 2.1 | 60.7% | 70.8% | +10.1 pp |
| SWE-bench Pro V2 Hard | 76.5% | 84.3% | +7.8 pp |
Selective Validation, Forward vs Reverse Gains, and Turn Masking
Constructing multi-file coding environments naively fails frequently on broken dependencies or leaking reference code. ProgramGen keeps pipeline costs low and training signal clean via three techniques:
- Complementary Forward + Reverse Supervision: On ProgramBench (200 tasks), reverse-mode trajectories raise average test pass rate from 48.0% to 61.6% and drop non-building submissions from 17 to 4; combining 500 forward + 500 reverse trajectories yields 47.9% on NL2Repo while cutting zero-gradable NL2Repo failures from 19 down to 1.
- Selective Partial Regeneration: When validation detects a failing build or ambiguous interface, ProgramGen regenerates only the defective spec or test fragment while deterministic rule-based programs handle dependency installation and interface extraction.
- Turn Masking During Trajectory Training: Masking 5,334 low-quality rollout turns reduces flagged agent behaviors per 1,000 turns from 10.8 down to 4.4 (cutting format errors from 3.97 to 0.96 and wasteful loops from 5.81 to 2.48) while lifting ProgramBench pass rate to 61.7%.
Combine Forward and Reverse Specs in Agent Harnesses
When evaluating coding agents in Smoke Monkey Harness, pair forward greenfield builds (SPEC.md -> repo tests) with reverse black-box reimplementations to catch specification ambiguity and hidden environment assumptions.
Reproducible ProgramGen Environment Validation Loop
Verify repository buildability, test isolation, and turn-quality diagnostics in a local container before running long-horizon coding agent evaluations:
# 1. Inspect repo workspace isolation & dependency reproducibility inside Docker
docker run --rm -v "$PWD":/workspace -w /workspace python:3.12-slim bash -c "
pip install -q pytest && \
pytest --collect-only -q && \
pytest -q
"
# 2. Verify zero reference-leakage and AST public interface extraction
python3 -c '
import ast, pathlib
for p in pathlib.Path("src").rglob("*.py"):
tree = ast.parse(p.read_text())
defs = [n.name for n in ast.walk(tree) if isinstance(n, (ast.FunctionDef, ast.ClassDef))]
print(f"{p}: {len(defs)} exported symbols")
'Frequently Asked Questions
Q:How do forward and reverse modes differ in ProgramGen?
In forward mode, the agent builds a repository from a written specification and is graded by the repository’s own tests. In reverse mode, the agent reimplements a reference program without seeing its source code, graded by generated verification tests.
Q:How many trajectories did ProgramGen need to boost Qwen3.8-27B?
Only 2,585 trajectories—lifting Qwen3.8-27B from 41.6% to 60.2% on DeepSWE, 60.7% to 70.8% on Terminal-Bench 2.1, and 76.5% to 84.3% on SWE-bench Pro V2 Hard.
Q:What is turn masking and why does it improve coding agents?
Turn masking excludes noisy intermediate turns (format mistakes, wasteful loops, probing) during training. Masking 5,334 turns cut flagged turns per 1,000 from 10.8 down to 4.4 while improving ProgramBench accuracy to 61.7%.
Q:How does ProgramGen keep environment generation costs low?
It relies on deterministic rule-based scripts for dependency installation and AST interface extraction, and selectively regenerates only the failing fragments of a task instead of rebuilding from scratch.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.