Repository navigation
fix(resources): move swebench_pro and interactive_browser onto the session contract - #4692
Merged
yaoyu-33 merged 18 commits intoOct 26, 2026
Merged
Conversation
yaoyu-33
marked this pull request as ready for review
October 19, 2026 21:00
yaoyu-33
changed the base branch from
main
to
yaoyu-33/resources-session-close-contract
October 19, 2026 22:57
…ess close Add ResourcesSessionFence, which serializes seed and close per resources_session_id and remembers closed sessions for CLOSED_SESSION_RETENTION_S instead of until shutdown. A seed for a closed session gets 409, which single_agent_turn does not retry. State that close must release state by resources_session_id when the request carries no cookie, as after a lost seed reply, and check it in check_resources_session_contract with an optional holds_state probe. Move example_single_tool_call onto the fence. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…s at verify Seed and close refusals that no retry can fix were plain ValueErrors, so they became a 500 and single_agent_turn dispatched the whole episode again. Add ResourcesSeedRejectedError (422) for input that fails validation and ResourcesSessionConflictError (409) for an ID bound to another episode, a close for another episode, or a closed session. A verify for a session the server no longer holds returned reward 0 (a policy failure) or an error. Add lost_session_verification, which builds a masked sample with failure_kind session_lost or session_expired, and ResourcesSessionLostError (404) for tool calls on such a session. check_resources_session_contract now requires 409 for a conflicting or late seed and, with verify_body, a masked verify after close. Move gdpval and nemo_user_sim, which already run the check, onto these rules; nemo_user_sim also maps resources_session_id to its cookie session so a cookie-less close releases it and a conflicting seed is caught. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33
force-pushed
the
fix/resources-session-fence-migration
branch
from
October 19, 2026 23:35
6b1dc1d to
f5a71af
Compare
yaoyu-33
force-pushed
the
yaoyu-33/resources-session-close-contract
branch
from
October 19, 2026 23:36
1275512 to
9fab94c
Compare
…completion A verify for a session gdpval no longer holds now returns a masked session_lost sample instead of a 409. The multistage orchestrator decides success by the failure class alone, so it counted that sample as a judged success: a final stage with half its tasks judged reported complete with a headline ELO, and a partial earlier stage was coverage-blocked and never retried. tag_results now turns a session_lost or session_expired result into the terminal verification failure the 409 used to produce, so routing, success, resume gating and partial-stage acceptance behave as before. aggregate_metrics also leaves such a row out of its stage's observed rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33
force-pushed
the
fix/resources-session-fence-migration
branch
from
October 20, 2026 02:49
f5a71af to
72876b5
Compare
…view - gdpval: bind the session cookie only after a seed's checks pass, so a refused 409 or 422 reply no longer hands the caller another episode's session. - example_single_tool_call and nemo_user_sim: a close of a closed session that names another episode gets 409, and check_resources_session_contract now checks it (keeps_state only). nemo_user_sim records the closing episode. - nemo_user_sim: a seed dropped after session_ttl_seconds verifies as a masked session_expired sample instead of session_lost. - lost_session_verification logs a warning, since a masked sample is otherwise visible only in coverage metrics, and documents the dict merge that avoids a duplicate-keyword TypeError with extra="allow" requests. - ResourcesSessionLostError says what each harness does with the 404 and validates its failure_kind. - Tests: fence locks are per session, clear() forgets records, the contract check rejects a 500 late seed, refusals reach the wire as 422/404, a masked sample is kept for coverage and dropped from quality, gdpval TaskData 422 and judged-not-masked gone session, nemo_user_sim close by ID first. - Docs: the resources server tutorial and the nemo_user_sim README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…ssion fence swebench_pro and interactive_browser kept their own per-session locks and closed-session records for the life of the process. Use ResourcesSessionFence instead, so closed records expire after CLOSED_SESSION_RETENTION_S and a seed for a closed session gets 409, which single_agent_turn does not retry, instead of a 500. Each server's tests now run check_resources_session_contract with a holds_state probe. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…ench_pro and interactive_browser Apply the rest of the session contract from the base: - conflicting seeds and closes raise ResourcesSessionConflictError (409) and task_data that is not an instance raises ResourcesSeedRejectedError (422), instead of a ValueError that became a retried 500; - swebench_pro answers a verify for a typed session whose sandbox is gone (consumed by an earlier verify, or closed) with a masked session_lost sample, instead of a 500 or a graded empty patch; a failed extraction from a live sandbox stays an unmasked failure; - interactive_browser masks a verify with no browser, and a tool call with no browser gets 404 session_lost instead of an observation the model would act on. Both contract checks now pass verify_body. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…y does simple_agent passes a tool's 404 body to the model and keeps going, so the 404 does not end the turn. It marks the call failed in the trajectory, and the masked verify keeps the sample out of the score. Say that in the comment, the tool section header and the test docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
… and bind cookies only on success - swebench_pro: a non-golden verify whose session holds no task sandbox (consumed, closed, never held: a resent or repeated /run verify, or an unknown session after a restart) is a masked session_lost sample. It used to grade an empty patch as an unmasked 0. The graded path now sets mask_sample, failure_kind and failure_reason itself. - swebench_pro and interactive_browser bind the session cookie only after a seed succeeds, so a refused 409 or 422 reply no longer points the caller at another episode's session. - interactive_browser: task_data that is not a browser task gets 422 instead of a retried 500. - Tests pin the 409/422 refusals over HTTP, every browser tool's 404, response-owned fields a caller sends, the golden-patch path and shutdown. - README: the closed-session window and how a lost browser is reported. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33
force-pushed
the
fix/resources-session-fence-migration
branch
from
October 21, 2026 01:03
72876b5 to
5199c24
Compare
Contributor
Author
|
/ok to test 5199c24 |
weijiac0619
previously approved these changes
Oct 26, 2026
Wait for the agent tool call as well as the resources in-flight count so a slow seed cannot start checkpoint preparation before the activation. Hold the sbatch stub until the competing resubmit is refused instead of assuming a one-second sleep makes the two calls overlap. Validation: 195 tests passed across test_checkpoint_agent.py, test_checkpoint_resources.py, test_checkpoint_coordination.py, test_eval_resubmit.py, and test_slurm_executor.py. The old checkpoint wait fails with delayed seeds in both modes; the fixed wait passes. Removing the submission lock makes the strengthened test fail, and 30 repetitions with the real lock pass. pre-commit run --all-files passed. Rollout evidence: N/A; only test synchronization changes. Signed-off-by: yaoyu-33 <[email protected]>
Merge origin/main at 8666d32. Keep main's comment wording for the checkpoint synchronization fix, which now has identical behavior on both branches. Preserve the deterministic resubmit concurrency test alongside main's O_EXCL lock fix. Validation: 258 tests passed across test_checkpoint_agent.py, test_checkpoint_resources.py, test_checkpoint_coordination.py, test_eval_resubmit.py, test_slurm_executor.py, test_base_resources_server.py, and test_session_contract_repo.py. pre-commit run --all-files passed. The PR diff against main passes git diff --check. Rollouts: N/A for the comment-only conflict resolution. Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 3e2c556 |
7 tasks done
yuhezhang-ai
approved these changes
Oct 26, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40359287013 |
This was referenced Oct 30, 2026
This was referenced Nov 3, 2026
This branch was previously 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.
Depends on #4679, which defines the contract:
ResourcesSessionFence, the refusal errors,lost_session_verification,ResourcesSessionLostError, and the strictercheck_resources_session_contract. This PR is stacked on it. Its base isyaoyu-33/resources-session-close-contract, which holds #4679's commits, so the diff here shows only this PR's change. After #4679 merges, this PR is retargeted tomain.nemo_user_simwas part of this PR; it moved into #4679 because #4679's stricter check fails without its fix.What changed
Two servers move onto the resources sessions contract from #4679.
swebench_pro_session_locksand_closed_sessionsgrew for the life of the process. They are replaced by aResourcesSessionFence, so a closed ID is remembered for the server'ssession_close_retry_window_seconds(300 s by default).Conflicting seeds, mismatched closes, and seeds for a closed session get 409;
task_datathat is not an instance, or aTaskIdthat does not match it, gets 422. All of these were aValueError, so a 500 that was retried.A non-golden
/verifyfor a session with no task sandbox returns a maskedsession_lostsample. That covers a sandbox an earlier verify consumed, one a close released, and a session this process never held: a resent verify of a/runsession, or a session from before a restart. Before:A failed patch extraction from a live sandbox, such as "not a git repository", stays an unmasked failure, because the agent can cause it. A graded verify sets
mask_sample,failure_kindandfailure_reasonitself, so stale values a caller sends are not passed through.interactive_browser_typed_locksand_typed_closedare replaced by aResourcesSessionFence.ValueError(500), andtask_datathat is not a browser task gets 422./verifywith no browser returns a maskedsession_lostsample. It used to return an unmasked reward 0.session_lost. It used to return a 200 observation saying the session was gone. The 404 marks the call failed in the trajectory. It does not end the turn:simple_agentstill shows the body to the model and keeps going, so the masked verify is what keeps the sample out of the score.Both servers bind the session cookie only after a seed succeeds. Before, a refused seed's 409 or 422 reply pointed the caller's cookie at the session it was refused, which may belong to another episode.
Both servers' tests now run
check_resources_session_contract(..., keeps_state=True, holds_state=..., verify_body=...). The check covers seed, re-seed, a conflicting seed, close, a cookie-less close after a lost seed reply, late seeds, and a masked verify after close.Where the changes apply
sequenceDiagram participant E as Environment server participant A as Agent server participant R as swebench_pro / interactive_browser E->>R: POST /seed_session R-->>E: 200, or 409 conflict/closed, 422 bad task_data (was 500) A->>R: browser tool call R-->>A: 404 session_lost when the browser is gone (was an in-band observation) E->>R: POST /verify R-->>E: masked session_lost sample when the sandbox or browser is gone (was 500 or reward 0) E->>R: POST /close_session (cookie optional) R-->>E: 200, released by ID, fenced for session_close_retry_window_secondsLinked issues
_session_id_to_identityis unbounded for sessions that are never closed (the never-closed-session TODO in fix(resources): tighten the session contract for close, refusals and lost sessions #4679)._releasedrops the state beforebackend.close()and only logs a failed close, so close records the session as closed and a failed release is not retried.Validation
pytest resources_servers/swebench_pro/testsin a venv built from itsrequirements.txt: 105 passed. New tests: an unknown session and a resent/runverify are masked without starting an eval sandbox; a golden-patch verify of a closed session is still graded; caller-sent response fields are ignored; seed 422s start no sandbox; a refused seed leaves the client's cookie alone; a close naming another episode gets 409 over HTTP while open and after close; shutdown clears the fence. Includes the contract check withverify_body; the repeated-verify test now expects a maskedsession_lostsample, and the extraction-failure tests still expect an unmasked failure.pytest testsfromresources_servers/interactive_browserin a venv built from itsrequirements.txt: 62 passed. Includes the contract check withverify_body; every browser tool gets 404session_lostwithout a browser; 409 for a conflicting seed and for mismatched closes (open and closed); 422 for badtask_data; a refused seed leaves the client's cookie alone; caller-sent response fields are ignored on the lost and graded verify paths.pre-commit run --files <changed files>: passed.Rollout evidence
Not run yet; the smoke rollouts run before merge, and their results will be added here. Verify behavior changes for lost sessions, so the rollouts should cover:
swebench_proundersingle_agent_turn: episodes verify normally, and a repeated verify is masked;interactive_browserundersingle_agent_turn: a browser episode verifies normally.Compatibility
task_dataforswebench_proreturns 422. These are final instead of retried.swebench_prothis includes a resent/runverify and a verify after a restart.interactive_browserseeds:task_datathat is not a browser task returns 422 instead of a retried 500.interactive_browsertool call without a browser returns 404 instead of a 200 observation.session_close_retry_window_seconds(300 s by default) instead of at shutdown.🤖 Generated with Claude Code