|
| 1 | +--- |
| 2 | +summary: "Use Daytona cloud sandboxes as a sandbox backend for OpenClaw agents" |
| 3 | +title: Daytona |
| 4 | +read_when: |
| 5 | + - You want cloud sandboxes instead of local Docker |
| 6 | + - You are setting up the Daytona plugin |
| 7 | + - You need agent tool execution isolated from the Gateway host |
| 8 | +--- |
| 9 | + |
| 10 | +Daytona is a cloud sandbox backend: instead of running Docker containers |
| 11 | +locally, OpenClaw creates [Daytona](https://www.daytona.io) sandboxes through |
| 12 | +the Daytona API and executes commands and file operations over the Daytona |
| 13 | +toolbox API (HTTPS). No SSH keys or inbound connectivity are required. |
| 14 | + |
| 15 | +The plugin reuses the same remote filesystem bridge as the generic |
| 16 | +[SSH backend](/gateway/sandboxing#ssh-backend) with a remote-canonical |
| 17 | +workspace model: the sandbox workspace is seeded once at creation and stays |
| 18 | +canonical until you recreate it. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Daytona plugin installed (`openclaw plugins install @openclaw/daytona-sandbox`) |
| 23 | +- A Daytona API key (`https://app.daytona.io/dashboard/keys`) |
| 24 | +- OpenClaw Gateway running on the host |
| 25 | + |
| 26 | +## Quick start |
| 27 | + |
| 28 | +```bash |
| 29 | +openclaw plugins install @openclaw/daytona-sandbox |
| 30 | +``` |
| 31 | + |
| 32 | +```json5 |
| 33 | +{ |
| 34 | + agents: { |
| 35 | + defaults: { |
| 36 | + sandbox: { |
| 37 | + mode: "all", |
| 38 | + backend: "daytona", |
| 39 | + scope: "session", |
| 40 | + workspaceAccess: "rw", |
| 41 | + }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + plugins: { |
| 45 | + entries: { |
| 46 | + daytona: { |
| 47 | + enabled: true, |
| 48 | + config: { |
| 49 | + apiKey: { source: "env", provider: "default", id: "DAYTONA_API_KEY" }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + }, |
| 53 | + }, |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +Export `DAYTONA_API_KEY` in the Gateway environment (or store the key with a |
| 58 | +SecretRef as above, or as a plaintext string). Restart the Gateway. On the |
| 59 | +next agent turn OpenClaw creates a Daytona sandbox and routes tool execution |
| 60 | +through it. Verify with: |
| 61 | + |
| 62 | +```bash |
| 63 | +openclaw sandbox list |
| 64 | +openclaw sandbox explain |
| 65 | +``` |
| 66 | + |
| 67 | +New sandboxes block all network egress by default, matching the Docker |
| 68 | +backend's no-network stance. If your agents need to install packages or reach |
| 69 | +the network from inside the sandbox, opt in explicitly with |
| 70 | +`networkBlockAll: false`, or grant selective egress with `networkAllowList` |
| 71 | +or `domainAllowList`. |
| 72 | + |
| 73 | +## How execution works |
| 74 | + |
| 75 | +- **Sandbox per scope**: one Daytona sandbox per sandbox scope (`agent`, |
| 76 | + `session`, or `shared`). Sandboxes are labeled `openclaw.sandbox=1` and |
| 77 | + adopted across Gateway restarts through the OpenClaw sandbox registry. |
| 78 | +- **Exec**: each `exec` call runs inside the sandbox through a Daytona session |
| 79 | + (or a Daytona PTY when the tool requests a TTY). Exit codes, stdout, stderr, |
| 80 | + stdin, and terminal resizes all flow through the toolbox API. |
| 81 | +- **Files**: `read`, `write`, `edit`, `apply_patch`, and media reads go through |
| 82 | + the sandbox filesystem bridge, so file tools operate on the remote workspace |
| 83 | + with the same path and writability rules as the SSH backend. |
| 84 | +- **Auto-stop**: Daytona stops idle sandboxes automatically (default 15 |
| 85 | + minutes). OpenClaw restarts a stopped sandbox on the next use, so idle |
| 86 | + sandboxes cost nothing while state stays warm. |
| 87 | + |
| 88 | +## Workspace model |
| 89 | + |
| 90 | +The session workspace is uploaded once when the sandbox is created |
| 91 | +(remote-canonical, like the SSH backend). Host-local edits made after the seed |
| 92 | +are not visible remotely until you recreate the sandbox: |
| 93 | + |
| 94 | +```bash |
| 95 | +openclaw sandbox recreate --session <sessionKey> |
| 96 | +``` |
| 97 | + |
| 98 | +This deletes the Daytona sandbox; the next agent turn provisions a fresh one |
| 99 | +and seeds it from the current local workspace. |
| 100 | + |
| 101 | +## Configuration reference |
| 102 | + |
| 103 | +All settings live under `plugins.entries.daytona.config`: |
| 104 | + |
| 105 | +| Key | Type | Default | Description | |
| 106 | +| ------------------------- | ----------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 107 | +| `apiKey` | string, SecretRef | unset | Daytona API key. Falls back to the `DAYTONA_API_KEY` environment variable. | |
| 108 | +| `apiUrl` | string | Daytona cloud | Daytona API base URL. Falls back to `DAYTONA_API_URL`. | |
| 109 | +| `target` | string | Daytona default | Target region for new sandboxes. Falls back to `DAYTONA_TARGET`. | |
| 110 | +| `snapshot` | string | Daytona default snapshot | Snapshot for new sandboxes. The image needs `sh`, `tar`, `base64`, `stat`, and `python3` on `PATH`. Mutually exclusive with `image`. | |
| 111 | +| `image` | string | unset | Docker image for new sandboxes, pulled or built by Daytona on first create. Mutually exclusive with `snapshot`. | |
| 112 | +| `resources` | object | unset | `{ cpu, gpu, memory, disk }` for image-based sandboxes (memory and disk in GiB). Omitted fields use the Daytona defaults (1 vCPU, 1 GB, 3 GiB). Snapshot sandboxes size from the snapshot. | |
| 113 | +| `user` | string | snapshot default | OS user for the sandbox. Align the remote workspace dirs with that user's writable paths. | |
| 114 | +| `volumes` | array | unset | Daytona volumes to mount, as `{ volumeId, mountPath }` entries. Reachable from `exec`; outside the file-tool workspace mounts. | |
| 115 | +| `autoStopInterval` | integer (minutes) | `15` (Daytona default) | Minutes of inactivity before Daytona stops the sandbox. `0` keeps it running continuously. | |
| 116 | +| `autoPauseInterval` | integer (minutes) | disabled | Minutes of inactivity before Daytona pauses the sandbox (VM-based runners; pause preserves memory state). At most one of auto-stop and auto-pause may be non-zero. | |
| 117 | +| `autoArchiveInterval` | integer (minutes) | `7` days (Daytona) | Minutes a stopped sandbox waits before archiving to cold storage. `0` uses the Daytona maximum. | |
| 118 | +| `autoDeleteInterval` | integer (minutes) | disabled | Minutes a sandbox may stay stopped before Daytona deletes it. `0` deletes immediately on stop. | |
| 119 | +| `networkBlockAll` | boolean | `true` (egress blocked) | Block all sandbox network egress, matching the Docker backend's no-network default. Set `false` for open egress; configuring an allow list implies selective egress. | |
| 120 | +| `networkAllowList` | string | unset | Comma-separated CIDR addresses the sandbox may reach. Setting this (with `networkBlockAll` unset) enables selective egress. | |
| 121 | +| `domainAllowList` | string | unset | Comma-separated domains the sandbox may reach. Setting this (with `networkBlockAll` unset) enables selective egress. | |
| 122 | +| `remoteWorkspaceDir` | string | `/home/daytona/workspace` | Absolute path of the session workspace inside the sandbox. | |
| 123 | +| `remoteAgentWorkspaceDir` | string | `/home/daytona/agent` | Absolute path mirroring the real agent workspace when `workspaceAccess` is not `none`. | |
| 124 | +| `timeoutSeconds` | number | `120` | Timeout for Daytona API operations (create, upload, filesystem commands). Image-based creates automatically get a higher floor to cover image pulls; raise this when declarative builds need longer. | |
| 125 | + |
| 126 | +## Lifecycle management |
| 127 | + |
| 128 | +```bash |
| 129 | +# List all sandbox runtimes (Docker + Daytona) |
| 130 | +openclaw sandbox list |
| 131 | + |
| 132 | +# Inspect effective policy |
| 133 | +openclaw sandbox explain |
| 134 | + |
| 135 | +# Recreate (deletes the Daytona sandbox, re-seeds on next use) |
| 136 | +openclaw sandbox recreate --session <sessionKey> |
| 137 | +``` |
| 138 | + |
| 139 | +Idle pruning (`agents.defaults.sandbox.prune`) treats Daytona runtimes the same |
| 140 | +as Docker runtimes: pruned entries delete the Daytona sandbox. |
| 141 | + |
| 142 | +## Cost controls |
| 143 | + |
| 144 | +- `autoStopInterval` (default 15 minutes) stops idle sandboxes; stopped |
| 145 | + sandboxes restart automatically on next use. `autoPauseInterval` pauses |
| 146 | + instead, on sandbox classes that support pausing. |
| 147 | +- `autoArchiveInterval` moves long-stopped sandboxes to cold storage; |
| 148 | + `autoDeleteInterval` deletes sandboxes that stay stopped, if you prefer |
| 149 | + Daytona-side cleanup in addition to OpenClaw pruning. |
| 150 | +- OpenClaw prune (`sandbox.prune.idleHours` / `maxAgeDays`) deletes registered |
| 151 | + sandboxes from the OpenClaw side. |
| 152 | + |
| 153 | +## Current limitations |
| 154 | + |
| 155 | +- Browser sandboxing is not supported on this backend. |
| 156 | +- `sandbox.docker.*` settings (image, binds, network) do not apply; use |
| 157 | + `snapshot`/`image` and the network allow-list options instead. |
| 158 | + `sandbox.docker.binds` is rejected; Daytona `volumes` cover shared storage. |
| 159 | +- Volume mount paths are reachable from `exec` commands only; the file tools |
| 160 | + stay inside the managed workspace mounts. |
| 161 | +- The workspace is seeded once (remote-canonical); there is no mirror mode. |
| 162 | +- Exec stdin is line-oriented text (Daytona session input); binary stdin |
| 163 | + streams are not preserved byte-for-byte in non-PTY execs. |
| 164 | + |
| 165 | +## Related |
| 166 | + |
| 167 | +- [Sandboxing overview](/gateway/sandboxing) |
| 168 | +- [Multi-Agent Sandbox & Tools](/tools/multi-agent-sandbox-tools) |
| 169 | +- [Sandbox vs Tool Policy vs Elevated](/gateway/sandbox-vs-tool-policy-vs-elevated) |
0 commit comments