# Sandboxes (https://www.agentenvframework.com/docs/sandboxes)

> Sandbox = The isolated machine or container that your environment or agent resides in

## Supported Providers

| Provider                    | A sandbox is                                                                            | Egress allowlist | Needs                                           |
| --------------------------- | --------------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------- |
| `local` (default)           | containers on your own Docker                                                           | no               | Docker                                          |
| [`modal`](#modal)           | a [Modal](https://modal.com) container for each env service and agent                   | yes              | a Modal token                                   |
| [`modal_vm`](#modal)        | a Modal VM with Docker inside, one per env                                              | yes              | a Modal token                                   |
| [`e2b`](#e2b)               | an [E2B](https://e2b.dev) sandbox with Docker inside                                    | yes              | an E2B API key and template                     |
| [`sail_vm`](#sail)          | a [Sail](https://docs.sailresearch.com/sailboxes) Sailbox, a root VM with Docker inside | yes              | the `sail` extra and a Sail API key             |
| [`tensorlake`](#tensorlake) | a [Tensorlake](https://tensorlake.ai) MicroVM with Docker inside                        | yes              | the `tensorlake` extra and a Tensorlake API key |

A `deploy_sandbox` or `deploy_agent` step with a `network_policy` gets a sandbox that only reaches
the hosts the policy allows. A provider that can't enforce the policy refuses the step instead of
creating an open sandbox. To run on a platform that isn't listed, write a [sandbox provider
plugin](https://www.agentenvframework.com/docs/plugins/sandbox-provider-plugins.md).

## Picking a Provider

```toml title=".agentenv/config.toml"
[sandbox]
default       = "local"   # envs and deploy_sandbox steps
agent_default = "local"   # agents
```

A comma-separated value, such as `"sail_vm,e2b"`, is a fallback chain: when one provider can't
create a sandbox, the next one is tried. For a single run, `--sandbox` on `agent-env run`, or
`--env-sandbox` and `--agent-sandbox` on `agent-env task run`, override the config. A provider's
own settings go in `[sandbox.providers.<name>.config]`, with keys given as `secret:` or `env:`
references, never as the key itself.

### Modal

`modal` and `modal_vm` read `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET`, or else the active profile
in `~/.modal.toml` that `modal token new` writes, so they need no config table.

### E2B

`e2b` needs an E2B template with Docker and Compose v2. Build one with the Docker Compose example
in E2B's [Docker guide](https://docs.e2b.dev/template/examples/docker#docker-compose), then set
`base_template` to its name. agent-env builds each sandbox size it needs from that template.

```toml title=".agentenv/config.toml"
[sandbox.providers.e2b.config]
api_key       = "env:E2B_API_KEY"
base_template = "docker-compose"   # the template the guide builds
```

### Sail

```bash
pip install 'agentenv-framework[sail]'
```

```toml title=".agentenv/config.toml"
[sandbox.providers.sail_vm.config]
api_key = "env:SAIL_API_KEY"
```

`agent-env run hello --sandbox sail_vm` checks the setup with no model. Sail injects an agent's
model key at its egress, so the key never enters the Sailbox. The [`sail_vm`
README](https://github.com/scaleapi/agentenv-framework/blob/main/src/agent_env/providers/sandbox_providers/sail_vm/README.md)
covers sizes, auto-sleep, egress and cost.

### Tensorlake

```bash
pip install 'agentenv-framework[tensorlake]'
```

```toml title=".agentenv/config.toml"
[sandbox.providers.tensorlake.config]
api_key = "env:TENSORLAKE_API_KEY"
```

`agent-env run hello --sandbox tensorlake` checks the setup with no model. Sandboxes boot from
`agentenv-dind-host-v1`, a public image with Docker and Compose v2; set `image` to boot your own.
The [`tensorlake`
README](https://github.com/scaleapi/agentenv-framework/blob/main/src/agent_env/providers/sandbox_providers/tensorlake/README.md)
covers sizes, egress and cost.