GitHub - huggingface/Repo2RLEnv: Convert any Repo into an RL Environment · GitHub
Skip to content

Repository files navigation

Repo2RLEnv

Turn repositories, pull requests and task seeds into executable RL environments.

PyPI Python versions CI License: Apache-2.0 and MIT Harbor task format

Quickstart · Pipelines · Output · Datasets · Documentation

Repo2RLEnv — generate, verify and share RL environments

Repo2RLEnv generates coding, terminal and reasoning tasks in the Harbor format: a task instruction, starting environment, reference solution and executable verifier. Run them with Harbor agents, inspect their quality, and publish them to the Hugging Face Hub.

Repository / PR / task seed
            │
            ▼
 Native pipeline · Tasksmith · Research recipe
            │
            ▼
 Harbor task: instruction + environment + solution + verifier
            │
            ▼
 Static checks → baseline / oracle → review and learner rollout
            │                          ↺ bounded repair
            ▼
 Labeled tasks + evidence → Hugging Face Hub → training / evaluation

Generation methods have different checks. The shared quality workflow can review and repair emitted tasks; exporting a task alone does not establish its quality.

Quickstart

Requires Python 3.12+ and Git. This example generates PR-diff tasks without building a container:

Windows CI covers CLI startup, recipe discovery, native task emission and static validation. Use Linux, macOS or WSL for Tasksmith, research-recipe generation and the quality controller; their full native Windows execution is not yet supported.

pip install repo2rlenv

# GitHub access; alternatively set GITHUB_TOKEN
gh auth login

repo2rlenv generate \
  --repo pallets/click --pipeline pr_diff \
  --pipeline-opt limit=3 --out ./workspace/click-tasks

repo2rlenv validate ./workspace/click-tasks --deep
repo2rlenv pipelines list

For test-based repository tasks, use pr_runtime or Tasksmith. LLM stages need a provider key such as ANTHROPIC_API_KEY or OPENAI_API_KEY. Native runtime pipelines build and cache Docker environments; owned recipes and Tasksmith build and execute remotely through Daytona or Modal.

Install the extras your route needs:

pip install 'repo2rlenv[tasksmith,daytona,harbor]'
# Other extras: modal, mutation
repo2rlenv tasksmith install-runtime  # Pi / OpenCode; requires Node.js 22.19+

See the quickstart for execution and publishing, and authentication for model, sandbox and Hub credentials.

Pipelines

Native pipelines

Pipeline Task
pr_diff Reproduce a real PR change; scored by diff similarity and an optional LLM judge
pr_runtime Fix a PR regression; failing tests must pass while existing tests stay green
commit_runtime Build the same test-based task from commit history
code_instruct Solve an LLM-authored problem grounded in repository APIs
equivalence_tests Implement a function matching a private reference
cve_patches Repair a vulnerability identified through public CVE and fix-commit records

The first three are marked stable; the others are experimental. Supported source hosts and languages vary by pipeline. See the pipeline guide.

Tasksmith

Tasksmith adaptively converts a merged PR into a Harbor task. LangGraph orchestrates Pi or OpenCode to investigate the change, establish a working environment, and design the instruction and private verifier. The merged implementation supplies the oracle. Baseline checks, review, learner rollouts and bounded repair produce labeled revisions with execution evidence and cost records.

Tasksmith is experimental and currently targets testable Python changes. CPU execution supports Daytona and Modal; the implemented GPU route uses Modal L4 GPUs. Start with the one-PR walkthrough, which includes example inputs, provider setup and an explicit spending limit.

Research recipes

These 14 experimental recipes adapt published methods into code owned by this repository. No upstream research package is installed at runtime. A pipeline names the generation family; a recipe selects its method.

Recipe Pipeline family Task
swe_smith repo_mutate Repair an introduced source defect
swe_gen pr_to_env Implement a supplied merged PR's behavior
swe_next pr_runtime Repair a task mined from PR history
r2e_gym commit_runtime Repair a task mined from commit history
swe_flow repo_reconstruct Reconstruct functions in dependency order
r2e equivalence_tests Match a private reference through generated tests
cli_gym env_repair Restore a damaged development environment
seta_seed2synth terminal_synth Solve a terminal task derived from question/answer seeds
seta_evol task_evolve Solve an evolved Harbor task
dataarc terminal_synth Solve a related or harder variant of a Harbor seed
tmax terminal_synth Solve a task sampled from a skill taxonomy
endless_terminals terminal_synth Solve a task sampled from categories and scenarios
terminalworld terminal_reconstruct Reproduce an outcome from a terminal recording
scaler reasoning_synth Solve a reasoning instance generated from a problem family
repo2rlenv pipelines describe repo_mutate --recipe swe_smith --json

Each recipe walkthrough includes configuration, a pipeline diagram, model prompts, verification steps, limitations and upstream credits. Use its example config with repo2rlenv generate --config <config.yaml>.

Harbor output

<task-id>/
├── instruction.md          # Learner's task
├── task.toml               # Runtime, resources, provenance and evaluation labels
├── environment/            # Dockerfile, source snapshot and fixtures
├── solution/solve.sh        # Private reference entrypoint
└── tests/test.sh            # Trusted verifier entrypoint

Private solutions and tests belong to their respective execution phases; the whole task bundle is not the learner workspace. Task assets and reference formats vary by recipe. Most owned verifiers return deterministic 0/1 rewards; SCALER uses −1/+1, and native pipelines also support graded test and diff-similarity rewards.

With the harbor extra and a configured runtime, execute a reference solution:

harbor run -p ./workspace/click-tasks -a oracle --env docker

validate --deep checks files and metadata without execution. Use review and repair for instruction quality, verifier defects, leakage and rollout evidence.

Datasets and quality

Explore the HuggingEnvs collection with the Harbor Visualizer. The release inventory records per-pipeline task counts, revisions and validation scope; the economics guide reports measured yield and cost per task.

The Tasksmith reference cohort contains 50 verified tasks from an assisted campaign. Research-recipe exports retain separate quality labels, including unverified and needs-repair. Consult the recorded evidence before using a cohort for training or evaluation.

hf auth login  # Or set HF_TOKEN with write access to your namespace
repo2rlenv push ./workspace/click-tasks <your-org>/<dataset-name>
repo2rlenv pull <your-org>/<dataset-name> ./workspace/downloaded-tasks

Documentation and contributing

Documentation · Exact prompts · Design RFCs · Contributing · Adding a pipeline · Release notes

License and credits

Repo2RLEnv's own code is Apache-2.0. Bundled adaptations retain their MIT and Apache-2.0 licenses; the distribution is Apache-2.0 AND MIT. Third-party notices link each recipe's source revision, retained material and attribution. Source repositories and generated task assets retain their respective terms; check each dataset's license and provenance before redistribution.

About

Convert any Repo into an RL Environment

Resources

Contributing

Stars

627 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages