In-Process Tool State That Serverless Invocations Cannot Survive
Agents need process-level persistence that serverless resets erase between invocations.

Persistent AI agent infrastructure differs from serverless functions in what survives between calls. Agents that accumulate runtime dependencies, loaded data, live sessions, and execution context need persistence at the process level. For these workloads, persistent VM infrastructure with snapshot-restore preserves work that stateless invocations must reconstruct after a reset.
Why serverless invocations and agent workloads are structurally mismatched
Serverless infrastructure was designed for short, stateless request-response cycles. A trigger fires, code runs, and the environment can be released when the invocation ends. This works well for webhook handlers and API glue because each request can be handled independently. An agent instead chains tool calls, retains context across them, and pauses between periods of activity. What it does next depends on the environment left by its earlier actions.
That dependency changes the unit of execution. For the agent, a session may span many calls and long waits for a user or an external service. For invocation-based infrastructure, each call is a bounded execution whose environment need not survive for the next one. A long-running task also hits the invocation’s duration limit even if its workflow has yet to reach a useful stopping point. The incompatibility therefore concerns what state is and where it lives.
What in-process state actually is and why it differs from data at rest
In-process state is the live condition of a running program. It includes the working state that makes the program ready to continue. Some of that condition belongs to process memory, while some depends on the kernel and the filesystem backing the runtime. A database record represents something different. It stores selected facts that a developer has deliberately written out.
A developer’s laptop session illustrates the distinction. Saving a file preserves its contents, but that file is not a substitute for the entire working session. After a restart, the saved artifact remains available while the environment needed to continue working may have to be rebuilt. Sleep preserves a different kind of continuity. The distinction is between retaining an output and retaining the machinery already positioned to produce the next one.
Rows in Postgres, blobs in S3, and vectors in a vector database belong to the first category. They can supply durable inputs and records of completed work. They do not, by themselves, reconstitute a live process. As an agent runs, it keeps creating working state, but that state does not become durable records on its own. Preserving that state through external storage therefore requires explicit serialization, where serialization is possible, followed by reconstruction when execution resumes.
The five categories of in-process state that a serverless reset erases
Installed packages and runtime dependencies form the first category. A coding agent that installs a package has changed its runtime environment, including the filesystem backing the process. Resetting that environment discards the change unless it has been preserved separately. A repository checkout has the same practical dependency on the working filesystem. For a pull-request review agent, cloning a large repository and installing dependencies again can make re-initialization often the majority of wait time.
Loaded datasets and in-memory computation form the second category. Raw data may stay safely stored while the parsed, indexed, or partly transformed form of that data is lost when the process ends. Retrieving the source does not recover the work already spent making it ready to query. Rebuilding that working form of the data can keep the agent from doing useful work for seconds to minutes, with the user waiting while it runs.
The third category is open file handles and filesystem state. Handles to files, sockets, and pipes are kernel resources attached to a process. When the process terminates, those handles are gone. Directories, partial outputs, and files written mid-operation may be recoverable if the developer has explicitly checkpointed them. But getting file contents back leaves the original open resource lost, and the state it was in may be lost too.
The fourth category is authenticated sessions and negotiated credentials. A token or cookie may be represented as data, but a live authenticated session also depends on runtime negotiation and connection state. Storing authentication material raises questions about how to keep it secure, while rebuilding a session can call for another handshake. Services that rate-limit authentication attempts or require multi-step authentication may make per-invocation reconstruction more than a latency problem.
The fifth category is execution context and workflow position. An agent partway through a plan has local variables, intermediate results, and a call stack that track where it is in the current operation. Checkpoints preserve only what has been written out. After a reset, the agent must read those records and work out how to restart from them, while in-flight state between checkpoints is lost. When execution reaches an invocation’s hard duration limit, the platform boundary can therefore cut across the workflow before a safe stopping point.
Why externalizing all of this state is not a complete solution
Databases are the right place for conversation history, completed step outputs, user preferences, and selected intermediate results. These are facts with useful durable representations. Moving them to Postgres, Redis, or a vector database lets later invocations retrieve them without relying on the previous process. That is a sound separation of responsibilities. It becomes incomplete only when persistence of those facts is treated as persistence of the agent’s working environment.
A package list records what to install, but installation still has to run. A stored dataset gives the agent input, but its loaded form still has to be rebuilt. An open handle cannot be recovered by reading a record, and closing and reopening a resource can change the semantics of an operation. Saved credentials can still leave the agent with a session handshake to complete. The external record is a recipe for reconstruction.
A developer must decide which state to save, when to save it, and how execution will restart from that representation. Step outputs can support recovery at known boundaries, but they do not preserve an arbitrary point within a call stack. This is substantial infrastructure work. Requiring it across every category of agent state shifts effort from agent quality toward a custom state-management layer without removing the categories that cannot be fully externalized.
How cold starts make the state-reconstruction cost visible to users
Before useful work can begin, a fresh environment needs its runtime initialized and its dependencies loaded. For a stateful agent, recovery can extend beyond platform initialization into authentication, data loading, and restoration of workflow context. The user waits through that work. A fast function startup does not make the agent ready if its working environment still has to be rebuilt.
Sequential tool calls make the delay compound. A plan-code-execute-verify chain may have to pay to rebuild its environment each time that environment is recycled between steps. Environment reuse may occur between invocations, but the workflow cannot rely on it as a persistence guarantee. Latency then depends not only on each tool’s useful work but also on how much prior work must be repeated before that tool can run.
Cold-start mitigations reveal the value of retained initialization state. Provisioned concurrency keeps environments ready, exchanging idle-compute spending for lower startup delay. SnapStart takes a different approach through snapshots, charging for snapshot caching and restores. Neither distinction should be blurred. Keeping an initialized environment cuts startup work, but keeping an agent’s session as it changes also means keeping the state built up after initialization.
What persistent VM isolation actually preserves that a serverless reset cannot
A micro-VM snapshot preserves execution below the application’s serialization layer. It captures memory contents, CPU state, and the guest’s live operating-system state, with filesystem persistence preserving the environment on which execution depends. The process is paused. Its working state does not need to be translated into a set of application records and then interpreted by a newly started program. That makes snapshot-restore categorically different from rebuilding an agent from database outputs.
Firecracker’s snapshot mechanism restores CPU state and memory mappings rather than booting a fresh kernel, running init, and restarting the agent. Execution resumes from its paused position. Installed packages remain available in the preserved filesystem, and loaded datasets retain their parsed or indexed form in memory. Guest file descriptors and execution context are preserved with the VM’s state. Authenticated session state also survives process suspension, although credential expiry and the requirements of external services still apply.
That last qualification is important for live connections. Preserving the local process cannot turn an expired credential into a valid one or eliminate a required handshake with an external service. Persistence removes process death as a reason to rebuild state. It does not suspend the outside world.
Firecracker snapshot loading takes tens of milliseconds at the API level, while end-to-end orchestration is typically 150–200ms. The complete path is the relevant comparison for an interactive agent. VM isolation adds a separate boundary because each agent has its own guest kernel, while containers share the host kernel. That boundary is particularly relevant when agents execute model-generated code.
The economics that follow from sleeping rather than resetting
Serverless economics depend on avoiding idle compute. Snapshot-restore retains that property without requiring the agent’s environment to be destroyed between bursts of work. A sleeping VM consumes storage rather than active compute, and waking restores the preserved execution state. The idle cost changes form. Storage pays to retain the packages, loaded data, session state, and workflow context that the agent would otherwise have to reconstruct.
This distinction fits a fleet whose agents spend most of their time waiting for users, external services, or scheduled triggers. A snapshot-restore scheduler can make compute spending track active concurrency. Warm pools make a different trade. They keep environments ready by paying to run them even when no request comes in. For bursty workloads with low utilization, preserving sleeping environments avoids that continuous idle-compute bill.
Each suspended environment occupies disk, giving scale-to-zero compute an explicit, plannable storage cost. It also supports a different product model. One isolated VM per user can preserve a working environment between sessions while charging the idle period to storage.
How should developers choose between persistent AI agent infrastructure and serverless functions?
The practical decision should begin with the state the workload creates. Serverless functions remain appropriate for genuinely stateless work, including webhook handlers, lightweight routing, and short tool calls that finish within one invocation without accumulated context. Those tasks do not require a persistent process. Their durable inputs and outputs can adequately describe the work.
Persistent VM infrastructure is the appropriate choice when an agent modifies its runtime, works with expensive-to-load datasets, maintains sessions across tool calls, or must preserve intermediate execution between user interactions. Kernel-level isolation is another criterion when the agent runs model-generated code. These requirements concern the execution environment itself. A database can complement that environment by storing durable facts, but it cannot substitute for all of its live state.
The deployment pattern that follows is one persistent VM per user, sleeping between sessions and waking in under a second. Firecracker-based snapshot-restore scheduling keeps that environment in place with persistent disk and a separate guest kernel. The decision is whether the infrastructure preserves what execution builds so the next interaction can continue the work.


