Beyond Git Worktree

Snapshot and Restore Mechanisms for Agent Sandbox State

Agents gain true exploration by checkpointing sandbox state.

· 10 min read
Cover illustration for “Snapshot and Restore Mechanisms for Agent Sandbox State”
Sandbox Infrastructure · October 16, 2026 · 10 min read · 2,243 words

A coding agent is partway through a multi-service migration when a test fails. Retry-from-scratch discards all of it. Snapshot-restore exists to make that discarding unnecessary, and in doing so it changes what agents are capable of, not merely how quickly they recover.

The assumption that rollback is nearly free comes from the earliest text-based agent tasks, where the only persistent state was the conversation itself. Truncating the prompt history returned the agent to a known-good position, and the cost was a few tokens of lost context. That assumption breaks the moment an agent executes code with side effects. The environment carries state the prompt never captured.

Graviet and Shah, in work published on arXiv in October 2026, identify the precise failure: the meaningful progress an agent makes before failing often lives outside the repository, in databases, services, and other runtime state. A git diff might show what the agent changed in code, but it says nothing about the schema migration the agent applied or the daemon it configured. Restarting from the initial state means re-deriving all of that before the agent can even reach the point of failure again.

The result is a brittle loop. Every failure costs the full setup time, the full environment rebuild, and all intermediate progress, not just the failed step. For a multi-day debugging session against a staging environment, it is not. The failure mode is not theoretical. It is the default behavior of any agent harness that treats the filesystem as the only source of truth about the world.

What makes this problem tractable is that the state has a structure. It is not a heap of arbitrary system modifications. It divides into two dimensions, and understanding that division is what leads, fairly directly, to the infrastructure that solves the problem.

What sandbox state actually consists of, and why it must be captured jointly

Agent sandbox state is two-dimensional. The first dimension is durable filesystem state: working directories, installed packages, written files, database contents, service configuration. The second dimension is ephemeral process state, and it is the one that disqualifies simple approaches.

Ephemeral process state includes process memory, the Python interpreter heap, open file descriptors, debugger attachment, and mid-expression REPL context. These are not recoverable from a log or a transcript. Restore the files and the interpreter still has no idea what expression it was evaluating. A debugger attached to a paused process is in the same condition: the attachment lives in kernel state and process memory, not in any file on disk.

The consequence is that the two dimensions must be captured and restored atomically, or the agent encounters state divergence. Restore the filesystem without process memory, and the running interpreter is in a state that never existed during normal execution. It is the computing equivalent of waking from a dream into the wrong room.

DeltaBox formalizes this requirement. Every search tree node in an agent's exploration corresponds to a joint filesystem-and-memory state that must be saved and restored as a unit. And this two-dimensional requirement is exactly what disqualifies the obvious approaches. Docker stop captures neither cleanly for a running agent. The infrastructure primitive has to operate at a different level entirely.

How snapshot-restore works at the infrastructure level

Snapshot-restore resolves the two-dimensional state problem by treating checkpoint and rollback as first-class operating system operations, not application-level workarounds. The baseline mechanism is Firecracker's snapshot-restore API, and it is worth understanding because it establishes the pattern that the more advanced systems build on. The Firecracker model boots a microVM once to a ready state, snapshots its memory and block device state to local NVMe, and then restores subsequent sandboxes from that snapshot rather than cold-booting them. The critical implication is that a sandbox create becomes a restore of an already-booted machine, not a cold boot. This eliminates the VM startup latency that once made per-run microVMs impractical for the inner loops of agent execution. Hardware isolation is now available at roughly container-grade latency.

DeltaBox, from Shanghai Jiao Tong University and Huawei, pushes the state of the art further with a new OS abstraction called DeltaState, which treats filesystem and process memory as a transactional, change-based state pair. DeltaFS organizes file states into layers, freezes the writable layer on checkpoint, and inserts a new one. Rollback is a layer switch, not a full copy, which reduces file updates to copy-on-write operations. DeltaCR enables change-based process state checkpointing using incremental dumps, and accelerates rollback by bypassing traditional pipelines to fork directly from a frozen template process.

The key insight driving DeltaBox is that subsequent checkpoints in agent execution are highly similar. Duplicating only the changes between consecutive checkpoints, rather than full state each time, yields millisecond-level latency. Evaluations on one coding benchmark show a mean checkpoint time of roughly 14 milliseconds and rollback of roughly 5 milliseconds. That is fast enough to sit inside an agent's inner loop, which is the threshold that matters.

Where snapshot-restore is not available, idle warm pools offer a complementary approach: pre-warmed sandboxes waiting for work cut effective cold start near zero for latency-sensitive applications, at the cost of idle resource burn. Zylos AI notes this trade-off explicitly. It is a useful fallback, but it buys startup speed without the more fundamental capability that fine-grained checkpointing enables.

Why fast checkpoint-restore changes what agents can do, not just how fast they recover

When checkpoint and restore are fast enough to sit inside an agent's inner loop, snapshot-restore becomes the unit of exploration, not just a tool for recovering from failures. Agent execution is inherently non-linear. Agents explore, backtrack, and fork hypotheses across a search tree, and each node in that tree is a joint filesystem-and-memory state. Without fast checkpoint-restore, agents must either commit to a single linear path or restart from scratch to explore alternatives. Both options discard useful intermediate work.

With fast checkpoint-restore, backtracking becomes a first-class runtime operation. An agent can branch at any checkpoint, retry a different approach from a known-good state, and compare outcomes without pretending that a pile of logs is recoverable state. This matters in two dimensions. Horizontally, execution-guided sampling allocates inference budget across many parallel candidate trajectories, each needing an isolated sandbox clone. Fast snapshot-fork is what makes this practical rather than prohibitively expensive. Without intermediate checkpoints, a failure at step N requires restarting from step zero.

The empirical case for this capability is not speculative. That is precisely the long-horizon, multi-service work where retry-from-scratch is most costly. The paper does not claim snapshot search helps everywhere. It claims it helps most where the state is hardest to reconstruct, which is the claim that matters for infrastructure decisions.

Reinforcement learning creates the same pressure from the training side. Each training step issues a batch of rollouts against a sandbox, requiring repeated teardown and re-creation of independent sandboxes at a known-good warm starting state. Fast snapshot-restore makes this tractable at scale. The capability compound: fast checkpoints enable deeper search, deeper search rewards better checkpoints, and the cycle tightens.

How sandbox snapshot design intersects with security isolation

Snapshot-restore and security isolation are not independent properties. The same design decisions that enable fast state capture also determine whether one agent session can contaminate the next. Getting snapshot design wrong undermines the security guarantees that the microVM boundary is supposed to provide.

The threat model for agent sandboxes is categorically different from traditional application sandboxing. The code being executed is generated at runtime by an LLM and cannot be reviewed before execution. Three distinct failure modes all require containment. The model can be wrong, and its mistakes look competent: it deletes the wrong files or runs a destructive migration. The model can be steered, through prompt injection via a web page, document, or tool result the agent reads. And the code can be exploited, when a malicious PDF or poisoned dependency turns a tool call into remote code execution regardless of model intent.

Snapshot design bears on each of these. Credentials must be scoped and session-bound: secrets injected at sandbox creation via a vault client per tenant and revoked on teardown. Snapshot storage itself is a security surface. Stateful agents use per-session VMs or snapshot-and-fork so continuity is never traded for isolation.

The inevitable bad moment, a wrong migration, an injected instruction, a poisoned dependency, lands in a disposable machine with scoped credentials, no egress, and a short fuse. Snapshot-restore ensures the blast radius is bounded and the machine is discarded after the session. Share the host kernel, and a kernel LPE or container escape crosses the boundary. MicroVM isolation is the only production-safe layer for LLM-generated code execution. This is not a matter of degree. It is a categorical distinction about where the trust boundary sits.

What production snapshot-restore looks like in practice: platforms and their trade-offs

The architectural choices around snapshot design, not just raw latency, determine whether a sandbox is fit for production agent workloads. The platforms implementing snapshot-restore today make different choices along several axes, and those choices map to different deployment profiles. Fly.io Sprites runs Firecracker microVMs with 100GB of persistent NVMe storage per sandbox and checkpoint-restore in roughly 300 milliseconds. The idle billing model stops charging for compute when the environment is not in use, though storage costs continue. That fits persistent coding agent sessions that need a warm environment between runs: the agent can pause, the meter stops, and the state remains on disk for the next session. Runloop's Devboxes take a different emphasis, using VM-plus-container isolation for agent code, API keys, secrets, sensitive data, and internal systems while providing agents a complete development environment. The emphasis is on isolating agent access to internal systems, which matters for teams where the agent operates inside a corporate network boundary.

Daytona, whose production codebase closed in June 2026 while the original open-source repository went unmaintained, offers native Git integration, LSP support, and experimental GPU access. It served as the full-snapshot substrate in Graviet and Shah's Go-Explore search research. OpenHands, formerly OpenDevin, sits at the fully autonomous end of the spectrum: the agent spins up a sandboxed environment, browses the web, writes code, runs tests, and submits pull requests. The team owns the infrastructure, so code stays off third-party servers, which matters for compliance requirements.

Alibaba OpenSandbox, which drew strong initial developer interest as of March 2026, is a general-purpose sandbox platform with multi-language SDKs and unified APIs across Docker and Kubernetes runtimes, supporting gVisor, Kata Containers, and Firecracker. It covers coding agents, GUI agents, agent evaluation, and RL training in a single abstraction layer. The distinction from self-hosted approaches is that the snapshot and session lifecycle is managed infrastructure, not an engineering project. That matters when you move from laptop experiments to production deployment across an engineering organization, where a sandbox platform needs highly concurrent container operation with sub-second cold starts.

The governance requirements that snapshot-restore must satisfy to clear enterprise production

For enterprise engineering teams, snapshot-restore is necessary but not sufficient. The session lifecycle must be observable, attributable, and cost-bounded from the moment a sandbox starts to the moment it is destroyed. Every agent file access, shell command, pull request creation, and API call should be logged with a timestamp and user identity. Tagging every run with a session and run ID provides the linkage between sandbox lifecycle events and the audit log, and snapshot-restore keeps the boundary fine-grained enough, through low create latency, that using it as the default audit unit is practical. A prompt injection attempt that is blocked must appear in the compliance record, not just successful tool calls.

The regulatory context sharpens these requirements. The EU AI Act's broad applicability phase, effective August 2, 2026, brought Article 50 transparency obligations and enforcement powers into effect, while high-risk AI system requirements, including logging and human oversight, moved to December 2, 2027 under the Digital Omnibus, Regulation (EU) 2026/1744. In parallel, NIST's Center for AI Standards and Innovation, CAISI, launched the AI Agent Standards Initiative in February 2026 to address identity, authorization, monitoring, and interoperability for agents. Snapshot session identity, credentials minted per session and revoked on completion, maps directly onto the identity and authorization requirements that initiative is standardizing.

Cost control is equally non-negotiable. A 2025 incident in which multi-agent pipelines generated tens of thousands of dollars in API invoices over a single weekend illustrates that uncontrolled agent loops are a documented financial hazard. Snapshot-restore only creates production value when it is wrapped in session-level audit trails, scoped credentials, and hard budget caps.

Moving from sandbox experiments to governed agent infrastructure

The path from running a coding agent on a laptop to deploying it across an engineering organization is not a model problem. It is an infrastructure problem, and snapshot-restore is the primitive that makes the infrastructure production-grade. The progression is concrete: laptop prototype, then isolated sandbox, then snapshotted sandbox with fast restore, then a governed, auditable, cost-bounded session lifecycle. Each step is a prerequisite for the next. The order is not optional.

The practical decisions facing engineering teams fall into a small set of categories. Session credential design: credentials minted fresh per session and revoked on completion, never carried across snapshot boundaries as ambient state. Agent configuration as code: YAML-defined agents checked into the repository, reviewed and versioned like any other infrastructure, with the same governance model applied to the rest of engineering.

Build versus buy is the final decision. Beyond that point, what the agent can do is bounded by the model. Before it, the infrastructure is the binding constraint.

Sources

  1. DeltaBox: Scaling Stateful AI Agents with Millisecond-Level Sandbox Checkpoint/Rollback
  2. [2610.13841] Returning to Development States: When Full Sandbox Snapshots Help Coding Agents

More in Sandbox Infrastructure