Skip to navigation

nemo_gym.sandbox.harness_config

View as MarkdownOpen in Claude

The typed sandbox_config of a harness sandbox: the sandbox an agent’s harness runs in.

Module Contents

Classes

NameDescription
HarnessSandboxConfigSandboxConfig for a harness sandbox, whichever server owns it.

API

class nemo_gym.sandbox.harness_config.HarnessSandboxConfig()

Bases: SandboxConfig

SandboxConfig for a harness sandbox, whichever server owns it.

The owner is the server that starts it and stops it: an Environment Server that starts one for an attempt and lends it, or an agent that starts its own because nothing was lent. A lent sandbox is borrowed instead, with borrow() from nemo_gym.server_runtime.

A server takes the image, working directory and files of a task sandbox from its task. A harness sandbox has no task to take them from, so they are configured here, with the keys agent recipes set today.

Its network rule replaces an agent’s own network_access: an agent that adopts this config refuses the two set together, so a sandbox never has two egress settings.

A recipe’s other SandboxSpec keys, such as sidecars, are refused here; an agent that moves onto this config with recipes that set them warns about them for one release first.

derive_cpu_env
bool = False

Cap tool parallelism to resources.cpu in the sandbox’s environment. Off by default, as in most agents today. The OpenCode and Pi sandboxed agents turn the caps on in their code rather than in a recipe, so a subclass of this config for either defaults it to True.

entrypoint
list[str] | None = None

The command the sandbox’s container runs, when the image’s own does not keep it alive.

files
dict[str, str] = Field(default_factory=dict)

Files to place in the sandbox at start, by absolute path.

image
str | None = None

The sandbox image.

ports
list[int] = Field(default_factory=list)

The ports the sandbox exposes.

user
str | int | None = None

The user commands run as, when not the image’s default.

workdir
str | None = None

The working directory the harness runs in.

nemo_gym.sandbox.harness_config.HarnessSandboxConfig.spec(
sandbox_provider: str | collections.abc.Mapping[str, typing.Any],
image: str | None = None,
workdir: str | None = None,
metadata: collections.abc.Mapping[str, str] | None = None,
files: collections.abc.Mapping[str, str | bytes] | None = None,
named_configs: collections.abc.Mapping[str, typing.Any] | None = None,
network_options: nemo_gym.sandbox.config.NetworkRuleOptions | None = None

The spec of the harness sandbox, with this config’s image, workdir, files, entrypoint, user and ports.

image and workdir override the config’s, and files add to its files. The CPU caps go under the config’s env, so a recipe’s own value wins.