Skip to content

fix(opencode): score a context overflow that OpenCode 1.15 reports with exit 0 - #6471

Merged
lafrancef merged 1 commit into
mainfrom
wprazuch/opencode-context-overflow-exit0
Nov 20, 2026
Merged

lafrancef merged 1 commit into
mainfrom
wprazuch/opencode-context-overflow-exit0

Conversation

@wprazuch

Copy link
Copy Markdown
Contributor

What does this PR do?

When the conversation is too large to compact, OpenCode 1.15.13 saves the last assistant message with finish: "error" and a ContextOverflowError, but exits 0. OpenCode 1.17.11 exits 1 for the same error. OpenCodeAgent._reported_model_error accepted only exit 1, so the 1.15 run became a 502. SWE-Together then recorded a terminal environment_server_failed row, and the rollout was dropped instead of scored.

  • opencode_agent: a ContextOverflowError report also counts with exit 0. Every other check stays the same: finish error, completed time, no timeout, no cleanup error. An APIError still needs exit 1.
  • swe_together: an activation that stops on context_limit ends the episode, and the patch so far goes to grading. Before, the simulator was asked for another turn, and that turn would hit the same full context again.

In an internal SWE-Together run on OpenCode 1.15.13, 55 rollouts failed this way. Each one ended with "Conversation history too large to compact" (or the "Session too large" variant) and exit code 0.

Validation

At 44185946f0cd71ccf1295c73d8c71870ca2e7c9c (base 1bc262ada7), with the frozen per-server locks:

  • responses_api_agents/opencode_agent/tests: 967 passed, 81 skipped. One random test fails per run with KeyError: '' inside agent.responses. That failure hits a different test each run, passes on rerun, and also happens on unchanged main (1 of 2 runs).
  • environment_servers/swe_together/tests: 227 passed with test_egress.py left out. Those egress tests fail locally on a TLS certificate check (Missing Authority Key Identifier) with or without this change.
  • pre-commit run --all-files: passed.
  • The new cases fail on main and pass with this change:
    • test_only_context_overflow_is_reported_on_exit_zero
    • test_context_limit_preserves_partial_work_without_hiding_cleanup_failure[None-0]
    • test_context_limit_stops_without_snapshot_or_simulator

Rollouts

N/A for a new rollout. The change is in outcome classification. The evidence is the 55 failed rollouts described above. Their saved error bodies match what OpenCode 1.15.13 session/compaction.ts writes on a compaction overflow.

Compatibility and benchmark impact

  • OpenCode 1.17.x behaviour does not change, because it already exits 1.
  • On OpenCode 1.15.x, a run that overflows its context is now graded (usually as 0) instead of being dropped. Fewer SWE-Together rows fail, and the denominator includes those episodes.
  • Other agents and environments do not change.

Checklist

  • I have read the contributing guidelines.
  • The change is focused.
  • Tests added and pass locally.
  • Documentation: N/A, no user-facing option changed.
  • Pre-commit checks pass locally on the changed files.
  • New source files include the SPDX header: N/A, no new files.
  • All commits have DCO sign-off.

…th exit 0

OpenCode 1.15.13 exits 0 when compaction itself overflows; the agent
accepted a ContextOverflowError report only on exit 1, so the run became
a 502 and SWE-Together dropped the row. Accept exit 0 for that error, and
stop the SWE-Together episode on context_limit so the patch is graded.

Signed-off-by: Wojciech Prazuch <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 19, 2026 13:42
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Nov 19, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP WITH CARE

RISK: Required real-model smoke evidence is missing

The PR reports no rollout with this change. The 55 historical failures support the original trigger, but they do not validate the newly reachable stop-to-grading path. AGENTS.md requires representative real-model smoke rollouts and inspection of agent and verifier behavior for behavior-changing environment or agent work. The supplied tests and historical error bodies do not cover that requirement, so the SWE-Together scoring change is still unvalidated in real execution.

Correction: Could you run and document one representative SWE-Together episode with this head and OpenCode 1.15.13 that reaches a completed ContextOverflowError with exit 0? A saved overflowing conversation could provide the setup if available. Inspect the activation, candidate close, final snapshot and verification result. No implementation change is requested for this finding.

Proposed acceptance checks: The activation returns incomplete without a response error. The environment records context_limit and starts no further simulator consultation or candidate activation. Candidate shutdown is confirmed before the final snapshot, and partial work reaches grading. Successful grading produces evaluation_completed=true, a measured judge_score and an unmasked result. Use a submission large enough to exercise the judge rather than only the reference short-patch zero.

Preservation: Keep exit-one overflow behavior and cleanup-error rejection covered by test_context_limit_preserves_partial_work_without_hiding_cleanup_failure: accepted overflows retain output and usage, while cleanup errors still raise. Keep exit-zero APIError rejection covered by test_only_context_overflow_is_reported_on_exit_zero. Failed grading must stay unmeasured and masked, as asserted by test_failed_judge_is_an_incomplete_masked_measurement.

I inspected all four changed files and traced error classification through response construction, episode termination, cleanup and grading. I found no source defect in those paths. Verification still captures the final patch after the early stop. This was a source-only review; I did not execute tests or access the historical rollout artifacts.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:agent Agent harnesses and Responses API agent behavior needs-review PR is ready for code review and waiting on a reviewer labels Nov 19, 2026
@yaoyu-33
yaoyu-33 requested a review from prokotg November 19, 2026 14:07
@lafrancef
lafrancef added this pull request to the merge queue Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44706735800

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the ready-to-merge PR is approved, current, and waiting for final CI or merge label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44707356641

Merged via the queue into main with commit 1f4923e Nov 20, 2026
67 checks passed
@lafrancef
lafrancef deleted the wprazuch/opencode-context-overflow-exit0 branch November 20, 2026 09:17
pthombre added a commit that referenced this pull request Nov 21, 2026
… in a checkpoint, and reprompt like a first launch

Review of #5268.

- A saved reply is given again only to the request that produced it: the session keeps the request's SHA-256
  with the reply, also in the checkpoint, and a different request under the same activation index is a 409, as
  before this PR.
- The checkpoint keeps a finished session's trajectory, restored under the replacement attempt's rollout ID, so
  a session that finished before the checkpoint still closes with it, also when closed before it is re-bound.
- A re-bind that has to install the runtime again passes the seed's pinned ripgrep and plugin dependencies, and
  stages them through the sandbox connection it holds (`state.session` is not set yet).
- "Resume" names the checkpoint step, so continuing a saved conversation is a reprompt: `reprompt.py`,
  `reprompt_opencode.sh`, `RepromptDecision`. `discard_conversation` is `set_conversation_aside`
  (`data.set-aside-N`).
- The reprompt helper rejects permission requests, as `opencode run` does; under `opencode serve` nothing
  answered one and the turn waited until the harness deadline. It keeps the server's log and the request's
  status in the launch directory, and prints the log's end when the request fails.
- A saved conversation that downloads but cannot be parsed starts the task afresh under its own reason; one
  that cannot be downloaded is still retried and then fails the activation.
- Tool calls a relaunch finds unfinished are counted once each (`interrupted_tool_calls` in the launch record)
  and mark the observations with the gap `tool_call_interrupted_by_relaunch`.
- The reply's metadata carries `harness_paused_seconds` next to `harness_launches`.
- `_reported_model_error` keeps main's exit-0 context overflow (#6471) for a launch that did not reprompt.
- The preparation command's package install takes a lock, so a retry that overlaps its first run waits for it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 21, 2026
… in a checkpoint, and reprompt like a first launch

Review of #5268.

- A saved reply is given again only to the request that produced it: the session keeps the request's SHA-256
  with the reply, also in the checkpoint, and a different request under the same activation index is a 409, as
  before this PR.
- The checkpoint keeps a finished session's trajectory, restored under the replacement attempt's rollout ID, so
  a session that finished before the checkpoint still closes with it, also when closed before it is re-bound.
- A re-bind that has to install the runtime again passes the seed's pinned ripgrep and plugin dependencies, and
  stages them through the sandbox connection it holds (`state.session` is not set yet).
- "Resume" names the checkpoint step, so continuing a saved conversation is a reprompt: `reprompt.py`,
  `reprompt_opencode.sh`, `RepromptDecision`. `discard_conversation` is `set_conversation_aside`
  (`data.set-aside-N`).
- The reprompt helper rejects permission requests, as `opencode run` does; under `opencode serve` nothing
  answered one and the turn waited until the harness deadline. It keeps the server's log and the request's
  status in the launch directory, and prints the log's end when the request fails.
- A saved conversation that downloads but cannot be parsed starts the task afresh under its own reason; one
  that cannot be downloaded is still retried and then fails the activation.
- Tool calls a relaunch finds unfinished are counted once each (`interrupted_tool_calls` in the launch record)
  and mark the observations with the gap `tool_call_interrupted_by_relaunch`.
- The reply's metadata carries `harness_paused_seconds` next to `harness_launches`.
- `_reported_model_error` keeps main's exit-0 context overflow (#6471) for a launch that did not reprompt.
- The preparation command's package install takes a lock, so a retry that overlaps its first run waits for it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
pthombre added a commit that referenced this pull request Nov 21, 2026
… in a checkpoint, and reprompt like a first launch

Review of #5268.

- A saved reply is given again only to the request that produced it: the session keeps the request's SHA-256
  with the reply, also in the checkpoint, and a different request under the same activation index is a 409, as
  before this PR.
- The checkpoint keeps a finished session's trajectory, restored under the replacement attempt's rollout ID, so
  a session that finished before the checkpoint still closes with it, also when closed before it is re-bound.
- A re-bind that has to install the runtime again passes the seed's pinned ripgrep and plugin dependencies, and
  stages them through the sandbox connection it holds (`state.session` is not set yet).
- "Resume" names the checkpoint step, so continuing a saved conversation is a reprompt: `reprompt.py`,
  `reprompt_opencode.sh`, `RepromptDecision`. `discard_conversation` is `set_conversation_aside`
  (`data.set-aside-N`).
- The reprompt helper rejects permission requests, as `opencode run` does; under `opencode serve` nothing
  answered one and the turn waited until the harness deadline. It keeps the server's log and the request's
  status in the launch directory, and prints the log's end when the request fails.
- A saved conversation that downloads but cannot be parsed starts the task afresh under its own reason; one
  that cannot be downloaded is still retried and then fails the activation.
- Tool calls a relaunch finds unfinished are counted once each (`interrupted_tool_calls` in the launch record)
  and mark the observations with the gap `tool_call_interrupted_by_relaunch`.
- The reply's metadata carries `harness_paused_seconds` next to `harness_launches`.
- `_reported_model_error` keeps main's exit-0 context overflow (#6471) for a launch that did not reprompt.
- The preparation command's package install takes a lock, so a retry that overlaps its first run waits for it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
ehosseiniasl pushed a commit to ehosseiniasl/Gym that referenced this pull request Nov 21, 2026
…-NeMo#5268)

* fix(checkpoint): leave the calls a checkpoint abandoned out of the capture ledger

A harness interrupted at a checkpoint (OpenCode killed while its model call is held) gives up on the call. The
ledger had recorded it, often as a failure row for a request that ended without staging coordinates, and the
gate no longer counted it as undelivered once the request had finished, so the row went into the commit and
the restored attempt's manifest reported a failure for a call no trajectory contains, which masks the sample.

The policy gate now remembers calls whose client left while admission was closed (`GateSnapshot.abandoned`);
the commit leaves their rows out like an undelivered call's, and the resume drops them from the live ledger
(`FileLineageStore.discard_calls`), in the single-process and the multi-worker policy server alike.

(cherry picked from commit 912ce78)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
(cherry picked from commit 7619754df96d015eb6bb98ec956aa5feb1c2c078)

* feat(agent-utils): pause a supervised harness in place at a checkpoint and park its activation

A checkpoint of an agent whose harness runs in a task sandbox had two choices: wait for the harness, which can
take an hour, or stop it and relaunch after the commit. This adds a third, which is now the first choice.

The bash supervisor pauses and continues the harness on request. Writing sequence number N to `pause.request`
sends SIGSTOP to every process a stop would reach and to every process carrying the supervisor's environment
marker, including services that left the harness, waits until each is stopped (longer while some are in
uninterruptible sleep), and acknowledges in `paused.json`; `continue.request` with N sends SIGCONT and
acknowledges in `continued.json`. Numbers only grow, so every checkpoint re-arms the protocol without removing
files. Time spent paused does not count against the harness deadline, a pause requested before the launch holds
the launch, and a stop while paused continues the processes first so the harness still sees TERM and can save its
state. The cleanup receipt gains `stopped`: the stop file, not the harness's own exit or the deadline, ended the
harness or fenced its launch. Receipts without it still parse.

`SandboxSession` opts in with `pausable=True` and gains `pause_harness()` / `continue_harness()`, which read an
existing receipt first, `execute(pause_allowance_s=...)` for the provider deadline, `session_root`, and
`checkpoint_state()` / `reattach()` to rebind a session to the sandbox a restore forks from a snapshot.

`run_until_parked()` races a launch against the activation's park request: it pauses the harness, parks the
activation at the adapter's boundary, continues the harness after the resume, and keeps racing for the next
checkpoint. A pause that is not confirmed, or a continue that fails three times, falls back to the stop the
supervisor already had; the adapter then relaunches. A cancelled activation still stops its harness, shielded and
bounded.

Where the provider has them, a confirmed pause holds the launch's command polls in the sandbox's
parked_exec_polling() scope until the continue, so a sandbox being snapshotted is not polled, and a stop for a
checkpoint runs in checkpoint_exec_polling() so the provider notices the launch's end promptly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* feat(opencode): pause at checkpoints and resume after a crash

OpenCode episodes were restarted from scratch by every checkpoint restore, and a checkpoint had to wait for the
harness. The agent now exports its sessions and uses the shared pause mechanism.

- checkpoint_mode = "exported" and rebinds_tool_accesses = True. A session whose sandbox the agent owns (no
  sandbox_access) or a continuation session restarts instead.
- A checkpointed session keeps OpenCode's conversation under the sandbox's session root, on the snapshotted disk,
  and the activation runs inside participant.activation(), so close and retire cancel the launch.
- The launch loop runs run_until_parked: a confirmed pause parks the activation and continues the harness in
  place; a stopped harness is relaunched with the unspent budget (time paused does not count). A relaunch, or the
  first launch after a restore, resumes the saved conversation when it starts with the task and has a completed
  assistant message: resume_opencode.sh starts `opencode serve` in the sandbox and re-posts the last user message
  with empty parts, so no user turn is added. Otherwise the original prompt runs fresh, with the reason logged.
- A re-sent activation index is answered from the saved reply; the reply metadata reports harness_launches.
- Hooks: export_agent_sessions, restore_agent_sessions (unconnected), and _rebind_restored_agent_session_state,
  which connects to the forked sandbox, reattaches the SandboxSession and reinstalls missing files. A restored
  session that was never re-bound answers 409.
- nemo_gym/testing/checkpoint_conformance.py: check_harness_adapter(), run here against OpenCode with a fake
  `opencode` that implements both `run` and `serve`.

Provenance: NVIDIA-NeMo#4274's pause idea, resume decision and resume helper, and NVIDIA-NeMo#4553's agent half (legacy stack),
rebuilt on main's SandboxSession and bash supervisor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): resume a saved conversation exported from OpenCode's database

snapshot.py keeps each message's id beside its info, because OpenCode stores the id on the message row and not
in its data; resume_payload read it from info and failed with KeyError 'id' on every real export, so every
relaunch and restore started the task afresh (16-node job 8459954: 2 of 2 relaunches).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): retry a new sandbox's setup commands, and report a launch that saved nothing in one line

A sandbox that was just created or restored can refuse a connection for a few seconds after it first answered (a
gateway 502). OpenCode's seed failed on its first commands then, and the rollout started over (job 8539361: the
workdir, preparation and runtime install failed for 3+ sandboxes each).

- `exec_idempotent` (agent utilities) runs a command and retries it, twice, when the provider raises; a returned
  result, any exit code, is final. Only for commands that are safe to run twice.
- OpenCode runs its workdir creation, sandbox preparation (it checks before it installs), runtime install (the
  installer serializes and skips a runtime in place) and the "set the conversation aside" move through it.
- A restore that finds OpenCode had written no conversation yet (no root session) logs one INFO line and starts
  afresh, as before, instead of a WARNING with a traceback (`NoRootSessionError`).
- A launch that ended without finishing and left no session database or no root session raises
  `NothingCapturedError`, which the session logs as one WARNING line with the runner's log, instead of a chained
  capture traceback on top of the launch's own error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): take the concurrency slot with Activation.slot, so a parked session's slot always comes back

The slot was taken inside Activation.queued() but given back by a try/finally that began only after it. A retire or
close of a session parked on the way out of queued(), after taking a slot while a checkpoint was open, raised before
that finally, and the agent server ran with one slot fewer for good. Activation.slot() takes and releases the slot in
one scope; without checkpointing, the same holds through a local helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): relaunch, re-bind and stop paths found in a review of the checkpoint pause

Found in a review of the harness pause and of OpenCode's relaunch.

Relaunch and re-bind (OpenCode):
- A relaunch that starts the task afresh no longer names the conversation it set aside. The launch command was
  built before the decision, so it kept `--session <id>` of the discarded conversation; it is now built after it,
  and the fresh start also drops the observations and trajectory of the discarded launch.
- A saved conversation that cannot be read is no longer taken for a missing one. The relaunch reads the database
  itself, three times, and raises if it still cannot, instead of setting a resumable conversation aside after one
  failed download on a sandbox a restore just forked.
- A restored session gets back what its seed had set and a checkpoint does not carry: `export_dir` and the
  environment of OpenCode's import and export. Without them a restored episode wrote no exports.
- The re-bind's first command on the forked sandbox goes through `exec_idempotent`, and a re-bind that fails
  releases its sandbox connection instead of leaving one behind per retried seed.
- A resumed launch that ends in a reported model error (API error, context overflow) is recognised:
  `resume_opencode.sh` exits 0 once the server answered, where `opencode run` exits 1.
- A session that continues an imported conversation (`session_import_path`) restarts after a crash: a relaunch
  compared the imported conversation's first prompt with the task's and discarded it.
- A reply given again from a saved one forwards its verification failure report, as the first reply does.
- Text parts OpenCode marks synthetic are not part of the prompt a saved conversation is matched against.

`resume_opencode.sh`:
- The prompt request runs in the background and is waited for. Bash runs a trap only between foreground
  commands, so the supervisor's TERM was held until the turn ended: every stop of a resumed launch took the full
  grace period and the server was killed.
- The server is ended with TERM: bash starts a background command with INT ignored.
- The loopback request ignores proxy variables, and a path outside ASCII is encoded as its UTF-8 bytes.

Pause and stop (agent utils):
- A stop of a launch that is still staging cancels it. The stop had no harness to end, and the launch then ran
  its harness through the checkpoint, or waited until the provider deadline for the continue of a pause request
  that did reach the sandbox.
- An error of a launch that left no receipt of a stop, for example because its sandbox died, propagates as the
  launch's own failure instead of parking a dead session.
- A pause waits, bounded, for a launch that is staging, so a snapshot does not run beside the uploads and the
  launch command's polls are held like a running launch's.

Process supervisor:
- A hold before the launch is not added to the harness deadline again by the first pause after it.
- An expire that arrives during a hold before the launch launches nothing.
- A pause scans until a scan finds no new process, not twice.

Other:
- The launch number in the client session id is gone. Only a continuation session sets that id and only a
  checkpointed session relaunches, and a session is never both, so nothing could send it.
- "discarded N abandoned call row(s)" is logged only when rows were dropped.
- The OpenCode runtime's sandbox path prefix is a module constant, so a test whose sandbox is the test machine
  installs its fake CLI under its own directory instead of one /tmp path shared by every run on the node.

Tests: the cases above; the receipt of a stop that fenced a launch, which has `stopped` since the pause in
place; the kit's local provider; pause numbering, malformed requests and receipts; deterministic
replacements for races and fixed sleeps (a harness that ticks until the test ends it, bounded waits, cleanup of a
paused harness when a test fails half way); larger limits around the real supervisor.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(checkpoint): require delete_calls of a capture ledger, and name the calls it deletes "disconnected"

Review of NVIDIA-NeMo#5268.

- `CheckpointableLedger` requires the method, and the model server refuses a ledger without it at startup, so
  the `getattr` fallback and its warning could not be reached. The method is called directly.
- "abandoned" already means a rollout attempt the framework gave up on, and "discard" a fenced write. The calls
  are now `disconnected` (`GateSnapshot.disconnected`, `take_disconnected`), the ledger method is `delete_calls`,
  and the helper `delete_disconnected_calls`. Nothing of this is released, so there is no alias.
- The comments describe the rule the code applies (a call that ended while admission was closed, before its
  response started) and the rows it leaves: an intent row and, sometimes, a failure row.
- `FileLineageStore.delete_calls` removes the rollout from the cache through `_ledger_cache_pop`, which also
  drops the lineage caches.
- `PolicyWorkerLink` uses its gate's ledger instead of a second copy.
- New test: a worker deletes the rows of such a call when it reopens.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(agent-utils): bound a checkpoint pause, retry its requests, and never park beside a launch that still writes

Review of NVIDIA-NeMo#5268.

Supervisor (`process_supervisor.sh`):
- `--max-pause SECONDS`: a pause nobody continues used to hold the harness for good, with the deadline not
  running and an expire waiting for the continue. Past the limit the supervisor ends the harness as at its time
  limit and the receipt records `pause_expired`. The limit counts the supervisor's polls, not the clock.
  `SandboxSession.execute` passes the pause allowance as the limit.
- The wait for a continue also ends when the harness is gone.
- The usage text lists the pause options.

Pause and continue requests (`supervisor_client._request`):
- bounded as a whole, so a request queued behind a full provider does not wait for a harness to end;
- run from `control_cwd`, so they do not need a workdir the task moved or deleted.

`SandboxSession.pause_harness` answers `unconfirmed` while the launch is still staging after its wait: a pause
request would only hold the launch command, and staging would keep writing during the snapshot.

`run_until_parked` is now `run_with_checkpoint_pauses` (it returns when the launch ends, parked or not), and
`Finished`/`Stopped` are `LaunchFinished`/`LaunchStopped`. It also:
- repeats a pause request that failed in transport (4 attempts, 1 s doubling) and waits the same way between
  continue attempts; a timeout or an answer of the supervisor is not repeated;
- treats a `receipt_missing` receipt (main's NVIDIA-NeMo#6280: the supervisor died and the provider proved the sandbox
  empty) after its own stop as a stopped launch, not a finished one;
- raises, and does not park, when a launch cancelled while staging does not end within the stop timeout;
- reads the exception of a park request or an abandoned launch, so asyncio does not log it as never retrieved.

`SandboxSession.reattach` is now `rebind`, the word the checkpoint code uses; `ParkingActivation` and
`SandboxSessionCheckpoint` are exported. `exec_idempotent` takes `cwd`, `env` and `timeout_s` explicitly.

The conformance kit moves to `nemo_gym.agents.testing` as `check_harness_checkpointing`: it checks an agent
adapter, and can now import `AGENT_ACTIVATION_HEADER`. Its local provider is private. The crash scenario ends
the first agent (handles, processes, tasks) before the restore and cleans up in a `finally`, and an adapter can
supply `crash_recovery_assertion` to prove the recovery continued the saved conversation.

Tests: the deadline-extension test now fails without the extension, the hold test no longer asserts a tight
real-time bound, and each change above has tests.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): bind a saved reply to its request, keep the trajectory in a checkpoint, and reprompt like a first launch

Review of NVIDIA-NeMo#5268.

- A saved reply is given again only to the request that produced it: the session keeps the request's SHA-256
  with the reply, also in the checkpoint, and a different request under the same activation index is a 409, as
  before this PR.
- The checkpoint keeps a finished session's trajectory, restored under the replacement attempt's rollout ID, so
  a session that finished before the checkpoint still closes with it, also when closed before it is re-bound.
- A re-bind that has to install the runtime again passes the seed's pinned ripgrep and plugin dependencies, and
  stages them through the sandbox connection it holds (`state.session` is not set yet).
- "Resume" names the checkpoint step, so continuing a saved conversation is a reprompt: `reprompt.py`,
  `reprompt_opencode.sh`, `RepromptDecision`. `discard_conversation` is `set_conversation_aside`
  (`data.set-aside-N`).
- The reprompt helper rejects permission requests, as `opencode run` does; under `opencode serve` nothing
  answered one and the turn waited until the harness deadline. It keeps the server's log and the request's
  status in the launch directory, and prints the log's end when the request fails.
- A saved conversation that downloads but cannot be parsed starts the task afresh under its own reason; one
  that cannot be downloaded is still retried and then fails the activation.
- Tool calls a relaunch finds unfinished are counted once each (`interrupted_tool_calls` in the launch record)
  and mark the observations with the gap `tool_call_interrupted_by_relaunch`.
- The reply's metadata carries `harness_paused_seconds` next to `harness_launches`.
- `_reported_model_error` keeps main's exit-0 context overflow (NVIDIA-NeMo#6471) for a launch that did not reprompt.
- The preparation command's package install takes a lock, so a retry that overlaps its first run waits for it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* docs(opencode): document partial-rollout checkpoints, their limits, and the supervisor's pause files

Review of NVIDIA-NeMo#5268: the OpenCode README gets a section on checkpoints (settings, what a pause and a stop do, pause
limits, clocks, recovery after a crash, the reprompt, interrupted tool calls, restart-only sessions); the agent
integration page summarizes it; the harness guide lists the pause and continue files, `stopped` and
`pause_expired` in the receipt, and `run_with_checkpoint_pauses`.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* test(hermes): expect `stopped` in the receipt of a stop that fenced the launch

The supervisor now records that a stop request, not the harness's own exit or the deadline, ended or fenced the
launch. Hermes's test compared the whole receipt.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): do not repeat a refused continue, give retries one budget, and report a timeout after a stop

Second review round of NVIDIA-NeMo#5268.

- A continue the supervisor answered with a refusal is not sent again: the same sequence number would read the
  same answer from the acknowledgement file. `HarnessPauseResult.acknowledged` tells such an answer from a lost
  one, which is still retried.
- `exec_idempotent`'s `timeout_s` is the budget of all attempts and the waits between them, not of each attempt.
- When a launch was stopped at a checkpoint and the activation's budget is spent, nothing is relaunched: the reply
  is built from the stopped launch and reports a timeout. Preparing the relaunch used to discard that launch's
  output and then raise.
- A re-bind installs the runtime again only when the check of its files ran and found some missing. A check the
  provider could not run is repeated and then fails the re-bind.
- `prepare_launch` creates the launch directory through `exec_idempotent`.
- The observation bundle of a restored session closed before its re-bind is schema 2.0, like every other close.
- The saved conversation's export is read and decoded in the worker thread that makes it.
- The test of the unread park-request exception now fails without its fix.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* test(agents): run the harness checkpoint conformance kit against a minimal adapter in the core suite

The kit's main check only ran in OpenCode's server suite, which the core
coverage gate does not measure, so the combined core coverage fell to
94.86%. A reference adapter whose harness is a shell loop now takes the
kit through every scenario with the real process supervisor, and a second
test shows the kit fails an adapter that cannot pause in place.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): hold a checkpoint for staging that is still writing, bound retries by one deadline, and report a timeout when the relaunch budget runs out

- run_with_checkpoint_pauses: a launch cancelled while staging is not
  reported stopped while its staging task still runs, and no error leaves
  the activation until the launch has ended and staging no longer runs.
  Until then the session is not ready, so the checkpoint waits for it up
  to its own deadline. SandboxSession gains staging and wait_staged.
- exec_idempotent: every attempt runs under the one deadline, which now
  also bounds a provider's wait for capacity; no attempt starts once the
  budget is spent.
- OpenCode: what a stopped launch produced is kept until its relaunch has
  started its harness. A budget that runs out before then, while the
  relaunch is prepared or staged, ends the activation as a timeout with
  the stopped launch's output.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* style(opencode): format a test line the linter rejects

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

* fix(opencode): reprompt a saved conversation whose prompt was sent quoted as one argv word

With argv_prompt_quoting (NVIDIA-NeMo#5458) a launch sends the prompt as `opencode run` builds it from one
argv word, so the saved user turn holds the quoted text. A relaunch after a stop compared that turn
with the unquoted prompt, found no match, and started the task afresh every time. It now compares
with the prompt as the launch sent it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

---------

Signed-off-by: Pranav Thombre <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer ready-to-merge PR is approved, current, and waiting for final CI or merge risk:mid Autobot PR risk: mid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants