Sandboxes
Safe, isolated execution.
A sandbox is the isolated environment where an agent's code runs. Each run gets its own sandbox, provisioned at start and torn down at the end.
What isolation gives you
- Containment. A run can't affect other runs, other workspaces, or the host.
- Reproducibility. Every run starts from the same base image with the same dependencies.
- Resource quotas. CPU, memory, disk, and network are bounded per sandbox.
What's inside
Every sandbox is provisioned with the things the agent needs and nothing else:
- The agent's code and current version.
- The resources you've declared.
- The tools it's allowed to call.
- Credentials to reach your own model provider, or ours.
Sandboxes are ephemeral by default: they're destroyed when the run finishes. Anything the agent needs to keep goes into the session or a durable resource.
Persistent workspaces
Some agents build up a working set that's expensive to recreate — a cloned
repository, downloaded datasets, a report that evolves across runs. For those,
switch the agent to a persistent workspace in its settings (or set
workspace_scope: "agent" in the agent's config via the API). The agent then
keeps one durable working directory that carries over between conversations
and runs, instead of starting empty each time.
For the built-in Levain assistant, persistence is per person: each workspace member gets their own durable working directory with the assistant, so your files carry across your conversations without appearing in anyone else's. In Slack this follows your Slack profile email — it should match the email you use with Levain.
Every persistent workspace is also backed by a git repository. Before a turn the platform syncs the working directory from it, and after the turn it commits and pushes what changed. Both steps are best-effort: if one fails, that turn falls back to the volume alone rather than failing the run. You can browse files and history from the agent's Files tab, or through the API: list files, read or write a file, and list commits. Where a file was edited both in the repository and in a run, the run's copy wins.
Three things change when it's on:
- Runs execute one at a time per volume. A dispatch while another run
holds the same workspace is queued (status
queued) and starts when the running one finishes. A person's message (or another agent's call) starts before queued trigger deliveries and scheduled fires; within each, the oldest goes first. The queue is bounded per agent: trigger deliveries for the same subject (say, the same pull request) collapse into the newest one, and at most one scheduled fire ever waits. When the queue is full, a scheduled fire is skipped, and a person's message or a new trigger delivery drops the oldest waiting trigger run: it shows as a cancelled run and the workspace gets a notification. A person's message is never dropped. A recipe that declares adeliveriesstate variable takes every trigger delivery waiting in its queue in one turn (see GitHub events), including any dropped to make room; the deliveries it took show as cancelled runs linking to the run that handled them. When a turn fails, the trigger delivery that started it and any it carried go back in the queue, once; one that fails again, or finds the queue full, is dropped with a notification. A turn you cancel puts back only the deliveries it took. An agent can run several turns at once instead: turn on Run turns at the same time in its settings (concurrentin its config,max_concurrent_runsfor an optional cap). Turns then start as they arrive, as many as the runtime serving the agent allows, and wait only when the cap is reached or when a turn on the same subject (the same pull request, the same schedule) is already in flight. The recipe has to be written for turns sharing the working directory: each turn's entry/drain sync snapshots (commits) whatever is on disk at that instant, so a snapshot taken while another turn is mid-way can carry its in-progress, not-yet-finished edits under this turn's commit message — there is no clean boundary between concurrent turns' changes. On a self-hosted runtime turns overlap only when it serves several sessions at once. A manual run request can ask for an immediate answer instead ("queue": falseon create run returns409when the agent is busy). With per-person persistence this only ever means your own concurrent conversations take turns — never someone else's. The agent's page under Usage lists what is waiting, in the order it will start, with what started each run and what it waits for;GET /api/v1/agents/{agent_id}/queueand the MCPget_agent_queuetool return the same, and a queued run'squeuefield inget_runsays why it hasn't started. - State persists. Files an earlier run left behind — including anything a misled run wrote — stay visible to every future run. A self-serve reset is on the way; until then, reach out and we'll wipe the workspace for you.
- Storage accumulates. Nothing expires automatically; large datasets sit on the volume until the workspace is wiped or the agent is deleted.
Fresh-by-default remains the recommendation for agents that don't need it: a clean workspace per conversation is easier to reason about and runs concurrently.
Inspecting a sandbox
While a run is live, you can query its sandbox to see real-time resource use:
GET /api/v1/sandboxes/lists every sandbox in your workspace.GET /api/v1/sandboxes/{sandbox_id}returns status, resource use, and the run it's attached to.
Direct sandbox interaction is uncommon in day-to-day use; the endpoints above are mainly for inspection and debugging.