Repository navigation
feat(checkpoint): prepared verification, so a checkpoint never waits for SWE-bench grading - #4778
Draft
pthombre wants to merge 1 commit into
Conversation
This was referenced Oct 20, 2026
pthombre
added a commit
that referenced
this pull request
Oct 20, 2026
…t a failed session database snapshot in full - README: a "Checkpoint resume" section. A checkpoint pauses OpenCode, and OpenCode is relaunched on its saved session only after a crash restore or when a pause cannot be confirmed. The relaunch re-enters the saved user message through resume_opencode.py without a new message. The section also gives the sandbox requirements and how to run the real-runtime resume regression. - The error for a failed `opencode db VACUUM INTO` names the destination, return code, error type and the tail of stdout and stderr. A background execution returns both streams in stdout, so stderr alone often held only a status. From #4553 (b53e39f, 4d077ea), whose resume helper and the rest of whose changes are now in #4274 and #4778. Signed-off-by: Anish Mahishi <[email protected]> Co-authored-by: Pranav Prashant Thombre <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
pthombre
force-pushed
the
pthombre/partial-ckpt-sandbox-prepared-verify
branch
from
October 20, 2026 17:01
a639248 to
1a96350
Compare
pthombre
changed the base branch from
pthombre/partial-ckpt-sandbox-capture
to
amahishi/opencode-resume-tool-call-lineage
October 20, 2026 17:01
pthombre
added a commit
that referenced
this pull request
Oct 20, 2026
…t a failed session database snapshot in full - README: a "Checkpoint resume" section. A checkpoint pauses OpenCode, and OpenCode is relaunched on its saved session only after a crash restore or when a pause cannot be confirmed. The relaunch re-enters the saved user message through resume_opencode.py without a new message. The section also gives the sandbox requirements and how to run the real-runtime resume regression. - The error for a failed `opencode db VACUUM INTO` names the destination, return code, error type and the tail of stdout and stderr. A background execution returns both streams in stdout, so stderr alone often held only a status. From #4553 (b53e39f, 4d077ea), whose resume helper and the rest of whose changes are now in #4274 and #4778. Signed-off-by: Anish Mahishi <[email protected]> Co-authored-by: Pranav Prashant Thombre <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
pthombre
force-pushed
the
pthombre/partial-ckpt-sandbox-prepared-verify
branch
from
October 20, 2026 22:18
1a96350 to
4a7590c
Compare
pthombre
added a commit
that referenced
this pull request
Oct 21, 2026
…t a failed session database snapshot in full - README: a "Checkpoint resume" section. A checkpoint pauses OpenCode, and OpenCode is relaunched on its saved session only after a crash restore or when a pause cannot be confirmed. The relaunch re-enters the saved user message through resume_opencode.py without a new message. The section also gives the sandbox requirements and how to run the real-runtime resume regression. - The error for a failed `opencode db VACUUM INTO` names the destination, return code, error type and the tail of stdout and stderr. A background execution returns both streams in stdout, so stderr alone often held only a status. From #4553 (b53e39f, 4d077ea), whose resume helper and the rest of whose changes are now in #4274 and #4778. Signed-off-by: Anish Mahishi <[email protected]> Co-authored-by: Pranav Prashant Thombre <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
pthombre
force-pushed
the
pthombre/partial-ckpt-sandbox-prepared-verify
branch
from
October 21, 2026 03:05
4a7590c to
37f5c84
Compare
7 tasks done
6 of 7 tasks
7 tasks done
pthombre
force-pushed
the
pthombre/partial-ckpt-sandbox-prepared-verify
branch
from
October 25, 2026 02:47
37f5c84 to
5fbfcb9
Compare
…for SWE-bench grading SWE-bench's /verify is a wait step: a checkpoint's prepare waits for every in-flight grading, which can take up to evaluation_timeout (1800 s, longer than a controller's prepare deadline). In a 32-node SWE-bench run two prepares took 833 s and 1126 s, idling every node. Verification can now take two steps: - /prepare_verify (a wait step for the caller): capture the patch, end the session and stop the agent's sandbox. A retry of a lost reply gets the same patch. - /verify_prepared: grade the captured patch in a fresh sandbox. It touches no session state, so the server declares it in the new checkpoint_replayable_paths: a checkpoint neither waits for it nor refuses it. SandboxedHarnessAgent runs an adapter's optional PreparedVerification: the capture is recorded in the verify bookmark, grading is a replay step, and a restore grades the saved capture again. OpenCode opts in with prepare_verification: true. verify_agent_response takes the route and extra body fields. From #4553 (4d077ea), which designed the same routes for the OpenCode agent before the harness driver: - A grading that fails or is cancelled before run_instance's own cleanup still stops its sandbox, and the container stop is shielded from cancellation. - run_instance gives each grading its own logger and no longer returns from its finally, which swallowed the cancellation of an interrupted grading. - The capture is a helper that leaves the sandbox running when it fails. - test_prepared_verification.py: retries return the captured patch after the sandbox stopped; a failed capture keeps the sandbox; one-step /verify still holds up prepare; a slow prepared grading does not, and replays in a restarted server without the original sandbox; /verify_prepared requires a patch but accepts an empty diff; and run_instance propagates cancellation after cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Anish Mahishi <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
pthombre
force-pushed
the
pthombre/partial-ckpt-sandbox-prepared-verify
branch
from
October 25, 2026 16:57
5fbfcb9 to
58299c1
Compare
This was referenced Oct 25, 2026
7 tasks done
This branch has not been deployed
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.
What changed and why
A checkpoint has to wait for grading. SWE-bench's
/verifyis awaitstep: a checkpoint's prepare waits for every grading in flight. A grading can take up toevaluation_timeout(1800 s), longer than a controller's prepare deadline. In a 32-node SWE-bench run with OpenCode, two prepares took 833 s and 1126 s, idling every node.Verification can now take two steps, so a checkpoint never waits for grading:
POST /prepare_verifyis a shortwaitstep for the caller. It captures the patch, ends the session and stops the agent's sandbox. A retry of a lost reply gets the same patch.POST /verify_preparedgrades the captured patch in a fresh sandbox. It touches no session state, so the server declares it replayable: a checkpoint neither waits for it nor refuses it, and after a crash it simply runs again.What this PR adds:
Replayable routes on resources servers (
nemo_gym/base_resources_server.py,nemo_gym/_checkpoint/resources.py).checkpoint_replayable_paths, a class variable listing further routes that are safe to run again after a crash and change no checkpointed session state.ResourcesParticipanttreats them like a replay-mode/verify.checkpoint_session_starts./prepare_verifyand/verify_preparedjoin the reserved routes.SWE-bench (
resources_servers/swebench/app.py):/prepare_verify, which captures the model patch and ends the session once (later calls get the same capture);/verify_prepared, which grades a givenmodel_patchin a fresh sandbox;/verify_preparedreplayable.The driver (
nemo_gym/_checkpoint/harness_run.py): an optional adapter protocol,PreparedVerification(prepares_verification,prepare_verification,verify_prepared). With it the run:prepare_verificationas awaitstep;VerifyBookmark.prepared);replaystep.A restore at a prepared verify bookmark grades the saved capture again without preparing again.
verify_agent_response(nemo_gym/sandbox/agent_tools.py) takes the route (url_path) and extra body fields (extra).OpenCode opts in with
prepare_verification: true(defaultfalse) when checkpointing is on.From fix(checkpoint): wake sandbox command polls while a harness launch is stopped #4553 (co-authored by Anish Mahishi, who designed the same routes for the OpenCode agent before the harness driver):
run_instance's own cleanup still stops its sandbox, and the container stop is shielded from cancellation;run_instancegives each grading its own logger and no longer returns from itsfinally, which swallowed the cancellation of an interrupted grading;test_prepared_verification.py.How it works
sequenceDiagram participant C as Checkpoint participant D as Driver (#4274) participant R as SWE-bench D->>D: bookmark {next: verify, prepared: null} D->>R: /prepare_verify (a wait step: capture the patch, end the session) R-->>D: {model_patch} D->>D: bookmark {next: verify, prepared: {model_patch}} D->>R: /verify_prepared (a replay step, in a fresh sandbox) C->>D: park requested Note over C,D: the checkpoint does not wait for grading:<br/>the run is exported at its prepared bookmark Note over C,R: after a crash, the restored run grades the saved patch again R-->>D: reward D->>D: bookmark {next: return}/prepare_verify/verify_prepared/verify(one step, unchanged)Where this sits in the stack
Stack #4578, on
ananthsub/partial-ckpt-fault-tests: #4220 → #4221 → #4222 → #4576 → #4274 → #4451 → #4553 → #4778 (this PR) → #4779 → #4936.This PR depends on #4274's driver and bookmarks. It does not depend on #4451 or #4553; it is stacked on top only to keep the stack linear.
Issue
Part of #3284 (sandboxed blackbox agents). It was split out of #4274 so that #4274 stays focused on the harness.
Validation
On this head (
1a9635095), in therl-gym.nightlycontainer on Slurm (job 8087405):ruffis clean, and the commit carriesSigned-off-by.Tests:
tests/unit_tests/test_checkpoint_harness_run.py:resources_servers/swebench/tests/test_checkpoint.py:resources_servers/swebench/tests/test_prepared_verification.py(from fix(checkpoint): wake sandbox command polls while a harness launch is stopped #4553):/verifystill holds up prepare;/verify_preparedrequires a patch but accepts an empty diff;run_instancepropagates cancellation after cleanup.Rollout evidence
32-node GRPO runs (nano-3.5 SWE policy, SWE-bench, 64 prompts × 2, 5 steps) with
prepare_verification: true:In those runs
prepare_verifyreported 0 errors, and rollouts restored at verify or return bookmarks were graded again from the stored patch.Compatibility
prepare_verificationdefaults tofalse, and one-step/verifyis unchanged.PreparedVerification(adapter protocol);checkpoint_replayable_paths(resources server);url_pathandextraonverify_agent_response.🤖 Generated with Claude Code