Skip to content

feat(swe_env): decoupled SWE environment library + verifier (#1249) [1/3] - #2

Closed
adil-a wants to merge 1 commit into
mainfrom
stack/1-swe-env-and-verifier
Closed

feat(swe_env): decoupled SWE environment library + verifier (#1249) [1/3]#2
adil-a wants to merge 1 commit into
mainfrom
stack/1-swe-env-and-verifier

Conversation

@adil-a

@adil-a adil-a commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Decoupled SWE environment library + verifier (NVIDIA-NeMo#1249)

Stacked PR 1 of 3 · base: main · next: stack/2-swe-agents-openhands

Part of #1249decouple the SWE environment infrastructure from the agent harnesses — built on top of the Sandbox API from NVIDIA-NeMo#1377 (now on main).

What this PR adds

Today the entire SWE-bench stack (sandbox provisioning, the per-dataset eval recipes, patch parsing, and grading) is fused into the OpenHands agent in responses_api_agents/swe_agents/app.py. No other agent can reuse any of it. This PR extracts that infrastructure into two reusable, agent-agnostic pieces. It adds the new pieces only — no existing agent is rewired yet (that is PR 2).

1. responses_api_agents/swe_env/ — a shared SWE environment library. An installable distribution that any agent imports to provision and drive its own task sandbox on top of the NVIDIA-NeMo#1377 Sandbox API:

  • environment.pyAsyncSweEnvironment, the provider-neutral execute/upload/download wrapper agents drive.
  • harness.py / registry.py — the SweTaskHarness ABC and a name→harness registry; one source of truth for the dataset families (swebench, swe-rebench, nv-internal, swe-bench-ext, r2egym, flat-eval).
  • grading.py — pure compute_resolved() / reward_from_report() helpers.
  • parsing/ — the SWE-bench-Ext test-log parser (relocated here as the single home; the duplicate under swe_agents is removed in PR 2).
  • providers/{apptainer,docker}_provider.pySandboxProvider implementations, including the Apptainer .sif path the on-prem clusters use.
  • lifecycle.py — a thin acquire_sandbox() context manager. (The heavier durable-registry/reaper/admission lifecycle layer is intentionally out of scope here and tracked as a follow-up to generalize it into the sandbox layer.)
  • model_endpoint.py — provider-neutral resolution of a sandbox-reachable model-server endpoint for self-driving agents.

2. resources_servers/swe_env/ — the verifier. A SimpleResourcesServer whose verify() is the single scoring entry point: it extracts the model's patch from the response, grades it in a fresh, stateless sandbox, and returns the eval-side fields. verify_task.py holds the server-private grading orchestrator (reset → apply patch → run eval → parse → reward). Ships with a launchable config + offline example fixtures for the data gate.

Tests

responses_api_agents/swe_env/tests/   168 passed, 1 skipped
resources_servers/swe_env/tests/        14 passed, 3 skipped

ruff check / ruff format clean. Real-container grading paths are skip-guarded (apptainer/Docker); the orchestrator is exercised via a FakeSandbox that replays recorded eval transcripts.

Review notes

  • Pure additions: 59 new files, no changes to existing code — safe to review in isolation.
  • The verifier imports the library as a packaged distribution (added to its requirements.txt), so the cross-tree import works under ng_run/ng_test.

🤖 Generated with Claude Code

…eMo#1249)

Adds the provider-neutral swe_env library (sandbox lifecycle, docker/apptainer
providers, per-benchmark task harnesses, test-output parsing, grading) and the
required stateless verifier resources server that grades an agent's patch in a
fresh sandbox and returns the reward. No agent is wired to it yet; it stands alone
and is covered by its own unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: adil-a <adil.asif2000@hotmail.com>
@adil-a

adil-a commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the stacked PRs opened directly on NVIDIA-NeMo/Gym (NVIDIA-NeMo#1677, NVIDIA-NeMo#1678, NVIDIA-NeMo#1679).

@adil-a adil-a closed this Jun 23, 2026
adil-a pushed a commit that referenced this pull request Jun 25, 2026
…ool error

Addresses review feedback on MCPResourcesServer:
- (#3) Replace the per-process token->session dict with a stateless signed token (itsdangerous
  URLSafeSerializer keyed by the deterministic session-middleware secret). Any worker can verify a
  token another worker minted, so this works with num_workers > 1 and there is nothing to evict.
- (#1) Offload blocking sync @gym_tool methods to a threadpool so they don't stall the event loop
  (and every concurrent rollout in the worker).
- (#2) Raise a plain MCPSessionError with a clean message instead of HTTPException(401). MCP runs
  over JSON-RPC (HTTP 200), so the status code never reaches the client; FastMCP surfaces this as a
  tool error (isError: true).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant