Est.

Persistent VM per Agent vs Serverless for Production AI Agent Deployments

Whether your agent keeps state decides between serverless and VMs.

· 9 min read
Cover illustration for “Persistent VM per Agent vs Serverless for Production AI Agent Deployments”
Agent Hosting Economics · November 12, 2026 · 9 min read · 2,017 words

The choice between persistent AI agent infrastructure and serverless functions comes down to state. Serverless fits short tasks that keep nothing locally between steps, while persistent environments fit agents that need to keep their files, processes, or authenticated sessions. Persistent microVMs offer a third shape, combining an isolated environment with suspend-and-resume and snapshot-fork operations rather than forcing a choice between disposable functions and always-running VMs.

Why AI agents break the serverless contract

Building a prototype agent is easy compared with deploying one. A laptop already has persistence, state, a real tool environment, and stable addressability. The agent can leave files behind, keep a browser open, and return to work later. Production infrastructure has to be built to give the agent those same things. The gap begins with the execution contract.

Serverless assumes that a function receives a request, executes, and returns a response. The platform can then reclaim memory, filesystem state, and open connections without preserving them. Agents instead run loops that observe, reason, act, and repeat, accumulating useful state across iterations. An agent may still need its installed dependencies, intermediate results, authenticated sessions, and a task queue after a step ends. That is a structural mismatch. Serverless is well suited to event-driven, stateless, short-lived work, but an agent loop is not automatically that kind of workload.

The three things an agent does with state, and why each one stresses infrastructure differently

Active working state is what an agent reads and changes during a task. A code-review agent may have working files, installed packages, running processes, and open connections while it works on a task. It needs to keep those until the work is done. Standard Lambda limits how long a task can run, so a longer task must pass its state across invocation boundaries to keep going.

Idle-suspended state is the environment an agent needs while waiting. An approval-gated workflow might stop overnight with its files and application session still needed for the next step. Waiting is not the same as being finished. A traditional VM preserves the environment by holding capacity, while a function that scales to zero offers no promise to preserve its local state. Checkpointing and resuming address a different need from uninterrupted execution.

Shared-prefix state is the state that many runs share when they branch from one starting point. An eval harness may prepare an environment once, then launch thousands of parallel rollouts from it. Repeating setup for every branch wastes work. Snapshot-fork support lets the infrastructure give those branches a warm starting state, saving each agent the work of rebuilding it.

Diagram: Three State Modes, Three Infrastructure Fits. Visualizes: Show three distinct agent state modes mapped to their best-fit infrastructure.

What serverless actually handles well, and the agent designs that fit it cleanly

Document classifiers, triage workers, webhook responders, and notification processors can fit serverless cleanly when they are stateless between steps. Bursty workloads benefit from paying only for execution. Cloud-native API integrations also avoid much of the need for a persistent local environment. There is no fleet to manage. For agents below the utilization crossover point, that can produce meaningful savings.

Externalizing state is a valid design. An agent can keep its context in a vector DB, an object store, or a task queue and treat every function invocation as disposable. The tradeoff is additional round-trips, careful serialization, and more application logic to debug. That tradeoff is harder to justify when state is large, changes often, or is hard to serialize. Traffic also changes the calculation, because interactive work depends on tail latency, bursty background work benefits from elasticity, and steady throughput can justify fixed resources.

What are the limitations of running AI agents on serverless functions?

Execution limits turn a continuous task into a coordination problem. Chained functions must externalize intermediate state and re-establish context at every hop. Keeping a long-lived container running on a nominally serverless platform avoids some of that work, but changes the operating model toward persistent compute. Cold starts add another source of delay. A large dependency tree or model client can slow an interactive agent before its own logic begins.

State loss is the more fundamental failure. Moving a stateful agent into functions without redesigning persistence can leave it depending on files or memory that disappear at invocation boundaries. The resulting inconsistency can take weeks to trace back to the platform model. Legacy integrations make reconstruction harder still, because a Citrix session, an EHR, or a DMS may require expensive re-authentication, and some systems rate-limit or block rapid login attempts. Keeping the orchestrator apart from a dedicated, persistent compute plane lets one direct the work while the other keeps the environment where it happens.

Why persistent microVMs are a third shape, not just a faster VM

A microVM is a substrate. Firecracker and other lightweight virtual machine monitors belong at that substrate layer, while managed services decide how to expose endpoints, suspension, scheduling, and charges. A microVM is a lightweight machine with its own guest kernel. That gives an agent root access and room to install packages or run tools without sharing the host kernel as a container does.

Snapshots connect that boundary to the three state modes. Memory and disk snapshots preserve an environment during suspension, while copy-on-write sharing lets forks reuse unchanged memory pages. A microVM can start nearly as fast as a container and still have VM-grade kernel isolation. The economics depend on the service layered above it. With per-second billing and sleep-when-idle policies, active-compute charges can stop while an agent waits, so an idle machine need not keep running up charges.

AWS announced Lambda MicroVMs on June 22, 2026, with dedicated HTTPS endpoints, memory and disk preservation on suspension, and launches from prepared snapshots. Google Cloud's infrastructure team made the category argument explicit in its Agent Compute Engine deep dive, writing that “a new form factor is needed”. Google announced the service on October 22, 2026, describing a customer preview “in the coming months” without a confirmed date or published price. Those service details are distinct from the underlying primitive.

Isolation as a first-class requirement, not an afterthought

An agent that executes LLM-generated or user-supplied code must treat that code as potentially hostile. Docker and runc share the host kernel, so a kernel exploit or container escape can expose the host and other tenants. Namespaces and cgroups do not create a separate kernel. The 2026 preprint “Quantifying Frontier LLM Capabilities for Container Sandbox Escape” documents frontier models' ability to escape containers under common misconfiguration and vulnerability conditions. For this threat model, shared-kernel isolation is not an adequate boundary.

A microVM places a hardware-enforced virtualization boundary between the guest kernel and the host. It does not remove the need for credential hygiene. AWS recommends refreshing credentials and validating network connections when a MicroVM resumes, because preserved state can include stale credentials or connections. The same trust-boundary logic supports one sandbox per task or user, since sharing a sandbox creates a path for data to cross between them. In regulated work, that separation also supports unique agent identities and isolation of protected information.

Running evals and RL rollouts at scale using snapshot-fork parallelism

When each branch rebuilds its environment, it spends time reproducing a common prefix and can introduce variance before the actual comparison begins. A warm snapshot fixes the starting point. Forking it into parallel instances lets each run work on its own while the host still shares unchanged memory pages across them. Memory use can thus grow sub-linearly as the number of branches grows.

Tree-based reinforcement learning uses the same operation on a larger scale. Algorithms such as Tree GRPO branch from intermediate states, so replaying the prefix for every branch repeats work already done. The DeltaBox paper demonstrates millisecond-level incremental checkpoint and rollback on Firecracker microVMs with 4 vCPUs and 8 GB RAM against software-engineering benchmark workloads. Those coding tasks match the multi-step environments that agent teams test. Google also states that Agent Compute Engine runs its internal model-evaluation and reinforcement-learning pipelines using memory-deduplicated snapshot forks.

Isolation remains part of this design. A documented architecture connects the forked Firecracker instances through vsock to an orchestrator and an egress proxy that holds credentials. The instances never handle those credentials directly. Standard serverless does not expose this shared-prefix fork operation, while traditional VM snapshots do not by themselves provide the same platform-level copy-on-write fork semantics.

Computer-use agents and why they mandate a full desktop environment

Some production software offers only a graphical interface. EHR systems, Citrix environments, document management systems, loan origination systems, and phone-only apps were built for people operating screens. Where retrofitting an API is expensive or impossible, the agent must use that interface directly. A shell is not enough for this work. The environment needs a display server and input controls such as mouse and keyboard injection, or touch injection for Android.

The guest environment must also match the application. Windows-only software needs Windows, while phone-only apps need an Android environment. Microsoft's UFO framework illustrates the scope through UFO² for Windows desktop agents and UFO³ Galaxy for orchestration across Windows, Linux, Android, macOS, and Web. With UFO²'s picture-in-picture virtual desktop mode, an agent can work without taking over the user's physical screen. Across these environments, authenticated sessions bring the argument back to state, because a desktop paused between agent steps must resume as the same working environment.

Regulated industries where the per-agent isolation model is a compliance requirement, not an option

Working files, browser sessions, and intermediate outputs can hold protected health information, so they must be kept apart for each patient or workflow role. A per-microVM compute boundary supports that separation. Shared-kernel containers and shared sandboxes need additional controls to provide auditable isolation. The architecture addresses a required protection, but it does not establish compliance on its own.

A production healthcare deployment also needs Business Associate Agreements with every vendor in the compute and storage stack. Role-based access controls and audit trails must allow for OCR review, and short-lived credentials must be injected at runtime and kept out of storage inside the agent environment. Each agent needs its own identity and a boundary around what it can access. In lending and insurance, DPA obligations and data residency requirements also place limits on how networks can connect. Proxied and logged outbound traffic, with credentials kept outside the sandbox, extends the boundary beyond files and memory to the systems an agent can reach.

Matching infrastructure to agent behavior — a decision framework for production teams

The first axis is task duration and state continuity. Teams should ask what must survive the end of each step. Sub-minute tasks that are stateless between steps and need no GUI fit serverless functions. Multi-minute to multi-hour tasks with working state fit a persistent VM or microVM more cleanly. Tasks that wait hours or days for approval favor suspend-and-resume with billing tied to active time.

The second axis is code execution and isolation. LLM-generated or end-user code calls for microVM-level isolation. Trusted internal code may fit containers, depending on the threat model. The source of the code should determine isolation requirements before teams optimize for ease of use or startup speed.

The third axis is the pattern of scale. Many independent, short tasks suit serverless autoscaling, especially when demand arrives in bursts. Branches sharing a prepared environment are different. Eval pipelines and RL rollouts favor snapshot-fork support, while one-machine-per-user agents favor persistent microVMs with sleep-when-idle billing. In the latter case, cost follows active use across provisioned environments.

The fourth axis is the operating system and interface. Linux-shell work leaves the broadest choice of substrate. A full Linux desktop, Windows desktop, or Android environment needs the right guest OS and display stack, and teams must check that a microVM service supports the environment they need. That requirement can narrow the options before price enters the discussion.

Teams should choose from the agent's behavior even when infrastructure is already on hand. Starting with the cloud default can lead to complex workarounds for persistence, while starting with familiar VMs can leave teams with more upkeep than they need. Persistent VMs versus serverless is therefore a false binary. MicroVMs add a third shape whose value comes from preserving, suspending, and branching the environment the agent actually uses.

Diagram: Four Axes for Choosing Agent Infrastructure. Visualizes: Visualize the four-axis decision framework for matching infrastructure to agent behavior.

More in Agent Hosting Economics