> This page is for version 0.7.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.agents.utils.sandbox_network

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

## Module Contents

### Functions

| Name                                                                                          | Description                                                                                         |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [`restrict_sandbox_network`](#nemo_gym-agents-utils-sandbox_network-restrict_sandbox_network) | Return `spec` with egress limited to the model server and, for `model_and_tools`, the tool servers. |

### Data

[`SandboxNetworkAccess`](#nemo_gym-agents-utils-sandbox_network-SandboxNetworkAccess)

### API

```python
nemo_gym.agents.utils.sandbox_network.restrict_sandbox_network(
    spec: nemo_gym.sandbox.providers.base.SandboxSpec,
    network_access: nemo_gym.agents.utils.sandbox_network.SandboxNetworkAccess,
    provider: nemo_gym.sandbox.providers.base.SandboxProvider,
    model_base_url: str,
    tool_urls: collections.abc.Sequence[str] = (),
    required_tool_urls: collections.abc.Sequence[str] = ()
) -> nemo_gym.sandbox.providers.base.SandboxSpec
```

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`.

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