Skip to content

fix(gdpval): keep a failed seed's sandbox until a stop succeeds - #6411

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/sandbox-stop-untracked-owners
Nov 19, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/sandbox-stop-untracked-owners

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

gdpval dropped its record of a sandbox when the stop after a failed seed raised, so the sandbox ran until its ttl_s.

  • The seed now starts the sandbox and uploads the task's reference files as two steps, so the session holds the sandbox before the upload.
  • A sandbox whose stop failed stays tracked until the session's close, a later seed of the session or the shutdown stops it.
  • Only the failed seed's own episode may close it, and only its own episode and task may seed over it. Another gets 409 and stops nothing, as for a live session.
  • The release removes the reference files shielded, so a close cut short by a disconnect still drops the session's record and fences it, instead of leaving a record without a sandbox. A thread running rmtree cannot be cancelled anyway, so the removal has no time limit of its own.

swebench_pro and terminal_bench_2_1, which this PR used to change too, pass their stop limits to stop() in #6410. The other servers that stop a one-off sandbox already get the shielded, bounded stop from #6410 without a change. They still log a failed or timed-out stop and drop the sandbox, which its ttl_s reclaims, until they move onto the shared owner component.

How it works

gdpval's seed, when the upload of the task's files or the reply fails and the stop of the new sandbox fails too:

flowchart LR
  subgraph before["Before"]
    direction TB
    a1["seed"] --> a2["start the sandbox and upload the files<br/>in one call"]
    a2 -->|"upload fails"| a3["stop fails"]
    a3 --> a4["nothing holds the sandbox,<br/>it runs until its ttl_s"]
  end
  subgraph after["After"]
    direction TB
    b1["seed"] --> b2["start the sandbox"]
    b2 --> b3["the session holds it"]
    b3 --> b4["upload the files, reply"]
    b4 -->|"fails"| b5["release"]
    b5 -->|"stop fails"| b6["kept as a failed seed"]
    b6 --> b7["the close, a later seed of the session<br/>or the shutdown stops it"]
  end
  before ~~~ after
Loading

Where this sits in the stack

This is one PR in a stack of PRs that implement Milestone 1 of the sandbox ownership design: every sandbox has one owner, the server that starts it, which stops it on every path, and every other user borrows it. Each PR is one commit, so each diff shows only that PR's change.

The highlighted box is this PR.

flowchart LR
  M["PR 5266<br/>sandbox checkpointer"]
  U1["PR 6410, merged<br/>shielded, bounded<br/>AsyncSandbox.stop"]
  U2["PR 6411<br/>gdpval failed-seed<br/>sandbox"]
  U3["PR 6412<br/>browser record kept<br/>until it closes"]
  U4["PR 6413<br/>vibench shielded<br/>scratch removal"]
  U5["PR 6414<br/>public<br/>OwnedSandboxes"]
  U6["PR 6415<br/>lifecycle<br/>under load"]
  U7["PR 6416<br/>typed<br/>network rule"]
  U8["PR 6417<br/>borrow and<br/>AgentSandboxConfig"]
  U1 --> U2 --> U3 --> U4
  U1 --> U5 --> U6 --> U7 --> U8
  M -.->|"PR 6414 rebases onto it"| U5
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef merged fill:#d1fae5,stroke:#047857,color:#1f2937
  class U1 merged
  class U2 this
Loading
  1. fix(sandbox): shield and bound AsyncSandbox.stop and the other releases #6410 (merged): fix(sandbox): shield and bound AsyncSandbox.stop and the other releases
  2. fix(gdpval): keep a failed seed's sandbox until a stop succeeds #6411 (ananthsub/sandbox-stop-untracked-owners): fix(gdpval): keep a failed seed's sandbox until a stop succeeds (this PR)
  3. fix(interactive_browser): drop a browser's record only after it closes #6412 (ananthsub/sandbox-stop-keep-record): fix(interactive_browser): drop a browser's record only after it closes
  4. fix(vibench): remove a released session's scratch files shielded #6413 (ananthsub/sandbox-stop-retried-owners): fix(vibench): remove a released session's scratch files shielded
  5. feat(sandbox): expose the shared OwnedSandboxes owner #6414 (ananthsub/owned-sandboxes): feat(sandbox): make the sandbox checkpointer the public OwnedSandboxes
  6. feat(sandbox): stop, start and export owned sandboxes safely under load #6415 (ananthsub/owned-sandboxes-lifecycle): feat(sandbox): stop, start and export owned sandboxes safely under load
  7. feat(sandbox): apply typed network rules through owner capabilities #6416 (ananthsub/owned-sandboxes-network): feat(sandbox): typed network rule and provider capabilities for owners
  8. feat(sandbox): borrow lent sandboxes and share harness configuration #6417 (ananthsub/sandbox-borrow): feat(agents): borrow lent sandboxes and type the agent's own sandbox

Validation

  • pre-commit run --files <changed files> on the unit's diff (ruff, ruff-format, import-linter, guardwords).
  • pytest -n 16 tests/unit_tests, in a venv with CI's extras, with the same failures as on main.
  • Server tests: gdpval.
  • New gdpval tests check that the close, a re-seed and the shutdown each stop the sandbox that a failed seed or upload kept, and that a close a disconnect cuts short while the sandbox stops still drops the record, removes the reference files and fences the session, so a re-seed is refused. Tests also check that a close from another episode, and a seed from another episode or task, are refused without stopping or starting a sandbox, and that the failed seed's own retry then stops it. Each fails on the parent commit or with its protection removed; the close-level test failed 5 of 5 runs without the shield.

Rollouts

N/A: the normal stop path is the same call; what changes is cancellation and failed stops, which the unit tests cover.

Compatibility and benchmark impact

None.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally.
  • Documentation added or updated, or N/A with justification. N/A: no user-facing behavior to document.
  • Pre-commit checks pass locally, run on this unit's changed files.
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Nov 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-shielded-stop branch from 0c508c8 to ff939b5 Compare November 18, 2026 23:19
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from ff2e211 to 4886429 Compare November 18, 2026 23:19
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:sandbox Sandbox providers, isolation, and sandbox runtime contracts labels Nov 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-shielded-stop branch from ff939b5 to 6ae610b Compare November 19, 2026 05:51
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from 4886429 to 77078c1 Compare November 19, 2026 05:51
@ananthsub ananthsub changed the title fix(sandbox): shield the stops that leave no owner behind fix(gdpval): keep a failed seed's sandbox until a stop succeeds Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from 77078c1 to bd640ef Compare November 19, 2026 15:03
@ananthsub
ananthsub marked this pull request as ready for review November 19, 2026 15:03
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 19, 2026 15:04
@yaoyu-33
yaoyu-33 requested a review from mpatel31415 November 19, 2026 15:07
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer 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

One RISK: retained failed seeds bypass episode/task ownership checks, so a conflicting request can stop and replace their sandbox or fence the session for another episode.

I reviewed all three changed files and traced the affected session, staging and cancellation paths. Validation was static; I did not execute tests.

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

Comment thread resources_servers/gdpval/app.py Resolved
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from bd640ef to ec990ad Compare November 19, 2026 15:31
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-shielded-stop branch from 0bac6ac to bba82a9 Compare November 19, 2026 15:31

@hemildesai hemildesai 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

This uses #6410 correctly. It doesn't re-shield the stop; it shields only the rmtree afterwards, which #6410 doesn't cover. Splitting out stage_reference_files means the session owns the sandbox before the upload. A failed release keeps the session in _failed_seeds, and the entry is popped only after a stop succeeds, which matches AGENTS.md. start_task_sandbox has no other callers, so dropping its reference args is safe. The gdpval session tests pass locally (54 passed).

+1 to the CI reviewer's open RISK on _release_failed_seed: a close or re-seed from a different episode can stop and fence another episode's retained failed seed. Could you add the identity check before both releases?

@ananthsub
ananthsub force-pushed the ananthsub/sandbox-shielded-stop branch from bba82a9 to 9c699e6 Compare November 19, 2026 15:54
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from ec990ad to caa0d8b Compare November 19, 2026 15:55
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-shielded-stop branch from 9c699e6 to 5c278b2 Compare November 19, 2026 15:56
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch 2 times, most recently from 3d60596 to 44b3b7e Compare November 19, 2026 16:31
Base automatically changed from ananthsub/sandbox-shielded-stop to main November 19, 2026 16:42
@ananthsub
ananthsub requested a review from a team as a code owner November 19, 2026 16:42
gdpval's seed dropped its record of the sandbox when the stop of a failed
seed raised, so the sandbox ran until its ttl_s. The seed now starts the
sandbox and uploads the task's files as two steps, so the session holds
the sandbox before the upload. A sandbox whose stop failed stays tracked
until the session's close, a later seed of the session or the shutdown
stops it. Only the failed seed's own episode may close it, and only its
own episode and task may seed over it; another gets 409 and stops
nothing, like a live session. The release also removes the task's
reference files shielded, so a close that a disconnect cuts short still
drops the session's record and fences it, instead of leaving a record
without a sandbox.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/sandbox-stop-untracked-owners branch from 44b3b7e to 33aba16 Compare November 19, 2026 16:43
@ananthsub
ananthsub requested review from agronskiy and hemildesai and removed request for a team and mpatel31415 November 19, 2026 16:46

@hemildesai hemildesai 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.

Approving at 33aba16. The failed-seed ownership check is in (a close or re-seed from another episode or task gets 409 and leaves the seed alone), with tests covering both paths. After the rebase onto main the PR's own changes are unchanged, and CI is green.

@ananthsub
ananthsub added this pull request to the merge queue Nov 19, 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/44575825702

Merged via the queue into main with commit 38842e7 Nov 19, 2026
63 checks passed
@ananthsub
ananthsub deleted the ananthsub/sandbox-stop-untracked-owners branch November 19, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:sandbox Sandbox providers, isolation, and sandbox runtime contracts bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants