Recipes

AutoEnvScaling

A task generator for AutoEnvScaling (preprint forthcoming): a coding agent rebuilds recorded coding-agent sessions as Harbor tasks, or varies seed tasks such as TMax, and the policy trains on the tasks. The recipe is beta (issue #422).

What it trains#

The served model's weights, on generated Harbor tasks, with their verifier rewards. Each round of the built-in generated-task recipe is one generation of count tasks. The Designer, pi or Claude Code in a cloud sandbox, rebuilds one session as a task from the session and the repository at its base commit, and runs the task's oracle and nop check until it passes. validate then runs the task checks (checks.py). A pass-rate band marks the tasks that the solver can reach. With adaptive, a training task outside the band becomes a parent, and a later generation writes a harder or simpler variant of it. Each rollout's advantage is its reward minus its task's mean reward (tinker.py on Tinker, GRPO without the std division on Slime). The Designer is not trained. generator.py and designer.py give the details.

When to use it#

  • Recorded coding-agent sessions on repositories that the sandbox can clone, to rebuild as tasks.
  • Harbor seed tasks, such as TMax, to vary around the policy's pass rate.
  • For tasks that the policy writes from a description, use SPADE. For tasks from the failures of live traffic, use continual environments.

Known limitations:

  • Task names do not hold the scenario. Give each scenario, and each Designer that you compare, its own deployment.
  • By default each train task trains once, before its pass rate is known. The training pool review or calibration: refuse keeps tasks outside the band from training.
  • Unlike upstream, the pool review does not run the current model again and asks for no replacement tasks, and a variant's prompt gives the parent's pass rate, not the solver's most common failure.
  • A long outage, such as a spent Claude Code weekly limit, uses up the rounds within minutes. Restart the run after it.
  • With agent_reef_url on the training deployment, the stage keeps the Designer's calls in memory. Use a separate Reef.
  • After stage credential, a task held the Claude Code token: make a new token.
  • Claude Code has run only in E2B, on seed variants.

Requirements#

  • The e2b extra and E2B_API_KEY, or with agent_sandbox: modal the modal extra and Modal's credentials.
  • git on the Reef host. The harbor command line on the generator's host, and Docker there unless generator.environment is e2b, as in the examples.
  • With pi: a Reef that serves agent_model, records its calls and holds the sessions, such as a record-only external-provider.yaml on another port. Its inference.timeout-s must allow one agent turn.
  • With Claude Code: an OAuth token made with claude setup-token, in CLAUDE_CODE_OAUTH_TOKEN.
  • On Tinker: the tinker extra and TINKER_API_KEY.
  • On Slime: one Linux node with 8 GPUs of 80 GB, the Reef image and Qwen/Qwen3.5-9B. Nothing removes the weights of a step, about 18 GB in the artifact repository and as much in its cache.

Run the example#

From recorded sessions, on Tinker. Import the sessions on the Designer's Reef (POST /reef/records/batch) and list them in a sources file (sources.py). Then:

Shell
export REEF_TOKEN=reef-local REEF_AUTOENVSCALING_STATE_DIR="$PWD/work/autoenvscaling"   # and TINKER_API_KEY, E2B_API_KEY
export REEF_AUTOENVSCALING_SOURCES_PATH="$PWD/sources.json"
export REEF_AUTOENVSCALING_DESIGNER_URL=http://127.0.0.1:8901 REEF_AUTOENVSCALING_DESIGNER_TOKEN=<its token>
reef serve -c recipes/beta/autoenvscaling/examples/recorded_sessions/serve-tinker.yaml
curl -s -X POST -H "Authorization: Bearer $REEF_TOKEN" -H "Content-Type: application/json" \
  -d '{"name": "autoenvscaling"}' http://127.0.0.1:8900/reef/scenarios
curl -s -X POST -H "Authorization: Bearer $REEF_AUTOENVSCALING_DESIGNER_TOKEN" -H "Content-Type: application/json" \
  -d '{"name": "autoenvscaling"}' "$REEF_AUTOENVSCALING_DESIGNER_URL/reef/scenarios"

The Designer's Reef records the Designer's calls. pi takes 10 to 25 minutes per session. Each generation's report is the state document report/<n> of the task store generated-tasks, in the table task_state_document of the scenario's SQLite database. It gives each session the stage where it stopped (STAGE_* in generator.py).

From seed tasks. Convert unzipped TMax-15K tasks, or extracted TMax v1.1 tasks with --harbor (tmax.py); 6,844 of the 13,565 v1.1 tasks convert. Then start a deployment and create the scenario as above:

Shell
python -m recipes.beta.autoenvscaling.tmax --harbor --tasks tmax-v11-tasks --out /data/tmax-seeds
export REEF_AUTOENVSCALING_SEEDS_PATH=/data/tmax-seeds CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
reef serve -c recipes/beta/autoenvscaling/examples/tmax_seeds/serve-tinker.yaml

On Slime, run tmax_seeds/serve.yaml as its header says, with PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True. The first round trains seeds only; later rounds give up to half their slots to Claude Code's variants, 6 to 20 minutes each.

Train from saved tasks. Run the generations with no trainer, as test_autoenvscaling_generator.py does: GeneratedTaskSamples.run(GenerationJob(...)) for each generation, on the scenario's storage, with the generator service of a deployment that trains nothing. Then start the example with --recipe.samples.rounds <n>; it trains the saved tasks and generates no more.

Configuration#

The generator's keys, in recipe.samples.generator.config; a mode off may be a bare YAML off:

  • generator_url (required): ${endpoints.generator}.
  • sources_path, or seed_tasks_path (needs adaptive): the sessions or the seeds. Keep the seeds fixed for a scenario; without sessions, give enough seeds for the rounds before the first parents exist.
  • count (8), designer_concurrency (1): the tasks of a generation, and the Designer runs at once.
  • band_low, band_high (0.25, 0.75): the pass-rate band; null is no bound.
  • designer (agent): or prompt, the one-reply baseline (agent_api openai or responses); compare it with both bounds null.
  • designer_harness (pi): or claude-code, with claude_model (opus) and claude_token_env (CLAUDE_CODE_OAUTH_TOKEN).
  • agent_model, agent_reef_url (required), agent_token_env (REEF_TOKEN), agent_api (openai, responses or anthropic): the Designer's model and its Reef.
  • max_checks (6), max_model_calls (250), agent_timeout_seconds (2700): the limits of one Designer run.
  • agent_sandbox (e2b or modal), agent_sandbox_options: the sandbox.
  • behaviour_rule (true): tests check only what the instruction states.
  • review (refuse), review_model (agent_model): the test review; it needs agent_api openai or responses.
  • contamination (off), contamination_tasks_path, contamination_ngram (13): the n-gram check against the instructions of reference tasks.
  • calibration (off, measure or refuse), calibration_rollouts (4), calibration_max_rollouts (8), calibration_margin (0.15), calibration_min_std (0.1), calibration_model (the generator's model): the solver's rollouts in validate.
  • adaptive (false), variant_share (0.5): vary tasks outside the band, in at most this share of the slots.

In recipe.samples:

  • Leave source-records-per-round at 0.
  • Raise generation-deadline-seconds (1800) to cover the Designer and the calibration; the examples set 21600. With the calibration on, raise validation-concurrency and generator.concurrency together.
  • AutoEnvScaling's training pool: pool-capacity: 32, review-interval: 16, review-window: 4, review-min-reward-std: 0.1, and review-band-low and review-band-high equal to the generator's band.
  • Keep eval-fraction and split-seed fixed for the life of a scenario.

The examples' YAML explains their agent settings. With compaction on, set model_info.max_input_tokens well under the context window. See generated tasks and the settings reference.

Results#

The full tables and methods, recorded nowhere else, are in the README at 50ac92fa1. Tasks from sessions (#791): the Designer on gpt-6-sol, gpt-6-luna as the strong solver; no model trained on them.

77 SWE-Together sessions, 3 rebuilds eachpromptagent
Valid: the oracle passes and nop fails30%100%
Faithful: the original fix passes the rebuilt tests, the rebuilt solution the original tests6%24%
Agent mode, SWE-chat sessionsWithout checks (20)Behaviour rule and review: refuse (84)
Fair tasks: gpt-6-luna solves 1 or more of 2 rollouts6 of 1941 of 51
Qwen3.5-9B rollouts that solve a fair task3 of 2336 of 91

Qwen3.5-9B on TMax seeds and Claude Code's variants, with paired bootstrap 95% intervals against the base model:

RunStep96 held-out seeds, avg@4Terminal-Bench 2.0, avg@5
Tinker, LoRA (#1214)5022.9 (+2.4 [-0.4, +5.4])
Slime, seeds only, run 2 (#1566)6458.3 (+8.6 [+2.3, +15.1])20.4 (+2.2 [-0.4, +5.2])
Slime, seeds and variants6457.0 (+7.3 [+0.5, +14.1])21.1 (+2.9 [-0.2, +6.1])

The Slime base model scored 49.7 and 18.2, and moved up to 4.7 and 2.9 points when scored again. No Terminal-Bench difference clears zero, nor does any difference between the run with variants and seeds only.

Files#

Text
autoenvscaling/
  __init__.py              exports the generator, the Designers and the checks
  generator.py             AutoEnvScalingGenerator: the cursor, admission, checks, band, parents and seeds
  designer.py              the Designer contract, pi behind a recording gateway, the prompt Designer
  designer_tools.ts        pi's task_check tool
  claude_designer.py       Claude Code as the Designer
  designer_credentials.py  the checks and redaction of Claude Code's token
  check_gateway.py         the gateway that serves a Designer's task checks
  task_check.py            Claude Code's task_check command
  checks.py                the oracle, seed, contamination, review and calibration checks
  sources.py               the sources file and the session text
  tmax.py                  converts TMax tasks into seed tasks
  tmax_verifier.sh         a converted TMax task's verifier
  tinker.py                the Tinker objective
  examples/
    recorded_sessions/serve-tinker.yaml  pi rebuilds recorded sessions, on Tinker
    tmax_seeds/serve-tinker.yaml         TMax seeds and Claude Code's variants, on Tinker
    tmax_seeds/serve.yaml                the same on Slime, one node of 8 GPUs

The tests are in tests/recipes/autoenvscaling/.