Timeouts and billing
Agents forget things. A process crashes between creating a sandbox and destroying it, a loop gives up halfway, a developer stops a script with Ctrl-C. Every sandbox therefore has two timeouts that the platform enforces on its own, whatever happens to the code that created it. They make sure a forgotten sandbox stops running, and stops costing money.
| Setting | Default | Minimum | Maximum |
|---|---|---|---|
idle_timeout_s | 600 (10 minutes) | 30 | 21600 (6 hours) |
hard_timeout_s | 3600 (1 hour) | 60 | 86400 (24 hours) |
Set both when you create a sandbox, to the budget of the task: the idle timeout a little longer than the slowest step you expect, the hard timeout a little longer than the whole task.
Idle timeout
Section titled “Idle timeout”The sandbox is destroyed after idle_timeout_s seconds without activity, and ends with end_reason: idle_timeout.
Activity is anything that uses the sandbox through the platform:
- Running a command. A command that is still running counts as activity until its own timeout has passed, so a long build does not look idle.
- Writing, reading or listing files.
- Exposing a port or taking a snapshot.
- An open SSH session or dashboard terminal. While one is open, the idle timeout does not fire.
- A keepalive call.
Not activity: reading the sandbox’s status or its audit trail, and requests to an exposed port. A web app that only serves traffic through an exposed port is destroyed when its idle timeout passes; call keepalive while you need it.
curl -X POST https://api.wardcase.com/v1/sandboxes/sbx_4f9k2m8q1z7x3c5v/keepalive \-H "Authorization: Bearer $VIVARIUM_API_KEY"keepalive on a sandbox that is no longer running returns conflict (409). The sandbox’s
last_activity_at field is updated at most every 30 seconds, so it can lag behind the real last activity.
Hard timeout
Section titled “Hard timeout”The sandbox is destroyed hard_timeout_s seconds after it was created, whatever it is doing, and ends with
end_reason: hard_timeout. expires_at on the sandbox tells you when. Keepalive does not extend it, and an open SSH
session ends with the sandbox.
The hard timeout is the ceiling on what one sandbox can cost and how long a runaway agent can keep a machine.
Command timeout
Section titled “Command timeout”Each command has its own timeout_s, default 300 and at most 3600
seconds. When it passes, the host kills the command’s process with SIGKILL and the result has timed_out: true; the
exit code is the one the kill produced (137 in the runs we tested). The sandbox keeps running.
The SDKs wait for the answer for timeout_s plus 30 seconds before giving up on the request, and the API ends a
command’s stream 15 seconds after its timeout at the latest, so a lost result never hangs your agent.
Creating
Section titled “Creating”A sandbox that has not reported ready 120 seconds after it was created ends as failed. Billing
starts only when a sandbox is ready, so a sandbox that never started costs nothing.
Billing on allocation
Section titled “Billing on allocation”A running sandbox is billed for its size’s vCPU and memory for every second it exists, from the moment its host reports it ready until it is destroyed, whether the processes inside are busy or idle.
| Size | vCPU | Memory | Disk | Per hour |
|---|---|---|---|---|
small | 1 | 1 GiB | 5 GiB | $0.13 |
medium | 2 | 4 GiB | 10 GiB | $0.32 |
large | 4 | 8 GiB | 20 GiB | $0.64 |
Why allocation and not measured use:
- The capacity is yours while the sandbox exists. A sandbox’s vCPUs and memory are reserved for it on the host whether it uses them or not.
- The cost of a task is predictable. Size times duration, known before you start. With measured billing, the cost would depend on how hard the code inside happens to work, which the agent decides as it runs.
- Timeouts become cost controls. With the default hard timeout, a forgotten
smallsandbox is destroyed after 60 minutes, which costs $0.13 plus any egress.
Hosts still measure each sandbox’s actual CPU and memory every 10 seconds. Those samples feed abuse detection and usage analytics; they do not change the bill. Outbound traffic is billed by the byte on top. See Billing and free tier for prices, the free tier and reading your usage.