Repository navigation
fix(config): declare environment servers for agents added after the migration - #4084
Merged
yaoyu-33 merged 1 commit intoOct 6, 2026
Merged
Conversation
…igration Six configs added after NVIDIA-NeMo#3929 (wordle, swemer_oml, swe_internal_v1) declare agents without an environment server, so every run generates legacy_agent relays with a deprecation warning, and runs with error_on_agent_without_environment_server fail. Add the relays with scripts/add_legacy_agent_environment_servers.py. Nothing checked repository configs, so add a test that runs the script's --check over them. Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub
force-pushed
the
add-missing-environment-servers
branch
from
October 6, 2026 16:53
429a557 to
b305b82
Compare
Contributor
Author
|
/ok to test b305b82 |
yaoyu-33
approved these changes
Oct 6, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37516346610 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37518499812 |
ananthsub
added a commit
that referenced
this pull request
Oct 6, 2026
…the migration (4084)` into `r0.7.0` (#4127) ## What This PR only cherry-picks #4084 (`33611bcc9`, "fix(config): declare environment servers for agents added after the migration") into `r0.7.0`. It adds no new code. The commit is applied with `git cherry-pick -x`, so its message records the source commit. It declares `legacy_agent` environment servers for the four configs on `r0.7.0` whose agents have none, and adds the unit test that runs `scripts/add_legacy_agent_environment_servers.py --check` over the repository: - `environments/wordle/config.yaml` - `resources_servers/wordle/configs/wordle.yaml` - `resources_servers/swemer_oml/configs/swemer_oml_example.yaml` - `resources_servers/swemer_oml/configs/swemer_oml_opencode.yaml` ## Why #4084 has the `r0.7.0` label, but the automatic cherry-pick failed. Without these blocks, runs of these configs on `r0.7.0` generate the relays at startup and log the deprecation warning, and a run with `error_on_agent_without_environment_server: true` fails with `AgentWithoutEnvironmentServerError`. ## Conflict resolution #4084 also updates `resources_servers/swe_internal_v1/configs/swe_internal_v1_example.yaml` and `swe_internal_v1_opencode.yaml`. The `swe_internal_v1` resources server exists only on `main`, so those two files are left out. Everything else applied unchanged. ## Validation - `python scripts/add_legacy_agent_environment_servers.py --check` on unmodified `r0.7.0` flags exactly these four configs and no others. Running the script there produces blocks identical to the ones in this PR. - The same `--check` on this branch: no files to update. - `pytest tests/unit_tests/test_add_legacy_agent_environment_servers.py tests/unit_tests/test_global_config.py`: pass, including the new `test_repository_configs_declare_every_environment_server`. - `pre-commit` hooks on the changed files: pass. ## Rollout evidence N/A. The added blocks are the relays the runtime already generates for these agents at startup, so a run's servers and routing do not change; only the deprecation warning goes away. Signed-off-by: Ananth Subramaniam <[email protected]>
yaoyu-33
added a commit
to yaoyu-33/Gym
that referenced
this pull request
Oct 6, 2026
…VIDIA-NeMo#3961) Hermes can be composed with a Resources Server through Environment Server. This PR decouples its default configuration and extracts a shared sandbox execution lifecycle for Pi (NVIDIA-NeMo#3626), Codex (NVIDIA-NeMo#3640), and OpenCode to adopt. Implements [GYMINT-5](https://linear.app/nvidia/issue/GYMINT-5), follows NVIDIA-NeMo#3554, and includes merged NVIDIA-NeMo#4053 from main. Only Hermes adopts the shared session in this PR; the other adapters retain their own output parsing when they migrate. ## Changes - Keep shared execution code in `nemo_gym/agent_utils/`, the agreed package name. This name preserves the agreed organization of the lifecycle and protocol helpers. Core connection, exec, transfer and provider lifecycle APIs remain in `nemo_gym/sandbox/`. - `SandboxSession` uploads its supervisor into the session directory, executes the harness, confirms cleanup and collects artifacts. `SandboxCommand` carries only argv and an explicitly installed Python interpreter. Preflight validates that interpreter before claiming launch; Python on the task image is not assumed. - Stage input and upload the supervisor in one cancellable task. Concurrent/retried closes share work; closing/closed derive from the close task. Execution retains the sandbox until explicit close. Borrowed cleanup failures retain state for retry; owned sandboxes can fall back to provider teardown. - Use one timeout-budget helper, one set of protocol filenames, and one cleanup receipt shape. Optional malformed diagnostics remain nonfatal; literal positive cleanup confirmation is still required. Session log access preserves diagnostics before files are released. - Hermes separates seed-time `install_runtime()` from `stage_activation()` and `collect_artifacts()`. Its process-identity schema stays in the adapter. The runner receives the stop-marker path from the session, preserving cancellation versus deadline reporting. - Keep `upload_text()` / `read_text()` in `sandbox/utils.py`, with Hemil's import/ordering cleanup. Remove unused byte helpers and their tests as requested. - Preserve native Hermes templates with explicit `resources_server: null` during legacy Environment Server migration. Bound Hermes, inherited Resources bindings and self-contained agents such as OSWorld retain their existing migration behavior. This fixes the merge-queue audit introduced by NVIDIA-NeMo#4084 without adding a conflicting legacy route. - Default an owned sandbox's missing `ttl_s` to install timeout + runner timeout + 600 seconds (23,100 seconds with default settings), so providers that enforce TTL can expire it after an agent-server crash. Preserve explicit values, including null, and borrowed connections; do not mutate shared configuration. ## Architecture From [Ananth's component diagram](NVIDIA-NeMo#3961 (comment)): ```mermaid flowchart LR subgraph AS["Agent server"] A["Harness adapter (Hermes)<br/>installs runtime, stages input, parses output"] S["Sandbox session<br/>uploads supervisor, runs, stops, collects, releases"] C["Supervisor client<br/>shell protocol over the session files"] end subgraph TS["Task sandbox"] D["Session directory<br/>claim, supervisor pid, stop request, receipt, log"] P["Process supervisor<br/>deadline, kills the process tree, writes receipt"] H["Harness process<br/>Hermes runner, Codex CLI"] end A -->|"argv and interpreter"| S S -->|"launch, stop, read receipt"| C C -->|"runs"| P C -->|"reads and writes"| D P -->|"starts and reaps"| H P -->|"writes receipt"| D ``` The session and supervisor client run on the agent server. Only `process_supervisor.py` from the shared package is copied into the sandbox; it uses only the standard library. A common runtime installer and provider default mounts from [the earlier diagram](NVIDIA-NeMo#3961 (comment)) remain follow-ups. The [owned-sandbox TTL request](NVIDIA-NeMo#3961 (comment)) is now implemented in this PR. ## Folder layout ```text nemo_gym/ ├── agent_utils/ │ ├── __init__.py # Component responsibilities and execution locations │ ├── sandbox_session.py # Server: upload supervisor; execute, stop, collect, close │ ├── supervisor_client.py # Server: protocol files, timeout budget, launch/stop/receipt │ └── process_supervisor.py # Sandbox: deadlines, kill/reap descendants, write receipt └── sandbox/ ├── api.py # Core connection, exec, file transfer and provider lifecycle ├── providers/ # Backend implementations └── utils.py # Text transfer, CPU caps and image rewriting responses_api_agents/hermes_agent/ ├── app.py # Config, request/session hooks and Gym response conversion ├── sandbox.py # Install Hermes, stage input, parse artifacts/runtime metadata └── sandbox_runner.py # Sandbox: Hermes SDK entry point and partial-result capture ``` The control files are `process_supervisor.py`, `launch.claim`, `supervisor.pid`, `stop.request`, `cleanup.json`, and `output.log`. `supervisor_client.py` documents each writer and timing. `session_dir` holds those files; `workdir` is the task repository. ## Compatibility - Downstream branches must use `nemo_gym.agent_utils.{sandbox_session,supervisor_client,process_supervisor}`. Both in-branch Hermes adapters and tests use the new package. Session adopters use `session_dir`, `stage_activation`, and `stop_harness`; they no longer upload or choose a supervisor path. - Default `resources_server` is null; unbound compatibility `/run` returns 422. Explicitly bound recipes remain supported; legacy agent swapping must restore that binding. The default model uses `${policy_model_name}`. - Owned TTL defaults only when the `ttl_s` key is absent. Explicit null retains provider defaults; long-lived or delayed sessions can set their own lifetime. Expiry still depends on provider support; this does not add TTL support to providers that ignore it. - No seed protocol or Hermes version change. Token accounting remains separate in NVIDIA-NeMo#3981. Invalid runtime metadata leaves valid responses intact and records an observation gap. - Transport errors remain execution errors after partial capture; capture failures are independent of cleanup confirmation. Model-writable output still does not qualify these trajectories for RL training. ## Validation **Latest reviewed head: `d5e6ad20b733faeeb3a35cabc4288c13609d4b11`.** [Full CI 37531286874](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37531286874) and [build 37531287625](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37531287625) **passed** on this head: core **6,594 passed / 2 skipped**, sandbox **913 passed / 5 skipped**, **95.25%** coverage, and all eight server shards. All applicable head checks are complete. The PR currently has no merge-queue entry; a maintainer needs to re-add it for fresh combined-tree CI. The prior failed queue run does not validate this fix. - Reproduced the [merge-queue failure](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37526772843/job/112486565515) at combined SHA `0f1001ef33be7f4ab99d0e236a2ce15053f0f64e`. With this patch applied to that exact tree, migration and configuration tests passed: **219 passed**, including the unchanged repository-wide audit. - Final PR checkout: migration, configuration and session-contract tests **220 passed**. Six new cases cover explicit null versus bound Hermes, OSWorld, inherited bindings and exactly one native Environment Server after composition. Two independent reviews found no remaining issues; the six focused cases also passed independently. - Full `pre-commit run --all-files`, `git diff --check` and the default Hermes migration `--check` passed. Model rollout: **N/A for this follow-up**, which changes offline configuration migration only. - Prior head `a309dfb9a5cb8c65b6bd7366260c189c3dcd3284`: both Hermes suites plus shared session/client tests **375 passed, 9 skipped**; mocked Docker TTL contract tests **2 passed**. No live provider expiry/model run was performed for the TTL change; earlier model evidence remains scoped to its recorded revisions. - That prior head passed [CICD 37525046614](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37525046614): core **6,588 passed, 2 skipped**, sandbox **913 passed, 5 skipped**, combined coverage **95.25%**, and all eight server shards. [Wheel/build 37525047397](https://github.com/NVIDIA-NeMo/Gym/actions/runs/37525047397) and lightweight checks also passed. These results do not validate this new migration commit or the failed merge-group tree. - All 20 implementation review requests remain addressed, including owned TTL; reviewer threads remain for reviewers to resolve. Shared Python provisioning remains future installer work. ```sh python -m pytest tests/unit_tests/test_add_legacy_agent_environment_servers.py \ tests/unit_tests/test_global_config.py tests/unit_tests/test_session_contract_repo.py \ --import-mode=importlib -q -o addopts='' -o log_cli=false --tb=short # Exact failed merge-group source plus the two-file patch: python -m pytest tests/unit_tests/test_add_legacy_agent_environment_servers.py \ tests/unit_tests/test_global_config.py \ --import-mode=importlib -q -o addopts='' -o log_cli=false --tb=short python scripts/add_legacy_agent_environment_servers.py --check \ responses_api_agents/hermes_agent/configs/hermes_agent.yaml pre-commit run --all-files git diff --check ``` --------- Signed-off-by: yaoyu-33 <[email protected]>
This branch was previously deployed
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.
What does this PR do?
Declares
legacy_agentenvironment servers for the six configs added after #3929 that have agents with no environment server:environments/wordle/config.yamlresources_servers/wordle/configs/wordle.yamlresources_servers/swemer_oml/configs/swemer_oml_example.yamlresources_servers/swemer_oml/configs/swemer_oml_opencode.yamlresources_servers/swe_internal_v1/configs/swe_internal_v1_example.yamlresources_servers/swe_internal_v1/configs/swe_internal_v1_opencode.yamlWithout these, every run of these configs generates the relays at startup and logs the deprecation warning, and a run with
error_on_agent_without_environment_server: truefails withAgentWithoutEnvironmentServerError. The blocks were written byscripts/add_legacy_agent_environment_servers.py, so they match what the runtime generates today.Nothing checked the repository's configs, which is how these slipped in. This PR adds a unit test that runs the script's
--checkover the repository and fails if any agent still lacks an environment server.Issue
No issue; follow-up to #3929.
Validation
test_repository_configs_declare_every_environment_server, fails onmain's configs and passes with this change.gym env resolve --config <file> +error_on_agent_without_environment_server=trueon each of the six configs: before this change, all six are rejected for having no environment server; after it, all six pass that check. Resolution then stops at the unsetmodel_servervalues, which need a localenv.yaml.pytest tests/unit_tests/test_add_legacy_agent_environment_servers.py tests/unit_tests/test_global_config.py: all pass.pre-commit runon the changed files: all pass.Rollouts
N/A. The added blocks are the relays the runtime already generates for these agents at startup, so a run's servers and routing don't change; only the deprecation warning goes away.
Compatibility
No behavior change for existing runs. Runs with
error_on_agent_without_environment_server: truenow accept these configs.