Default: persistent (no auto-hibernate)
By default the timeout is0, which means never auto-hibernate. The sandbox stays running until you explicitly kill or hibernate it.
Persistent sandboxes keep accruing compute cost for as long as they’re running. If you only need the sandbox to respond to occasional requests, set a timeout so it hibernates between them — see below.
Setting a timeout
Passtimeout in seconds to have the sandbox auto-hibernate after N seconds of idle time. The timer resets on every operation — exec, file access, agent activity — so a busy sandbox never hits the timeout.
Update on a running sandbox
You can change the timeout at any time:What happens when the timeout expires
When an idle sandbox hits its timeout, the platform:- Snapshots the VM state (memory + disk) and stops the VM — no compute cost while hibernated.
- Marks the sandbox
hibernated. Its ID, files, and configuration are preserved.
Waking up
Any operation from the SDK automatically wakes a hibernated sandbox. You don’t need to callwake() yourself — calling sandbox.exec.run(...), reading a file, or any other operation transparently restores the VM and then performs the requested action.
You can still call
sandbox.wake() explicitly if you want to pre-warm a sandbox before routing user traffic to it.Choosing a timeout
| Use case | Suggested timeout |
|---|---|
| Always-on agent / bot that must respond instantly | 0 (persistent) |
| Interactive dev sandbox, keep for the session | 600–3600 (10 min – 1 hr) |
| Short-lived batch or test run | 60–300 (1–5 min) |
| One-off exec — kill it yourself when done | 0 + explicit kill() |
See also
- Lifecycle overview — all sandbox states
- Set timeout API
- Hibernate API / Wake API