What a Persistent Sandbox Process Actually Holds Between Agent Steps That a Serverless Invocation Forfeits

Persistent sandboxes keep five kinds of agent state that cold starts lose.

· 8 min read
Cover illustration for “What a Persistent Sandbox Process Actually Holds Between Agent Steps That a Serverless Invocation Forfeits”
Sandboxed Code Execution · November 11, 2026 · 8 min read · 1,839 words

A persistent sandbox preserves the working state an AI agent needs between steps, while a cold serverless invocation starts again from its base environment. That difference decides whether an agent continues its task, repeats work, or breaks.

Why do long-running AI agents fail on serverless infrastructure?

Serverless assumes that a function can run, finish, and leave no necessary state in its local environment. An agent often assumes the opposite. Its loop moves through planning, acting, observing, and repeating, with each step depending on what the previous step left behind. An edited file, a running subprocess, or a signed-in browser can be part of the next step’s starting conditions.

That mismatch is structural. Even with more time to run, an invocation cannot pass its working environment on to a later cold invocation. A persistent sandbox instead keeps the process and its accumulated state available between steps, rather than requiring the application to rebuild them. The state at stake falls into five concrete categories.

What the filesystem layer holds that a cold start cannot recover without re-running work

The filesystem preserves the agent’s work in its most visible form. It holds edited source files, compiled artifacts, downloaded assets, intermediate outputs, and configuration changes made during earlier steps. A coding agent building a patch across several steps needs the latest working files.

A cold invocation starts from the base image, without those local mutations. Files survive only if the team has explicitly saved them to external storage and arranged to restore them. That requires separate design, maintenance, and storage work. Without it, the coding agent must redo its edits or fail to apply the patch it was building.

DeltaBox (arXiv:2605.22781) treats “files and process state” as primary checkpoint requirements for agent test-time tree search and reinforcement learning rollouts. Its DeltaFS mechanism freezes the writable filesystem layer and inserts a new one, so updates use copy-on-write and rollback switches layers. A restored agent needs the filesystem that belongs to its restored point in execution.

What in-memory interpreter and runtime context holds that no restart can reconstruct

Disk state is only the visible part of the workspace. A running process also holds variable bindings, call stacks, open file descriptors, in-flight data structures, and cached computation results in memory. CPU registers, including the instruction pointer, hold the record of where execution stands. Together, these determine what the process will do next.

That working context can hold conclusions that were never written anywhere else. An agent debugging a failing test, navigating a multi-page document, or tracking partial web-search results uses memory as its scratchpad. A fresh interpreter has none of it. Re-reading files and re-parsing outputs can recover some context, but an intermediate result that was never saved cannot be recovered from those files. Re-issuing tool calls repeats work.

A Firecracker snapshot preserves this context by saving the full memory contents, CPU register state, and device state so the guest can pick up at the next instruction. The process does not start its program again. The supplied bare-metal comparison puts snapshot restore at 26x faster than cold boot, showing the overhead avoided by resuming an execution state.

Why installed dependencies are the hidden tax that serverless agents pay on every cold start

Before an agent can use its working context, it needs the tools that make the work possible. A persistent sandbox retains language runtimes, installed packages, cloned repositories, compiled binaries, and environment configuration added during the session. Setup becomes part of the available environment. The next step can use the tool the previous step installed.

A cold invocation retains what was baked into the base image. Any newly installed package, cloned repository, or configured tool must be restored or rebuilt before useful work resumes. That consumes both time and compute budget. For coding agents working on SWE-bench–style tasks, cloning a repository and installing its dependency tree over and over can use up a large share of the task’s wall-clock budget.

Baking dependencies into the base image is a valid answer for a known, fixed environment. It removes repeated installation of that known toolchain. But an agent working on arbitrary repositories or choosing tools during execution does not know its full dependency set in advance. Its environment develops as the task unfolds. Persistence keeps those additions as they are, while a cold-start design needs fallback logic for anything that was left out of the image.

What process metadata holds about where a task is and why losing it silently corrupts agent behavior

Having the right files and tools does not establish the right execution context. Process metadata includes process identifiers, environment variables, open network connections, background processes, signal handlers, and the working directory. These determine how subsequent system calls are interpreted. A command issued in a fresh process need not mean the same thing as that command issued in the process the agent left running.

A background server started in step one can still be listening in step three, while a file lock remains held and a long-running subprocess continues producing output. A cold replacement has no such continuity. The prior processes, their locks, and their pending work are not present in the new invocation.

Unlike a missing file, this loss can be deceptive. The agent may issue commands under the assumption that a process still exists, receive unexpected output, or treat a restart as normal continuation. The task seems to move forward even as it gets the results wrong. DeltaBox treats process state as a checkpoint requirement equal to filesystem state, using CRIU, short for Checkpoint/Restore In Userspace. Its DeltaCR mechanism rolls back by forking from a frozen template process backed by a CRIU dump, preserving an execution point.

Why authenticated sessions can make a cold restart depend on human intervention

Authenticated sessions let the agent get into external systems. Browser cookies, OAuth tokens, service credentials, signed-in SaaS contexts, and API session handles provide the proof of identity that those systems expect. A persistent sandbox retains the signed-in context between steps. The agent can authenticate, navigate away, and return without rebuilding that context for each action.

A cold invocation loses any session state that was kept only locally. At the next step, the agent may hit a login wall or get an unauthenticated response that it mistakes for output it can use. Freshly injected credentials can sometimes establish another session, but that session may not have the state of the previous one. Access and continuity are different requirements. Restoring the ability to sign in does not necessarily restore the context in which the task was underway.

For computer-use agents in legacy desktop apps, EHR systems, Citrix environments, loan origination systems, or document management platforms, re-authentication may require MFA or human approval. The agent may also be barred from holding credentials itself. Keeping credentials outside the sandbox and injecting them through a proxy only for allowlisted destinations addresses credential handling, but does not by itself preserve the session. If every cold start requires authentication again, the human bottleneck returns. Where authentication requires human action, session loss is the category for which “just re-run it” is not an autonomous recovery option.

How the five categories interact and why losing one can break the task

These categories form a compound dependency. Even if the files are saved, the task cannot keep running if the process writing them is gone. A preserved authenticated session is unusable if the tools needed to act through it are missing. Keeping four categories does not compensate for losing the fifth when the task depends on all of them.

Durable serverless workflows offer a real alternative for explicitly modeled state. They save progress and release compute during waits, but the application must identify, serialize, store, and restore what the next step needs. Saving selected values to a database cannot preserve an unrecorded dependency on a running subprocess or an in-memory result. An application-layer patch therefore works only to the extent that it accounts for the task’s actual state requirements.

What the checkpoint/restore mechanism reveals about how much state actually changes between agent steps

Preserving a whole working environment can sound expensive because the environment itself may be large. DeltaBox identifies a more useful unit of cost. Consecutive sandbox states differ only slightly, so a checkpoint system can record the changes.

DeltaBox reports approximately 10.83 ms of checkpoint work hidden under inference time and approximately 1.86 ms for rollback. Those figures apply specifically to its checkpoint-and-rollback mechanism. They nevertheless change the comparison with reconstruction. Reinstalling tools and re-deriving context repeat earlier work, while delta-based preservation records only what changed. Persistence can therefore cost much less than the size of the full environment suggests.

Firecracker shows two ways to keep execution state while no work is being done. Pause keeps all guest memory while no CPU runs, and its resume latency is approximately 1.5 ms on bare metal. Hibernate writes a full snapshot to disk and kills the VMM, with wake-to-first-answer of approximately 21 ms on bare metal. These preserve state at different resource granularities. With either approach, the application can keep its interpreter context without having to rebuild it from a set of saved values.

Checkpoint work can run while the agent waits for inference results, so it can stay off the critical path before the next action. When that work fits inside the wait, keeping the state adds no task wall-clock time. This weakens the assumption that discarding state is necessarily the economical choice.

Where persistent sandboxes belong in a workload placement decision and what serverless still does well

Serverless remains a good fit when the work is genuinely independent between invocations. A one-shot summarization or a single tool call with no follow-on does not need a live workspace after completion. There is nothing necessary to resume. For those workloads, retaining a sandbox would solve a state-continuity problem the task does not have.

Datadog’s 2026 guide frames placement around the workload’s execution profile. It recommends recording how much active compute time each run uses against its total elapsed time, along with the peak arrival rate, how much memory it needs, and which persistent connections it needs. A low active-compute ratio strengthens the serverless case. A high ratio, especially with steady arrivals, can make dedicated workers more economical. These measurements show how resources are used, while the dependencies between steps decide what the execution environment must keep.

For agent builders, the lesson is to evaluate those dependencies before treating cold starts as a tolerable delay. Coding agents, computer-use agents in legacy applications, per-user long-lived sessions, and regulated workflows with audit-continuity and session-integrity requirements tend toward persistence because their work spans execution steps. Serverless’s stateless execution model leaves out the local context the task needs in those cases.

The placement test is concrete. Enumerate whether filesystem mutations, in-memory interpreter context, installed dependencies, process metadata, or authenticated sessions must survive between steps. If the task needs any of them as continuing sandbox state, use a persistent environment rather than expecting a cold invocation to inherit them. If the steps are genuinely independent, serverless is the leaner fit.

Sources

  1. DeltaBox: Scaling Stateful AI Agents with Millisecond-Level Sandbox Checkpoint/Rollback

More in Sandboxed Code Execution