The short version Keeping and branching a sandbox's state
A sandbox is disposable by design, but throwing everything away after every run is wasteful. Snapshots and forking are how modern sandboxes get the best of both: a clean, isolated machine, without paying the full setup cost each time. The idea is simple once you separate three moves, save, restore, and branch.
Snapshot and restore: skip the setup, not the isolation
A snapshot freezes a machine's full state, memory, CPU and disk, into storage. A restore loads it back into a live sandbox. Because the restored machine is already booted, already has your dependencies, and still holds its warm caches, it is ready far faster than a cold start that has to redo all of that. You keep the isolation of a fresh environment while skipping the part that was slow.
Forking and copy-on-write: why branching is cheap
A fork starts a new live sandbox from a snapshot, and you can start many at once. The reason this is not ruinously expensive is copy-on-write: the forks share the parent's unchanged memory and disk pages and only allocate space for what each one writes. That shared-page trick is what makes it practical to branch one warm state into dozens of parallel copies, which is exactly what a reinforcement-learning rollout or a parallel agent search needs.
What it unlocks: pausing and rewinding
Two payoffs fall out of the same machinery. Pausing freezes an idle sandbox so its state survives while compute billing stops, which matters on long agent tasks with a lot of think time between actions. Rewinding uses a snapshot taken before each step so a failed tool call rolls back to the last good state instead of restarting the whole run. Both turn "state" from something you rebuild into something you move around.
Live from our vendor data, verified and dated on each vendor page. "State handling" is each provider's own description of persistence, snapshots and forking.
Frequently asked
What's the difference between a snapshot and a fork?
A snapshot is a frozen copy of a sandbox's full state, its memory, CPU and disk, saved to storage. A fork is a new live sandbox branched from a snapshot. One snapshot can spawn many forks, and each starts from the same saved point.
How is restoring from a snapshot faster than a cold start?
A cold start boots a kernel and then re-runs your setup: installing packages, warming caches. Restoring skips all of that. It loads a machine that is already set up and already warm, so the environment is ready in a fraction of the time a fresh boot would take.
Why are forks cheap to create?
Forks share the parent's unchanged memory and disk pages and only store what each one changes, an approach called copy-on-write. Ten forks of a 2 GB machine do not cost 20 GB; they cost the shared 2 GB plus each fork's small set of writes.
Can I stop paying while a sandbox sits idle?
On providers that support pausing, yes. Freeze the sandbox and its state is kept while compute billing stops, then resume the same machine later. E2B, for example, offers pause and resume with the memory state intact.
How does this help an AI agent?
An agent can snapshot before each risky step, then roll back to the exact state just before a failed tool call instead of restarting the whole task. The same trick powers reinforcement-learning rollouts, where one saved state is forked into many parallel attempts.
Which sandboxes support snapshots and forking?
In our dataset, E2B offers pause and resume with memory snapshots, Runloop does git-style disk snapshots with branching, CodeSandbox has a git-versioned forking filesystem, and Fly Machines keep checkpoints. Support and granularity vary, so check each vendor page.
The Sandbox Brief What moved in the sandbox world, every Friday.
Pricing changes, new entrants, benchmark refreshes and one sharp take from Eve Harper. Read by engineers choosing where their agents and apps run. No fluff. Read the archive.