Repository navigation
Conversation
Reuse the Resources session lifecycle and regression cases from NVIDIA-NeMo#3902/NVIDIA-NeMo#4064. Compose the existing OpenClaw adapter through the single-agent EnvironmentServer and declare the TB pairing. Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
This was referenced Oct 9, 2026
yaoyu-33
added a commit
to yaoyu-33/Gym
that referenced
this pull request
Oct 12, 2026
Incorporate TB recipes from NVIDIA-NeMo#4241 and NVIDIA-NeMo#4242 on main. Preserve successful borrowed task services through grading for all four harnesses; retain failed execution cleanup and verify OpenCode CLI completion before transcript snapshots. Signed-off-by: yaoyu-33 <[email protected]>
ananthsub
pushed a commit
to ananthsub/Gym
that referenced
this pull request
Oct 14, 2026
…A-NeMo#3902) Enable Pi, Codex, OpenCode and OpenClaw on Terminal-Bench 2.1 through the shared Resources/Agent session protocol. Resources prepares one task sandbox, the harness borrows it, verification runs in that same sandbox, and Resources closes it afterward. Consolidates NVIDIA-NeMo#4064, NVIDIA-NeMo#4241 and NVIDIA-NeMo#4242 into NVIDIA-NeMo#3902 after their parent integrations merged into main. Those sibling PRs remain closed; these review repairs stay in this PR. The existing benchmark integration and author-requested consolidation do not need another feature issue. Legacy lifecycle retirement is tracked in NVIDIA-NeMo#4570 under NVIDIA-NeMo#2763. ## Changes and compatibility - One TB Resources session implementation and one benchmark recipe selecting any of the four harnesses. The recipe uses taskset routing, `materialize_task`, and `single_agent_turn`. Existing direct-agent recipes remain available. - Session seed/verification replay validates task identity; Resources keeps ownership through grading and retries failed stops. Completed close records expire after `session_close_retry_window_seconds` (default 300 seconds); retries do not extend it. Close fences slow setup before waiting for its lock, and late setup attempts bounded cleanup; failed stops retain ownership. After a cancelled final close and failed late stop, no durable automatic retry is scheduled: explicit close retry or shutdown can use the retained handle, while provider TTL can stop the sandbox but does not purge the in-memory record. - The Linux supervisor stops live harness-group processes and reaps its children. Before timeout/close, it snapshots already adopted children, typically services from completed tools. After stopping the harness, it repeatedly kills/reaps newly adopted children, including in-flight tools in separate sessions, within the existing cleanup budget. Previously adopted services outside the group remain for the sandbox owner. Zombie-only groups held by another live parent do not falsely fail termination. There is no `preserve_descendants_on_success` policy switch. - A valid final negative termination receipt fails activation and skips capture/verification, but permits borrowed-session release so Resources can tear down the sandbox. Missing or inconclusive termination evidence stays retryable; positive confirmation tolerates malformed optional diagnostics. Each final cleanup callback gets its own deadline, so an unresponsive agent close cannot consume the Resources owner's close attempt. - Task shell HOME is preserved. Pi/Codex/OpenClaw use their harness-specific state locations. OpenCode keeps private CLI HOME/XDG state and restores task HOME/XDG for shell commands through its `shell.env` hook. A fresh successful-initialization receipt is required before accepting a gradable result; missing/invalid receipt fails activation even when the CLI ignored a plugin error. This check prevents grading, not earlier execution. Borrowed agent close removes the private session directory; Resources retains the task sandbox. - OpenClaw sets `OPENCLAW_NO_RESPAWN=1` so its pinned CLI does not detach the agent during non-TTY startup. Compile-cache wrappers may still spawn within the supervised group. - Removed `keep_sandbox_for_close`. Session verification grades the existing sandbox; legacy `verify` owns its bounded cleanup; golden verification owns a separate sandbox and bounded `finally` cleanup. A legacy seed created before golden verification is also closed. - Direct sandboxed Hermes redirects inherited stdout/stderr to a session log, preventing detached services from holding the provider exec pipe open. It downloads only a bounded 1 MiB tail, including a truncation marker, for diagnostics. Shared caller docs and Linux regressions cover Hermes and SWE-Pro as well as the four TB harnesses. This changes shared process-lifetime behavior. Services from completed tools must use task-owned files and avoid retaining transport streams; the pinned harnesses already run shell tools in separate sessions. Natural CLI exit has no stop-time cutoff, so unfinished detached tools cannot be distinguished from services and may still change task files. Adoption timing, PID reuse and later service forks also limit the forced-stop rule. A positive receipt does not guarantee an idle sandbox and is not a security boundary. SWE-Pro still extracts a patch and grades it in a fresh sandbox; TB grades the original task state. No original TB task prompt, dataset, scoring formula, or default permission profile is changed. Sessions remain process-local and require one worker. ## Lifecycle The Agent and Resources servers run outside the task sandbox. Normal gradable completion is: ```mermaid sequenceDiagram participant E as Environment server participant R as Resources server participant A as Agent server participant S as Task sandbox E->>R: Seed Resources session R->>S: Create and set up sandbox R-->>E: Sandbox access E->>A: Seed agent with sandbox access E->>A: Run agent A->>S: Harness CLI and tools Note over A,S: Stop live harness-group processes and reap children Note over A,S: On timeout/close, also drain newly adopted tools Note over A,S: Confirm termination, then capture artifacts A-->>E: Gradable agent response E->>A: Close agent session A->>S: Remove private harness session files A-->>E: Release borrowed connection Note over R,S: Task files and preserved services remain E->>R: Verify R->>S: Run task tests in this same sandbox R-->>E: Verdict E->>R: Final cleanup R->>S: Stop sandbox and remaining processes ``` On failure or cancellation, final cleanup still attempts each registered owner. Successful session release alone does not make a failed activation gradable. Confirmed harness termination permits capture, not a passing reward. Golden verification creates and closes its own sandbox and has no agent session. ## Validation — current review repair Runtime repair [`8d8809e13`](NVIDIA-NeMo@8d8809e13), merged with main `e085a1d2a` in `6f6f9ac3e`; final test-only follow-up [`ab9f3cc27`](NVIDIA-NeMo@ab9f3cc27). Three independent agents implemented, challenged and cross-reviewed the nine comment fixes over multiple rounds. No additional PR was created. - Final Linux/Python 3.13.14 affected suite: **2,012 passed, 0 skipped**, tree `7765f9bcac97fd7a7f81e398ff9286c0329896bf`. Includes shared supervisor/session/environment/checkpoint lifecycle, both environment adapters, TB/SWE-Pro, four harness suites and affected Hermes suites. Pinned CLI tests were enabled, not skipped. - The first full attempt retained **2,011 passed, 1 failed**: a Codex fixture modeled an in-flight child as a completed-tool service. The corrected fixture preserves the original alive-service/dead-CLI assertions; its whole session file passes 133 tests before the complete rerun. - All eight new detached-writer regressions fail against the previous supervisor; all 40 isolated supervisor tests pass after repair. Pinned OpenClaw non-TTY startup reaches a held model request in one group and stops; changing only `OPENCLAW_NO_RESPAWN` to 0 fails its PGID assertion. Pinned OpenCode loader tests reproduce ignored plugin failures with no receipt. Final pinned-runtime selection: 13 passed, 0 skipped (overlaps the full suite). - Removing only the second final-negative-receipt check fails the new regression; restoring unbounded Hermes output fails its diagnostic test. - Final `pre-commit run --all-files`, Ruff and diff checks pass; Fern `npm run check`: zero errors, one warning. All three new commits have DCO sign-off. Fresh real-model smoke: Qwen2.5-7B-Instruct revision `a09a35458c702b33eeacc393d103063234e8bc28`, vLLM 0.8.5 on RTX A6000; temperature 0, 32,768 context, 4,096 provider output tokens/call, 300s harness/verifier, 1,200s episode, 1,800s sandbox TTL, 2 CPU/4,096 MiB. Dataset `7131e4375048a0e408a8fb404b5f499d726b695b`; original task/test bytes and images retained, current taskset routing and default harness permissions unchanged. | Harness | Original certificate task | Original log-summary task | Synthetic HOME/XDG/service control | | --- | --- | --- | --- | | Pi 0.80.2 | graded 0 | graded 0 | reward 1 | | Codex 0.144.4 | graded 0 | graded 0 | reward 1 | | OpenCode 1.17.11 | graded 0 | graded 0 | reward 1 | | OpenClaw 2026.6.11 | graded 0 | graded 0 | reward 1 | **12/12 attempts graded; no failed activation or missing row; all four strict 3/3 profiles pass.** Four synthetic controls each contain an actual native tool call and verify task HOME/custom XDG markers, an HTTP service alive after agent close, removed private session directories, and unchanged task OpenCode config. Eight original-task zeros have `evaluation_completed=true` and task-test failures, not verifier infrastructure exceptions. These scores are not benchmark successes. Native responses include five completed and seven incomplete results. Pi log-summary and OpenClaw certificate/log-summary have no actual tool calls despite textual tool markup. Pi/Codex/OpenCode certificate runs exercise partial-result grading after time limits. Native observations/token joins have gaps; strict profile completion does not certify rollout quality or full training-token parity. Automated health reports Codex 2 unhealthy/1 unobserved (failed model endings, including output/context limits) and OpenCode 1 unhealthy/2 healthy (token-count mismatch). Pi and OpenClaw are 3 healthy each; that does not imply task success. The explicitly detached control service does not establish compatibility for every service-launch recipe. Smoke source is tree `4f455a30592b106eafba853cf64db193a5e3c4e6` (`6f6f9ac3e`). The only later changes are three test files in `ab9f3cc27`; all runtime/docs bytes match. Each arm's source hashes stayed unchanged. All 12 containers have normal destroy events, no fallback removal or forced Gym stop; task-owned model/Gym processes, control image and ports are cleaned, and raw evidence is archived. Existing unrelated workloads were preserved. ## Historical evidence and remaining gates Earlier repair `c2a6dec84` had 1,926 Linux passes plus a 397-test OpenCode follow-up. Its 16 retained model attempts included one OpenCode startup failure before any model call; a separate repeat graded zero but did not explain or erase that failure. [Earlier repair report](NVIDIA-NeMo#3902 (comment)). That evidence and the October 12 `06bd366b5` smoke predate the current adoption-cutoff policy. The new Pi/Codex/OpenCode certificate runs exercise deadline drain under a real model. Preserving a service already adopted before a forced stop is covered by the Linux regressions only; the synthetic service controls cover normal completion and do not establish that forced-stop preservation behavior. The full PR touches shared core code and requires full CI and maintainer review. Earlier CI at `3dd3ae027` passed core/server shards but reported a Hermes P0 `model_error` conformance failure; this local validation does not claim to clear that scenario. Exact-current-head CI remains a separate gate. No trust-gate command was posted. - NVIDIA-NeMo#4570 is attached as an actual sub-issue of NVIDIA-NeMo#2763 and tracks retiring legacy direct-agent ownership; removing only `single_agent_turn_legacy` does not retire those agents. - NVIDIA-NeMo#4571 tracks inherited verifier infrastructure failures recorded as unmasked zero; this lifecycle repair does not change that scoring contract. - SWE-Pro/Hermes and benchmark-owner review remain relevant because the supervisor is shared. --------- Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Adil <[email protected]>
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.
Superseded by #3902, which now contains Pi, Codex, OpenCode and OpenClaw TB2.1 support on
main. All four upstream harness PRs have merged. Closing this duplicate at the author's request; its branch and original evidence remain available. Current validation and limits are recorded in #3902.Historical description (the parent status and validation below refer to the earlier revision):
Enable OpenClaw for Terminal-Bench 2.1 using Resources-owned task sandboxes and the shared agent-session lifecycle. Resources prepares and grades the task; EnvironmentServer closes the agent before verification and closes Resources afterward.
Follows #3637 at
e01e9a09f7bf8c4431df1b1d3c212808e1a33159. That parent remains open, so this PR retains its parent target and a five-file TB diff. Inherited harness/core code matches the parent. No separate issue is needed for this requested pairing and dependency refresh.Changes
single_agent_turn_legacyas the format adapter over shared sessions.No dataset, prompt, reward or verifier changes. This enables the pairing; it does not establish benchmark accuracy.
Validation at
4c11fa526b1b10b466fbb8f7b76aba4999e461f4pre-commit run --all-files: Passed. DCO, PR-diff whitespace and relative README links checked.python -m pytest tests/unit_tests/test_sandbox_session.py tests/unit_tests/test_sandbox_supervisor_client.py tests/unit_tests/test_sandbox_supervisor_bootstrap.py tests/unit_tests/test_process_supervisor.py tests/unit_tests/test_sandbox_stop_retry.py tests/unit_tests/test_sandbox_connect.py tests/unit_tests/test_agent_sessions.py tests/unit_tests/test_agent_session_retries.py tests/unit_tests/test_base_responses_api_agent.py tests/unit_tests/test_global_config.py tests/unit_tests/test_add_legacy_agent_environment_servers.py tests/unit_tests/test_session_contract_repo.py environment_servers/single_agent_turn/tests environment_servers/single_agent_turn_legacy/tests resources_servers/swebench_pro/tests responses_api_agents/openclaw_agent/tests --import-mode=importlib -q -o addopts= -o log_cli=false --tb=short -rs gym env test +entrypoint=resources_servers/terminal_bench_2_1 +should_validate_data=true ++skip_venv_if_present=true pre-commit run --all-filesThis is the targeted local selection, not full core/server CI. Labels and draft status are retained.
Rollout evidence and limits
Earlier local-model TB smoke at
159dfbef1eac3c6bc7bc78d18da5a5851503ffb8reached real verification with an unmasked zero reward and inspected agent/tool/artifact handoff. That evidence remains pinned to its original revision. No fresh model rollout was run for this dependency synchronization; current inherited parent/main changes are covered by the deterministic checks above. TB implementation/verifier behavior is unchanged by this refresh.The earlier original-prompt
regex-logsmoke used Qwen2.5-7B-Instruct. Its regex was incorrect; this was a graded failure, not a solved task. Native usage matched raw backend responses. Collector health wasunobserved, with missing standard capture/trajectory model-call records. The initial OpenCode tmpfs upload failure was a smoke-driver issue; its failed evidence was retained and the unchanged source completed after removing that override. All smoke resources were cleaned up.Keep draft. The shared supervisor stops agent-started descendant services before grading, so service-dependent tasks remain a known limitation. File-producing smoke does not validate service lifetime. Replay remains process/session-local; full benchmark baselining and training-token parity remain outside this PR.