Repository navigation
Conversation
Hermes and Stirrup uploaded uv into the task sandbox and built a virtual environment there from the network, with the task workdir as cwd and without --no-config. A task's uv.toml or [tool.uv] could change the install, uv's cache and managed Python landed in the task's HOME, and --python 3.13 could bind the image's own interpreter. Add nemo_gym/agent_utils/sandbox_python.py. On the Agent Server it downloads a pinned python-build-standalone CPython for the sandbox's architecture and C library, checks its SHA-256, and installs the harness's requirements into a site-packages archive with uv --no-config --python-platform --only-binary :all:, constrained to the agent environment's versions. Only direct-URL requirements, such as Hermes at a commit, are built from source. Both archives are cached on the host. install_python_runtime.sh unpacks them under /tmp, checks the harness import with HOME inside the runtime directory, and publishes the runtime with an atomic rename, so concurrent seeds share one runtime and a runtime that fails its check is replaced. The sandbox needs sh and tar, but no network, uv or Python. Remove uv_bootstrap.py and Hermes's uv_cache_dir option, update the tests, and drop Hermes and Stirrup from the harness guide's exceptions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…-stirrup-runtime Signed-off-by: yaoyu-33 <[email protected]> # Conflicts: # responses_api_agents/hermes_agent/sandbox.py # responses_api_agents/hermes_agent/tests/test_app.py
yaoyu-33
force-pushed
the
fix/host-built-hermes-stirrup-runtime
branch
from
October 27, 2026 17:27
a10538b to
d4c74ed
Compare
…o/Gym into fix/host-built-hermes-stirrup-runtime Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33
added a commit
to yaoyu-33/Gym
that referenced
this pull request
Oct 27, 2026
…DIA-NeMo#5137 Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 6b720aa |
Contributor
yaoyu-33
changed the base branch from
yaoyu-33/bash-sandbox-runtime
to
refactor/bash-sandbox-runtime
October 27, 2026 20:52
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 and why
ananthsub pointed out on #5094 (Hermes, Stirrup, docs) that Hermes and Stirrup still upload
uvinto the task sandbox and build a virtual environment there from the network. Hermes ran it with the task workdir ascwd, without--no-config,UV_CACHE_DIRorUV_PYTHON_INSTALL_DIR. That meant three problems:uv.tomlor[tool.uv]could change the install;--python 3.13could bind the image's ownpython3.13.Stirrup had the same problem but set the two env vars; it still lacked
--no-config. #5094 lists both as known exceptions. This PR removes them.nemo_gym/agent_utils/sandbox_python.py(new):SandboxPythonRuntime. On the Agent Server host it:probe_sandbox_platform());20260805,install_only_stripped) for that platform and checks its published SHA-256 on every use. The digests come from the release'sSHA256SUMS, whoseinstall_onlygnu entries match NOOA's existing pins. musl and aarch64 are included;site-packagesarchive withuv pip install --no-config --target … --python-platform <arch>-manylinux_2_<N>|<arch>-unknown-linux-musl --python-version 3.13.14 --only-binary :all:.--no-binary hermes-agentfor Hermes pinned to a commit). Every other package must publish a wheel for the sandbox's platform.lxml[html_clean]with plainlxmland dropslxml_html_clean. Adapter-specific overrides are an explicit field: Stirrup passes itsoverrides.txt(Pillow).~/.cache/nemo_gym/sandbox_python. Concurrent cold seeds in a process share one build, writes are atomic across processes, and a failed build is retried by the next seed.nemo_gym/agent_utils/install_python_runtime.sh(new, runs in the sandbox withsh,tar/gzip,mv,rm):.setup-<uuid>directory under the runtime directory;python -I,cwd=/, andHOMEinside the runtime directory (importing Hermes writes~/.hermes);rename(2). It loops until a runtime that passes the check is in place, so concurrent seeds share whichever one wins, and a runtime that fails its check (for example one from another platform) is set aside and replaced.The runtime lives at
/tmp/nemo-gym-<harness>-runtime-<key>/python. The key hashes the Python pin, the requirements, the overrides and the agent environment's versions, so a runtime left in the sandbox is reused only when it was built from the same inputs. Seed-time execs run from/, and nothing is written into the task's workdir or HOME.Adapters.
RUNTIME.is_installed()/RUNTIME.install()at seed. The activation argv and the runner files are unchanged apart from the interpreter path.uv_bootstrap.pyand its tests are removed; nothing else used it.uv_cache_diroption is removed.Docs. The harness guide no longer lists Hermes and Stirrup as exceptions; Codex stays. Its shared-module table and installation-contract example now describe
sandbox_python.py, and the paragraph that recommended NOOA now points atSandboxPythonRuntime(NOOA's runtime still installs packages from the network in the sandbox). The Hermes and Stirrup READMEs describe the new requirements.No issue was filed; this is the follow-up named in #5094's "Known exceptions".
Compatibility
uvor Python needed for seeding;shandtarwith gzip are. glibc ≥ 2.17 or musl; x86_64 or aarch64. Hermes still needsbashand the Model Server's address, as before.uv(it already needed it for the old path) and access to GitHub releases and the package index (or a mirror viaUV_*env vars, which--no-configstill honors).uv_cache_diris removed.BaseServerConfigignores unknown keys, so configs that set it still load./tmp/nemo-gym-hermes-runtime-<commit>/venv→/tmp/nemo-gym-hermes-runtime-<key>/python. An image that baked the old venv path no longer short-circuits the install.Validation
pre-commit run --files <changed files>: all hooks pass, no changes.tests/unit_tests/test_sandbox_python.py(new, 26 tests), passing on macOS and Linux:uvargv (--no-config, platform,--only-binary,--no-binaryonly for URL requirements, constraints, adapter overrides, scratchcwd);test_seeding_ignores_the_task_uv_configuration_and_leaves_the_task_untouched. The task's workdir has auv.tomland apyproject.toml[tool.uv]pointing at a dead index, and its PATH has auvthat records calls and exits 2. Seeding succeeds, the fakeuvis never called, and the workdir and HOME are byte-for-byte unchanged while the harness writes under the runtime's own HOME. I checked that the test fails when the HOME redirect in the installer is removed.responses_api_agents/stirrup_agent/testson Linux: 171 passed.responses_api_agents/hermes_agent/testson Linux: 346 passed, 2 failed. The 2 failures (test_close_preserves_interrupted_observations_before_release[False|True], "launch outcome is unknown; termination deadline exceeded") also fail on refactor(agent_utils): run sandboxed harnesses with only bash in the task image #5094's head with the base Hermes files on the same host, regardless ofTMPDIR. I checked at7908559f8, and they still fail withfb642f9d2on this branch. They exercise only the supervisor's close path, which this PR doesn't touch, so they need looking at on refactor(agent_utils): run sandboxed harnesses with only bash in the task image #5094./procfor the bash supervisor fail there; that is unrelated and they pass on Linux.install_python_runtime.shby hand with--network none, three rounds each:debian:bookworm-slim(no Python),python:3.13-slim(image has Python 3.13.17) andalpine:3.20(musl, BusyBox, no bash);uv.tomland HOME were untouched, the setup directory was removed, and a failing check published nothing. On Alpine,pydantic_coreandyamlimport from musllinux wheels.Rollout evidence
Real-model smoke rollouts with
nvidia/nemotron-3-ultra-550b-a55b(NIM) on an x86_64 Linux workstation, using the Docker sandbox provider:docker network create --internalnetwork: it reached only the Gym Model Server proxy on the gateway, with no route to the internet by IP or by name.workdir: /workspace./workspace/answer.txtin the sandbox./tmpwas a per-run bind mount from/dev/shm.docker cpdoes not write into tmpfs mounts.python3/uv/ internet/workspace,~/workspace/answer.txtdebian:bookworm-slim.bashrc .profilecode_exec,code_exec,finish1591debian:bookworm-slim.bashrc .profileterminal,terminal1591python:3.13-slim/usr/local/bin/python3; runtime still reports 3.13.14 under/tmp/nemo-gym-hermes-runtime-…/pythonterminal,terminal1591After merging
main(Hermes venv now hasmcp1.30.0 and the runtime addsmcp>=1.28.1,<2), I reran the same checks ondebian:bookworm-slim. Both passed, with the same sandbox findings and/workspace/answer.txt=1591, and their containers were removed. Hermes seeded in 17.4 s with a fresh host build (terminal×2); Stirrup seeded in 32.0 s (code_exec×2,finish). On Linux after the merge: Stirrup 171 passed;test_sandbox_python.py26 passed; Hermes 346 passed plus the same 2 pre-existing failures.An earlier Hermes run (with the overrides version) seeded in 18.5 s from a cold host cache with a 15 MB site-packages archive. The constraints version is 20 MB because it keeps the extras the overrides dropped.
Not in this PR (follow-ups)
run_agentbefore it setsHERMES_HOME, so~/.hermesstill appears in the task's HOME after an episode (seen in the smoke). Seeding no longer writes it. This is existing runner behavior.🤖 Generated with Claude Code