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: refusekeeps 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_urlon 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
e2bextra andE2B_API_KEY, or withagent_sandbox: modalthemodalextra and Modal's credentials. giton the Reef host. Theharborcommand line on the generator's host, and Docker there unlessgenerator.environmentise2b, as in the examples.- With pi: a Reef that serves
agent_model, records its calls and holds the sessions, such as a record-onlyexternal-provider.yamlon another port. Itsinference.timeout-smust allow one agent turn. - With Claude Code: an OAuth token made with
claude setup-token, inCLAUDE_CODE_OAUTH_TOKEN. - On Tinker: the
tinkerextra andTINKER_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:
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:
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.yamlOn 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, orseed_tasks_path(needsadaptive): 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): orprompt, the one-reply baseline (agent_apiopenaiorresponses); compare it with both bounds null.designer_harness(pi): orclaude-code, withclaude_model(opus) andclaude_token_env(CLAUDE_CODE_OAUTH_TOKEN).agent_model,agent_reef_url(required),agent_token_env(REEF_TOKEN),agent_api(openai,responsesoranthropic): 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(e2bormodal),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 needsagent_apiopenaiorresponses.contamination(off),contamination_tasks_path,contamination_ngram(13): the n-gram check against the instructions of reference tasks.calibration(off,measureorrefuse),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 invalidate.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-roundat 0. - Raise
generation-deadline-seconds(1800) to cover the Designer and the calibration; the examples set 21600. With the calibration on, raisevalidation-concurrencyandgenerator.concurrencytogether. - AutoEnvScaling's training pool:
pool-capacity: 32,review-interval: 16,review-window: 4,review-min-reward-std: 0.1, andreview-band-lowandreview-band-highequal to the generator's band. - Keep
eval-fractionandsplit-seedfixed 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 each | prompt | agent |
|---|---|---|
| Valid: the oracle passes and nop fails | 30% | 100% |
| Faithful: the original fix passes the rebuilt tests, the rebuilt solution the original tests | 6% | 24% |
| Agent mode, SWE-chat sessions | Without checks (20) | Behaviour rule and review: refuse (84) |
|---|---|---|
Fair tasks: gpt-6-luna solves 1 or more of 2 rollouts | 6 of 19 | 41 of 51 |
| Qwen3.5-9B rollouts that solve a fair task | 3 of 23 | 36 of 91 |
Qwen3.5-9B on TMax seeds and Claude Code's variants, with paired bootstrap 95% intervals against the base model:
| Run | Step | 96 held-out seeds, avg@4 | Terminal-Bench 2.0, avg@5 |
|---|---|---|---|
| Tinker, LoRA (#1214) | 50 | 22.9 (+2.4 [-0.4, +5.4]) | |
| Slime, seeds only, run 2 (#1566) | 64 | 58.3 (+8.6 [+2.3, +15.1]) | 20.4 (+2.2 [-0.4, +5.2]) |
| Slime, seeds and variants | 64 | 57.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#
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 GPUsThe tests are in tests/recipes/autoenvscaling/.