Browser Session Persistence Inside Agent VMs
Persistent VMs with durable storage let browser agents keep their login state across turns.

Browser Session Persistence Inside Agent VMs addresses the choice between persistent AI agent infrastructure and serverless functions. Browser agents need an execution environment that preserves their full profile. An isolated VM with a persistent disk provides that foundation, while snapshot-restore lets the agent stop consuming compute without discarding its session.
Why browser session persistence is an infrastructure problem, not a browser configuration problem
An agent was logged in yesterday but is logged out today. The browser may have done nothing wrong. Chromium writes cookies, localStorage, IndexedDB, and site preferences to a profile directory, but that work is lost if the execution environment discards the directory. Asking the agent framework to make up for this with cookie exports or credential reconstruction puts the fix in the wrong layer.
The distinction is between a session for one run and a profile that survives across runs. A durable profile gives the browser continuity across process boundaries, provided the next run reuses it. Yet several failures can look like the same lost login, including a directory that was not reused, a session cookie that was never flushed to disk, a profile locked by another process, or a site's own session expiration. These need different remedies. Infrastructure can preserve browser state, but it cannot make a site's authentication remain valid indefinitely.
What Chromium actually writes to disk, and why a process boundary erases it
Playwright's storageState() exports cookies with the fields name, value, domain, path, expires, httpOnly, secure, and sameSite. It also exports per-origin localStorage key/value pairs, with optional support for IndexedDB and passkeys. This is useful, but it is not a profile. Browser extensions, site preferences, cached device fingerprint signals, sessionStorage, and state outside the serialized origins array are not included in that export.
Sites that bind authentication to more than cookie values expose that gap in the exported state. The TLS fingerprint, installed font set, and canvas rendering can affect whether a restored context looks like the client that signed in. Valid cookies alone do not guarantee acceptance. A full Chromium user data directory preserves the browser's disk-backed state, while a consistent execution environment avoids rebuilding the session inside what appears to be a different machine. Copying JSON addresses neither requirement completely.
Playwright warns that an exported state file “may contain sensitive cookies and headers that could be used to impersonate you or your test account”. The file therefore needs password-grade handling. It should never enter a repository or be exposed in agent context. Serialization does not reduce the sensitivity of the credentials it contains.
A standard Playwright context does not provide a durable profile that remains available after the process ends. A persistent context using userDataDir changes that only when the directory itself survives. The path is not the persistence guarantee. A container's disposable local filesystem or a function's ephemeral scratch disk can vanish with the compute unit, and a shared volume alone does not give one agent sole ownership of the profile. A full profile on durable storage addresses preservation without requiring an application to enumerate Chromium's state.
Why do long-running browser agents fail on serverless infrastructure?
Stateless infrastructure treats a completed invocation as permission to reclaim resources. A browser agent may instead need the same resources for its next conversational turn. Those lifecycles are not interchangeable. A browser can be configured for persistence and still lose its working session when the surrounding task cleanup destroys it.
NousResearch/hermes-agent issue #11020, opened in April 2026, documents this collision. At the end of every agent turn, _cleanup_task_resources unconditionally called cleanup_browser(task_id), killing the browser window immediately after every reply. The hook served the Morph sandbox backend, where ephemeral VMs needed teardown to prevent leaks. That was a legitimate resource-management goal. Applied to headed and persistent local-browser workflows, however, it destroyed login state, open tabs, and in-progress sessions regardless of inactivity timeout settings.
The project's fix, commit 5988fe6 and PR #67018, reached main in September 2026 and skips cleanup after each turn when headed mode is active. The broader proposed approach was to gate cleanup on a persistence flag or infer persistence from a CDP URL or profile path. Per-turn teardown had been designed for ephemeral workloads, then applied to a workflow whose useful state extended beyond the turn.
Serverless and container deployments expose the same mismatch when scale-down, pod eviction, or function timeout reclaims a disposable filesystem. Managed remote-browser services have a similar limit when the provider sets idle timeouts. Once the session expires, the next request gets a fresh browser with none of the old tabs or login state. Teams then face an expensive trade. They can keep browser instances running or spend multiple minutes on re-authentication on cold wakes and keep a recovery layer outside the sandbox.
Why a persistent disk inside an isolated VM removes the entire class of failures above
A VM with its own persistent disk answers the disposable-filesystem failure directly. Chromium writes its profile to storage that outlives the agent process, so a process restart does not require rebuilding that profile from JSON. The disk remains the source of continuity. After an agent crash, a new process can find the same profile, and where the browser session remains alive, it can attach and continue.
With one VM, one agent, and one profile, parallel agents do not compete for the same profile directory or silently overwrite a common state file. Extensions, credentials, cached device signals, and the full user data directory stay together without having to choose which parts to export. This preserves the stored client state instead of approximating it. It does not override a site's decision to expire or revoke authentication, nor does a persistent disk recover data that was never written.
The VM lifecycle also need not end with each conversational turn. That separation removes the reason for the per-turn browser teardown illustrated by the browser lifecycle issue. Resource reclamation can happen at the VM scheduling layer without treating each reply as the end of the browser's useful life. Conversation boundaries stop being destructive storage boundaries. Keeping an open, running browser while it is idle then becomes a matter of scheduling, with no need for serialization.
VM isolation adds a boundary for agents that install packages, run arbitrary code, or run into browser exploits. Each agent runs within its own guest kernel, which it does not share with other agents. The boundary is broader than a browser process. Hardware virtualization separates the guest from the host and other VMs, so a compromise inside one guest does not itself grant access to another agent's profile.
The snapshot-restore scheduler as the economic answer to always-on browser VMs
A VM per agent looks costly if every VM must keep running to keep its state. Snapshot-restore breaks that assumption by separating the cost of keeping state from the cost of executing work. When an agent becomes idle, the running VM is snapshotted to disk and compute stops. On the next message, the scheduler restores it. The browser profile, open tabs, and authenticated state resume from the snapshot.
Idle storage is orders of magnitude cheaper than active compute, so a parked agent pays to keep its state without paying for compute it is not using. Storage still has a cost. The economic change is that idle cost trends toward zero compared with keeping the VM active, especially when agents spend most of their time waiting between tasks.
Always-on operation spends money to minimize wake latency, while a cold start saves idle compute at the expense of rebuilding the execution environment. Hibernate-and-wake occupies the middle ground. Snapshot restoration can operate well below cold-boot times, with latency dominated by guest memory pre-touch and device re-attach.
The DeltaBox paper, submitted in May 2026 and revised in June 2026, explores this direction at the research stage. It observes that consecutive sandbox states between checkpoints differ only slightly and proposes checkpointing the changes. It is research, not evidence of a deployed service. It aims to make execution state cheaper to keep and faster to recover, which helps lower the cost of many per-user agents that sleep between tasks.
Per-user agents with persistent browser sessions as a product primitive
An e-commerce inventory checker needs to come back each day as the same authenticated user. A social media agent needs to wake for a scheduled post without turning every posting window into a login workflow. A customer-service agent needs continued access to an authenticated dashboard. These are product requirements. They all need a browser identity for each user that stays available between tasks.
One isolated VM for each user gives that identity a home that lasts. Separate disks and browser processes prevent agents for different users from locking one another's profiles or corrupting shared session state. Concurrency follows from separate ownership rather than a coordination protocol around one browser. The user boundary and storage boundary align. That alignment lets a product associate each user's work with a specific profile instead of choosing which fragments of browser state to restore before every action.
Session establishment then has a clear division of responsibility. A human signs in, handles credentials, MFA, and bot checks, and leaves the resulting profile on the VM's persistent disk. Later agent runs use that same profile as long as the site's session is valid. A human may still need to step in when the site's session expires, which differs from an infrastructure reset that forces a login after every run.
Adding a user becomes a provisioning and scheduling task, with a VM created from a template and restored when needed. Until the agent becomes active, its cost is primarily storage. Shared browser instances or exported JSON profiles would reintroduce the ownership and completeness problems this model avoids. For products that depend on these guarantees, the infrastructure unit must match the user-specific agent.
What to look for in browser agent infrastructure that actually preserves sessions
For teams evaluating infrastructure, the first criterion is a dedicated, durable profile directory. The distinction is concrete. A full Chromium user data directory preserves extension state and cached device signals that a storage-state export omits. Filesystem durability and exclusive profile ownership should be evaluated separately, because retaining a directory does not make concurrent access safe.
The next criterion is session-to-compute decoupling. A platform should make clear what happens to the browser when a task finishes, compute scales down, or an idle timeout is reached. “Persistent” needs a lifecycle definition. A surviving session that a new agent process can attach to is different from a saved profile used to launch another browser, and both differ from reconstructing a context from cookies. The product's requirements determine which continuity it needs.
Continuity across a fleet must be affordable under the idle cost model. Always-on billing pays for compute while an agent waits, whereas snapshot-based parking pays for stored state until work resumes. Wake behavior belongs in the same evaluation. A low idle bill that comes with cold-browser reconstruction on every return gives a different result from resuming the existing VM.
Isolation and access complete the evaluation because retained credentials need both a security boundary and a way to diagnose failures. A separate guest kernel gives a different boundary from process-level separation in a shared runtime. Profile portability is equally concrete. Full-directory upload, download, or migration, together with SSH or filesystem access, lets developers inspect the actual browser state.


