Repository navigation
feat: pause an episode's model calls - #3284
mikasenghaas wants to merge 3 commits into
Conversation
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — Adds episode-level pausing with model-call gating and sandbox checkpoint suspension. An unresolved review concern indicates failed suspension can leave sandbox compute running throughout the pause, requiring a decision on retry behavior or acceptance of that cost exposure. Notes:
You can add or adjust custom eligibility rules. Learn more. |
An owner that sheds inference load can now pause a running episode instead of cancelling it. While paused, each new model call of the episode's rollouts waits at the interception server before it goes upstream; a call already upstream finishes. The box keeps running and the paused time does not count against the agent deadline. The deadline hold is now keyed by reason, so an owner's save and a pause can overlap without one ending the other, and a hold under way when a segment starts stops that segment's deadline too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A paused episode used to keep its box running, holding the box's compute for the whole pause. Each rollout that takes memory snapshots now stops its box, and its tool server VMs, at a memory checkpoint that stays stopped (`snapshot_network(..., stay_stopped=True)`), and wakes them (`wake`) when the episode resumes. The checkpoint is a regular one: it becomes durable while the box is stopped, an owner save of the paused rollout returns it, and a retry restores from it if the box does not run again. Each checkpoint has one owner, and a suspension already under way is joined, not repeated. A rollout with no harness program yet (booting, or between segments) stops its box at its first model call that waits for the pause. A paused rollout puts off its periodic snapshot, and a closing one wakes its box first so that teardown can reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aebce31 to
fdf6957
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fdf6957. Configure here.
| if session.on_paused_call is not None: | ||
| session.on_paused_call() | ||
| await session.running.wait() | ||
| started = time.time() |
There was a problem hiding this comment.
Failed pause stop is not retried
Medium Severity
A model call waiting on a pause invokes on_paused_call once, then blocks in running.wait(). If that suspension returns without stopping the box, for example because a tool call outlasts the rest timeout, nothing starts another suspension. The sandbox keeps running for the rest of the pause.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit fdf6957. Configure here.
The resume fakes take the peers and network checkpoint that `_resume` now receives, and a network stop polls its pause once before it holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Summary
Pause(verifiers.v1.pause): an episode's pause switch onRunSlot.pause. Every rollout of the episode follows it, retries included.snapshot_network(..., stay_stopped=True)). It wakes them when the episode resumes (wake), which resumes the network pause. A long pause then holds no sandbox compute. A rollout with no harness program yet (booting, between segments) stops its box at its first model call that waits for the pause (RolloutSession.on_paused_call). A rollout without memory snapshots keeps its box running.saveof a paused rollout returns it without stopping the box again, and a retry restores from it if the box does not run again. A rollout that closes while paused wakes its box first, so teardown can reach it.snapshot(stay_stopped=True)wakes its box, andclosewakes a stopped box before finalizing.OWNER_HOLD,PAUSE_HOLD), so an owner's save and a pause can overlap without one ending the other. A hold that is under way when a segment starts also stops that segment's deadline.prime-rl uses this to shed inference load by pausing episodes instead of cancelling them (adaptive concurrency). The A/B on ScaleSWE is in the prime-rl PR.
Verification
tests/unit/test_pause.py, new box-stop tests intests/unit/test_checkpoint.pyandtests/unit/runtimes/test_prime_fork.py, and a network stop that stays stopped untilwakeintests/unit/test_tool_vm_snapshot.py. The unit and integration suites run in CI.🤖 Generated with Claude Code
Note
High Risk
Touches episode execution, model-call gating, agent deadlines, and memory checkpoint/save/restore paths across rollouts and Prime sandboxes—errors could stall episodes, leak stopped boxes, or break restore points.
Overview
Adds
Pauseon eachRunSlot, so an owner can halt new upstream model traffic without cancelling the episode (e.g. shedding inference load). While paused, model calls block in the interception server untilresume, and paused time is excluded from agent deadlines via a separate hold reason alongside owner saves.Rollouts that use memory snapshots suspend the workspace box and tool VMs with
snapshot(..., stay_stopped=True)andwake()on resume, so long pauses free sandbox compute. Suspension checkpoints integrate withsave, periodic snapshots, and teardown (e.g. closing a paused rollout wakes the box first).PrimeBackendimplements stay-stopped network pauses and cancellation-safe wake behavior.Docs describe
RunSlot.pauseand the checkpoint semantics.Reviewed by Cursor Bugbot for commit b160280. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add episode pause support that stops boxes, VMs, and model calls
Pausein pause.py, a per-slot running event propagated through a context variable in env.py. Pausing a rollout begins a pause hold that stops the agent deadline and starts a box suspension via a stay-stopped memory snapshotRollout._begin_hold/_end_holdin rollout.py now track hold reasons in a set, so overlapping owner and pause holds no longer end each other. Saving a paused rollout can reuse the pause suspension's checkpoint instead of taking another snapshotstay_stoppedoption onRuntimeBackend.snapshotand a newRuntimeBackend.wakemethod, implemented for network snapshots in prime.pyRollout._begin_hold/_end_holdand the reason constants in rollout.py.RuntimeBackend.wakeraisesNotImplementedErroron backends that do not implement itMacroscope summarized b160280.