How snapshots work
A snapshot is a saved copy of a sandbox’s /work directory that new sandboxes can start from. Sandboxes are
disposable on purpose, so a snapshot is how state outlives one. For the calls, see the
Snapshots guide.
Why agents use them
Section titled “Why agents use them”- Set up once, start many times. Installing packages or cloning a repository can take longer than the task itself. Do it once, snapshot, and start every later sandbox from the snapshot.
- A checkpoint before a risky step. Snapshot before a migration, a large refactor or a command the model is unsure about. If the step goes wrong, destroy the sandbox and start a new one from the checkpoint.
- The same starting point for every run. Evaluation harnesses start each attempt from one snapshot, so results differ only because the agent did something different.
There is a fourth use that follows from how policies work: a sandbox’s egress policy is fixed when it is created, but a snapshot is not tied to a policy. Install dependencies in a sandbox that can reach the package index, snapshot it, and run the agent’s code in a new sandbox from that snapshot with a stricter policy. The Running agents safely guide shows the code.
What a snapshot saves
Section titled “What a snapshot saves”The host packs the files in /work into a compressed archive and uploads it to object storage through a signed URL,
retrying up to three times. When it is stored, the snapshot is ready, with its size and SHA-256.
It saves /work only, because /work is the only place a sandbox can change: the root filesystem comes from the
image and is read-only. Packages installed with pip install or npm install -g land under /work, so they are
saved. Not saved:
- Running processes and anything in memory, including
/tmpand/run. - Environment variables passed with
env. Pass them again when you create a sandbox from the snapshot. - Exposed ports and the egress policy. Set them on the new sandbox.
The sandbox keeps running while the snapshot is taken, and files that change during it may be saved half-written.
Take snapshots between steps, when nothing is writing to /work.
Restoring
Section titled “Restoring”Restoring creates a new sandbox. Pass the snapshot’s id when you create one: it starts from the snapshot’s files with the snapshot’s image, and the original sandbox is untouched.
- The snapshot must be
ready. A pending one returnsconflict. - The new sandbox runs in the region the snapshot was taken in. Leave
regionout, or pass that same region; any other returnsvalidation. - Size, timeouts, policy, environment and metadata come from the create request, as for any new sandbox.
Where snapshots live
Section titled “Where snapshots live”Snapshots are kept in the object storage bucket configured for the service, which is not tied to the sandbox’s region, until you delete them. Only your organization can list, restore or delete them. Snapshot storage is not billed during early access.