> ## Documentation Index
> Fetch the complete documentation index at: https://trytilde.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandboxes

> Give an agent a VM to work in, launched through E2B or Modal, where it can clone repositories, run tests, and push changes without holding long-lived secrets.

A sandbox is a VM that Tilde launches for an agent to work in. Use one when the agent needs a real machine: to clone a repository, install dependencies, run tests, or push a branch.

The agent itself still runs outside the sandbox, as a normal [deployment](https://trytilde.ai/docs/agent-registry.md). It works in the VM through sandbox tools, such as `sandbox.exec`. Tilde launches the VM through your [E2B](https://e2b.dev) or [Modal](https://modal.com) account, wakes it when the agent needs it, and puts it to sleep when it goes idle.

## How sandboxes work

![The agent calls sandbox tools on the Tilde gateway. The sandbox VM dials out to the gateway. The gateway adds credentials for tools and GitHub.](https://mintcdn.com/tilde/zToKfgUFnZ6uOc1T/images/sandbox-architecture.drawio.svg?fit=max\&auto=format\&n=zToKfgUFnZ6uOc1T\&q=85\&s=4fa6493aa7f80dd48d50004c9c94f6ce)

&#x20;*Click to zoom*

Everything goes through the gateway:

* The agent calls sandbox tools, and the gateway runs them in the VM.
* The VM dials out to the gateway, so it exposes no ports.
* Processes in the VM reach private systems through the gateway too. The gateway adds the credential, so the VM never holds a long-lived secret.

Processes reach private systems in two ways:

| Way | What it is | Editions |
| - | - | - |
| [GitHub egress](https://trytilde.ai/docs/sandboxes/github-egress.md) | Git and the GitHub API work through the gateway, which adds the credential and checks every push. | Cloud, Enterprise |
| [Blueprint tools](https://trytilde.ai/docs/sandboxes/credential-vending.md) | Processes call tools you choose, for example one that returns a short-lived token. | All |

## Sandbox blueprints

A sandbox blueprint is the configuration for a set of sandboxes. It sets:

* The E2B or Modal **connection**, and the **template** or container image the VM starts from.
* The **reuse mode**: which invocations share a sandbox. See [Reuse modes](https://trytilde.ai/docs/sandboxes/reuse-modes.md).
* **Timings** for sleep and termination.
* Encrypted **environment variables** exported in every shell.
* The **tools** processes in the VM may call, and, in Cloud and Enterprise, **egress** grants.

You give an agent one blueprint. See [Set up sandboxes](https://trytilde.ai/docs/sandboxes/setup.md).

## Sandbox tools

An agent with a sandbox gets a fixed tool source, **Sandbox · `<blueprint name>`**, on its **Tools** tab:

| Tool | What it does |
| - | - |
| `sandbox.exec` | Runs a shell command, in the foreground or the background. |
| `sandbox.exec_output` | Reads the output and status of a background command. |
| `sandbox.read_file`, `sandbox.write_file`, `sandbox.edit_file` | Read, create, and edit text files. |
| `sandbox.apply_patch` | Adds, deletes, moves, and updates files with one patch. |
| `sandbox.list_dir`, `sandbox.glob`, `sandbox.grep` | List directories, find files, and search their contents. |

To limit which ones the agent calls, use its `tools.invoke` [capability](https://trytilde.ai/docs/iam.md#capability-reference).

Foreground commands time out after 120 seconds by default, and 10 minutes at most. For longer work, run the command in the background and poll it with `sandbox.exec_output`.

## Lifecycle

1. On each invocation, Tilde finds the agent's sandbox according to the [reuse mode](https://trytilde.ai/docs/sandboxes/reuse-modes.md). It launches one if there is none, or wakes it if it is asleep. The agent runs once the VM has connected.
2. After 10 minutes idle by default, the sandbox goes to sleep. The next tool call wakes it.
3. After 7 days unused by default, Tilde terminates it, and its files are gone.

What survives sleep depends on the provider:

| Provider | Sleep | What survives |
| - | - | - |
| **E2B** | Pauses the VM. | The filesystem, memory, and running processes. |
| **Modal** | Snapshots the filesystem, then terminates the VM. | The filesystem only. Modal also ends every VM after 24 hours. |

## Audit

Sandbox tool calls appear in the agent's [Sessions](https://trytilde.ai/docs/sessions.md) and [Tracing](https://trytilde.ai/docs/traces.md) tabs like any other tool call. Calls that processes in the VM make, to blueprint tools or through egress, appear in the same trace, under the invocation they belong to.

## Good to know

* **The gateway must be reachable from the provider's cloud.** If you self-host, see [Network exposure](https://trytilde.ai/docs/security/overview.md#network-exposure).
* **Direct and Lambda agents only.** [Sidecar agents](https://trytilde.ai/docs/deployment/sidecar-agents.md) cannot use sandbox tools.
* **Linux templates only.**
* Sandboxes are in all three editions. Egress is in Tilde Cloud and Tilde Enterprise. See [Editions](https://trytilde.ai/docs/editions.md).

## Next steps

> [card] [Set up sandboxes](https://trytilde.ai/docs/sandboxes/setup.md)
>
> Pick an image, create a blueprint, and give an agent a sandbox.

> [card] [GitHub egress](https://trytilde.ai/docs/sandboxes/github-egress.md)
>
> Clone and push from a sandbox with no GitHub token in the VM.

> [card] [Reuse modes](https://trytilde.ai/docs/sandboxes/reuse-modes.md)
>
> Choose which invocations share a sandbox.

> [card] [In-sandbox CLI](https://trytilde.ai/docs/sandboxes/cli.md)
>
> Call blueprint tools from processes in the VM.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.