Configure Sandboxed Gym for Evaluator
Sandboxed Gym runs NeMo Gym and environment code outside the trusted Evaluator task container. The Evaluator task keeps platform and OpenSandbox credentials, starts a per-run Gym host, sends rollout requests over HTTP, and destroys the host when the run ends.
This page is for platform operators. Job submitters cannot select the host provider, runtime image, PVC, or egress policy.
Prerequisites
- Complete the shared OpenSandbox platform setup. It configures the server connection, credentials, and top-level platform sandbox capability.
- A Kubernetes or Volcano Jobs execution profile with a shared job-storage PVC. The claim should
support
ReadWriteManywhen Jobs and OpenSandbox pods can run on different nodes. - Published
nhx-tasksandnhx-gym-hostimages for the platform release. Upgrade them together: a Gym host image from an earlier release ignores the job’senv_varsandenv_secrets, so its Gym servers start without them. - An allowlisted model endpoint reachable from the Gym host.
Execution topology
For a built-in environment, sandboxed execution runs one platform step:
For a custom environment FileSet, Evaluator runs two platform steps:
The Gym host mounts the environment read-only and a separate workspace path read-write.
Configure Evaluator
After completing the shared OpenSandbox setup, add the Evaluator-specific values. Replace the image, PVC, and model URL for your deployment:
The Evaluator-specific sandbox_cluster_capable flag is separate from the top-level
sandboxClusterCapable value configured in the shared setup. Both must be true: the top-level
value injects the OpenSandbox connection into Jobs pods, and the Evaluator flag makes its compiler
fail closed until the remaining Evaluator settings are configured.
sandbox_job_storage_pvc_claim must match the PVC configured on the Jobs execution profile.
Evaluator rejects a FileSet-backed job when staging writes to one claim and OpenSandbox would mount
another.
Configuration reference
Evaluator requires at least one entry across sandbox_policy_base_urls and
sandbox_egress_allow. The OpenSandbox provider applies a deny-by-default policy and adds the
trusted episode broker automatically.
Configure model egress
Use sandbox_policy_base_urls for model and inference endpoints:
Use sandbox_egress_allow for non-model dependencies:
A package index is not needed for built-in environments, whose virtual environments ship in the
nhx-gym-host image, nor for wheels-v1 custom environments: their servers run on the image’s Gym
install, and the package’s wheels/ directory supplies everything their requirements.txt files
add. Only native-v1 custom environments install from an index at job start; for those, allow
pypi.org:443 and files.pythonhosted.org:443, or whichever index mirror the cluster uses.
When sandbox_egress_allow is empty and the job runs a wheels-v1 environment on the OpenSandbox
provider, Evaluator starts the host in offline mode: uv never consults an index and the Hugging Face libraries read only
from the cache the package vendored. A dependency or dataset the package forgot then fails with a
named error at startup instead of a blocked connection later. Any entry in sandbox_egress_allow,
or for a docker: true job in the Docker profile’s egress_allow, leaves the host online. The run records the decision as environment_offline in its runner
provenance.
Submitters cannot extend these lists from GymRunnerTarget. This prevents an environment from
widening its own network access.
Configure credentials
OpenSandbox credentials remain in the trusted Evaluator task. The Gym host receives only per-run tokens and the environment variables required by its selected Gym components.
Each Gym host and episode sandbox also gets its own execd access token. execd, the command server in
every OpenSandbox sandbox, then refuses any request without it (execd v1.0.15 or later; an older execd
ignores the token), including requests through the
OpenSandbox server proxy from a pod that holds the server’s API key. Outside the sandbox, the
Evaluator task that created it holds the token, and like the job’s env_secrets values it appears in
the sandbox’s pod spec, so anyone allowed to read pods in the sandbox namespace can read it. The Gym
host also removes the token from its own
environment before it starts anything, so nothing it starts inherits it. On the image that runs
Docker (see below), the Gym servers can’t read it at all. On the default image they run as the same
user as execd, so they could read it from the process table, but it gives them nothing they can’t
already do.
For a job-specific model credential, create a NeMo Helix secret and reference it through
GymRunnerTarget.env_secrets:
A job’s env_vars and resolved env_secrets travel to the Gym host together and may total about
90 KiB; Evaluator refuses a job over that limit.
Do not use env_vars for API keys, tokens, passwords, or other secrets. Evaluator rejects
credential-shaped env_vars for sandboxed jobs because environment code can read them.
Timeouts
The job’s own startup_timeout_s and collection_timeout_s apply to sandboxed runs too:
startup_timeout_s(default 240s) bounds how long the Gym host may take to report ready once its sandbox is running. Pulling thenhx-gym-hostimage is not counted against it.collection_timeout_sbounds the whole collection, from the first rollout request to the last, however many requests the rollouts are split across. When it is exceeded, the job fails with acollection_timeout_serror and the Gym host is destroyed.collection_timeout_s: null(the default) sets no collection deadline. The Gym host still stops when its sandbox lifetime ends, four hours after creation.
Three more timeouts bound the sandbox creation itself. They must agree, because the OpenSandbox server holds the create request open until the sandbox pod is Running:
The SDK request timeout must be longer than the server create wait. When it is shorter, a node that
still has to pull the nhx-gym-host image fails the job with
OpenSandbox did not answer the create request within the SDK request timeout, caused by the SDK’s
Request timed out, while the server is still creating the sandbox. Set it only when the server
create wait is longer than the default:
Install an agent CLI into the Gym host
Gym’s CLI agents, such as Codex, Claude Code, and OpenCode, install their CLI at startup unless it
is already on PATH. To skip that download or pin a version without rebuilding nhx-gym-host,
install the CLI from an agent bundle image:
The OpenSandbox server’s nemo-agent-bundle extension runs installer /installed-agent from
image in an init container and mounts the result read-only into the host. The host puts the
directory containing entrypoint first on PATH and runs entrypoint --version before starting.
If that fails, the host never becomes ready and the job fails at its startup timeout.
The bundle is a deployment setting: every Gym job on the deployment gets the same CLI. It requires
the OpenSandbox provider with the NeMo extension installed, and a bundle built for the
nhx-gym-host image’s architecture and C library. Evaluator rejects agent_bundle with the
docker provider.
Run Docker in Gym servers
Some environments start containers from a resource server, for example with docker compose up, and
some agents run docker themselves. The nhx-gym-host-podman image supports both with rootless Podman
behind the Docker CLI. Each compose project gets its own network with service-name DNS, and the Gym
host’s egress policy still applies to every container.
A job asks for Docker with docker: true on its Gym target. Only those jobs get the Docker-enabled
image, its privileged setup, its container storage and the extra egress, all from the deployment’s
sandbox_docker_profile. Every other Gym job keeps the plain nhx-gym-host image. A job that sets
docker: true is refused at submit when the deployment has no sandbox_docker_profile, runs Gym in
the job container, or uses the local docker host provider.
The image’s setup needs SYS_ADMIN, which only a Kata VM contains. Point the platform at an
OpenSandbox server that creates every sandbox with a Kata runtime class: the bootstrap.execd.isolation
extension grants SYS_ADMIN when the sandbox is created, before anything in it runs. The Gym host also
checks for a Kata VM and fails the job instead of running the setup anywhere else. The server’s
execd image must be v1.0.15 or later: execd keeps root, and only from that release does it require
the per-sandbox token described under credentials.
Agent servers and resource servers run in the same Gym host, so they share one Podman service: a
resource server can inspect the containers an agent started. The docker CLI finds the service through
the image’s DOCKER_HOST and also at its default socket, so it works from an agent’s shell tool that
starts commands with only the agent’s own variables, such as a registered Deep Agents agent with a local
shell backend. Rollouts that run concurrently share the service too, so give each rollout’s compose
project its own name, for example with docker compose -p or COMPOSE_PROJECT_NAME.
After setup, the Gym servers run as an unprivileged user with no capabilities, an empty capability
bounding set and no_new_privs, so no setuid program in the image can give capabilities back. The
job’s env_vars and env_secrets reach Gym only after that, never the root setup. NET_ADMIN is
never granted, so nothing in the host can change its network or egress rules. Gym servers use the
docker CLI, which only talks to the Podman service’s socket.
The image isn’t published yet. Build it from the repository with the nhx-gym-host-podman-docker
bake target and push it to a registry your cluster can pull from:
GPU access is not supported yet.
Container storage
Images, containers and volumes live in one ext4 filesystem inside a sparse file in the Gym host’s ephemeral storage. Its size is a ceiling for everything the job’s rollouts pull and write together, not an allocation: the file takes node disk only as data is written. The exception is the filesystem’s journal, written when the file is formatted, whose size steps up with the configured size and stops at 1 GiB:
The first three rows were measured in a Kata sandbox; the last follows from the journal size. The file holds slightly less than its size, since ext4 keeps some for itself. It lasts as long as the Gym host, so every job starts empty.
- Discard. Without it, space freed inside the file stays allocated on the node until the Gym host ends. With it, every delete also frees the space on the node, which costs some extra I/O.
- Reserving disk. The size reserves nothing. Without an
ephemeral-storagerequest, the scheduler doesn’t account for the host’s disk use, and hosts that fill their storage can put a node under disk pressure, where Kubernetes evicts pods. A request makes the scheduler place each host only where that much disk is free, so it also limits how many hosts fit on a node. Setting it in the profile’sresourcesreserves disk fordocker: truejobs only. Requests are sent in whole GiB, rounded up, and must not exceed anephemeral-storagelimit set increate.resourceof the merged host provider options. - Upgrades. Upgrade the Evaluator and the Gym host image together before setting these: an older
Docker-enabled image ignores
discard.
To pull private images, create a NeMo Helix secret holding the registry token and pass it to the job
through env_secrets, like any other job credential. Add the registry, and the host it redirects
image layers to, to the profile’s egress_allow. For nvcr.io, that’s nvcr.io:443 and
layers.nvcr.io:443.
The resource server logs in before it pulls:
The login is stored for the Gym host’s container user, so every Gym server in the host can pull with it.
Local Docker provider
Set sandbox_host_provider: docker only when debugging the runtime contract on a local deployment.
It runs the same nhx-gym-host image but does not enforce the OpenSandbox egress policy and is not
an isolation boundary.
The memory episode backend is also local-only. It requires both:
Ordinary evaluations do not create nested episode sandboxes. Environments that request them must
use the OpenSandbox episode backend and list every permitted image in sandbox_approved_images.
Verify the deployment
Before accepting custom environment jobs, verify:
- OpenSandbox is ready and reachable over the configured in-cluster protocol.
- The selected Jobs profile uses Kubernetes or Volcano and mounts the configured PVC.
nhx-tasksandnhx-gym-hostcan be pulled by pods in the platform namespace.- The Gym host can reach each configured model URL but cannot reach an unlisted destination.
- A completed and a failed run both destroy their Gym hosts.
The repository’s sandboxed Gym end-to-end tests check part of items 4 and 5 against a running deployment. They submit a small custom environment whose verifier probes the network and storage from inside the Gym host:
- Item 4, for one model URL: the one the tests call, which is the platform API unless they are given
a real model. They also check that the Kubernetes API, a public address, and a public name are
unreachable. They do not read
sandbox_policy_base_urls, so to check another configured model URL, run them again withNHX_E2E_GYM_POLICY_ROUTEset to it,NHX_E2E_GYM_POLICY_MODELset to a model it serves, and the endpoint’s key as the section linked below describes. - Item 5, for a run that completes and a run that fails after its Gym host is ready. They watch the cluster for the host’s removal.
They need a source checkout and kubectl access to the cluster. See
Sandboxed Gym evaluation
for the settings and the command.