Repository navigation
feat: restore rollouts from memory snapshots - #3141
Merged
Merged
Conversation
Add an in-box relay (`interception/relay`) that a harness in a remote box reaches the interception server through, at 127.0.0.1, instead of the tunnel URL (`agent.relay`, off by default). The relay retries a model call for up to 5 minutes while the tunnel cannot be reached, and marks each retry so the interception server joins it to the call it already serves. When a tunnel is lost for good, its server still takes no new rollouts, but no longer fails the ones that reach it through a relay: it opens a new tunnel, allows its host in each box's egress policy and reroutes each relay. Rollouts with tool servers or deployment services still fail, since those reach the old URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop `agent.relay`: a harness in a remote box always reaches the interception server through its relay, and a relay that does not start leaves it on the tunnel URL with a warning. - Give the relay only the model secret, which the harness already holds: a harness that reads the relay config gains no capability. - Run one relay per rollout (own dir, ephemeral port) and stop it when the rollout closes, so rollouts that share a box never share one. - Make a rollout movable before the server registers it; a tunnel lost while the relay starts waits for it. - Replace the tunnel again when it is lost during a replacement. - Retry a non-streaming body that breaks before any data, and a body that ends before its Content-Length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The relay added about 4 s to setup (GSM8K, p50 6.4 s -> 10.6 s): eight sandbox calls one after another. Launch it while the harness sets up, with a placeholder upstream, and configure it once the interception slot is acquired: one write and one exec on the critical path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `Relay` object owns the relay's lifecycle (launch alongside the harness setup, connect, reroute, stop), so the rollout keeps one field. The retry window is a constant; tests patch the script source. The relay verified the tunnel's certificate against the system CA store, which a task image may lack: terminal-bench-2's financial-document-processor image has no /etc/ssl/certs, so both its relayed rollouts failed on their first model call while the harness's own HTTP client (certifi) worked on main. Trust certifi's roots as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The relay is part of the machinery like the interception server: a relay that does not start fails the rollout with a SandboxError, which the rollout retry rules cover, instead of a silent fallback to the tunnel URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `RelayError` (an `InterceptionError`, next to `TunnelError`). A relay that does not start raises it. A relay that gives up on a request appends the reason to a failures file in its directory; when the harness then dies, the rollout checks that file and whether the relay still runs, and records `RelayError` with the relay's reason instead of the harness's `HarnessError`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scripts prepared in parallel each ran the uv bootstrap under a lock of their own script: in an image without uv, two `pip install --user uv` runs or downloads to one path (or apt's lock) raced, and one failed. The relay prepares its script during the harness setup, so CI hit it: a random network-policy cell failed with zero branches. The first preparation per user now holds a bootstrap lock; once uv is there, scripts prepare in parallel. The integration grid's one-branch assertions show the trace's errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Mark a resend as a retry only after an attempt that may have reached the server; a connect failure or an edge page did not, so a body a later turn repeats is never answered from the replay cache. - Never frame SSE with a fixed length, and close an edge error page unread instead of draining it. - Count a new outage from its start once a response stayed up. - Record "ok" after a request goes through again, so a stale relay failure never names a later, unrelated harness death. - Stop the relay process also after a failed or cancelled launch. - Leave a closing rollout's egress alone on a reroute (shared scoring sets its own), and strip the trailing slash `host_url` may return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent snapshots its prime box as model turns go upstream, and a rollout retry restores the newest snapshot in a new box and continues the trace from there instead of starting over. On by default (`[env.agent.checkpoint]`: interval, keep, after, boxless). The trace records each snapshot (`Trace.checkpoints`), rewinds to the one a retry restores (`Trace.rewind`, `Trace.generation`), and gives another process what it needs to continue it (`Trace.restorable`, `RestorePoint`, `Env.run_slot(restore=...)`). null and bash relaunch on the transcript; claude-code, codex and rlm load their ACP session from the restored box (rlm pinned to nano-rlm with session/load). A request hook that raises now ends the rollout with its error. This is the filesystem-only state of verifiers#2994 as of ebfd9f8, on today's main. Its env-server parts moved with the env server to prime-rl and are not part of this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scope rollout checkpointing to retries within one Agent.run: drop the cross-process restore (Env and Agent.run restore params, RestorePoint, PinnedResult, Trace.restorable, Agents.only). Call the runtime side a snapshot: backends return a typed Snapshot (id, type) from snapshot(), wait_snapshot() and discard_snapshots() take it, and restore_config() builds the config a new box boots from. Runtimes and harnesses declare SUPPORTS_FILESYSTEM_SNAPSHOTS, and RolloutCheckpointConfig.type takes a SnapshotType, so memory snapshots can slot in behind the same API. Also from review: - snapshot every 10th turn by default - copy state before the first await of a capture, so response hooks that run meanwhile do not leak into the checkpoint - trim the checkpoints after the restored one by position, not node - build the rollout params once per run, so an RLM retry keeps its skill home and the restored session loads - discard snapshots on the shared leased client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A turn cancelled while its reply waits for the snapshot capture now still records its call and abandons its preview. The wait is shielded, so the snapshot finishes in the background, where the rollout awaits it. A capture reads the turn's node and tail before its first await, like the state copies, so everything a checkpoint describes comes from the idle box. Docs: show the checkpoint config as a TOML example, and shorten the harness flag's entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore a rollout from a snapshot end to end on prime: per harness, at the default interval, for rlm with skills, and for each retention policy. The cases run once per SnapshotType, on every harness and runtime that declare SUPPORTS_<TYPE>_SNAPSHOTS, so a new snapshot type gets its cases without a test change. CI runs it as "Checkpoint Restore". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A box-less checkpoint let a harness that runs no code restore from the trace alone on a runtime without snapshots. It served restores in another process, which this PR no longer does; for retries in one run it only saves the few turns of a short chat rollout. Every checkpoint now has a snapshot, and the boxless setting is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record every snapshot the run's boxes take, across attempts, and check each on the platform once the run is done: deleted, except the ones the retention policy keeps, which stay restorable. Before, only the checkpoints left on the final trace were checked, so a rewound snapshot or one still uploading at the end could leak unnoticed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # verifiers/v1/agent.py # verifiers/v1/rollout.py # verifiers/v1/runtimes/backends/prime.py
When a rollout is cancelled (an agent timeout, shutdown), its harness turn is cancelled and then joined. A second cancellation during that join left the turn running while teardown began, where it could still write the trace or use the box. Join it shielded, then re-raise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review: keep the checkpoint config to what a user decides. - interval counts from turn n (the n-th, 2n-th, ...), so a rollout shorter than n turns takes no snapshot; the turn a restore resumes at is not snapshotted again, so keep = "last" no longer deletes the snapshot that just restored - every snapshot is deleted once the run is final: drop `after` - drop keep = "all", which keep = 1 already expresses - drop `type` from the config and SnapshotType from the API: the runtime takes the best snapshot it supports and records its type on the checkpoint (Snapshot.type) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A harness can continue a rollout in a box restored from a snapshot when a new process of it can take the rollout over. For a harness that resumes on the transcript (SUPPORTS_RESUME), a restore is that same relaunch, so it needs nothing more. An ACP harness keeps its session in a live process and needs its agent to load the session from its files: ACPHarness.LOADS_SESSIONS (claude-code, codex, rlm). This replaces the harness-side SUPPORTS_FILESYSTEM_SNAPSHOTS (Harness.can_restore). browser-use now restores like any harness that resumes on its transcript. A restore whose attempt fails before its first new turn is marked failed like one whose box never booted, so the next retry steps back to an older snapshot or starts over instead of restoring the same snapshot until the retries run out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The condition read `target is not None and A or B`, so B ran for runs that restored nothing and read `restored_turns` on them. Group it as `target is not None and (A or B)`. The new test's fake rollout also called the run's `on_trace` hook, which it does not pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mem-ckpt # Conflicts: # verifiers/v1/session.py
…at/mem-ckpt # Conflicts: # verifiers/v1/interception/server.py
A memory snapshot (a pause of the box) holds the box's processes. A retry boots a new box from it, reroutes the box's relay to the new session and waits for the harness program the box still runs, so no harness has to load a session or be told about the restore. The ACP runner can run as a job of the box with one job per request, because no connection from the host survives a stopped box. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Nov 24, 2026
mikasenghaas
pushed a commit
that referenced
this pull request
Nov 24, 2026
Stacked on #3265. Fixes the [capture/commit race reported on #3141](#3141 (comment)). When one reply commit sets the session event, a second commit can clear it and append a trace node before the snapshot waiter runs. The waiter would then capture that node before the corresponding replay response existed. On restore, the harness could retry a turn already present on the trace. Recheck the event after each wake. Once all commits have settled, the snapshot copies the trace position and replay state without yielding. This covers both interval and trainer-triggered captures. Extended the existing regression to start a second commit in the wakeup window and verify its response is replayable. It failed on the #3265 head and passes with this change. The unit suite passed (377 passed, 19 skipped), as did the contributor checks. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches memory checkpoint timing in the agent rollout path; incorrect behavior could cause restore/replay bugs, but the change is narrow and covered by a targeted regression test. > > **Overview** > Fixes a **capture/commit race** where a memory snapshot could record the trace **after the first reply commit finished but before a second commit stored its replay**, leaving a trace node without a matching replay on restore. > > `_take_snapshot` now **loops on `session.settled`** until no reply is still committing, instead of waiting once. That covers the window where a new `committing()` clears `settled` and appends a node right after the waiter wakes. > > The checkpoint unit test was extended to **simulate a second commit in that wakeup window** and assert the snapshot includes the new node’s replayable response. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9caa788. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Fix `Rollout._checkpoint` to recheck settled event after each commit wake > `Rollout._checkpoint` in [rollout.py](https://github.com/PrimeIntellect-ai/verifiers/pull/3268/files#diff-f886b7f4717cf8fce9270bd4ff4790f3182aa1016abb9efb7f6e57efe18d1bf2) previously waited once on the session's settled event. Now it loops: after each wake it rechecks the event and waits again if another commit has cleared it. This keeps checkpoint capture blocked while any turn is still committing. > > - Updates the unit test in [test_checkpoint.py](https://github.com/PrimeIntellect-ai/verifiers/pull/3268/files#diff-54ce262e8695b5b1a922eaf3a5a664714a8057462f83fbe9cb9ffe7785cce33d) to start a second commit after the first wakes the checkpoint waiter, and to assert the checkpoint includes the replay response. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 9caa788.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
Stacked on #3141 for the training checkpoint flow in PrimeIntellect-ai/prime-rl#4456. A model turn can spend minutes in a REPL or subprocess. Set `env.agent.checkpoint.interval` to the interval in minutes to capture the running sandbox on a wall-clock timer, including during those stretches. Periodic capture remains opt-in. A held owner save (the call made by the trainer) adopts a recent rollout-owned capture within the same interval. A racing save can wait for its upload. Adoption uses the existing snapshot ID and saved host session. A resumed episode repeats the work since that capture. A fresh capture resets the timer. An ordinary unheld save still captures on demand. Ownership follows #3141's deletion contract. Each exported snapshot belongs to one external owner. An already exported snapshot cannot be adopted a second time or used as a guaranteed local retry point. Repeated trainer saves may therefore need a fresh capture inside the interval. Sharing the same ID across independent owners would require coordinated release. The unit suite passed (371 passed, 19 skipped), along with Ruff, all contributor hooks and the Python 3.13 type check. The timer regression test exercises a rollout with no model calls and checks that a held save returns the same snapshot ID after one backend capture. Two live RLM integration cases hold an IPython cell open across a memory snapshot. The first verifies that a held save adopts the periodic ID without another backend capture. The second verifies that a subsequent owner receives a distinct ID. Both forks finish the interrupted cell and read its in-memory variable on the next turn. The existing two-sub-agent recovery case also passed using the public DeepSeek v4.1 Flash 1017 model. Ran a three-step Qwen3-0.6B training job with PrimeIntellect-ai/prime-rl#4456 and live Prime RLM sandboxes. At step 1, the periodic snapshot and the saved rollout had the same ID and capture timestamp. The checkpoint's open-work manifest and snapshot ledger both referenced it. A fresh trainer fork loaded step 1, restored that exact ID at turn 0, and finished the same trace on attempt 2 with reward 1. The two rollouts still booting at the save were recorded to start over. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Checkpoint rollouts on a wall-clock timer instead of model-turn count > - Periodic snapshots are now scheduled by elapsed minutes since the last capture (`Rollout._schedule_snapshot` / `_periodic_snapshot` in [rollout.py](https://github.com/PrimeIntellect-ai/verifiers/pull/3265/files#diff-f886b7f4717cf8fce9270bd4ff4790f3182aa1016abb9efb7f6e57efe18d1bf2)), so checkpoints happen even during segments without model calls. `RolloutCheckpointConfig.interval` is a positive float in minutes, rejecting infinity and NaN. > - Model exchanges no longer trigger checkpoints: the per-exchange checkpointer task in [server.py](https://github.com/PrimeIntellect-ai/verifiers/pull/3265/files#diff-84e2f8d027d609e8760ef6d533535ec9d99dfc6384d5ddb6111b4001b2010f35) and the `RolloutSession` checkpointer field are removed. > - A held owner save can adopt a recent eligible periodic snapshot (`Rollout._owner_checkpoint`), pinning it and waiting for durability; otherwise it takes a fresh one. Holds are tracked by ID rather than a boolean, so release/disown operations target only the matching save's hold. > - `Trace.split_agent_time` now attributes capture duration to checkpoint time, subtracting overlap with model-call spans; `Checkpoint.held` records sandbox capture wall time excluding upload. > - Restorable traces export only the checkpoint transferred for the save, and failed uploads no longer remove pinned snapshots from stray tracking unless they were exported. > - Behavioral Change: `interval` semantics change from model-turn count to minutes; any existing config using a turn count will now be interpreted as minutes (e.g. 5 turns becomes 5 minutes). `RolloutSession.checkpointer` is removed, and `Rollout._take_snapshot` no longer limits captures to one per trace node. > > <!-- Macroscope's changelog starts here --> > #### Changes since #3265 opened > > - Changed checkpoint interval handling in `Rollout` to treat `interval` as seconds rather than minutes [0b527c8] > - Updated the documented unit of the checkpoint `interval` from minutes to seconds [0b527c8] > - Converted checkpoint test intervals from minutes to seconds [0b527c8] > <!-- Macroscope's changelog ends here --> > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized dd84780.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core checkpoint timing, save/hold ownership, and restore trace shape—misconfigured `interval` values (turns vs seconds) and trainer resume behavior need careful validation in production training flows. > > **Overview** > **Rollout checkpoints now fire on a wall-clock timer** instead of every N model turns. `env.agent.checkpoint.interval` is a duration in **seconds** (not turn count); periodic captures run during harness work even when there are no model calls. > > The interception server no longer triggers snapshots alongside each model exchange—the `RolloutSession` checkpointer hook is removed. **`Rollout`** schedules `_periodic_snapshot` via `_schedule_snapshot`, and **held `save_all` / `save(hold=True)`** can **pin a recent timer capture** (`_owner_checkpoint`) instead of forcing a new backend snapshot when one is still within the interval. Holds are tracked by snapshot/hold id rather than a single boolean. > > **`restorable`** exports only the checkpoint being handed off (avoids cross-owner GC/retry confusion). Retry teardown **skips deleting owner-pinned** snapshots except the one offered for restore. Timing: **`Checkpoint.held`** is sandbox stop/capture wall time; **`split_agent_time`** subtracts overlap with model-call spans. > > **Docs** and **integration tests** (including RLM IPython cell across adopt/re-pin) reflect the new semantics. **Config migration:** any existing numeric `interval` meant “turns” will now be read as seconds. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0b527c8. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Mika Senghaas <mika@primeintellect.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # uv.lock # verifiers/v1/interception/server.py # verifiers/v1/session.py
- An aborted segment waits for the owner's release, like a finished one, so an owner never records a rollout that already ended. - Parse, mediation and request-stop errors wait for a snapshot under way, like replies: at scale a pause takes tens of seconds, and a box that got its stop before the pause would restore as already ended. - A reply's replay window counts from when it went out, not from when it was ready: a hold can keep a reply back for minutes. - rewind clears stop_info with the stop condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The task state lives on the host, so a restore needs it in the checkpoint. A state that does not serialize now skips the snapshot before the box is paused, warns once per rollout, and the owner's save reports "its task state cannot be serialized" instead of a generic error with a traceback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # verifiers/v1/interception/server.py # verifiers/v1/session.py
Each held save armed its own 120 s release when it returned. A held save waits for its snapshot to be durable, and at a few thousand boxes that takes minutes, so the first rollouts went on, and could finish, while later boxes were still being saved and before the owner recorded them. save_all now arms the watchdogs when it returns, or leaves them to the owner (watchdog=False, then arm_hold_watchdogs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A held save waited for its snapshot to become durable. At a few thousand boxes that is 5-9 minutes at the median (upload throughput is capped platform-wide), past the 300 s an owner such as prime-rl's orchestrator waits for a save. A held save now returns once the box runs again, and adopts a recent timed snapshot without waiting for its upload. The snapshot becomes durable in the background; PrimeBackend waits for that before it restores from it, and a snapshot that never gets there fails the boot, so the rollout starts over. A pinned snapshot whose upload fails stays the owner's to delete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A held save now returns before its snapshot is uploaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 954ec3f. Configure here.
An interaction, or a rollout whose agent has checkpointing off, has no checkpoint config. It could still take a memory snapshot in save_all, and its prune after the upload then failed on the missing config. Only Agent.run continues a rollout from a checkpoint, so these rollouts now report why they are not saved instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hallerite
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
A running rollout can now be stopped and continued later, in a new sandbox and by another process, without losing work. The harness needs no changes and gets no notice.
save_all), or the rollout snapshots itself on a timer (checkpoint.interval, in seconds), also while the harness runs a long tool call with no model calls. A held owner save adopts a snapshot younger than the interval instead of taking another. No snapshot is taken by default.It includes the relay between the harness and the interception server, and supersedes #3073 and #3074 (both closed).
It needs
attach_process(PrimeIntellect-ai/prime#1147, released in 0.5.13) andwait_for_pause/wait_for_resume(PrimeIntellect-ai/prime#1233, not released yet). Until #1233 is released,[tool.uv.sources]pinsprime-sandboxesto its commit, and the requirement stays at>=0.5.14(main requires>=0.5.15; the pinned commit reports 0.5.14). Remove the pin and go back to main's requirement before merge.How it works
flowchart LR subgraph box["Sandbox (forked on restore)"] H["Harness program"] -->|"127.0.0.1"| R["Relay"] end R -->|"tunnel"| A["Interception server, host A"] R -.->|"after restore"| B["Interception server, host B"]Snapshot
Restore
Runtime.attach).API surface
Config
[env.agent.checkpoint]--no-env.agent.checkpointturns it off.checkpoint.intervalcheckpoint.keep"last"runtime.snapshots_per_minFor the owner of a rollout (
verifiers.v1.restore)save_all(hold=False, skipped=None)release_all()save_all(hold=True), under which a saved rollout waits at its checkpoint. A hold ends by itself after 120 s.RunSlot(task, id=..., restore=trace),Agent.run(task, restore=trace)unsaveable(config)Trace
Trace.checkpointsCheckpointper snapshot:id,snapshot,node,pinned,restored,deleted.agent_timeis the agent time spent when the snapshot was taken. A saved trace also carries what a restore needs (Checkpoint.session): the host state beside the trace, as plain data.Trace.rewindtiming.agent.checkpointRuntime and harness
RuntimeBackend.snapshot,wait_snapshot,restore_config,discardSUPPORTS_MEMORY_SNAPSHOTS).Runtime.run(..., program=),Runtime.attachattachrecords the program's job asrundoes, so a restored rollout can be saved again.Harness.SUPPORTS_MEMORY_RESTORERelay(#3074)connect,reroute,installed,state,failure,stop.x-vf-interceptionheaderIdempotency-Keyfrom the relayRobustness on Prime
checkpoint.intervalruns on a wall-clock timer from the newest snapshot, so a long tool call with no model calls is still snapshotted (Checkpoint active rollouts on a wall-clock timer #3265).wait_for_pause/wait_for_resume. They share the client's batched status lookups, back off from 1 s to 10 s and wait through 429s.attachwaits while a snapshot stops the box, and attaches again when one lands during the call.ping, the Responses placeholder) like comment lines, so a snapshot or reroute replays a waiting call. Relay config changes run one at a time.close()was cancelled, and isolated grading waits for an owner's uploads before it stops the box.save_all(hold=True)arms the holds' 120 s self-release only once it has every save, or leaves that to the owner (watchdog=False,arm_hold_watchdogs).save_allthat is cancelled gives finished saves back to their rollouts. A held rollout fails, like it finishes, only after the release.Trace.generationchanged) restarts its live delta stream, as a retry does. From @xeophon in fix: memory checkpoint attach race, restore egress order, keep stride, and delta rewind #3263.RelayError.Checkpoint.pinned) is the owner's to delete.Limits
A rollout takes snapshots only when all of these hold. Otherwise a retry starts over, and
save_allreports why it skipped the rollout:Two more:
Verification
Checkpoint Restore suite on Prime sandboxes, run locally at
e93524a95with the CI command (pytest tests/integration/test_checkpoint.py -n 8 --dist worksteal): 16 passed, 4 skipped. The traces of the 10 restored rollouts are on Prime: rollout-ckpt-restore-ci-2026-11-19. Each one shows attempt 1 failing at its turn, and attempt 2 continuing in a new box from the snapshot thatcheckpoints[].restorednames. Each test proves a restore with a nonce that exists only in the memory of a process in the box, and checks that no snapshot or sandbox leaks.test_retry_restores_checkpointtest_another_owner_continues_a_saved_rolloutsave_allsaves a running rollout, the rollout is cancelled, and a second env with its own server, tunnel and secrets continues it from the pickled trace.test_another_owner_continues_running_sub_agentstest_every_saved_turn_continues_to_the_same_resulttest_a_restore_point_that_leads_nowhere_starts_the_rollout_overSkips: in
test_retry_restores_checkpoint, pi, openclaw and mini-swe-agent retry the failed call themselves and finish, so no retry restores them;test_another_owner_continues_a_saved_rolloutcovers their restore (run locally atcf3684328: 13 passed, Kimi skipped). Kimi is rejected by the test endpoint.Default path, no checkpointing. The relay, the harness session and the ACP runner daemon run for every rollout in a remote box, so this compares the branch to main on the prime-rl regression eval: PI-TerminalBench2.1 (82 tasks), bash harness, Prime sandboxes, the CI model, avg@1, with the rollout budget cut to 30 min. Both ran at the same time on 2026-11-19 against the same endpoint (prime-rl main
561b609b8vs this branch at28c20b059).SandboxError: the sandbox was terminated)On the 52 tasks that both finished before the cap (medians): model time per turn 6.76 s vs 5.66 s, harness time per turn 1.07 s vs 1.04 s, setup 3.6 s vs 4.3 s (the relay install), boot 5.6 s vs 3.5 s. Every rollout on both sides has one branch and one call per turn, so the relay re-sent no model call as a new turn. Turn counts differ only in the tails (median difference per task 0). The two calls of this branch that are not on a turn are 429s of the endpoint, which the harness retried.
Training runs through PrimeIntellect-ai/prime-rl#4456, with traces linked there:
RelayErrorThe 3 h fork found a platform behaviour: a box from a snapshot older than the paused box's idle timeout ends as idle about 20 s after it runs. 46 creates were repeated for this. The create retry and the start-over above come from that.
Measured on Prime
🤖 Generated with Claude Code
Note
Add memory-snapshot checkpoint and restore for agent rollouts
Checkpointmodel andTrace.rewind, which truncates graph nodes after a checkpoint, restores checkpointed session state, and returns unpinned removed snapshots (trace.py).PrimeBackendgainssnapshot(pause sandbox, take checkpoint, resume), memory-restore sandbox creation with durability waits and retry, and reattachment of in-flight process sessions after a snapshot (prime.py).SUPPORTS_MEMORY_RESTORE; ACP harnesses run a detached socket-based runner so prompts survive snapshots (harness.py, runner.py).pyproject.tomlsourcesprime-sandboxes(min 0.5.14) from a specific Git revision override, so builds depend on that repository being reachable. Restored rollouts skip task/harness setup and require both snapshot-capable runtime and memory-restore harness; ineligible combos disable checkpointing with a one-time warning (pyproject.toml, restore.py).Macroscope summarized a015ace.
Note
High Risk
Touches core rollout lifecycle, remote sandboxes, tunnels, and model-call replay—errors could lose work, leak snapshots, or mis-attribute failures across many harnesses.
Overview
Adds rollout checkpointing and memory restore on Prime: failures (and
save_all/restore=trace) can continue from a sandbox memory snapshot instead of restarting the harness, with periodiccheckpoint.intervalcaptures and pruning viacheckpoint.keep.Agent and rollout flow now picks the newest restorable checkpoint on retry, falls back to a clean start when restore makes no progress, discards snapshots when the run is final, and exposes
RelayErrorwhen the in-box relay fails.In-box interception relay retries tunnel blips and migrates in-flight model calls when the host tunnel is replaced; interception server tests cover rerouting “movable” sessions. ACP harness runs a detached Unix-socket runner so prompts survive snapshots (
SUPPORTS_MEMORY_RESTORE).Docs cover retries/checkpoints and relay behavior; integration adds a Checkpoint Restore CI matrix plus relay tests; unit coverage is extensive for checkpoint, relay, and Prime fork/attach.
prime-sandboxesis pinned to an unreleased git rev forwait_for_pause/wait_for_resume.Reviewed by Cursor Bugbot for commit a015ace. Bugbot is set up for automated code reviews on this repo. Configure here.