The engineering tradeoff at the heart of every AI agent platform running code today.
There is an unwritten law in systems engineering: the stronger the barrier you draw around a piece of code, the longer it takes to get that code running. No committee formalized it. No standard encodes it. But every infrastructure team that has tried to make software simultaneously safe and fast has encountered it, usually at the worst possible moment. The safer you make something to run, the more machinery has to be assembled before the first instruction executes. That assembly takes time, and time, in computing, is money.
The industry has lived with this tradeoff for decades. It became genuinely urgent only when AI systems started running code autonomously. An agent that generates a program and then executes it to check its own reasoning cannot wait several seconds for a new secure environment to spin up on every iteration. Users are watching. Costs are accumulating. The tradeoff that was once a manageable nuisance became a hard architectural constraint, and the solutions that engineers had developed for serverless cloud infrastructure suddenly found themselves at the center of a much larger conversation.
Isolation in computing is not binary. It sits on a spectrum, and moving up that spectrum provides more protection while extracting a heavier startup cost.
At the shallow end, software containers partition workloads by dividing a shared operating system kernel through namespaces and control groups. They start in milliseconds and carry very low overhead, but they share that kernel with everything else on the host machine. A well-crafted exploit inside a container can, in principle, reach through to the host. One level up sits hardware virtualization, where each workload receives its own kernel, enforced by the processor itself. The CPU's privilege model polices the boundary. Breaking out requires defeating it directly, which is a substantially harder problem. That guarantee costs time: a full virtual machine has to boot an operating system before it can run anything at all.
Amazon's Firecracker is the most studied attempt to bring that upper tier down to something practical. Designed specifically to run the disposable, high-turnover sandboxes that AWS Lambda and Fargate require, Firecracker can initialize user-space code in as little as 125 milliseconds, with memory overhead under five megabytes per instance and a creation rate of up to 150 micro virtual machines per second on a single physical host. For a long-running web service, 125 milliseconds is imperceptible. For an AI agent that spawns an isolated environment to execute code, checks the result, revises, and repeats, it is a tax levied on every iteration. A session that executes fifty programs pays that tax fifty times, and the bill arrives in real time while a user waits.
The most direct solution to the problem of slow starts is to not have slow starts. Initialize a set of execution environments in advance, keep them running, and assign incoming work to one of them when it arrives. The environment is already warm when the request lands, so the startup cost never appears on the critical path. This is the approach the industry calls a warm pool, and it is exactly as simple and as expensive as it sounds.
The challenge is calibration. A pool that is too small will overflow during traffic spikes, forcing the excess onto cold-start infrastructure and undermining the whole point. A pool that is too large idles at full cost, paying for capacity that earns nothing. Cloud platforms generally expose warm pools as a provisioned capacity option: customers declare how many pre-initialized environments they want, pay a fixed rate regardless of utilization, and receive single-digit-millisecond startup in return.
Cloudflare took the warm-pool idea in a different direction by changing what the pool contains. Workers, its serverless compute platform, runs functions inside V8 isolates rather than containers or virtual machines. A V8 isolate is the same sandboxing mechanism Chrome uses to keep web page tabs from interfering with each other: a constrained runtime with strict memory boundaries, no shared state, and a restricted interface to the outside world. A single host process can hold thousands of V8 isolates simultaneously. A new isolate starts in under five milliseconds; a warm one responds in under a millisecond. Cloudflare further compounded the advantage by observing that establishing a TLS connection takes a measurable amount of time. When the encrypted handshake identifies which hostname a request is heading for, Cloudflare uses that window to pre-load the relevant Worker. By the time the connection is fully established, the execution environment is already live. The tradeoff is a narrower runtime: Workers cannot execute arbitrary compiled code or interact with a real filesystem. For stateless functions that accept a request, do computation, and return a response, that restriction almost never matters.
Warm pools solve the latency problem by spending money continuously. Snapshot-restore solves it by spending time once, at deployment, and recovering the investment on every subsequent start. Run the initialization sequence, capture a precise image of the resulting memory state and CPU registers, and then skip initialization on every future start by restoring directly from that image. The more expensive the setup, and the more often the environment is launched, the larger the payoff.
AWS built this into its Lambda platform as a feature called SnapStart. At deployment time, the function is initialized inside a Firecracker micro virtual machine, and a complete snapshot is captured. That snapshot is distributed across a three-tier cache: remote object storage at the base, a distributed in-memory layer in the middle, and a local cache on each physical host that can retrieve a 512-kilobyte chunk in roughly one millisecond. The system monitors which chunks a given function reads first during startup and prefetches them proactively on subsequent restores. In published benchmarks, a Spring Boot Java application that previously required 6.1 seconds of cold-start time came up in 1.4 seconds with SnapStart enabled. The 4.3-fold improvement required zero changes to the application's source code. Under ideal cache conditions, Firecracker restore latency reaches as low as four milliseconds.
Research systems have pushed further. Ant Group's Catalyzer, described in production since 2020, achieves cold restores under ten milliseconds by mapping snapshot images directly into memory using copy-on-write semantics rather than deserializing them. Each environment begins from the stored image, and divergences accumulate in private memory pages only as the workload writes new data. A 2025 preprint from MIT CSAIL called Spice claims cold restores below five milliseconds in controlled benchmarks, by addressing operating-system overhead that other restore implementations had treated as fixed.
General-purpose serverless infrastructure accommodated cold starts measured in seconds because most workloads were not interactive. A background job that processes a batch of data does not care if it waited an extra two seconds to initialize. An AI agent that generates code, runs it, inspects the output, and uses the result to decide what to generate next cares a great deal. The user is present. The loop is tight. The environment overhead is not a footnote but a primary variable in the cost and latency budget.
Research from Tsinghua University quantified what that means in practice. Their analysis of production agent infrastructure found that execution environment overhead can consume up to 70 percent of the total cost of running an AI agent session, nearly matching the cost of the underlying model API calls. The wall, in other words, can cost as much as the intelligence it is protecting.
E2B, the infrastructure platform running code execution for products including Manus and Perplexity, has oriented its entire design around these numbers. Their system starts a Firecracker micro virtual machine from cold in under 200 milliseconds, and resumes a paused, snapshotted environment in between five and thirty milliseconds. The difference between those two figures is what determines whether an agentic loop feels interactive or feels like waiting. An agent running thirty execution cycles in a session against cold environments absorbs six seconds of pure initialization cost. The same session with snapshot resume absorbs less than one. The threshold between a viable and a non-viable architecture runs through that gap.
Modern AI agent platforms spawn isolated execution environments dozens of times per session to run model-generated code. The startup latency of each sandbox determines whether the experience feels interactive or sluggish. Snapshot-restore infrastructure compresses that cost from seconds to milliseconds. Daice Labs / 2026.
Snapshot-restore has an advantage over warm pools in cost and scalability, but it carries a liability that warm pools mostly avoid: when you restore a snapshot, you restore everything in it, including things that were never meant to be reused.
A pseudorandom number generator is initialized once during startup, with a seed drawn from the operating system's entropy pool. After that seed is fixed, every random value the program produces follows deterministically from it. A restored snapshot inherits that same seed. Two instances restored from identical snapshots will produce identical sequences of random values, because they started from the same internal state.
That is not an abstract problem. Amazon's own research team documented the consequences in a paper on microVM snapshot security. Reused random-number state has previously exposed TLS session keys in production systems and, in older cryptographic designs, private signing keys. If two environments restored from the same snapshot produce identical TLS session random values, the encryption between them and the outside world becomes trivially breakable. A feature designed to accelerate secure execution becomes a mechanism for undermining it. The industry response has been a layer of mitigations that signal to the restored guest that it is a clone and force a full reseed of cryptographic state before any traffic is handled.
The underlying principle is worth stating plainly. A restored environment is not a fresh environment. It is a copy of a specific prior moment, and any property that was supposed to be unique to a single execution needs to be deliberately re-established before that copy handles real work. Snapshot hygiene is not a performance concern. It is a security property, and treating it as optional transforms a speed optimization into an attack surface.
Key references: Agache, A. et al., "Firecracker: Lightweight Virtualization for Serverless Applications," NSDI 2020. AWS Lambda SnapStart documentation and engineering blog, Amazon Web Services, 2022 and 2024. Du, D. et al., "Catalyzer: Sub-millisecond Startup for Serverless Cold-starts with Non-intrusive Container-Compatible Memory Snapshot," ASPLOS 2020. Spice: fast microVM snapshot restore, MIT CSAIL, arXiv preprint, 2025. Brooker, M. et al., "Restoring Uniqueness in MicroVM Snapshots," arXiv 2021. Chai, X. et al., "Fork in the Road: Reflections and Optimizations for Cold Start Latency in Production Serverless Systems," OSDI 2025 (Ant Group / AFaaS). TrEnv: Transferable Execution Environments for AI Agents, Tsinghua University, 2025. E2B platform documentation, e2b.dev. Cloudflare Workers architecture and isolation model, developers.cloudflare.com.
Daice Labs Inc.
Brookline, MA, USA
Roll the "daice"–exploration & programmable adaptation.