Repository navigation
feat: add sandboxed Hermes for SWE-bench Pro - #3542
Merged
Merged
Conversation
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Use Pro passed-test grading for incomplete test reports and retain patch scores at the Hermes turn budget. Match evals-v2 tool defaults and agent timeout. Rebuild old runtimes using copied packages and an explicit matching host Python for uv. Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Bundle checksum-pinned static ripgrep, preserve the task image PATH through login-shell initialization, and pass the configured context length to the main and summary model. Retain the latest persisted tool call when an in-flight tool is interrupted. Signed-off-by: James Nolan <[email protected]>
Enable the pinned harness session store so its pre-tool message snapshot exists. Checkpoint on tool start as well as between iterations, preserving the latest actual tool call when a hard kill prevents the final result write. Serialize concurrent checkpoint writers. Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Signed-off-by: James Nolan <[email protected]>
Contributor
|
/ok to test 326a472 |
Use Hermes's text_response exit reason to distinguish a natural final answer from a forced budget summary. Keep summary and wall-time stops incomplete. Add four regressions, including the shared-budget completed-summary case. Quote the README image template for Hydra and correct the review guide's shared-library scope. Leave deferred runtime startup, Environment Server routing and auxiliary usage work unchanged. Validation: 755 focused tests passed, 18 optional telemetry tests skipped; 39 model/proxy compatibility tests passed; all tracked-file pre-commit hooks passed. The new natural-completion regression fails before the fix. Signed-off-by: yaoyu-33 <[email protected]>
Contributor
|
/ok to test 39f9e2a |
yaoyu-33
approved these changes
Sep 28, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36474788170 |
This was referenced Sep 29, 2026
ananthsub
added a commit
to ananthsub/Gym
that referenced
this pull request
Sep 29, 2026
## What does this PR do? Adds typed session support to SWE-bench Pro while preserving its legacy request shapes, and makes the single-agent-turn Environment Server verify through each Resources Server's own verify body. SWE-bench Pro sessions: - The Resources Server owns task sandbox setup, verification, and cleanup. - The typed sessions build on the SWE-bench Pro lifecycle from NVIDIA-NeMo#3542. `/close_session` closes a typed session when given a `ResourcesCloseSessionRequest`, and closes the cookie session when given an empty body, as `hermes_sandboxed_agent` sends. - A repeated verify of a typed session fails once its task sandbox has been consumed, instead of grading an empty patch and returning a normal-looking reward. Verification contract: - `single_agent_turn` now sends `/verify` the flat body an Agent's `/run` sends: the task's `task_data` fields, `responses_create_params`, and the agent's `response`. The request carries the Resources session cookie from seeding, which identifies the episode. - `SingleAgentTurnVerificationInput` and `SingleAgentTurnResourcesVerifyRequest` are removed, so no Resources Server depends on an Environment Server's protocol. This changes `single_agent_turn` code merged in NVIDIA-NeMo#3717. - SWE-bench Pro accepts one verify model, `SWEBenchProVerifyRequest`, and finds its sandbox through the session. - `ResourcesVerifyRequest[T]` stays for Resources Servers paired with their own Environment Server, whose payload type they define. - Records from `single_agent_turn` now carry the same echoed task fields as records from an Agent's `/run`, and reverification sends the body live grading sends. ## Single-agent-turn interaction flow This diagram describes SWE-bench Pro under the built-in single-agent-turn Environment Server. Other Environment Servers may use different lifecycle and result contracts. ```mermaid sequenceDiagram participant E as EnvironmentServer participant R as SWEProResources participant S as TaskSandbox E->>R: Seed with task data and caller ID R->>S: Start and prepare sandbox R-->>E: SandboxAccess and session cookie E->>R: Verify with task fields and the Agent response, under the session cookie R->>S: Extract patch and run evaluator R-->>E: Verification result E->>R: Close session ``` ## Stack position Part 1 of 4, based on `main`. Next: [NVIDIA-NeMo#3720](NVIDIA-NeMo#3720). No issue is linked because this is one layer of the Environment Server stack. ## Validation - `uv run pytest resources_servers/swebench_pro/tests -q` — 84 passed - `uv run pytest environment_servers/single_agent_turn/tests/test_app.py -q` — 12 passed, including a check that `/verify` receives the flat body under the Resources session cookie - `uv run pytest tests/unit_tests -q` — passes except two tests that also fail on `main` in the local environment (missing `sandbox` extras and a pip notice) - `pre-commit run` on the changed files ## Rollouts A real Hermes + SWE-bench Pro rollout through `single_agent_turn_legacy` resolved its task (reward `1.0`, 300 of 300 tests) with the flat verify body under a typed session, with an empty failure sidecar and no leftover sandboxes. Its record carries the task fields, as a `/run` record does. ## Compatibility and benchmark impact Legacy SWE-bench Pro request bodies remain supported. Existing Resources Servers verify single-agent-turn episodes without changes. `SingleAgentTurnVerificationInput` and `SingleAgentTurnResourcesVerifyRequest` are removed from `nemo_gym.single_agent_turn_types`; they landed in NVIDIA-NeMo#3717 and had no users outside this stack. --------- Signed-off-by: Ananth Subramaniam <[email protected]>
aroshanghias-nvd
pushed a commit
to aroshanghias-nvd/Gym
that referenced
this pull request
Sep 30, 2026
## What does this PR do?
Runs Hermes in a Resources-owned sandbox when `SandboxAccess` is
supplied, or creates an Agent-owned fallback sandbox otherwise. Both
paths return sandbox-captured model and tool observations during close.
Hermes calls the Model Server directly from the sandbox, so the sandbox
must be able to reach it. The runner points every model client Hermes
builds at the rollout's Model Server URL: the root agent, its
iteration-limit summary, delegated children, and auxiliary clients.
Streaming is turned off because the Model Server answers only whole
responses.
The sandbox installs the Hermes version pinned in `requirements.txt`,
derived at startup from the Hermes installed with the server, so there
is one version pin and the sandbox runs the same Hermes as the host.
Seeding reuses that Hermes when it already imports in the sandbox, for
example because the image bakes it in, and otherwise installs it and
checks the import again. The runner starts with one blocking `exec`, so
it works on any sandbox provider. Close cancels an activation still in
flight, and the runner's shell records its PID and honors a stop marker,
so an interrupted activation, or one that exceeds
`sandbox_runner_timeout_seconds`, stops the runner. Tearing down the
sandbox remains the backstop.
Sessions use MCP tool grants. Each activation adds the granted servers
to that session's Hermes configuration, and the runner fails before the
first model call when a required server does not connect. The sandbox
installs Hermes with its `mcp` extra, which carries the MCP client.
Hermes names MCP tools `mcp_<server>_<tool>`; the response reports them
as `mcp__<server>__<tool>`, the form Gym strips before verification,
while captured model calls keep Hermes' names. Other required grants,
such as direct HTTP, are rejected at seed, and an MCP grant may not
reuse a Hermes toolset name.
## Single-agent-turn interaction flow
This diagram describes Hermes under the built-in single-agent-turn
Environment Server. Other Environment Servers may use different Agent
activation and sandbox ownership rules.
```mermaid
sequenceDiagram
participant E as EnvironmentServer
participant A as HermesAgent
participant S as TaskSandbox
participant M as ModelServer
E->>A: Seed with optional SandboxAccess
A->>S: Borrow or create sandbox
E->>A: One /v1/responses activation
A->>S: Run Hermes and tools
S->>M: Model calls
A-->>E: Agent response
E->>A: Close session
A->>S: Disconnect borrowed or stop owned sandbox
```
## Stack position
Part 1 of 3, based on `main`. Next:
[NVIDIA-NeMo#3721](NVIDIA-NeMo#3721).
No issue is linked because this is one layer of the Environment Server
stack.
## Validation
- `responses_api_agents/hermes_agent/.venv/bin/pytest
responses_api_agents/hermes_agent/tests/ -q` — 72 passed
- The runner tests run the pinned Hermes against a local HTTP model
server and check that the iteration-limit summary and default OpenAI
clients reach it, and that delegated children do not stream.
- Required Direct HTTP tool-grant reproduction now fails seed explicitly
instead of running without the tool.
- A runner test starts the example MCP weather Resources Server with MCP
exposure, grants it to Hermes, and checks that the model's tool call
reaches the seeded Resources session; another checks that an unreachable
required server fails before any model call.
- Non-Hermes real-model smoke: not run because this workspace has no
configured model endpoint or credentials.
## Rollouts
MCP grants: all 5 `example_mcp_weather` tasks with `gpt-5.6-sol` through
`single_agent_turn_legacy` with the MCP tool transport scored reward
`1.0`, with Hermes calling `get_weather` over MCP from its sandbox. That
run also used the Resources Server change that returns MCP access in
`resources_tools` for Environment Server seeds, which is a separate PR.
See the final integration PR for SWE-bench Pro rollout evidence.
## Compatibility and security impact
`reasoning_content` replay on assistant messages comes from NVIDIA-NeMo#3542; this
PR adds tests for it. Sandbox requirements, including Model Server
reachability, and the writable result-file limitation are documented in
the Hermes README. Sandbox mode is suitable for evaluation, not RL
training data, until result transport is isolated from model-written
files.
---------
Signed-off-by: Ananth Subramaniam <[email protected]>
This was referenced Oct 1, 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.
Adds sandboxed Hermes support for SWE-bench Pro, using
opencode_sandboxed_agentas the reference.The existing SWE-bench Pro resources server creates the task container. The Hermes agent attaches to it and runs Hermes inside, with model calls routed through Gym's model server. The resources server then extracts the patch and grades it in a fresh verification container.
Both this approach and
anysweuse sandboxes. Inanyswe, the agent adapter manages task setup, execution, and grading. Here, those responsibilities are split: Hermes solves the task, while the benchmark resources server owns the environment and verification.Includes a portable Hermes runtime for glibc and musl task images, plus Apptainer support for attaching to an existing sandbox.
Validation: focused agent, resources-server, and sandbox tests on the rebased branch; pre-commit checks; real-model SWE-bench Pro rollouts before this rebase.
Suggested labels:
feature,area:agent(maintainer access required).