Skip to content

feat(swebench): seed typed resources sessions for environment server episodes - #4277

Merged
adil-a merged 10 commits into
mainfrom
ananthsub/swebench-typed-seed
Nov 5, 2026
Merged

adil-a merged 10 commits into
mainfrom
ananthsub/swebench-typed-seed

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

SWE-bench now uses the shared resources-owned sandbox session implementation from #4302. An Environment Server seeds the task, passes sandbox_access to the harness, verifies its saved patch, and closes the session. The Hermes recipe uses current single_agent_turn taskset routing with the agent borrowing that sandbox.

This update incorporates repaired parent fb5525f87dbd56d6070e38b68c8405823cbbc8fb without rewriting the author's history. Failed startup/teardown retains cleanup ownership; identical typed verification retries reuse the captured patch or verdict. Missing/closed sessions return masked SESSION_LOST, and expiry returns SESSION_EXPIRED. Canonical caller TaskIds are accepted. Legacy flat seeds and seedless golden-patch verification remain supported. Main's seed-head handling, staged/committed patch extraction, binary filtering, patch hashes, masking and sandbox observations are preserved.

No separate issue is needed: this is the SWE-bench consumer of the reviewed shared session change. Merge #4302 before this PR.

Validation at 94142e1768f12604063b7e19e3ca299f591572d9:

  • pytest resources_servers/swe_gym/tests resources_servers/r2e_gym/tests resources_servers/swebench/tests tests/unit_tests/test_session_contract_repo.py tests/unit_tests/server_runtime/test_resources_sessions.py tests/unit_tests/data/test_task_materialization.py --import-mode=importlib -q: 299 passed on Python 3.13.14.
  • CI example-data validation for all three resources passed. pre-commit run --all-files passed; the new commit has DCO sign-off.
  • Independent source review covered ownership, cancellation, saved-patch retries, compatibility and current-main verification behavior.

Real Linux/Docker smoke with nvidia/nemotron-3.5-super-vl-120b-a12b on django__django-11099:

Harness Result
Current opencode_agent + single_agent_turn 901-byte patch; Django ran 22 tests, OK; reward 1, unmasked; rollout health passed; 19 model calls
This Hermes recipe, default 30-turn budget 901-byte patch; Django ran 22 tests, OK; reward 1, unmasked; rollout health passed; 22 model calls

Both used canonical outer TaskId caller-row-0 and left no task containers. Changed runtime/recipe files on the smoke host were hash-checked against the committed source. These are representative lifecycle/verification checks, not a full benchmark or solve-rate comparison.

An additional Hermes run capped at 15 turns completed the same verification, but its token health check failed: the forced final-summary call's 12,318 input / 737 output tokens were absent from returned usage. Source tracing places that defect in the unchanged Hermes runtime/adapter; the failed health result is retained separately and is not counted as a clean smoke.

@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 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.

@ananthsub
ananthsub marked this pull request as ready for review October 9, 2026 06:06
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 9, 2026 06:06
@yaoyu-33 yaoyu-33 added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 9, 2026
Add resources_servers/swebench/task_sandbox_sessions.py, a shared helper for
SWE resources servers whose seed starts one task sandbox, and use it in
swe_gym and r2e_gym. An Environment Server can now seed a typed session,
hand the agent the task sandbox through sandbox_access, verify, and close.

The legacy seed body and response are unchanged.

Signed-off-by: Ananth Subramaniam <[email protected]>
…episodes

Make SwebenchResourcesServer a SandboxSessionResourcesServer, so it serves
environment server episodes the same way the SWE training servers do. A
typed seed validates task_data as a SWE-bench instance, starts the task
sandbox with the same anti-cheating setup as the legacy seed, and returns
sandbox_access with the serialized sandbox and the image's working
directory, resolved with pwd. That is the directory verify extracts the
patch from.

The first verify of a typed session consumes the task sandbox, and is
claimed before the evaluation sandbox starts, so a rejected repeat leaks
nothing. Close, fences, expiry, and shutdown cleanup come from the base
class.

The legacy seed body and response are unchanged.

Signed-off-by: Ananth Subramaniam <[email protected]>
Add benchmarks/swebench/verified/hermes.yaml, which runs SWE-bench Verified rows through single_agent_turn_legacy with the swebench resources server preparing the task sandbox and Hermes working inside it through sandbox_access. The configuration's own resources server instance allows hermes_agent, so the shared swebench.yaml and its allowed_agents stay unchanged.

Signed-off-by: Ananth Subramaniam <[email protected]>

Copy link
Copy Markdown
Contributor

💬 I found an existing repair for the KiloCode model-error failure: #5088. It targets main and preserves the structured error response. I’ll track it rather than open a duplicate repair while continuing to watch #4277 through merge.

Copy link
Copy Markdown
Contributor

PR NVIDIA-NeMo/Gym#4277 left the merge queue after validation failed.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026

Copy link
Copy Markdown
Contributor

💬 Merge-queue validation failed in two OpenClaw cancellation/close tests at their termination deadline. Both tests passed on current main and the PR head, and the queue has identical relevant code, dependencies and test configuration. This supports a timing-flake diagnosis, so I’m requesting the first bounded CI rerun without changing the branch.

Copy link
Copy Markdown
Contributor

CI restart for NVIDIA-NeMo/Gym PR #4277 was declined: The retry is neither the watched head nor an owned repair..

Copy link
Copy Markdown
Contributor

💬 No rerun started: this lane can’t restart the synthetic merge-queue commit. Could a maintainer requeue #4277 for validation against current main? The PR is still open with its ready-to-merge label, and I’ll keep watching it.

@yaoyu-33
yaoyu-33 added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

PR NVIDIA-NeMo/Gym#4277 left the merge queue after validation failed.

1 similar comment

Copy link
Copy Markdown
Contributor

PR NVIDIA-NeMo/Gym#4277 left the merge queue after validation failed.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026

Copy link
Copy Markdown
Contributor

💬 I can’t inspect the new merge-queue failure because brokered GitHub reads still return credential_rejected (HTTP 403) after the credential retry. I haven’t obtained its logs, so the cause remains unknown and I haven’t requested another CI rerun. Could a platform operator restore brokered GitHub access for this session? The PR watch remains armed.

@adil-a
adil-a added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

PR NVIDIA-NeMo/Gym#4277 left the merge queue after validation failed.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit 41949ae Nov 5, 2026
65 of 68 checks passed
@adil-a
adil-a deleted the ananthsub/swebench-typed-seed branch November 5, 2026 19:45

Copy link
Copy Markdown
Contributor

The PR is no longer an open ready-to-merge PR targeting main.

Copy link
Copy Markdown
Contributor

The PR is no longer an open ready-to-merge PR targeting main.

Copy link
Copy Markdown
Contributor

The PR is no longer an open ready-to-merge PR targeting main.

ananthsub added a commit that referenced this pull request Nov 5, 2026
#4277 gave the swebench server an agent-run seed path that still used
the removed ResourcesSessionFence API (_task_session_fence.closed_episode)
and the old "legacy seed" and "typed session" wording. It now tests
membership in the shared base's _task_session_fences and refuses with
"An agent-run seed cannot replace an episode session", as r2e_gym and
swe_gym do. Its test names and docstrings say episode seed and agent-run
seed, and the refusal test checks the message.

A pi_agent test comment merged since says "terminal 422".

Signed-off-by: Ananth Subramaniam <[email protected]>
yaoyu-33 added a commit to yaoyu-33/Gym that referenced this pull request Nov 5, 2026
…ease (NVIDIA-NeMo#5083)

* refactor(sessions): one name per session lifecycle concept before release

Give each resources session and agent session lifecycle concept one
name across code, docstrings, error messages, tests, config
descriptions and docs.

- Split ResourcesSessionFence into ResourcesSessionLocks, which runs a
  session's seed and close one at a time, and ResourcesSessionFences,
  which replaces ClosedResourcesSessionRecords and refuses a seed after
  its close until the fence expires.
- Call the fence's duration the close retry window everywhere,
  including close_retry_window_seconds in session routing.
- Add AgentSessionConflictError for agent session 409 refusals.
- Use episode session, episode seed, legacy run seed, saved reply,
  release, lost and terminal in place of typed, untyped, close receipt,
  tombstone, free and final.

Nothing renamed has been released, so there are no aliases.

Signed-off-by: Ananth Subramaniam <[email protected]>

* fix(sessions): clarify seed names and unavailable-session errors

Signed-off-by: yaoyu-33 <[email protected]>

* test(sessions): match the unavailable-session message in OpenClaw and OpenCode tests

The agent base now refuses a retried close or a seed after the fence expires with
"Agent session is no longer available". Two sandbox tests still matched "expired".

Signed-off-by: Ananth Subramaniam <[email protected]>

* refactor(sessions): say owner for session routing and release for freeing state (NVIDIA-NeMo#5087)

* refactor(sessions): say owner for session routing and release for freeing state

Session routing called the worker that holds a session a claimant and
its record a claim, while the checkpoint stack uses claim for a worker
taking a restored record (unclaimed, settled in NVIDIA-NeMo#4997). Routing already
said owner in x-ng-session-owner and routes_sessions_to_owner, so it now
says owner everywhere: SessionClaims becomes SessionOwners, claim files
become owner files in session-owners, and claimed_session_routing
becomes owned_session_routing.

The checkpoint stack said a retire frees a session, while the session
code says release. It now says release too, and on_session_freed
becomes on_session_released.

A few session tests still called an episode seed typed; they now use
the episode session names.

Signed-off-by: Ananth Subramaniam <[email protected]>

* docs(sessions): define ownership by the current session holder

Signed-off-by: yaoyu-33 <[email protected]>

---------

Signed-off-by: Ananth Subramaniam <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>

* refactor(sessions): carry the session names to servers merged since

Servers and routing code merged after this branch opened still used the
earlier names: ResourcesSessionFence in browsecomp_advanced_harness and
the shared SWE sandbox-session base, ClosedResourcesSessionRecords in
agentic_if, officeenv, partner_if's SWE adapter and scale_swe, and
claim, claimant and ROLLOUT_CLAIM_PREFIX in the rollout-stop routing.
Move them onto ResourcesSessionLocks, ResourcesSessionFences and the
owner names, and drop "typed", "Environment Server session",
"retention window", "remembers the close" and "close receipt" from
their prose, tests and docs. terminal_bench_4 keeps its own fence
bookkeeping under fence names, and nemo_user_sim's closed-session map
becomes fenced_resources_session_ids.

Add a Sessions section to the key terminology page with each term and
the names it replaces, and point AGENTS.md at it in one line. Export
the new classes from nemo_gym.server_runtime and AgentSessionConflictError
from nemo_gym.agents, and record the renamed names in the import-surface
fixture in place of the removed ones.

Signed-off-by: Ananth Subramaniam <[email protected]>

* refactor(sessions): finish the name sweep and scope the glossary to the code

Review follow-ups for the session names:

- The glossary's Conflict row now names the shared session code that raises
  ResourcesSessionConflictError and AgentSessionConflictError, instead of
  promising that no session code raises a plain 409. Release also covers a
  worker releasing ownership of a session ID, Lost says how an agent refuses
  a cookie for a lost session, and the note on other features' senses lists
  token capture and launch fences, MCP token claims, the launch claim file,
  the checkpoint terminal step and SandboxSession.expire().
- The harness guide says saved reply, close retry window and fence instead
  of "retained close", "replayed" and "final", and points 409 refusals at
  AgentSessionConflictError. The nemo_user_sim README names
  session_ttl_seconds, the window its fences really last.
- partner_if's SWE adapter keeps its fences in _adapter_fences, apart from
  the Scale-SWE _fences it inherits, as it did before the rename.
- ResourcesSessionFences.get() tells callers whose record may be None to
  test membership, and the TODO about sessions that are never closed moves
  to close_resources_session.
- Test names, locals, comments and READMEs drop the remaining "typed",
  "legacy seed", "close receipt", "frees" and "final 422" wording.
- New tests pin AgentSessionConflictError as a 409 that is still a
  ValueError, a fence holding a None record refusing a late seed, and the
  Codex refusal of a sandbox cookie that names no agent session. The agent
  retry tests match the exact close and seed messages.

Signed-off-by: Ananth Subramaniam <[email protected]>

* refactor(sessions): carry the session names to swebench's agent-run seed

NVIDIA-NeMo#4277 gave the swebench server an agent-run seed path that still used
the removed ResourcesSessionFence API (_task_session_fence.closed_episode)
and the old "legacy seed" and "typed session" wording. It now tests
membership in the shared base's _task_session_fences and refuses with
"An agent-run seed cannot replace an episode session", as r2e_gym and
swe_gym do. Its test names and docstrings say episode seed and agent-run
seed, and the refusal test checks the message.

A pi_agent test comment merged since says "terminal 422".

Signed-off-by: Ananth Subramaniam <[email protected]>

---------

Signed-off-by: Ananth Subramaniam <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 1e050998 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants