Skip to Content
Repo2RLEnv

Quickstart

Generate PR-diff tasks, check their files, then run their reference and baseline controls.

Edit on GitHub

This walkthrough uses pr_diff to turn merged PRs from pallets/click into Harbor tasks. Generation needs Python 3.12+, Git and the GitHub CLI. Executing the tasks later needs Docker and a model key for the correctness judge.

For test-based rewards, start with pr_runtime or Tasksmith. The examples below use patch similarity.

Install Repo2RLEnv

pip install repo2rlenv
gh auth login

You can use GITHUB_TOKEN instead of interactive login, but gh must still be installed. Installation covers extras and checkout installs.

Generate tasks from three PRs

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

limit=3 means three candidates, not three guaranteed exports. Filters remove changes such as docs-only patches, reverts and oversized diffs. A summary might be:

candidates  3
emitted     1
skipped     2 ({'too_many_files': 2})

This is illustrative; the repository's latest PRs determine your result. If no task is emitted, the command exits 1. Increase limit or try a different repository.

Look at what you made

task.toml # configuration, source PR and evaluation label
instruction.md # the learner's request
environment/ # checkout at the PR's base commit
solution/ # reference patch and solve.sh
tests/ # private patch capture, scorer and reference diff

The learner edits the starting checkout. During grading, the verifier captures that change and compares it with the reference patch, using deterministic similarity components and a correctness judge. Read the task layout and PR-diff reward for the full contract.

Validate the tasks

repo2rlenv validate ./tasks --oracle

This checks the native task format, required files and oracle assets. It does not build the image, run the reference or establish task quality.

Run the tasks with Harbor

Start Docker and install the Harbor integration:

pip install 'repo2rlenv[harbor]'

Set ANTHROPIC_API_KEY in your shell, then run the reference (oracle) and the untouched baseline (nop). These controls incur judge calls.

harbor run -p ./tasks -a oracle --env docker \
  --ve ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"
harbor run -p ./tasks -a nop --env docker \
  --ve ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"

The reference should receive a high score and the baseline should score zero. Unlike binary test tasks, the PR-diff reference score includes a model judgment. If the judge is unavailable, the trial is ungraded and has no reward file; Harbor reports VERIFIER_FAILED. Diagnose that separately from a scored failure.

Now try a solver:

harbor run -p ./tasks -a claude-code -m anthropic/claude-sonnet-4-6 \
  --ak max_budget_usd=2.00 \
  --ae ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  --ve ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" --env docker

--ae supplies the agent key; --ve supplies the judge key. The $2 setting caps the Claude Code agent's spend per task, not judge calls or sandbox costs. Results and traces go to jobs/; use harbor view jobs to inspect them. Run with Harbor covers other agents and providers.

Push to the Hub (optional)

Authenticate, then replace YOUR_NAME with your Hub username or organization:

hf auth login
repo2rlenv push ./tasks YOUR_NAME/click-pr-diff --private

This publishes task files, a dataset card, a manifest and a Harbor registry. It adds no quality guarantee. See publishing for public releases and container images.

Next steps

On this page