Repository navigation
Description
Summary
On Docker, a session's workspace (/agent) is a directory on the host with no size bound of its own. Nothing bounds what a program in a sandbox writes there except the disk itself; the only host-level guard, a free-space floor, stops new sessions from starting but does nothing about a session that is already running. The spawner's own source says so ("A free-space floor is not a per-workspace quota"), and its Docker-in-Docker docs advise a quota "before exposing this to untrusted tenants". Since v0.5.87 any organization member can run code from chat by default, so the people who can start such a program are no longer only administrators. This issue collects the evidence and the options. It proposes no fix.
Context
services/sandbox/src/host-disk.ts:1-12: "A free-space floor is not a per-workspace quota. … Every session's workspace … is a directory under the spawner's session root on the Docker host, with no quota of its own (Kubernetes gives each a volume of a fixed size instead). A disk that fills up fails the next write of every running session and, on a single-machine install, of the platform's own databases beside them."services/sandbox/docs/docker-in-container.md:226-238("Disk bound", written about the inner Docker store of Docker-in-Docker sessions): "A plain Docker named volume has no hard size cap … Tale does not configure those quotas … Set a quota before exposing this to untrusted tenants … This free-space floor pauses new creates; it does not constrain already-running writers."services/sandbox/README.md:108-111and:478-479: the free-space check "does not cap already-running writers", and these checks "do not enforce per-session disk quotas".- Kubernetes bounds each session with a sized volume (
SANDBOX_K8S_WORKSPACE_SIZE_LIMIT). This issue concerns Docker.
What changed: #4817 made code execution available to every member from chat (default on; Chat tools › Code), and #4844 lets a task run on the shared engine use the same sandbox. Before, the audience was administrators configuring agents. A document the model reads can also steer it into running code.
What bounds a session today
Read from docker inspect and from inside a default-profile session on a local rig:
| Bound | Value | Where |
|---|---|---|
| size of one file | 100 MiB (ulimit -f, fsizeBytes: 104857600). A 300 MiB dd stopped at 104,857,600 bytes |
docker-session-args.ts:158 (DEFAULT_PROFILE). The agent profile defaults to 512 MiB (config.ts:996); the limit is dropped under Docker-in-Docker (docker-session-args.ts:268-277) |
/tmp |
tmpfs, 128 MiB | docker-session-args.ts:159 |
| root filesystem | read-only | |
| memory, processes, CPU | 1500 MiB, 512 pids, 1 CPU | DEFAULT_PROFILE |
| the workspace | none: df inside the session reports the host filesystem (1007 GB, 888 GB free on the rig) |
Host-level checks: SANDBOX_MIN_FREE_DISK (default a twentieth of the disk, at least 2 GiB, at most 20 GiB; host-disk.ts:38) makes creates answer 429 host_disk below the floor, and below a critical tier idle Docker-in-sandbox sessions are stopped. Neither limits a session that is already running.
Bounds specific to chat: one run_code call runs at most 180 s (RUN_CODE_MAX_TIMEOUT_SECONDS, lib/agent/work-tools.ts:77); an organization's light sandboxes are capped by maxLightSessionsPerOrg (default 2, minimum 1; packages/shared/src/schemas/governance.ts:186); a light sandbox is destroyed after 5 idle minutes (LIGHT_SESSION_IDLE_MS). On destroy the workspace directory is removed from the host (checked on the rig). A run attaches at most 10 files of 20 MB (RUN_CODE_MAX_OUTPUT_FILES, ARTIFACT_MAX_BYTES), so what a run delivers is small; what it writes along the way can be larger.
Measurements
From inside a default session on the rig (Docker Desktop on an Apple-silicon Mac; the workspace is on the VM's virtual disk, /dev/vda1), writing in 100 MiB files (the per-file limit) with oflag=direct, then removing them:
| Writers | Data | Time | Rate |
|---|---|---|---|
| 1 | 3,000 MiB | 8.9 s | 339 MiB/s |
| 4, in parallel | 3,200 MiB | 8.4 s | 383 MiB/s |
Arithmetic from those numbers, not measured on a deployment:
- One 180-second
run_codecall at 339 MiB/s writes about 60 GiB. - A host with a 100 GB disk and 50 GB free has a floor of about 5 GB. One writer reaches the floor in about two minutes and fills the disk in under two and a half.
- On a slower disk, say 125 MiB/s, filling the same 50 GB takes about six minutes: two or three calls.
Not done: filling a disk (it would harm the machine it runs on), observing the platform's behavior on a full disk, and inode exhaustion.
Options (not exhaustive, no preference stated)
- Operator-side quotas. Recommend, and have the CLI's generated stack optionally set up, a dedicated filesystem or project quotas for the sessions root (the docs say Tale configures none today).
- Enforcement in the spawner. Periodic usage accounting per session workspace and a stop or freeze when one exceeds a limit. Cheap with project quotas, costly with
duon a large tree. - A bounded workspace for the
defaultprofile. Its deliverables are small (see above), though intermediate files can be larger, so a bound needs a margin. A size-limited filesystem fits; a memory-backed one trades RAM for bounded disk. - Contain the blast radius. Place
default-profile workspaces on their own filesystem, apart from the platform's databases and the agent workspaces, so that filling it stops code runs and nothing else. - Leave it to the operator and say so. State it next to the Light sandboxes limit on the Sandboxes admin page, where an admin decides how much code to allow.
Questions
- Which profiles need a bound:
defaultonly, or the agent profiles as well? Their legitimate work (clones, builds) needs far more room. - Docker only, since Kubernetes already has sized volumes?
- What size is reasonable for a light sandbox?
- Is it acceptable on a single-machine install that one member's chat can fill the disk the platform's databases share?
Related
#4870 (the network side of the same sandbox exposure), #4124 (host disk floor follow-ups), #3977 (concurrent runs exhausting the host), #4726 (reserving memory for the database and platform).
Observed at main a83e645e27.
Activity
yannickmonney commentedon Nov 14, 2026
Decision
On Docker, each sandbox session's workspace becomes a fixed-size, disk-backed filesystem of its own, as it already is on Kubernetes and Incus. The spawner keeps a sparse ext4 image per session under the session root. A managed, privileged loop helper, built by Tale from a pinned image and shipped with the release, attaches the image. It is mounted at
/agentas a Dockerlocalvolume (ext4,discard,nodev,nosuid).SANDBOX_DOCKER_LIGHT_WORKSPACE_SIZEdefault-profile sessions: chat run_code, renders, light task runsSANDBOX_DOCKER_WORKSPACE_SIZESANDBOX_DOCKER_STORAGE_SIZEThe bound fails closed without taking the spawner down. If a sized workspace cannot be provisioned, the spawner still boots, reports
workspaceBound: falsewith a reason, and refuses new sessions with503 workspace_unbounduntil the probe succeeds. The only exception is when the operator setsSANDBOX_DOCKER_WORKSPACE_QUOTA=off. The Sandboxes page shows a warning in both cases. Existing directory workspaces keep working without a bound until they are destroyed. The free-space floor stays.As an immediate fix on
main: below the critical disk tier, the spawner also stops runningdefault-profile sessions.Answers
default, 10 GiB for agents, 20 GiB for the DinD store. Documents can steer agent prompts too.Rationale
Only a sized filesystem per session gives a hard bound, enforced by the kernel, on a default rootful Docker install with no operator setup, and inodes are bounded too. It keeps agent workspaces across stop and resume and adds no memory pressure. Image block counts replace
duin reclaim. Refusing creates instead of refusing to boot keeps the same safety, but a host without loop devices then shows a clear reason on the admin page instead of a crash-looping spawner, and it recovers once fixed. The spawner already runs a privileged helper (buildkitd), so this adds no new trust boundary.Implementation units
fix(sandbox)(basemain, S): stop runningdefault-profile sessions below the critical tier. Docs in EN, DE and FR.feat(sandbox)(baserelease/0.6, L): the loop-helper image and container, image-backed workspaces for thedefaultprofile, the probe and theworkspace_unboundcreate gate, measurement from image blocks, the environment reference, docs and the upgrade note.feat(sandbox)(baserelease/0.6, M): the same for agent profiles, with legacy directory workspaces marked. Depends on 2.feat(sandbox)(baserelease/0.6, M): a sized inner Docker store for DinD sessions and a rewritten Disk bound section. Depends on 2.feat(platform)(baserelease/0.6, M): the Sandboxes page shows the bound or an unbounded warning with its reason, the CLI doctor gets the shared-filesystem and loop-device warnings, plus self-hosting docs and a manual-test box. Depends on 2.Cross-issue amendments (decisions taken together with #5374):
disk_full(host free-space floor or host ENOSPC), which keeps the waited retries, andworkspace_full(the session's sized workspace), which gets one immediate retry on a fresh workspace only when the run does not resume its workspace and otherwise none. The workspace_full sentence names the workspace size setting (SANDBOX_DOCKER_WORKSPACE_SIZE or SANDBOX_INCUS_WORKSPACE_SIZE) as the operator's fix.