Designing AI Agents

Why Serverless Functions and Shared Containers Break Down for Per-User Persistent Agents

MicroVMs with checkpoint and resume fit agents better.

· 8 min read
Cover illustration for “Why Serverless Functions and Shared Containers Break Down for Per-User Persistent Agents”
Per-User Agent Patterns · December 2, 2026 · 8 min read · 1,820 words

Per-user persistent AI agent deployment at scale needs an isolated machine for each user, with state that survives idle gaps and execution that resumes mid-task. Serverless functions break that continuity through timeouts and stateless resets, while shared-kernel containers leave the wrong security boundary for untrusted code. The right architecture combines machine-level isolation with checkpoint and resume, then matches the machine’s lifetime to the task.

Why per-user persistent agents are architecturally different from the workloads serverless was built for

A request handler takes in work, returns a result, and ends. A persistent agent has a different lifetime. It waits for a model reply, operates a tool, keeps the result, and decides what to do next. The agent may make many calls and wait between them, but it is still working on the same task. It must keep its filesystem, context, and unfinished work through those gaps.

Persistence is only half of the requirement. An agent serving one user must also keep that user’s state inaccessible to other sessions, including while it runs tools or executes code. Meanwhile, most of its elapsed time goes into waiting for the model. Together, these needs change what the platform must provide, because it can have CPU to spare and still have no isolated environments free. The mismatch is architectural.

How execution timeouts terminate agents mid-task on every major serverless runtime

A serverless execution limit applies whether the agent has finished or not. Common serverless functions cap a single invocation or request at 5 to 60 minutes. Multi-step retrieval pipelines, GUI automation, and long reasoning chains can run for several minutes, putting them against those limits. Waiting for a model does not make unfinished work safe from termination.

When the function terminates, its volatile memory disappears. Any intermediate context, partial tool output, or reasoning state that was not explicitly written elsewhere is lost. The runtime’s timeout ends execution without preserving a resumable version of the process.

The exact limit changes how soon this happens. It does not change the failure mode. A workflow that fits comfortably today may need more tool calls or a longer reasoning chain on another task, so successful short runs do not establish continuity. Recovery requires the developer to write application code that saves enough information outside the function to reconstruct the work.

Why stateless resets force agents to re-hydrate context on every step, compounding latency and cost

Finishing before the timeout avoids termination, but not statelessness. When each reasoning step runs as a separate invocation, the next step cannot depend on the previous invocation’s memory. It must reload the conversation and other saved context from an external store before continuing. The agent pays this reconstruction cost repeatedly. State survives only because the application moves it outside the process that uses it.

Render describes serverless functions as systems that “spin down after handling a request and retain no in-memory context.” This forces each turn to read state from an external database, which adds latency. As the conversation grows, the context that must be serialized, restored, and sent to the model grows too. The overhead is not a one-time startup penalty. Stateless execution adds reconstruction work to an already expanding conversation payload.

Render notes that maintaining a WebSocket connection to a serverless function is not supported on platforms like Vercel. Developers must then assemble separate services for saved state, background tasks, and the API layer, such as a database and a message queue around the function. Debugging crosses those service boundaries as well. The application is now responsible for stitching a continuous agent out of components designed to end.

The environment-scarcity problem that emerges when every session holds its own isolated slot

Diagram: Idle vs. Active: The Environment-Scarcity Gap. Visualizes: Visualize the utilization mismatch measured in the study 'Held While Waiting': agents on Amazon Bedrock AgentCore waited a median of 2.7 seconds per model reply but computed for…

Mekhala Hithyshini Sreenivasa’s study, Held While Waiting, measured agents on Amazon Bedrock AgentCore waiting a median of 2.7 seconds for each model reply, then computing for only a few milliseconds per step. The author did the work independently of Amazon despite an AWS affiliation. A session holds onto its environment for the whole wait, even though it barely uses the processor.

Only a handful of every thousand held environments may be using a processor at any moment, yet every session still needs its reserved space. The platform can run out of environments while CPU remains available. More compute does not directly solve that shortage. The scarce resource is the isolated slot.

The same study surveyed nine agent runtimes and found that AWS and Microsoft runtimes dedicate an environment to each session. Google’s runtime shares environments only when agent code is asynchronous, while the runtimes that share by default are general-purpose platforms. Sharing is an obvious way to improve utilization. But when agents run tools and code chosen by the model, putting sessions together changes the security boundary. Efficient packing cannot be separated from who can reach whose state.

Why shared-kernel containers cannot give each agent the isolation boundary it requires

Containers use operating-system controls to limit what processes can do, but those processes still share a host kernel. A flaw in the kernel, an unsafe mount, or too much privilege can let one session reach another session’s data. The shared-kernel boundary becomes especially important when the workload runs shell commands or code selected by a model rather than only a known, static application.

A virtual machine adds an isolation boundary at the hardware level. Each guest has its own kernel instead of relying on process restrictions around a shared one, which gives agent execution a stronger separation from other sessions. That boundary does not replace careful configuration. Running restricted containers inside a VM, with orchestration and secrets outside the execution environment, acknowledges the same need for another layer.

Regulated workloads make these choices harder to ignore. HIPAA’s Security Rule includes access controls that fit users’ roles and audit controls for systems that handle electronic protected health information, while its addressable implementation specifications cover encryption in transit and at rest. Those obligations reach into infrastructure design. Per-session isolation is a widely recommended practice derived from access-control and minimum-necessary principles. A container boundary alone is neither a substitute for those controls nor evidence that a deployment meets them.

What microVMs with checkpoint/resume actually provide that containers and serverless do not

A checkpoint preserves the machine, including the application’s saved records. For a Firecracker microVM, that includes filesystem contents, guest memory with kernel and process state, and device and virtual CPU state. Restore memory-maps the snapshot file, loads the CPU state, and resumes execution from the captured position. The guest does not reboot.

AWS announced Lambda MicroVMs on 22 June 2026. The service gives each user or agent session a Firecracker microVM that starts from a snapshot, suspends when idle, and resumes with memory and disk intact for an extended period. Suspended machines incur only storage charges. Google described Agent Compute Engine on October 22, 2026, with a microVM for every agent session, checkpointed while the model thinks and cloned copy-on-write from warm snapshots.

Suspension connects persistence to efficient use of resources. In this model, an idle VM is saved as stored state and frees a live environment slot under the quota, so sessions doing work can use that capacity. For reinforcement-learning rollouts and evaluation pipelines, incremental checkpoints add another advantage by capturing only changes between nearby states. Those checkpoints can be made during inference time and allow rapid rollback without capturing the whole machine each time.

How does a machine per user or task fit persistent agents, swarms, and regulated desktops?

A long-lived personal agent needs to keep its work across hours or days. Its environment must survive model calls, tool use, and pauses between interactions without discarding the work already underway. Sleep and resume fits that lifecycle. Human takeover also depends on a persistent, addressable machine, because a person needs to enter the agent’s desktop to correct or redirect it. A stateless invocation provides no equivalent place to step in.

Swarms invert the lifetime requirement without weakening isolation. Their tasks may be short and disposable, but thousands of independent sandboxes can be needed in bursts, each deleted when its rollout ends. Published agent reinforcement-learning setups run hundreds of rollouts in parallel with the model served on separate GPUs. The sandbox layer must keep pace. Provisioning or teardown queues can stall the training loop even when the model-serving layer is ready.

These rollouts also need non-preemptible execution. A sandbox lost to eviction forces its rollout to run again, which directly slows training. Spot-priced serverless compute introduces exactly that failure mode. The relevant unit is therefore an independent machine for each task, with a lifetime long enough to finish that task.

Epic Hyperspace accessed through Citrix or VMware Horizon presents a visual stream rather than inspectable DOM elements, so the agent must operate the interface as a person would. In an enterprise hospital environment, that requires a dedicated Windows VM or Citrix worker node with access to the EHR environment. The desktop is the bridge to the application. Sharing it across users or tearing it down between steps breaks the required session boundary and continuity.

Healthcare controls also shape that desktop’s lifecycle. HIPAA requires audit controls for PHI access under §164.312(b), while §164.312(a)(2)(iii) makes automatic termination of user sessions that are inactive an addressable specification. The infrastructure must support those controls as well as the application policies.

Choosing the right machine type for the job — persistent boxes, throwaway sandboxes, and swarms

Diagram: The Three Machine Types and Their Lifetimes. Visualizes: Show three distinct agent deployment patterns as a ranked or segmented comparison, using the article's own categories and their defining traits.

A persistent agent box suits an agent that serves one user, keeps signed-in browser sessions, operates scheduled tasks, or needs human takeover. It should sleep when idle and resume with its state intact. Billing by the second of active use matches that behavior, with only storage charges while suspended.

A throwaway sandbox fits untrusted or model-generated code whose state must not survive task completion. Its disk is deleted with the VM, so the execution environment does not retain task residue. Its lifetime ends with the job. A swarm applies that disposable model to many parallel rollouts, evaluations, or batch tasks, and requires provisioning and release at burst rate without queues that stall the pipeline. Non-preemptible execution is an additional criterion where losing a rollout means repeating it.

These choices also define the cost structure. A throwaway sandbox charges for its task duration, while a swarm accumulates per-second charges across concurrent instances. Neither has the same resource pattern as an always-held container node pool, and a sleeping persistent box does not behave like a series of independent function invocations. Pricing should follow the workload’s actual lifetime.

For teams choosing a managed platform, support for all three machine types is a practical criterion. The customer can bring the model and keys while the platform handles the computer’s isolation, persistence, and scaling. Regulated deployments also need the right network configuration, pre-installed application images, and infrastructure for compliance. Those requirements remain distinct from simply offering a VM. The platform must preserve the right state, behind the right boundary, for exactly as long as the work requires.

Sources

  1. Held While Waiting: What LLM Agent Sessions Reserve on Serverless and Agent Runtimes

More in Per-User Agent Patterns