Skip to content

feat(vibench): run OpenCode through agent sessions - #5701

Merged
yaoyu-33 merged 14 commits into
mainfrom
weijiac/n4p0-vibench
Nov 10, 2026
Merged

yaoyu-33 merged 14 commits into
mainfrom
weijiac/n4p0-vibench

Conversation

@weijiac0619

@weijiac0619 weijiac0619 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What and why

ViBench ran vibench_agent, a subclass of opencode_sandboxed_agent, behind a legacy_agent relay. The agent created the build sandbox, ran OpenCode in it, tarred the app into a directory shared with the resources server, and posted /verify with the tarball path. This PR adds a second path for ViBench 1.0, on the single_agent_turn_legacy Environment Server and opencode_agent, following the gdpval pattern: the resources server owns the build sandbox and lends it to the agent. The new path is opt-in through resources_servers/vibench/configs/vibench_sessions.yaml; configs/vibench.yaml keeps vibench_agent on the legacy relay, unchanged, and stays the default.

This PR builds on #5778 (vibench-public 2.0 moved ViBench 1.0 under v1/), which is merged; main is merged into this branch.

  • Seed (seed_session): validates the row and refuses, with ResourcesSeedRejectedError (HTTP 422), what no retry can fix: a row that is not a task, a path outside the checkout, a missing PRD. Without a build image it fails with an error naming VIBENCH_BUILD_IMAGE. It then starts the build sandbox from ViBench's base image with the PRD at /app/prd.txt and the PRD assets under /app/assets/, and lends it as sandbox_access (workdir /app). A failed asset upload stops the sandbox. A repeated seed for the same episode and task is idempotent; a session bound elsewhere answers 409.
  • Agent session: opencode_agent borrows the sandbox and builds the app there.
  • Verify: tars /app inside the sandbox (excluding dependency and VCS trees and the staged brief, as before), downloads it, stops the sandbox and grades the copy with ViBench's own scripts. Grading is unchanged. A repeated verify regrades the same copy. The harvest holds the session's lock and copies the tarball into the verify's own work directory, and grading runs outside the lock: a concurrent verify waits and harvests nothing twice, and a close waits for the copy instead of removing it mid-unpack. A verify without a live session (a restart, a restore, or after close) is a masked session_lost sample instead of a zero.
  • Harvest failures: a missing /app or a fatal tar error (exit 2) is a build failure, as the model left nothing to grade. Tar's exit 1 (a file changed while it was read, typically because the model left its app server running) still grades, since the archive is complete. A provider failure to run the command or transfer the archive is masked with the provider's failure kind (or provider_request_failed for an untyped error), and an exit code that is not tar's own (such as 127) with verifier_error; in both cases the sandbox is kept, so a resent verify can harvest again, and close stops it.
  • Close (close_resources_session): stops a sandbox that verify did not, removes the copy and fences late seeds (ResourcesSessionLocks and ResourcesSessionFences, as gdpval uses them). A failed stop is an error and the close can be retried. A stop that fails right after a harvest does not fail the verify: it is logged, the verify grades the harvested app, and close stops the sandbox. A seed whose setup fails after the sandbox exists keeps the session until its teardown succeeds, so close can retry it; such a session, or one already harvested, is never lent again. Checkpoint retirement (retire_session_state) releases a session the same way close does. The harvest command runs from /, so a missing /app is a build failure, not a provider error. Episode sessions are process-local, so the server requires one worker.
  • Agent permissions: the recipe loads opencode_agent's command deny-list (configs/permissions/default.yaml) but not opencode_agent.yaml. OpenCode 1.17.11 places the keys of a tools map, such as the one that file sets, before the permission map's "*" rule, and the last matching rule wins, so with that map none of the denials apply (the same finding as partner_if's SWE config). Web, subagent and skill tools are denied through permission instead, and the agent's other fields are set in the recipe.
  • Legacy relay path: responses_api_agents/vibench_agent, its configs and resources_servers/vibench/configs/vibench.yaml are unchanged. The resources server serves both paths: a seed without a resources_session_id (the agent's /run) gets the PRD text and asset directories and starts no sandbox, and a verify that names artifact_path grades the tarball from artifact_dir as before (a missing or out-of-directory tarball is a build failure, not a masked sample). sandbox_provider is now needed only by sessions, and artifact_dir only by the legacy path.
  • The new path's Docker provider overlay is resources_servers/vibench/configs/docker.yaml, which uses use_absolute_ip instead of the host.docker.internal rewrite; vibench_agent's own overlay stays for the legacy path.

This PR does not change ViBench's grading, vibench_agent, opencode_agent, opencode_sandboxed_agent, or the Environment Server. Feature tasks (feature-ri) and ViBench 2.0 are not integrated. No issue is linked: the work is tracked internally.

Kept from the legacy recipe, and what differs

Kept: OpenCode 1.17.11, a 5,400-second build, no subagents (task: false), the same build image, the /app workdir, the staged PRD and assets, the harvest exclusions, the build check and grading.

Differences that can move scores:

  • The output budget is 32,768 tokens per model call and the context window 229,376 (the gdpval convention), so a call fits a 262,144-token served context. The legacy recipe asks for the whole 262,144-token window on every call. vLLM refuses that request, and OpenCode then ends the build with no model call and no error; the first real run below shows it.
  • OpenCode runs with opencode_agent's command deny-list, which also denies Git network commands, Git history mining and curl/wget to GitHub. The legacy recipe denies only process killing and rm -rf /.
  • Prompt placement and runtime follow opencode_agent's session path (its README, "Configuration compatibility").

Compatibility

vibench_agent stays on the legacy relay and is not removed here, and resources_servers/vibench/configs/vibench.yaml still starts it, so existing runs keep their harness and budgets. Making the session path the default, and removing vibench_agent, is left to a later PR, once both paths are graded on the same tasks.

Moving a run from the legacy path to the session path:

Legacy relay Session path
vibench_opencode_agent.responses_api_agents.vibench_agent vibench_opencode_agent.responses_api_agents.opencode_agent
...vibench_agent.build_image, app_workdir, harvest_timeout_s vibench_resources_server.resources_servers.vibench.sandbox_config.image, app_workdir, harvest_timeout_s
...vibench_agent.sandbox_config, sandbox_provider vibench_resources_server.resources_servers.vibench.sandbox_config, sandbox_provider
...vibench_agent.sandbox_timeout ...opencode_agent.timeout
...vibench_agent.opencode_max_context_window ...opencode_agent.context_window and max_output_tokens
artifact_dir / VIBENCH_ARTIFACT_DIR on both servers Not used: the resources server harvests the app itself
responses_api_agents/vibench_agent/configs/docker.yaml resources_servers/vibench/configs/docker.yaml
vibench_opencode_environment_server (legacy_agent) vibench_environment_server (single_agent_turn_legacy)
sandbox_model_base_url on the agent use_absolute_ip=true with absolute_ip_server_types=[responses_api_models] (set in configs/docker.yaml; pass both for other providers)
VIBENCH_BUILD_IMAGE on the agent VIBENCH_BUILD_IMAGE on the resources server

absolute_ip_server_types keeps every server except the model server on loopback: the server whose config endpoint returns the merged config, and this resources server, whose /seed_session and /verify run with the grader's keys.

Validation

Unit tests

At the head of this PR, after merging main, Linux, unless noted. tests/unit_tests/test_public_api_facades.py: 845 passed.

  • resources_servers/vibench/.venv/bin/pytest resources_servers/vibench/tests -q: 110 passed, 3 skipped. The skipped tests are the three jinja2 rendering tests; jinja2 is not in the server's venv.
    • test_sessions.py runs the session path against the local sandbox provider: seed staging (PRD and assets only, no test plans), harvest exclusions, regrade on a repeated verify, a build failure, close and fence, close after verify, close retry after a failed stop, a stop that fails after the harvest (the verify still grades, close stops the sandbox, and a later seed is refused), failed setup kept for close to clean up, retirement retrying a failed teardown, idempotent seed and 409 on a conflicting one, each 422 refusal, a failed asset upload, a missing image (no scratch directory left), a row whose app holds a path, a lost session (masked), verify after a real seed and close (masked), shutdown, the one-worker check, and check_resources_session_contract.
    • Harvest outcomes: a failed download is masked and a resent verify harvests and grades; a typed provider failure keeps its failure kind; a command the provider did not run, and a non-tar exit code, are masked; tar exit 1 grades; tar exit 2 and a missing app directory are build failures. A GraderConfigError through a live session fails the verify and removes its work directory.
    • Concurrency, with overlapping requests: a close that arrives while verify harvests waits for it and then removes the session, and the verify still grades its own copy (reward 1, not a build failure); two verifies at once run the harvest command once, stop the sandbox once, and both grade the same app.
    • test_app.py covers the legacy relay path: the seed returns the PRD text and asset directories without starting a sandbox, verify grades the tarball and removes it, no tarball is a build failure (not a masked sample), and a path outside artifact_dir (or any path without one) is refused and never deleted.
    • test_configs.py resolves vibench_sessions.yaml offline: the deny-list survives with no tools map, the four tool denials follow "*", and the output budget fits the served context. It also checks docker.yaml scopes the host address to model servers, and that vibench.yaml still wires vibench_agent to this server through a shared artifact_dir.
  • .venv/bin/pytest -q tests/unit_tests/test_public_api_facades.py tests/unit_tests/test_public_api.py tests/unit_tests/test_fern_docs_links.py tests/unit_tests/test_session_contract_repo.py tests/unit_tests/test_moved_paths.py tests/unit_tests/test_packaging_paths.py tests/unit_tests/telemetry/test_trace_context_path.py responses_api_agents/opencode_sandboxed_agent/tests/test_app.py, at efd5fc3b7 (the later commits touch only resources_servers/vibench): 1234 passed, 2 skipped, 1 failed. The failure, test_import_only_loads_shared_opencode_modules, is its 30-second subprocess timeout expiring on a cold import on a heavily loaded shared host; nothing it imports changed since 4d685b849, where it passed, and it passes on rerun (the import takes about 7 s warm).
  • resources_servers/vibench/.venv/bin/pytest responses_api_agents/vibench_agent/tests -q (its tests as on main): 17 passed.
  • gym env resolve of the session config (at 4d685b849, when it was vibench.yaml) with the OpenSandbox provider and a vllm_model server: the agent binds the ViBench resources server and the Environment Server binds both. The run below starts vibench_sessions.yaml at efd5fc3b7.

Real runs

The final run is at efd5fc3b7, from configs/vibench_sessions.yaml (the later commits change only the interpreter lookup from #5778 and the handling of a failed stop after the harvest); the first row is from the first revision and shows the output-budget problem. Model: a Nemotron checkpoint served by vLLM (262,144-token context) through Gym's vllm_model server. Sandbox provider: OpenSandbox, with ++use_absolute_ip=true and absolute_ip_server_types=[responses_api_models]: only the model server listened on the host address, and the other servers stayed on loopback. Build image: nikolaik/python-nodejs:python3.12-nodejs22, the public parent of app-bench-base, since app-bench-base is not published to a registry. One rollout of the notes MVP row from example.jsonl, through gym env start and gym eval run --no-serve.

Grading was not exercised: the run host has no Docker. ViBench grades each test plan in a Docker Compose stack (Postgres, the app, Playwright), and the grader's seeding step stops at "Docker is not installed". The runs cover seed, build and harvest only; the grading code path is unchanged and shared by both paths.

Run Seed Build Harvest Grading
First revision, before the budget fix (max_output_tokens = 262,144) Sandbox started, PRD staged, lent; OpenCode ran in it Ended incomplete after about a minute with no model call and no error: vLLM answered 400 ("you requested 262144 output tokens") Empty app, build_failed: true Not reached
At efd5fc3b7 (32,768 / 229,376) Sandbox started, PRD staged, lent; OpenCode ran in it Ended completed (the whole rollout took 465 s): 46 tool calls (32 bash, 6 write, 3 edit, 3 todowrite, 2 read), 1.20M input and 24k output tokens. The deny-list applied: OpenCode refused a pkill call and an rm -rf call by rule Tarred, downloaded and copied into the verify's own work directory in 2.6 s: start-server.sh, setup-environment.sh and a Python app (main.py, static/), without the staged prd.txt. Build check passed (build_failed: false) All three test plans failed at seeding with "Docker is not installed"; reward 0.0, not masked (as before this PR)

Checks

  • pre-commit run --from-ref fd1fa273f --to-ref HEAD (from the merge base) at de6686b0f: passed (the private guardwords check skipped itself because its catalog was unavailable; this text was checked by hand).
  • DCO sign-off on every commit.

Known limits

  • Grading was not exercised: the run host has no Docker, so graded rewards are unverified (see "Real runs"). A run needs a resources server host with Docker, and the session path should score a nonzero reward end to end before it becomes the default.
  • Grader endpoint (open question). ViBench 1.0's seeding and evaluation agents default to Sonnet 4.5 on Anthropic's API (env_creator.get_env_dict). The seeding slot has no endpoint override, and the evaluator's context compression uses openai/gpt-4.1. Whether the grader can be pointed at an OpenAI-compatible URL without changing ViBench's grading is not answered here.
  • app-bench-base is built locally by ViBench's pipeline and is not published. A remote sandbox provider needs it pushed to a registry and VIBENCH_BUILD_IMAGE set; the run above used its public parent image.
  • A grader that cannot start (for example, no Docker) still scores 0.0 unmasked, as before.
  • Tool denials are half verified. The run shows the deny-list acting on bash and the four tool denials (webfetch, websearch, task, skill) in the config OpenCode received, but it does not record the tool list sent to the model, so their removal from that list is not confirmed. The tools-map ordering behind the workaround belongs in opencode_agent.yaml, outside this PR.
  • Tar's exit 2 is a build failure even when it comes only from a directory tar cannot read beside a working app (for example a root-owned Postgres data directory in /app). The legacy path fails every non-zero exit, so this is not a regression.
  • The resources server keeps sessions in process and requires num_workers of 1.
  • Feature tasks (feature-ri, from v1/results/<app>/RI_MVP/app/, 21 of 24 apps) and ViBench 2.0 are left for follow-ups.

🤖 Generated with Claude Code

Move ViBench off the legacy_agent /run relay onto the
single_agent_turn_legacy Environment Server and opencode_agent.

The resources server now starts the build sandbox at seed (PRD at
/app/prd.txt, assets under /app/assets), lends it to the agent, and at
verify tars /app, downloads it, stops the sandbox and grades the copy
with ViBench's scripts as before. Close stops a sandbox verify did not,
removes the copy and fences late seeds. A verify without a live session
is a masked session_lost sample. A provider failure while harvesting is
masked with its failure kind and keeps the sandbox, so a resent verify
can harvest again; a missing app directory or a fatal tar error is a
build failure, and files that changed while tar read them are not.

The agent loads opencode_agent's command deny-list but not
opencode_agent.yaml, whose tools map would cancel the denials under
OpenCode 1.17.11; web, subagent and skill tools are denied through
permission. The Docker overlay scopes use_absolute_ip to model servers.

Remove responses_api_agents/vibench_agent, whose only user was ViBench,
and move its Docker provider overlay to resources_servers/vibench.

Read ViBench 1.0 from vibench-public's v1/ layout (v1/prds, v1/.venv),
keeping the old layout working, and regenerate example.jsonl from tag
v2.0.7 (prompts unchanged, paths gain the v1/ prefix).

Set the OpenCode output budget to 32,768 tokens with a 229,376-token
context window: the previous whole-window budget is refused by vLLM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 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.

weijiac0619 and others added 4 commits November 5, 2026 17:37
Restore responses_api_agents/vibench_agent and its mentions as on main, so
the legacy_agent relay keeps working beside the agent-session path, which
stays the documented default.

The resources server serves both: a legacy seed gets the PRD text and asset
directories and starts no sandbox, and a verify that names artifact_path
grades the tarball from artifact_dir as before. The legacy recipe moves to
configs/vibench_agent.yaml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
vibench-public moved ViBench 1.0 under v1/ when ViBench 2.0 landed: the
apps are in v1/prds/ and the 1.0 project (venv, .env) in v1/, while
_harness/ stays at the root. prepare.py looked for prds/ at the root and
stopped on a current checkout.

prepare.py now finds the apps in v1/prds/, or prds/ for a checkout from
before 2.0, and looks for ViBench's interpreter in v1/.venv, then .venv.
Row paths stay relative to the checkout root, so the resources server
and vibench_agent are unchanged. example.jsonl is regenerated from tag
v2.0.7 (only the paths change), example_rollouts.jsonl gets the same
path update, and the README setup follows the new layout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
configs/vibench.yaml is main's legacy relay recipe again, unchanged, so
existing runs keep their harness and budgets; the session path moves to
configs/vibench_sessions.yaml. vibench_agent's README is back to main's.
The default switches, and vibench_agent goes, only after both paths are
graded on the same tasks.

verify now holds the session's lock while it harvests and copies the
tarball into its own work dir, then grades outside the lock. Before, two
verifies could tar into the same remote file and download over the same
copy, and a close could remove that copy mid-unpack, which graded as a
build failure. New tests cover a close during verify and two verifies at
once. example_rollouts.jsonl keeps vibench_agent's artifact_path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
Bring in the v1/ layout fix, now its own PR, so this PR's diff shows only
the session work. This branch already carried the same changes; the
README keeps this branch's text, which covers the same layout notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@weijiac0619
weijiac0619 changed the base branch from main to weijiac/vibench-v1-layout November 6, 2026 23:27
@weijiac0619

Copy link
Copy Markdown
Contributor Author

Hi @deepbuilder, I’m moving ViBench onto Gym’s agent-session path. The build and harvest steps work in OpenSandbox. Grading still needs a host with Docker and docker-compose, and our cluster nodes don’t have Docker. Which host did you use for the end-to-end grading in NVIDIA-NeMo/Gym#2674, and could I run the resources server there for a quick check?

weijiac0619 and others added 3 commits November 6, 2026 17:52
The resources server looked for ViBench's interpreter only in the checkout root's
.venv, while the v1 setup puts it in v1/.venv, so the server fell back to Gym's
own Python. It now checks v1/.venv first, then .venv, as prepare.py does.

The README names the full assets path in Anti-cheat and lists, under P0
limitations, that grading has not been re-run on v2.0.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
_harvest_app stopped the sandbox once the app was out, and a failed stop raised
through verify as a 500, so a rollout whose tarball was already harvested lost
its grade. The failure is now logged and the sandbox stays on the session for
close to stop, which raises if that stop fails too, so the caller can retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@weijiac0619
weijiac0619 marked this pull request as ready for review November 7, 2026 04:14
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 7, 2026 04:15
Base automatically changed from weijiac/vibench-v1-layout to main November 7, 2026 04:27

@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

I found three runtime RISK findings below, plus missing grading evidence and a documentation NOTE.

RISK — Validate the session path through real grading

The reported session rollout exercised seed, build and harvest, but every test plan stopped because Docker was unavailable. The nonzero rewards in the README's validation section explicitly come from the legacy agent. Those results don't validate grading artifacts produced through the new session path. The pinned rubric requires reward-comparison evidence for changes to fixed-benchmark verification, and the trusted repository guidance requires inspecting real agent and verifier behavior. Keeping the recipe opt-in and verified: false doesn't replace that evidence.

Please run the session recipe on a Docker-capable resources-server host and record a representative successful build-to-score rollout. Also provide a before/after reward comparison on a fixed task set, naming the policy model, grader, image and harness settings, with mean_reward, plans_graded_rate, build_failure_rate, mean_seeding_failure_rate and masked-sample counts. Preserve the documented legacy default and distinguish intentional budget/permission effects from unintended grading changes; identical scores aren't required.

Acceptance evidence: real scorecards for the selected test plans, at least one nonzero graded session result, and inspected artifacts showing that the harvested app—not the staged brief or dependency trees—was graded. These are requested checks, not checks I executed.

NOTE — Document the new pairing in Fern

The new session recipe is documented in the component README, but this notable user-facing pairing has no corresponding Fern update. The rubric places user documentation under Fern. Please add a short ViBench section to the existing agent-integration guide, linking the detailed README and showing the session config plus a provider overlay. Retain the legacy-default distinction, Docker grading requirement, model-only address exposure and score-comparability warning. Static acceptance: the published guide links to the session recipe, its example includes the provider config, and it doesn't imply that the session path replaces the default.

I inspected all eight changed files and traced the affected environment, agent, session and provider contracts. The delegated configuration report wasn't collected, so I covered that topic directly. This was a static review; I didn't execute tests or Docker/OpenSandbox runs.

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

result = await session.sandbox.exec(
f"[ -d {workdir} ] || exit {_NO_APP_DIR_EXIT}; cd {workdir} && tar "
f"{HARVEST_EXCLUDES} --exclude={PRD_FILENAME} -cf {quote(REMOTE_ARCHIVE)} .",
timeout_s=self.config.harvest_timeout_s,

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.

RISK — Run the missing-app check from a directory that still exists.

If the builder deletes or moves /app before verification, this exec inherits /app as its working directory. The shell can fail before reaching [ -d /app ] || exit 3, and verification then masks the model's failed build as an infrastructure failure. This incorrectly excludes the sample from quality metrics. AsyncSandbox supplies its configured workdir when cwd is omitted; Docker passes it as docker exec -w. The local provider likewise uses it to start the subprocess. The existing missing-app test removes the directory only after the shell starts, so it misses this trigger.

Replace this argument line with the following; please verify the suggestion before adopting it:

Suggested change
timeout_s=self.config.harvest_timeout_s,
cwd="/",
timeout_s=self.config.harvest_timeout_s,

The command already changes to app_workdir before running tar. This makes the missing-directory guard independent of the directory it checks, while retaining normal harvesting and exclusions, tar-exit-1 grading, fatal-tar build failures, provider-outage masking and failed-stop-after-harvest grading.

Proposed checks, not executed: seed with the local-provider fixture, remove root before calling /verify without wrapping exec, and expect reward == 0, build_failed is True, mask_sample is False, no grading and sandbox teardown. Check the equivalent Docker case. Retain the successful harvest/exclusion, tar-exit-1, tar-exit-2, failed-download retry and concurrent verify/close assertions.

Comment thread resources_servers/vibench/app.py Outdated
if item.is_file():
await sandbox.upload(item, f"{workdir}/assets/{item.relative_to(asset_dir).as_posix()}")
except BaseException:
with suppress(Exception):

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.

RISK — Keep ownership when failed setup cannot stop its sandbox.

A reproducible sequence is: asset upload raises, then sandbox.stop() raises. This handler suppresses the stop failure and discards the only sandbox reference; the outer seed handler removes the scratch directory without recording any session. A later /close_session therefore returns success and fences the ID without retrying teardown, and another seed can create a second sandbox. The serialization-error branch has the same ownership gap when its _release(session) fails before registration. These sandboxes survive until provider expiry, despite the sandbox API preserving failed stops for retry.

Could seed retain pending-cleanup ownership by session ID from sandbox creation through file delivery, asset staging and serialization, releasing the record only after teardown succeeds? Close and shutdown must retry that same sandbox. Keep pending setup distinct from a usable session: simply inserting it into the current replay branch would lend a partially staged sandbox on the next seed. The pending-state representation needs an implementation decision, so a one-line replacement isn't safe.

Proposed checks, not executed: make upload fail and the first stop raise OSError, then let stop succeed; a later close must retry the same sandbox and return success only after releasing it. Repeat for serialization failure followed by stop failure. A seed retry must never receive access to incomplete setup. Preserve the existing assertions that upload failure with successful teardown leaves no session, successful repeated seed reuses its sandbox, and failed close retains state for a successful retry.

await session.sandbox.stop()
session.sandbox = None

async def _release(self, session: _BuildSession) -> None:

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.

RISK — Release session state through the checkpoint retirement hook too.

With checkpointing enabled, seed a live session and retire its attempt through the resources participant. ResourcesParticipant.retire waits for requests, calls retire_session_state(session_id), then stops tracking the session. ViBench inherits the no-op implementation, so retirement reports success while the build sandbox and scratch directory remain owned in _sessions. This also defeats the retirement backstop when an upstream close didn't finish. A successfully harvested session still leaks its retained archive through this path.

Insert the following method after close_resources_session, and verify it before adopting it:

    async def retire_session_state(self, session_id: str) -> None:
        async with self._locks.locked(session_id):
            session = self._sessions.get(session_id)
            if session is not None:
                await self._release(session)
                del self._sessions[session_id]
                self._fences.fence(session_id, session.episode_id)

The invariant is that retirement releases known state before reporting it released, while a failed stop keeps that state available for retry. This uses the same lock and teardown path as ordinary close; it doesn't change grading on a verify's independent copy. Include pending setup cleanup in this teardown contract if such records are added.

Proposed checks, not executed: enable checkpointing, seed through a rollout-prefixed route, then call the authenticated resources retirement endpoint. Expect sandbox teardown, removal of the scratch directory and an idempotent repeated retirement. Inject a stop failure: retirement must fail with state retained, and a retry must release it. Also retain ordinary close/fence behavior, and check that retiring an already harvested or normally closed session doesn't stop its sandbox twice.

@copy-pr-bot

copy-pr-bot Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 7, 2026
@yaoyu-33

yaoyu-33 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

This branch conflicts with main since #5778 was squash-merged: resources_servers/vibench/README.md (4 hunks, wording) and resources_servers/vibench/app.py (main's _artifact_root property, which only the old _resolve_artifact used). #5819, which is stacked on this PR and makes the session config the default, resolves them in its merge commit 8f2f800: it keeps this PR's text and drops _artifact_root. Use that if it helps. Separately, the 8 harvest tests in tests/test_sessions.py fail on macOS through the local provider's tar (on your head too); they pass on Linux.

@yaoyu-33

yaoyu-33 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

One more thing that surfaces once main is merged here: tests/unit_tests/test_public_api_facades.py::test_code_outside_the_library_imports_exported_names_from_the_public_api fails on resources_servers/vibench/tests/test_sessions.py:691 (from nemo_gym.sandbox.providers.local.provider import LocalProvider). from nemo_gym.sandbox import LocalProvider is the exported form; #5819 carries that change as 53dad36.

#5778 was squash-merged into main; this branch already carries its changes, so the conflicts in resources_servers/vibench/README.md and app.py keep this branch's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 9, 2026
weijiac0619 and others added 2 commits November 9, 2026 15:45
AsyncSandbox.start() now delivers the spec's initial files through
upload(), so mocking upload() wholesale also failed the PRD inside
start(). Fail only the asset uploads, which is the step these tests
are about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@weijiac0619

Copy link
Copy Markdown
Contributor Author

/ok to test a877ab2

@yaoyu-33
yaoyu-33 added this pull request to the merge queue Nov 10, 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/42849864044

Merged via the queue into main with commit b75d482 Nov 10, 2026
69 checks passed
@yaoyu-33
yaoyu-33 deleted the weijiac/n4p0-vibench branch November 10, 2026 16:13
weijiac0619 added a commit that referenced this pull request Nov 10, 2026
main now has #5701 as one squashed commit, so its files conflicted with
the branch's own copy of #5701's history. Each conflict is resolved to
the branch's change applied on top of #5701's final head; the result
equals that head merged with this branch, plus main's later commits.
configs/vibench_sessions.yaml, which main adds and this branch renamed
to configs/vibench.yaml, stays removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>

This branch was previously deployed

1 inactive deployment
public — a877ab29 Deployed Nov 10, 2026 by copy-pr-bot[bot] via release / finalize / notify #11255
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 feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants