Skip to navigation

nemo_gym.agents.utils.sandbox_network

View as Markdown

Egress policy for a sandbox that an agent creates for its own session.

Module Contents

Functions

NameDescription
restrict_sandbox_networkReturn spec with egress limited to the model server and, for model_and_tools, the tool servers.

Data

SandboxNetworkAccess

API

nemo_gym.agents.utils.sandbox_network.restrict_sandbox_network(
model_base_url: str,
tool_urls: collections.abc.Sequence[str] = (),
required_tool_urls: collections.abc.Sequence[str] = ()

Return spec with egress limited to the model server and, for model_and_tools, the tool servers.

inherit leaves the provider’s default network. Each allowed host is opened on every port and path, so co-hosted services stay reachable. The policy is fixed when the sandbox is created: it applies only to a sandbox the agent creates, never to a task sandbox borrowed from Resources.

tool_urls are the MCP grants the harness keeps; required_tool_urls are those of them the episode requires. model_only blocks every tool host, so a required grant would fail only after the sandbox and the runtime exist; it is refused here instead.

A configuration that cannot be enforced (an explicit provider policy as well, a provider without network policies, an endpoint the sandbox cannot reach, or a required tool grant under model_only) raises AgentSeedRejectedError, so the seed fails once with HTTP 422 instead of being retried; it is still a ValueError.

nemo_gym.agents.utils.sandbox_network.SandboxNetworkAccess = Literal['inherit', 'model_only', 'model_and_tools']