Pause, resume and snapshots
Set the lifetime, pause, resume, kill and snapshot a sandbox.
Sandbox states
| State | What it means | Billed |
|---|---|---|
| Running | Commands, files and ports work | Yes, per second |
| Paused | Memory and files saved | No, for up to 72 hours |
| Ended | Killed or timed out. Memory and files deleted. | No |
Read the state with get_info() / getInfo() or fdtn ls -s running,paused.
Lifetime
At the end of its lifetime, the sandbox is killed.
| Default | 300 s (5 minutes) |
|---|---|
| Maximum | 24 hours |
| CLI minimum | 30 s |
| Units | Python: seconds. TypeScript: ms. |
Each fdtn command that uses a sandbox makes its time left at least 5 minutes. The SDKs do not.
Python · TypeScript · CLI
sbx = Sandbox.create("base", timeout=3600) # 1 hour
const sbx = await Sandbox.create('base', { timeoutMs: 3_600_000 }) // 1 hour
$ fdtn create base -d --timeout 3600Lifetime is not request_timeout, the SDK API wait.
Change the time left
The new value counts from now, up to 24 hours.
Python · TypeScript · CLI
sbx.set_timeout(600) # 10 more minutes from now info = sbx.get_info() print(info.state, info.end_at)
await sbx.setTimeout(600_000) // 10 more minutes from now const info = await sbx.getInfo() console.log(info.state, info.endAt)
$ fdtn sandbox timeout <id> 600 $ fdtn sandbox info <id>
Pause at the end
Set lifecycle={"on_timeout": "pause"} (Python), lifecycle: { onTimeout: 'pause' } (TypeScript) or --lifecycle.ontimeout pause (CLI).
Terminal sessions
An open terminal from fdtn create or fdtn connect keeps the sandbox running. When you leave fdtn create:
- By default, the CLI kills the sandbox.
- With
--timeout <seconds>, it runs that long. - With
--lifecycle.ontimeout pauseand no--timeout, it pauses.
Pause
A pause saves memory, files and running programs, and stops billing.
Python · TypeScript · CLI
sbx.pause() # True when paused, False when it was paused already sandbox_id = sbx.sandbox_id # keep the ID to resume later
await sbx.pause() // true when paused, false when it was paused already const sandboxId = sbx.sandboxId // keep the ID to resume later
$ fdtn pause <id>- A paused sandbox is kept 72 hours after its last pause, free.
- Paused sandboxes and snapshots hold up to 100 GiB of memory per workspace. Limits
- For a group, use
fdtn pause --metadata run=eval-1.
Resume
A connect resumes a paused sandbox, or attaches to a running one.
Python · TypeScript · CLI
sbx = Sandbox.connect(sandbox_id, timeout=600) # resume, then 10 minutes of lifetime print(sbx.commands.run("cat /tmp/state.txt").stdout)
const sbx = await Sandbox.connect(sandboxId, { timeoutMs: 600_000 }) console.log((await sbx.commands.run('cat /tmp/state.txt')).stdout)
$ fdtn resume <id> # resume only $ fdtn connect <id> # resume and open a terminal
A resume sets a new lifetime: 5 minutes for the CLI, or the timeout you give. On a running sandbox, a longer timeout extends it; a shorter one does nothing. fdtn cp, each and collect also resume.
A resume does not wait in the queue. If it cannot start, it fails at once with 429. Limits
Kill
A kill ends the sandbox and deletes its memory and files. Call kill() in a finally block.
Python · TypeScript · CLI
sbx.kill() # this sandbox Sandbox.kill(sandbox_id) # any sandbox, by ID
await sbx.kill() // this sandbox await Sandbox.kill(sandboxId) // any sandbox, by ID
$ fdtn kill <id> <id2> # one or more IDs $ fdtn kill --all -m run=eval-1 # only this group
--all kills every running sandbox. Add -s running,paused or -m to change the set.
At the spending limit
Running sandboxes pause, so you lose no work. Raise the limit on the Billing page, then resume. Spending limits
Snapshots
A snapshot saves memory and files now, for example after a long install. New sandboxes start from it.
Python · TypeScript · CLI
sbx.create_snapshot(name="ready") # later: start a new sandbox from the snapshot name copy = Sandbox.create("ready")
await sbx.createSnapshot({ name: 'ready' }) // later: start a new sandbox from the snapshot name const copy = await Sandbox.create('ready')
$ fdtn snapshot create <id> --name ready $ fdtn create ready -d
- Always give a name. You start from it and delete by it.
claudeand--trustedsandboxes cannot make a snapshot (400 trusted_copy_not_supported).- If a create from a new snapshot gets
404, try again after some seconds. - Delete:
fdtn snapshot delete <name>. - A snapshot counts toward the 100 GiB limit and the template count. It outlives the source sandbox.