Skip to content

feat: pause an episode's model calls - #3284

Open
mikasenghaas wants to merge 3 commits into
mainfrom
feat/pause-episodes
Open

mikasenghaas wants to merge 3 commits into
mainfrom
feat/pause-episodes

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add Pause (verifiers.v1.pause): an episode's pause switch on RunSlot.pause. Every rollout of the episode follows it, retries included.
  • While an episode is paused, each new model call waits in the interception server before it goes upstream. A call already upstream finishes.
  • A rollout that takes memory snapshots also stops its box, and its tool server VMs in the same network pause, at a memory checkpoint that stays stopped (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.
  • The stop is a regular rollout checkpoint: it becomes durable while the box is stopped, an owner's save of 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.
  • A save that arrives while a suspension is under way joins it and returns its checkpoint. Each checkpoint has one owner: a later save while the box is still stopped at an owned checkpoint saves nothing. A cancelled snapshot(stay_stopped=True) wakes its box, and close wakes a stopped box before finalizing.
  • The paused time does not count against the agent deadline.
  • The deadline hold is keyed by reason (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

  • New tests/unit/test_pause.py, new box-stop tests in tests/unit/test_checkpoint.py and tests/unit/runtimes/test_prime_fork.py, and a network stop that stays stopped until wake in tests/unit/test_tool_vm_snapshot.py. The unit and integration suites run in CI.
  • ScaleSWE A/B on Qwen3.6-35B-A3B (details in feat: pause episodes instead of cancelling on overload prime-rl#4807): 1,302 episodes paused at an overload cut. 1,299 boxes stopped (7.4 s median) and all 1,299 woke again (10.5 s median, 89.6 s max), after stops of up to 61.5 min. 1,283 of the paused episodes finished ok and 18 were still running at stop. One failed: the platform terminated its box 3 min after a successful wake, with no reason recorded.

🤖 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 Pause on each RunSlot, 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 until resume, 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) and wake() on resume, so long pauses free sandbox compute. Suspension checkpoints integrate with save, periodic snapshots, and teardown (e.g. closing a paused rollout wakes the box first). PrimeBackend implements stay-stopped network pauses and cancellation-safe wake behavior.

Docs describe RunSlot.pause and 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

  • Adds Pause in 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 snapshot
  • server.py blocks model calls while the episode's running event is unset, so no upstream requests happen during a pause
  • Rollout._begin_hold/_end_hold in 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 snapshot
  • Backends gain a stay_stopped option on RuntimeBackend.snapshot and a new RuntimeBackend.wake method, implemented for network snapshots in prime.py
  • Risk: hold semantics change — code relying on a single owner hold restarting the deadline should check Rollout._begin_hold/_end_hold and the reason constants in rollout.py. RuntimeBackend.wake raises NotImplementedError on backends that do not implement it

Macroscope summarized b160280.

Comment thread verifiers/v1/rollout.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/pause.py Resolved
Comment thread tests/unit/test_pause.py Resolved
@macroscopeapp

macroscopeapp Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/interception/server.py Resolved
Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/runtimes/backends/prime.py Resolved
Comment thread verifiers/v1/rollout.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/rollout.py Resolved
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 27, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread verifiers/v1/rollout.py Resolved
Comment thread verifiers/v1/rollout.py Resolved
mikasenghaas and others added 2 commits December 3, 2026 21:02
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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant