Repository navigation
feat(agentic_if): Add e2e agentic instruction-following benchmark - #4959
Conversation
Adds a benchmark that measures whether a coding agent follows instructions while it completes a real repository (Scale-SWE) or terminal (Terminal-Bench format) task in OpenCode. The task's verifier gives the reward; an LLM judge and deterministic checkers grade the recorded session against each instruction. - benchmarks/agentic_if: the benchmark entry (config, manifest, README with the measurement contract), prepare.py, which downloads the 586 internal rows and the terminal tasks' tests from Gym's dataset registry and pins both by SHA-256, and the lockfile for OpenCode's offline plugin dependencies. - resources_servers/agentic_if: owns each single_agent_turn episode. It checks the sealed row, borrows the task's sandbox through the scale_swe or terminal_bench_2_1 typed session, stages two OpenCode plugins that apply the row's harness profile and record every model call, collects the session evidence, has the task backend verify the task, and grades the instructions with the judge through a Gym model server. - responses_api_agents/opencode_agent: opt-in sandbox settings for owner plugins, a pinned offline runtime, session exports and session imports; unusable settings refuse the seed with AgentSeedRejectedError. The request's temperature and top_p are applied instead of refused. - resources_servers/scale_swe: typed resources sessions for an environment-server owner, as terminal_bench_2_1 has; masked infrastructure failures, bounded sandbox stops, shutdown stops, and num_workers fixed at 1. - resources_servers/swebench: patch capture raises CaptureCommandError, a RuntimeError subclass that carries the exec's return code. No change under nemo_gym/. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
…h the dataset Task sandboxes without internet access cannot download OpenCode's ripgrep or the plugin dependencies OpenCode installs at every start. Dataset agentic_if 2.1.0 adds them as a third artifact (same rows and tests as 2.0.0); prepare.py writes them under data/opencode-runtime/ and checks each file's SHA-256. The benchmark config has the agentic_if resources server stage them into each task sandbox at seed (opencode_runtime_files, like the OpenCode plugins it already stages) and points opencode_agent's in-sandbox ripgrep and plugin-dependency pins at them. Only the OpenCode binary remains a per-deployment setting. opencode_agent is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
…es server Keep only what running the benchmark needs, and say what the code does rather than where it came from. Rows, receipts, grading, failure classes and the evidence format are unchanged: the judge config hash is still 5bf772a4a461, the five example rows' receipts verify, and every golden fixture's recorded data is byte-identical (only its provenance fields were dropped). Removed: - tests/opencode_bundle/derive_fixtures.py: a one-off generator that only runs against the deleted environment server's code; no test imports it. - Code nothing calls: save_jsonl, AgenticIFTaskInput, validate_task_identity, BoundSandbox.download, the export-list bundle test, unused test helpers and parameters. - Branches no row or config reaches: the seed's full-receipt check (Gym's environment server never seeds with the actor's request), tool-alias handling left in the evidence builder and both plugins (aliases are refused when the bundle is compiled), the frozen error-receipt branch in the profile plugin, collect_bundle's fallback for a missing staging receipt. - Duplicates and single-use layers: seed_check.py (its checks now share task_variants/runtime.py's source checks), episode/bundle.py's copies of the bundle's outputs and receipt, the one-subclass session base class, and the one-field TaskBackendSettings (task_resources now maps each backend straight to its server reference). - The fixture index's list of dropped cases and its gateway-era provenance. Comments and docstrings no longer narrate the deleted Python gateway, the environment-server driver or commit 00be188; where a value is kept only because a hash covers it, they say which hash. Kept on purpose (recorded fixtures pin them): the boundary's max_completion_tokens and instructions handling, and three gateway-era fixtures that still name tool aliases. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e and history wording opencode_agent: the export runner wrote export-status.json next to the session exports, but no owner reads it; the adapter already takes the same outcome from the runner's one-line JSON status on stdout. Stop writing the file, and drop its README entry and the tests that read it. Fold a duplicate host-pin refusal test into the stricter one, and stop documenting the host-pin cache's key in the README. scale_swe: describe the cookie path by what it does (it masks and replays nothing) instead of "as before" / "as on main", and drop an exec_error_type that the "workdir missing" result never carries and nothing reads. Tests call FakeSandbox directly instead of through a one-line wrapper. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream NVIDIA-NeMo#4943 (swe_together) added an OpenCode binary pin to opencode_agent with the same field names as this branch's. Resolve the four opencode_agent conflicts by adopting upstream's pin as-is: sandbox_executable_path and sandbox_executable_sha256 with its installer arguments 3-6, sandbox_python_executable, sandbox_path_prefix and sandbox_model_id. swe_together's behavior is unchanged. This branch's own binary pin goes: the digest-keyed runtime directory, the installer's pinned block (exit 3 as a final 422) and sandbox_local_executable_path. A binary that fails its checks is now a retryable setup error, as upstream has it. - Installer: upstream's script, plus NG_OPENCODE_SKIP_RIPGREP when a ripgrep pin is set. - app.py: each config field is declared once; _sandbox_prepare_command takes python= and export_dir= and the seed passes both, so the export_dir check runs with the configured interpreter; the installer command is upstream's argv behind the ripgrep prefix; a request temperature marks the sandbox_model_id model entry instead of the literal dummy_model. - README: upstream's offline-runtime section, then Owner extensions without the binary row. - Tests: upstream's installer pin tests and this branch's ripgrep skip test; the extension tests expect upstream's 7-element installer argv, the host upload tests use ripgrep, and a new test checks that a failed binary pin stays retryable. - agentic_if docs no longer name sandbox_local_executable_path or say that a SHA-256 without its path is refused. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No config uploads a pinned file from the Gym host: the agentic_if resources server stages ripgrep and the plugin dependencies into each task sandbox itself, and the OpenCode binary now uses upstream's in-sandbox pin. Remove sandbox_local_ripgrep_path and sandbox_local_plugin_dependencies_path with the upload path in seed, the host digest helpers and cache, and the upload semaphore. A ripgrep or plugin-dependency pin is now always a file already inside the sandbox; its seed refusals and in-sandbox digest check are unchanged. Drop the host-upload tests and README text. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nterpreter Upstream's sandbox_python_executable and sandbox_path_prefix reached the installer, the supervisor and the run, but not the commands this branch adds. The plugin-file check, the ripgrep and plugin-dependency staging, the session import and the session export now run with the configured interpreter instead of a hard-coded python3 (the export_dir check already did so after the merge). OpenCode's export and import now get the same PATH prefix as its run: the runner applies path_prefix in the environment builder that all three share, and seed writes the prefix into import.json. With the default settings (python3, no prefix) nothing changes, so agentic_if and swe_together run as before. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Request temperature and top_p go to every OpenCode built-in agent, and the agent list is OpenCode 1.17.11's; a name OpenCode does not define adds an agent. After the merge, opencode_agent also runs other versions (swe_together pins 1.15.13). Key the list by OpenCode version and, for any other version, refuse request sampling with 422 as the adapter did before it applied any. Nothing in the tree sends request sampling to such a version: swe_together's candidate requests carry none. Also test that a request temperature marks the sandbox_model_id model entry (the merge's fix for the literal dummy_model key). Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The startup guard refused num_workers other than 1, which the server supported before: its module-level app exists for multi-worker uvicorn. Gym routes each session's requests to the worker that holds it (NVIDIA-NeMo#3905), typed seeds and closes included, so Environment Server sessions need no guard. Drop the guard, its config lines, README line and test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
- Stage workspace files by upload instead of on the command line, which caps one argument at 128 KiB. Prefix replay shares the same private staging directory helper. - Log a failed removal of that directory, and keep the error raised inside it. - Report a seed reply without a usable sandbox, or an unusable sandbox configuration, as a retryable failure instead of an invalid task. - Record the model that answered each judge call. - Parse the bundle's records and touch its temporary files off the event loop. - Make Verdict and Judge.prompt keyword-only. - Reword "native" and an Environment Server mention in if_grading. Its sources make up the scorer identity, which changes; the judge config hash stays 5bf772a4a461. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
2.2.0 drops the one terminal task whose image has no python3, which opencode_agent and the resources server's file staging run on, and that task's tests. The rows are otherwise byte-identical to 2.1.0, and the OpenCode runtime artifact is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Raise the resources server's test coverage from 91% to 97% (434 to 124 missed of 4659 statements), above the 95% the add-benchmark skill asks for. The new tests grade small synthetic sessions through each module's public functions: - language: the user's language read from their own words with pasted output set aside, each script and Latin-language verdict, and which uncertain texts go to the judge. - rendering: edits shown as their change, the files changed before a message, the run after an event, and the redraw of a long run. - engine: first_turn after an event, if_no_text, the `user` language value, changed-file marks checked before the judge, prefix failures. - git_diff and change marks: Git's quoted paths, renames, copies, binary and mode-only sections, test outputs, and runs without diffs. - calls, shell and text: bash_writes folders, copies and plan files, inline and library writes, sed, truncate, test runners, and the marks of changed-file mentions. - instructions, OpenCode evidence and export, read-first guards. Only tests change; the if_grading sources the scorer identity hashes are untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
…ion closes OpenCode compacts a long session with a summary call. opencode_agent parsed the session's turns, which leave summaries out, but returned them only for continuation sessions. For an ordinary session, rollout collection rebuilt one turn per captured call, so the summary call was both a turn and the compaction's model call, and the evidence gate's TE-9 check (steps.attempt_accounting) failed on every compacted rollout. Ordinary sessions now return the trajectory at close, as /run and continuation sessions already do, and as terminus_2_sandboxed_agent does. Turns become one per saved assistant reply, with source message IDs and step counts, and a reply cut off mid-step is reported as turns_unavailable. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
… needs The boundary plugin turned a max_completion_tokens field into max_tokens (with a Python-style min) and deleted a request's `instructions` field when it replaced the system prompt. The pinned OpenCode 1.17.11 provider sends neither field (its real requests carry max_tokens and no instructions), so both paths only ran for three synthetic fixtures; remove the code and those fixtures. Also remove three fixtures that duplicate their derived-* counterparts call for call (compaction as JSON and as a stream, the auxiliary title call). Their specs named tool aliases, which the golden test rewrote to identity names; that shim goes with them. The remaining 35 golden cases still match byte for byte. With the six fixtures gone, the only plugin code no test runs any more is a number branch of the general truthiness helper. Signed-off-by: Katherine Huang <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Two changes this branch made for every opencode_agent sandbox user now apply only to configs that ask for them, so other users keep the existing behavior: - An ordinary session's close returns its own turns only with the new return_session_trajectory setting (default false). agentic_if turns it on, so a compaction's summary call is not counted as a step (TE-9). - The adapter sets PWD to the task workdir only with export_dir or session_import_path, whose export and import need the session bound to that directory; otherwise OpenCode inherits PWD from the sandbox as before. The runner no longer forces it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Shutdown cleanup now stops only what Environment Server sessions hold. The cookie path that an Agent's /run uses keeps its behavior: what it still holds at shutdown is left to the provider's TTL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
The replayed command now writes its marker 5 s in instead of 1 s, so a starved event loop cannot let it through before the 0.1 s timeout kills it. The test still finishes in about half a second. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
The five example rollouts are rerun at 9a81d47 the way the committed file was made (vLLM-served Nemotron 3.5 Super, capture off), so they show the current output, for example the model that answered each judge call. All five completed and are unmasked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
|
/ok to test 51474e5 |
|
💬 The run failed: {"container_build":{"correction":"","duties_complete":true,"equivalent_attempt":0,"justification_evidence":"","preflight_complete":false,"preflight_evidence":"","reason":"not_requested","requested":false,"reuse_checked":false,"reuse_evidence":""},"do":[],"say":"","state":"working","wait":[{"item":"watch","on":"ci_watch_pr","pr":4959,"repo":"nvidia-nemo/gym"}]}. |
|
💬 The run failed: {"container_build":{"correction":"","duties_complete":true,"equivalent_attempt":0,"justification_evidence":"","preflight_complete":false,"preflight_evidence":"","reason":"not_requested","requested":false,"reuse_checked":false,"reuse_evidence":""},"do":[],"say":"","state":"working","wait":[{"item":"watch","on":"ci_watch_pr","pr":4959,"repo":"nvidia-nemo/gym"},{"item":"watch","on":"retry_turn","retry_kind":"platform"}]}. |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41757951046 |
Main named the OpenCode runtime files with constants (NVIDIA-NeMo#4837). The OpenCode agent keeps its owner-staged plugin check, pinned ripgrep, plugin dependencies and session import, and uploads the installer and plugins through those constants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Main now exports JUDGE_FAILURES and is_judge_failure from nemo_gym.verification and AGENT_RUN_ERROR from nemo_gym.core, so the public-API test rejects importing them from their submodules. That test failed this PR's merge-queue run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
Main moved every server to a committed pyproject.toml and uv.lock (NVIDIA-NeMo#4837), and its tests reject a server's requirements.txt. The project declares the same dependency as before (nemo-gym[dev,sandbox] from this checkout) with the shared uv policy, as scale_swe does; the lock was generated with uv 0.13.4, the version the component-locks workflow uses. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Katherine Huang <[email protected]>
|
@weijiac0619 could you comment /ok to test and enable auto-merge again? The merge queue dropped this PR because a public-API test failed earlier. Thanks! |
|
/ok to test c0e8ff0 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41885053122 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41930693475 |
|
💬 I traced the queue failures to three separate issues: an artifact download returned HTTP 503, a chat-keepalive cancellation test failed an assertion, and Kilo's model-error probe failed. On current main ( |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42067854723 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42068715492 |
|
The PR is no longer an open ready-to-merge PR targeting main. |
Benchmark
agentic_ifmeasures whether a coding agent follows instructions while it completes a real repository task(Scale-SWE) or terminal task (Terminal-Bench format). Each task pairs the work with synthetic instructions about how to do it. The task's own verifier gives
reward, and an LLM judge plus deterministic checkers grade the recorded session against each instruction.examplesplit holds 5 public tasks (3 from Terminal-Bench 2.1, 2 from Scale-SWE) whose synthetic instructions exercise the same features.Linked issue
None: this adds a new benchmark.
Validation
gym eval prepare --benchmark agentic_if(585 tasks and the OpenCode runtime files; every SHA-256 pin matches),gym env validate agentic_if --kind benchmark,gym env test agentic_if --kind benchmark(the verifier fixture's3 cases),
gym env publish agentic_if --kind benchmarkandgym env test --resources-server agentic_if.ng_test +entrypoint=<dir> +should_validate_data=true, on Linux at the evidence commitfor
resources_servers/agentic_if,responses_api_agents/opencode_agent,resources_servers/scale_sweandresources_servers/swebench: all pass.resources_servers/agentic_if(901 passed),opencode_agentwithtests/unit_tests/test_agent_sessions.py(656 passed, 49 Linux-only tests skipped),scale_swe(107 passed) andbenchmarks/agentic_if/tests(14 passed).resources_servers/agentic_if: 97% (Gym's add-benchmark skill asks for 95%).pre-commit runon every changed file (the private guardwords catalog is read only in CI), and DCO sign-off.gym dataset collate --mode example_validationof the example split matches the committedexample_metrics.json.replies, call records and issues.
Frontier Eval onboarding guide's exit checks
gym eval health-checkon the evidence run: 5 healthy, 0 unhealthy, 0 unobserved, no check ignored.quality_summary.jsonhas 5 of 5 records, 0 missing. The run used 5 internal probe rows that cover every task feature, a vLLM-served Nemotron 3.5 Super, OpenSandbox sandboxes and the in-sandbox OpenCode binaryscripts/inspect_harness_conformance.py --require-sandbox: exit 0, TE-1 to TE-9 each fulfilled on 5 of 5 rollouts. A run that forced compaction fulfills them on 5 of 5 as well (18 compactions)gym eval submit.resolved-config.yamlis in its run folder, and it andgym-job.jsonname0b25288d4scripts/run_harness_conformance.py --harness opencodeon this PR's code: exit 0, 0 of 7 scenario checks failed (unit stage: 1,039 passed, 8 skipped). The matrix is published from CI (#4500)Rollout evidence
resources_servers/agentic_if/data/example_rollouts.jsonl: five rollouts of the example split from this PR's code,served by vLLM, all completed and unmasked. Reward /
if_all: prawcore 1 / 1, pystow 1 / 0, fix-git 1 / 1,cobol-modernization 1 / 1, raman-fitting 0 / 1.
5 of 5.
capture holds the policy's 59 calls and nothing else. The 4 judge calls (2 judged rollouts) each report a reply ID
and token usage, and every rollout's
judge_usagematches itsjudge_calls. No file in the run folder holds thejudge key, the registry token or the sandbox key.
are the tools' own failures); no judge call lacks a reply ID or tokens; no infrastructure failure is scored as a
model failure.
quality_summary.jsonof the evidence run (the run folder itself is internal), itsrunblock in short:{"records": 5, "captures": 5, "expected": 5, "missing": 0, "failed": {"total": 0}, "healthy": true, "verdicts": {"healthy": 5, "unhealthy": 0, "unobserved": 0}, "ignored_checks": []}.context_window, so OpenCode compacts: 4 of 5 compacted (18 compactions),all completed and healthy, and the inspector fulfills TE-1 to TE-9 on 5 of 5; no compaction call is bound to a turn.
The same run before
return_session_trajectoryfailed TE-9 on every compacted rollout.afterwards.
agentic_ifstaging 5 s,opencode_agentseed 9 s(of which the binary copy and SHA-256 check 3 s). Close at most 1.1 s.
scale_sweon its own cookie path (scale_swe_opencode.yaml, 2 public example rows): both completed with reward1.0, and both were healthy.