Blog / 31 October 2026
Deep dive · 31 October 2026 · 7 min read
Memory snapshots vs disk snapshots: what "checkpoint" means for an agent sandbox
A disk snapshot saves a sandbox's files; a memory snapshot also saves its RAM and every running process, so a restore resumes mid-task instead of booting again. Neither reliably keeps open network connections, and every clone made from one memory snapshot carries the same secrets and random state.
01What does a disk snapshot of a sandbox capture?
A disk or filesystem snapshot copies the sandbox's files at a point in time. Restoring it gives you the installed packages, the repository and the build cache, but not anything that was only in memory: running servers, shell variables, an agent's in-process state. The sandbox boots or runs its entrypoint again, and the processes start from scratch.
Several cloud sandboxes document exactly this behaviour. Modal's filesystem snapshots are copies of the sandbox's root filesystem, and mounted volumes are not included. Vercel Sandbox snapshots capture the filesystem and installed packages, and taking one stops the sandbox. Cloudflare's Sandbox SDK says a snapshot saves the writable root filesystem but not memory or processes, so the repository comes back while the development server has to be started again. Daytona keeps the filesystem when a sandbox stops, but not the memory state.
Disk snapshots are the right tool for skipping setup. Install dependencies once, snapshot, and start every later run from there. They are the wrong tool for undoing a mistake in the middle of a long task, because the task itself is gone.
02What does a memory snapshot capture?
A memory snapshot saves the machine's RAM and the CPU and device state alongside it, so restoring it continues execution where it stopped. In Firecracker, a snapshot is a guest memory file plus a microVM state file. The block devices are not part of it: Firecracker's docs say the disk files have to be handled by the user. A whole-machine checkpoint therefore pairs a memory snapshot with a copy of the disk taken at the same moment, or the restored memory will disagree with the files.
Cloud services that expose this describe it in similar terms. E2B's pause saves both the filesystem and memory state, including running processes and loaded variables, at about 4 seconds per GiB of RAM, and resumes in about 1 second. Modal's memory snapshots, documented as alpha, copy the sandbox's entire state, both in memory and on the filesystem, and running processes are still running after restore. Modal lists limits too: the snapshot expires after 7 days, taking it terminates the sandbox, and it can be restored only on the same instance type.
A third approach works below the VM. CRIU, checkpoint and restore in userspace, can freeze a running container or a single application on Linux and write its state to disk. It checkpoints processes rather than a machine, so anything outside those processes, such as the kernel or other containers, is not part of the snapshot.
- Disk snapshot: files only; processes restart; fast to share and keep.
- Memory snapshot: RAM, processes and device state; must be paired with the matching disk.
- Process checkpoint (CRIU): chosen processes only; the host kernel stays outside it.
03Do network connections survive a snapshot restore?
Usually not, at least not connections to the outside world. Firecracker's docs say to expect packet loss after resuming in a new process, that the state of network connections may not survive the restore, and that open vsock connections are closed. E2B says network connections drop on pause and clients must reconnect after resume. Modal says open TCP connections close and must be reopened.
The reason is that the other end did not pause. A remote server sees silence, times the connection out, and forgets it. CRIU can restore established TCP sockets using the kernel's TCP repair mode with --tcp-established, but it has to hold off the peer while the socket is down and needs the same IP address on restore, which is why it fits same-host restores and planned migrations.
Connections that live entirely inside the machine are a different case. A database and the app talking to it in the same VM are both in the snapshot, so they come back together. For agents, the practical rule is: expect calls to model APIs and external services to fail once after a restore, and make the agent retry.
04Is it safe to fork a VM for agents from one memory snapshot?
Forking means restoring one memory snapshot into several machines at once, which is how you run parallel attempts from the same warm state. Firecracker's docs flag the risk directly: they consider resuming execution from the same state more than once insecure, because unique identifiers, cached random numbers and cryptographic tokens are copied into every clone.
Firecracker notes that on Linux 5.18 and later its VMGenID device reseeds the guest kernel's random number generator on resume. Applications that cached their own randomness, session IDs or nonces still need to deal with it themselves. The guest clock also resumes from the moment of the snapshot and should be updated after restore.
For agents this adds one more reason to keep real credentials out of the sandbox. A short-lived token held in memory at snapshot time is held by every fork, and any of them can use it until it expires.
05What do memory snapshots cost in speed and storage?
A memory snapshot is roughly as large as the RAM in use, so it is slower to take and heavier to store than a disk snapshot of a small workspace. Restore can still be fast: Firecracker maps the memory file with MAP_PRIVATE, so pages load on demand as the guest touches them, at the price of keeping the memory file available for the whole life of the resumed VM. Diff snapshots store only memory changed since the last one, and generally have to be merged with a base before they can resume.
Retention differs widely between services. Modal keeps filesystem snapshots for 30 days by default and memory snapshots for 7. Vercel's snapshots expire 30 days after last use by default, adjustable to never. E2B keeps a paused sandbox until you kill it. Check this before you build an undo feature on top of someone's snapshots.
06Which snapshot does an AI agent need?
Match the snapshot to the question you want to answer later. If the question is how to start the next run faster, a disk snapshot after setup is enough. If it is how to undo the last five minutes without losing the running task, you need memory and disk captured together.
Many teams use both: a disk snapshot as the base image that every new sandbox starts from, and memory checkpoints during a task, discarded once the task is done and its results are committed.
- Faster starts: disk snapshot after dependencies are installed.
- Undo mid-task: memory plus disk, taken together, before the risky step.
- Parallel attempts from a warm state: memory snapshot forked into copies, with care for duplicated secrets and randomness.
- Long-term records: neither; keep logs and artifacts, because snapshots expire and are large.
Takeaways
- A disk snapshot restores files; processes start again from scratch.
- A memory snapshot restores RAM and running processes but must be paired with the matching disk.
- External network connections usually drop on restore; agents should retry.
- Every clone of one memory snapshot shares its identifiers, cached randomness and in-memory tokens.
- Snapshot retention varies by service from days to indefinitely, so check it before relying on it.
Where kosa8 fits
kosa8 takes the memory-plus-disk approach on your own machine. A checkpoint saves the whole running machine, memory and processes, in about 0.7 seconds, and a rewind puts it back, still running and under the same name, in about half a second. Each checkpoint costs a disk clone, so kosa8 keeps ten per sandbox and drops the oldest. A running machine can also be forked into live copies to try approaches in parallel, and API keys stay on the host, so forks do not copy real keys.
Check yourself · +100 XP
According to Firecracker's documentation, which part of a microVM is not included in a Firecracker snapshot and must be handled by the user?
A Firecracker snapshot is a guest memory file plus a microVM state file. The block device files are separate, and the docs say the user has to back them up and manage them.
Questions people ask
What is the difference between a memory snapshot and a disk snapshot?
A disk snapshot saves files, so a restore boots or restarts processes. A memory snapshot also saves RAM and device state, so a restore continues the running processes where they stopped.
Do network connections survive a VM snapshot restore?
Connections to outside hosts usually do not. Firecracker, E2B and Modal all document dropped connections after restore. Connections between processes inside the same machine come back with it.
Can I checkpoint a running process instead of a whole VM?
On Linux, CRIU can checkpoint and restore a running application or container, including established TCP connections in some setups. It captures those processes only, not the kernel or the rest of the machine.
Sources
- Snapshot support — Firecracker on GitHub
- CRIU — CRIU project
- TCP connection — CRIU project
- Sandbox persistence — E2B docs
- Sandbox snapshots — Modal docs
- Snapshots — Vercel docs
- Sandbox lifetime — Cloudflare docs
- Sandboxes — Daytona docs
- How do I undo what an AI coding agent did? — kosa8 guides
- How do I try several AI agent approaches in parallel? — kosa8 guides
Written by the kosa8 team. Every kosa8 command was checked against the CLI, and every claim about another product links to that product's own documentation. Spotted a mistake? Tell us.
Try it on your own machine
Give your next agent its own sealed machine.
One line installs kosa8 on your own machine. Every feature, plans from $29 a month.