Foundational Compute

Pause, resume and snapshots

Set the lifetime, pause, resume, kill and snapshot a sandbox.

Sandbox states

StateWhat it meansBilled
RunningCommands, files and ports workYes, per second
PausedMemory and files savedNo, for up to 72 hours
EndedKilled 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.

Default300 s (5 minutes)
Maximum24 hours
CLI minimum30 s
UnitsPython: 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

Lifetime 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)

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 pause and 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
  • 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)

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

--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")
  • Always give a name. You start from it and delete by it.
  • claude and --trusted sandboxes 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.

Next