Continual environments
A task generator for continual training: the failed sessions of the policy's live traffic go to a generation service, which builds Harbor tasks from them, and the policy trains on those tasks. The recipe is beta: no learning results are published yet.
What it trains#
The served model's weights, on Harbor tasks built from its own failures. Each traffic session ends with a report of a
judge's score, with no verifier. Each round of the built-in generated-task recipe takes one window of sessions and
sends the sessions that scored at most max_score to a new run of the Reef Platform's generation service. The run's
spec mines environments from the failures, builds and reviews tasks, and keeps what its reviews learn about building
tasks. A run publishes each task when it passes and goes on across rounds: each generation downloads the tasks that
every working run published since the last one, and returns once min_tasks are there. Harbor's oracle and nop agents
check each task on this host. A run has no time limit; one whose progress stops for stall_seconds is cancelled.
The recipe trains on the tasks' rollouts with their verifier rewards, and the next window is the traffic of the
trained policy. generator.py gives the flow and its restart rules.
When to use it#
- A policy that serves live traffic with a scored outcome for each session, where the failures can become tasks.
- A deployment changes how tasks are built by changing the generation spec, not this package.
- For tasks that the policy writes itself, use SPADE. To rebuild tasks from recorded coding sessions, use AutoEnvScaling.
Requirements#
- A Reef Platform whose generation Cell runs a spec with a mine stage that reads the run source
traffic(one folder<report ID>/session.jsonfor each session) and a build stage named bystage. Each task that the build stage publishes names its session's folder among its source records. - A workspace access token with the scope
generators:write, inREEF_ACCESS_TOKEN. - For the example: one Linux node with 8 GPUs of 80 GB in the Reef image (docker/README.md),
4 for the actor, 3 for Slime's rollout engines and 1 for Reef's serving engine, and a local copy of
Qwen/Qwen3.5-9B. - Docker and the
harborcommand line on the training host, for the training rollouts and the oracle checks.
Run the example#
export REEF_TOKEN=reef-local REEF_CONTINUAL_ENVS_STATE_DIR="$PWD/work/continual-envs"
export REEF_CONTINUAL_ENVS_MODEL_PATH=/models/Qwen3.5-9B PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
export REEF_PLATFORM_URL=https://console.example REEF_ACCESS_TOKEN=rft_...
export REEF_GENERATION_SPEC=terminal-failures REEF_GENERATION_GENERATOR=terminalworld-continual
reef serve -c recipes/beta/continual_envs/examples/terminalworld/serve.yaml
curl -s -X POST -H "Authorization: Bearer $REEF_TOKEN" -H "Content-Type: application/json" \
-d '{"name": "traffic"}' http://127.0.0.1:8900/reef/scenariosThen send the traffic to the scenario traffic. Each session sends x-reef-tag-source: traffic with each model call
and ends with a report of its score, from 0 to 1, against its last call. reef.harness.harbor.rollouts.TaskRolloutRunner
with labels={"source": "traffic"} and is_reporting=False runs such sessions on Harbor tasks; the client then
reports its own score with ReefClient.report. A round starts when a whole window of 64 sessions waits. The
rewards of each task's first rollout are in the state document results/<generation> of the task store
generated-tasks.
Configuration#
The generator's keys, in recipe.samples.generator.config:
service_url,spec,generator(required): the Platform's URL, the spec (<name>or<name>@<version>), and the service's generator, whose tables and stage memory every generation of the scenario shares.token_env(REEF_ACCESS_TOKEN): the variable that holds the access token.stage(tasks): the spec's build stage whose published tasks come back.params,targets({}): the run's parameters, such asper_failure, and the targets of each stage.max_score(0.5): the highest score of a failure; 1 sends every scored session.max_source_bytes(15 MiB): the most bytes of the session files of one run; a session that does not fit is left out.min_tasks(8): a generation returns once so many new tasks downloaded, or when no run works.stall_seconds(7200),poll_seconds(30): when a running run with no progress is cancelled, and how often the generator reads the runs. A start refused by the workspace's run limit (429) waits and is tried at each look.oracle_check(true),oracle_environment(docker): Harbor's oracle and nop check of each task on this host.
The stage's keys, in recipe.samples: source-tag (source=traffic), and source-records-per-round and
min-source-records-per-round at the window size. generation-deadline-seconds bounds one generation's wait for
min_tasks. The example also trains each task again in a training pool (pool-capacity and the review-* keys). See generated tasks
and the settings reference.
Results#
No measured results. The tests check the generator, its sessions and its client against stand-ins.
Files#
continual_envs/
__init__.py exports TrafficTaskGenerator and TrafficGeneratorSettings
generator.py TrafficTaskGenerator: the failed sessions of a round to a run, and every run's new tasks back
generation_service.py the client of the Reef Platform's generation API
sessions.py the traffic sessions of a round's records, and the folders that a run reads
examples/terminalworld/
serve.yaml Qwen3.5-9B on Slime, one node of 8 GPUs, on a replay of TerminalWorld trafficThe tests are in tests/recipes/continual_envs/.