Skip to main content

Sandbox Lifecycle

VoidRun sandboxes are designed for long-running workloads with intelligent resource management. A running sandbox has no maximum execution time, and idle sandboxes are snapshotted to disk so you only pay for active compute. A snapshotted sandbox wakes in a fraction of a second on the next request.

Infinite running

VoidRun sandboxes are designed to run for as long as you need. There is no maximum execution time, making them a good fit for:
  • Long-running AI agent workflows
  • Persistent development environments
  • Multi-step code execution pipelines
  • Background processing tasks

No hard timeouts

Run tasks for minutes, hours, or days. Idle sandboxes are snapshotted, not killed.

Cost efficient

Auto-sleep releases compute while a snapshot preserves the sandbox on disk.

Fast wake

Wake a snapshotted sandbox in well under a second: the same sandbox, same files, same processes.

Lifecycle states

The status field on a sandbox is one of:

Auto-sleep and auto-delete

When you pass autoSleep: true on create, the platform manages the lifecycle for you. You can change autoSleep later with PATCH /sandboxes/{id}:
TypeScript
Python
The flag is stored on the sandbox document. The next auto-lifecycle scan (default every 30 seconds) picks it up; the VM is not restarted. autoSleep: false skips idle snapshot only. It does not stop auto-delete of a sandbox that is already snapshotted.
1

Activity monitoring

The platform treats sandbox API requests (for example exec, filesystem calls, and opening a PTY) as activity. An open terminal connection alone does not keep the sandbox awake; see PTY.
2

Auto-sleep (default: 1 minute idle)

After the configured idle window, the sandbox is snapshotted: memory + disk are persisted and the VM process exits. Status becomes snapshotted.
3

Auto-wake on demand

The next API call (or public URL request) transparently wakes the sandbox back into running. You do not need to poll or issue a wake call yourself.
4

Auto-delete (default: 7 days snapshotted)

A sandbox that stays snapshotted past the retention window is deleted, and its snapshot is removed. Download anything you need before you leave a sandbox idle for that long.

Defaults

These are hosted-VoidRun defaults. On self-hosted deployments, tune the environment variables above and disable the whole loop with AUTO_LIFECYCLE_ENABLED=false if you want per-sandbox opt-in only.
An open PTY connection does not count as continuous activity. After you connect, idle time still advances unless other API calls keep the sandbox active. Details: PTY → Auto-sleep interaction.

Wake is transparent

You don’t have to call wake yourself to use a snapshotted sandbox. Every path that talks to the guest does the right thing:
  • REST API and SDKs: an exec, filesystem, or command call against a snapshotted sandbox triggers a wake and then executes.
  • Public URLs: a request to a published port while snapshotted wakes the sandbox through the gateway and then proxies the request. See Public URLs.
The first request after a long idle pays the wake cost once (memory + disk restore + readiness probe). Subsequent requests are hot.

Manual lifecycle controls

You can drive the lifecycle explicitly.

Sleep a sandbox

Snapshot a running sandbox now, instead of waiting for the idle timer.

Wake a sandbox

Explicitly restore a snapshotted sandbox back to running. In most cases you don’t need this: any API call against a snapshotted sandbox auto-wakes it.

Start a recovered sandbox

start is for recovery: it accepts sandboxes in snapshotted, killed, or error and boots them from the latest snapshot. Use wake for the normal sleep/wake loop and reach for start when the platform reports the sandbox in a non-running, non-snapshotted state.
start fails with 500 if no snapshot is available. That usually means the sandbox never reached running after create, or the snapshot was cleaned up: create a fresh sandbox in that case.

Delete a sandbox

Permanently remove a sandbox, its snapshot, and all its data.
Deletion is permanent. Files, environment variables, and any snapshot are destroyed. Download important data first.

Public URL cold wake

Sandboxes that expose ports via publishPorts remain reachable while snapshotted. A request to a published URL is served after the gateway wakes the sandbox: the first request after idle is slower, and subsequent requests are hot. Design HTTP clients to retry once on a gateway timeout during that first request. See Public URLs for how to publish ports and fetch the URLs.

Best practices

Let sandboxes sleep

Sandboxes with autoSleep: true cost storage only while snapshotted. Wake latency is well under a second, so the user-visible penalty is minimal for interactive workflows.

Design long-running workflows for wake

For workflows that live for hours or days:
  1. Persist state to disk — files inside the sandbox survive sleep/wake. State kept only in a process’s memory does not: on wake, that process no longer exists.
  2. Detect status — before assuming the sandbox is hot, read the current status (GET /sandboxes/{id}); the SDKs expose sandbox.status.
  3. Retry idempotent calls — the first request after a long idle can hit the wake budget; retry once with a small backoff on gateway timeouts.

Long-running AI agent example

Next steps

Public URLs

Publish sandbox ports and reach them from the internet.

Code Execution

Run commands and code inside a sandbox.

File System

Files persist across sleep/wake and only vanish on delete.

SDKs & API

TypeScript and Python method surface for the lifecycle.