Repository navigation
feat(terminus-2): run Terminus 2 in task sandboxes through agent sessions - #5650
Conversation
…ions terminus_2_agent now serves agent sessions. At seed it borrows the task sandbox the Resources Server lends, or starts one from sandbox_provider, installs a private Python runtime with the pinned Harbor through SandboxPythonRuntime (reused when it passes its import check), stages the runner and checks that tmux runs. Each activation runs Terminus 2 inside the sandbox under SandboxSession's process supervisor, and close returns the invocation, its model calls, the command batches with their terminal output, summarizations and the sandbox outcome. The host path, /v1/responses without a session and /run, keeps working for AnyTerminal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 3791915 |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Review fixes for the Terminus 2 agent-session adapter: - A rollout stop during seed, or one that ends the runner before it saves a result, is reported as an empty wall_time run with ng_rollout_stop instead of failing the activation (which was retried). - The run's budget starts once the run has a concurrency slot, so a provider transport timeout after a long queue stays a failure. - Terminus's own tmux commands run from / when a task command removes or moves the workdir, instead of ending the run as a harness error. - Request instructions join Terminus's instruction; tools, tool_choice and parallel_tool_calls stay out of its model calls; a field the converter cannot represent is refused with 422 before the activation starts. - An owned sandbox carries the provider's default metadata and session labels, gets its workdir created at setup, and its default TTL reserves both setup steps. - A runner result that does not validate becomes an observation_capture_failed gap instead of failing the activation or close. - Setup refuses an image without bash. - Add configs/profiles/benchmark.yaml, like the other session harnesses, and register it with the shared profile tests. - README: capability level Evaluation until #3520 lands, supported pairings, request-field rules, terminal lifetime, scoped absolute IP, limits, and the relation to terminus_2_sandboxed_agent. - Tests: the real SandboxSession lifecycle over an in-memory sandbox (stops, close during a run, activation after close), /run refusals, runner max_turns, moved workdir, background process and imports without nemo_gym, and a regression test for each fix. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test d3e7115 |
Signed-off-by: yaoyu-33 <[email protected]>
- timeout, model_timeout_sec and command_timeout_sec must be positive and finite: the run timeout sets the supervisor's deadline and an owned sandbox's TTL. - After the runner removes its SIGTERM handler, it ignores the signal, so a stop that arrives once Terminus has returned no longer kills the runner before it writes its result. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 32ef036 |
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
- A SIGTERM without the supervisor's deadline receipt (a task's `pkill python3`) ends the run as `terminated`, not as a `wall_time` timeout. - A deadline that ends the runner before it saves anything is an empty `wall_time` run, as a rollout stop already was, instead of an activation error. - The runner saves its result while it still handles SIGTERM, so a late signal cannot end it unsaved. - A reply Harbor cannot parse no longer clears a pending completion claim, matching Harbor's own handshake. - Usage is unknown when the result carries no usage count, and on the host path when any call lacked usage; reasoning tokens are never a measured zero. - `reasoning_effort` and `max_thinking_tokens` are refused at startup: Harbor applies them only to its own client. - Update the HLE profile test and README for main's grant-free judge Environment Servers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 53cda02 |
Only agent sessions refuse request max_output_tokens: a session's request covers the whole episode, which Terminus cannot bound across model calls. The host /v1/responses and /run paths again send it as each model call's max_tokens, as on main, so anyterminal_terminus_2 rows that carry max_output_tokens keep working. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 22951c7 |
|
The two RISKs from the bot review still apply at 22951c7. Close runs with cwd=workdir, so it fails after a task moves its workdir, and the bash/script probe runs after the runtime install, so a no-bash image gets a setup error instead of a 422. Could you address both, or reply on the threads if you think they’re out of scope for this PR? |
Signed-off-by: yaoyu-33 <[email protected]>
…ge first Session lifecycle commands (stop, expiry probe, session-file removal) only address files under an absolute session directory, so they now run from "/" instead of the task workdir. A task that moves or deletes its workdir (Docker then refuses `exec -w`) no longer turns a finished run into a cleanup failure or leaves an active run's stop unconfirmed. Relative session directories still resolve against the workdir; the harness launch keeps the workdir. Terminus 2 now probes for bash, script and tmux before the runtime installer, which itself runs bash, so an image without bash gets a final 422 instead of an installer RuntimeError. A probe with a provider error is not a missing tool. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
Thanks for flagging these. Both RISKs are fixed in c844be1:
New regression tests: moved-workdir close (finished and active, local provider), stop/removal with a missing workdir, and "no install or upload before the refusal". All of them fail on the previous sources. |
|
/ok to test c844be1 |
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test dd76fa4 |
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test a956c8e |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43813201342 |
Terminus 2 now tracks unknown cache reads per call (#5650); keep that and leave a missing total_cached_tokens unknown instead of defaulting it to 0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
terminal_bench_2_1/terminus_2 now lends each task sandbox to terminus_2_agent, Harbor's Terminus 2 at the Harbor commit it pins, which serves agent sessions since #5650; the terminus_2_legacy_agent recipe keeps terminus_2_sandboxed_agent on the relay. The README lists how the two harnesses' defaults differ, and a test checks that a model server can read each preset harness's header without loading the harness's app. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]>
…the Harbor environment server and keep the relay recipes as *_legacy_agent (NVIDIA-NeMo#6181) * feat(terminal_bench_2_1): run the Terminus 2 and OpenCode presets on the Harbor environment server terminal_bench_2_1/terminus_2 and terminal_bench_2_1/opencode ran on the legacy_agent /run relay of the terminal_bench_2_1 resources server. They now name `harbor_target: terminal_bench_2_1` and run the 89 pinned Harbor task folders through the Harbor environment server with agent sessions: terminus_2_sandboxed_agent's episode sessions (its /run route is the deprecated part) and opencode_agent in place of opencode_sandboxed_agent. Both keep eight rollouts per task. The previous recipes stay unchanged as terminus_2_legacy_agent and opencode_legacy_agent (lifecycle deprecated). The Super 3.5 bundle and inkling_small, which compose the resources server's servers, now include terminus_2_legacy_agent.yaml. The resources server's README marks it legacy; the benchmark README gets a Harbor "Run" section and the differences between the two paths. Docs that show agent composition and instance renaming use opencode_legacy_agent, and the tests that exercise the relay recipes follow them to their new names. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Document TB2.1 Harbor scoring, repairs and command mapping The benchmark README now says how the Harbor presets score an episode, which tasks the resources server repairs at run time and what each does when run as published, how the two paths differ (sandbox size, time budgets, the OpenCode adapters' defaults), and which Harbor setting replaces each resources-server key or command. The preset test imports from the public API. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Correct the OpenCode adapter differences in the TB2.1 README On TB2.1 both adapters keep OpenCode subagents enabled (the relay loads opencode_sandboxed_agent.yaml, which denies only webfetch, websearch and skill), and both bound the whole run at 10,800 seconds; the sandboxed adapter also caps each model call at one hour. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Load the Terminus 2 agent app on first use A model server imports each harness package that uses it to read the assistant-message header, in the model server's own environment. The terminus_2_agent package imported its app, which needs Harbor, so any run of terminus_2_agent against a model server without Harbor (vllm_model, for one) stopped at startup with "No module named 'harbor'". The package now exports the app's classes lazily, as stirrup_agent does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Run the TB2.1 terminus_2 preset with terminus_2_agent terminal_bench_2_1/terminus_2 now lends each task sandbox to terminus_2_agent, Harbor's Terminus 2 at the Harbor commit it pins, which serves agent sessions since NVIDIA-NeMo#5650; the terminus_2_legacy_agent recipe keeps terminus_2_sandboxed_agent on the relay. The README lists how the two harnesses' defaults differ, and a test checks that a model server can read each preset harness's header without loading the harness's app. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Compose the agent-selector example onto the TB2.1 relay recipe terminal_bench_2_1/opencode now runs on the Harbor environment server, where --agent-type swaps the harness instead of composing it onto the benchmark's agent; the composition case uses opencode_legacy_agent, as the docs do. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> * Record Terminus 2's feedback on an unparsed reply as a user turn When Terminus cannot parse a reply it runs no command and sends parse-error feedback as the step's observation. The response gave that observation a function_call_output with a made-up call_id that no function call opened, so the Harbor environment server could not export the transcript to ATIF ("function result ... matches no pending call") and masked the sample: 5 of 39 Terminal-Bench 2.1 rollouts in a 20-task run. A result with no call to answer is now the next user turn, which ATIF attaches as that step's observation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: weijia chen <[email protected]> --------- Signed-off-by: weijia chen <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Adds agent sessions to
terminus_2_agent, running Harbor's Terminus 2 loop inside the task sandbox throughSandboxSession. Seed prepares the runtime; a supervised activation drives local tmux and calls Gym's Model Server; close collects observations before verification. No separate issue is needed for this focused adapter integration.script(an image without either gets a final 422 before any install), then uploads a reusable, version-constrained private Python runtime and prepares tmux before activation. Runtime installation needs no sandbox package-index access; installing missing tmux can still require root and network.x-session-id. Input/instructions and supported sampling reach Terminus; unsupported representations are refused before activation. The wall-time budget starts after the concurrency slot is acquired. Terminal control and session close survive a task moving or removing its workdir.wall_timetimeout; a SIGTERM a task command sends (pkill python3) ends the run asterminated. Usage is reported only when every model call had a usage record, in both execution modes; otherwise it stays unknown. Close reports invocation/model references, conversation, command batches, summarization, sandbox outcome and cleanup evidence.Compatibility and limits
Shared lifecycle change:
SandboxSession's stop, expiry probe and session-file removal now run from/when the session directory is absolute (control_cwdinnemo_gym/agents/utils/supervisor_client.py), instead of in the task workdir. These commands only touch session files, and Docker refusesexec -winto a directory the task moved, so every sandboxed adapter's close was affected. Relative session directories and the harness launch keep the workdir.The host Responses entrypoint remains available; host
/runis preserved throughentrypoint: legacy_app.py. They keep main's handling of requestmax_output_tokens: it becomesmax_tokenson every model call, whichanyterminal_terminus_2rows rely on. Agent sessions reject a non-null requestmax_output_tokenswith HTTP 422 before binding the activation, because a session's request covers the whole episode and Terminus cannot bound it across model calls; session task rows should drop the field and set a per-call cap on the Model Server.model_info.max_output_tokensremains model metadata, not a budget.terminus_2_sandboxed_agentand benchmark declarations remain unchanged. Capability is Evaluation: multi-command result pairing still depends on #3520, and per-command timing is unavailable. Task commands share the runner's user and can alter result files; training is unqualified. No full TB2.1 evaluation or supported pairing is claimed.The host path now prepends request
instructionsto the instruction, as agent sessions do;mainignored them.reasoning_effortandmax_thinking_tokensmust staynull: Harbor applies them only to the LiteLLM client it builds itself, so the agent now refuses to start with either set.Validation
mainmerged in; commits have DCO sign-off.tests/unit_tests/agents/test_sandbox_session.pyandtest_sandbox_supervisor_client.py: 318 passed on the Linux workstation. The new moved-workdir close tests (finished and active run, real local provider) and the no-bash refusal assertions fail on the previous sources. Because the cwd change is shared, these sandboxed adapter suites were rerun and pass: codex 548, pi 378, openclaw 522, opencode 404 (1 workstation-only failure:shexit code for an exec-format error), claude_code 208, cline 197, copilot 144, droid 144, openhands 131, goose 44, kimi_code 31. hermes and stirrup were not run (their runtimes are not installed in that venv).alpine:3.20image (no bash) is refused with a 422 before any runtime directory or harness file is written. A borroweddebian:bookworm-slimsandbox whose task runsmv /app /app.bakcloses cleanly for a finished run and for an active one (stop confirmed, rc 143, partial output collected). Session files are removed,/appis not recreated, and the sandbox stays up. With the previous cwd, the same runs fail withCould not remove ... session filesandlaunch outcome is unknown; cannot confirm termination.tests/unit_tests/tooling/test_agent_environment_*,environment/test_session_harness_benchmark_profiles.py,test_session_contract_repo.py): 294 passed on the Linux workstation. After the hostmax_output_tokenschange, the adapter suite again passed (194); the two host tests for it fail on the previous code.pre-commit run --files <changed paths>passed;uv lock --check(uv 0.13.7) passed forresponses_api_agents/terminus_2_agent.nvidia/nemotron-3.5-super-vl-120b-a12b, agent-owned Dockerdebian:bookworm-slim, temperature 0, top_p 1, Model Server max_tokens 4096, thinking disabled, 180-second activation budget. Responsecompleted, reward 0.0, unmasked, no failure outcome; verifier output inspected; all task process groups and containers removed. This one-row smoke checks runtime and verification behavior, not benchmark qualification. The last round changed result grading and usage reporting only, so no new rollout was run.CI repair validation (2026-11-14)
main, including the upstream CrewAI timeout-test fix that caused the failed server shard./runrelay tolegacy_app.py; the default session adapter inherits the Environment Server entrypoint. Existing host/runconfigurations must setentrypoint: legacy_app.py. Added a regression assertion for the default entrypoint and retained legacy refusal and request-forwarding tests.python -m pytest responses_api_agents/terminus_2_agent/tests -q -o addopts='': 195 passed.python -m scripts.environment_server_compliance.inspection responses_api_agents/terminus_2_agent --output findings.json: no findings.pre-commit run --all-files(pre-commit 4.2.0): passed after formatter fixes. No harness loop or verifier behavior changed; the existing real-model smoke above remains applicable. No additional model rollout for this entrypoint extraction.python -m pytest tests/unit_tests/agents/test_sandbox_session.py tests/unit_tests/agents/test_sandbox_supervisor_client.py tests/unit_tests/environment/test_session_harness_benchmark_profiles.py tests/unit_tests/tooling/test_agent_environment_default_configs.py tests/unit_tests/tooling/test_agent_environment_session_templates.py -q -o addopts='': 226 passed.