Designing AI Agents

Agent State Persistence Across Sleep and Redeploy Cycles

Long-running agents need separate durability guarantees for memory, checkpoints, files, and secrets.

· 9 min read
Cover illustration for “Agent State Persistence Across Sleep and Redeploy Cycles”
Persistent Agents · October 20, 2026 · 9 min read · 1,975 words

Persistent AI agent infrastructure differs from serverless functions by preserving an agent’s work beyond any single invocation. Agent State Persistence Across Sleep and Redeploy Cycles explains why that requires separate guarantees for conversation memory, checkpoints, tool outputs, working files, and credentials. Durable workflows protect task progress, VM snapshots preserve the working environment, and secret injection restores access without embedding credentials in saved images.

Why agent state is not a single thing

An onboarding agent pauses while it waits for a document to be signed and wakes three days later to find it has lost everything. It no longer knows which approvals arrived, where it saved the welcome packet, or whether it already sent an email. Replaying the conversation might recover some context, but it cannot reliably establish what happened outside that conversation. The failure is structural because LLMs are stateless by design, while the work agents perform is not.

A context window is temporary and ends with the session or runs out of room as the conversation grows. Durable state is the case file that survives that boundary, including completed steps, pending approvals, and previous attempts. Losing different parts of that file produces different failures, from repeated questions to missing documents or duplicated side effects. This is why long-running agents fail when deployed as stateless functions without a persistence architecture. A larger context window does not repair the missing durability boundary.

The five layers of agent state and what each one requires

The useful operational map has five layers, namely conversation memory, task checkpoints, tool outputs, files and artifacts, and credentials and config. Conversation memory holds the message history, what the user prefers, and decisions already made, and needs low-latency reads on every inference call. Task checkpoints record the current step, remaining steps, and branch decisions so that recovery resumes from the recorded position. Tool outputs keep the results of API calls, searches, and computations so that retries do not redo work that costs a lot or is rate-limited.

Files and artifacts are the documents an agent creates, outputs from steps along the way, and large payloads that need a home that lasts after the process stops running. Credentials and config supply API access and settings, but secrets require injection from a separate store and must remain outside the agent’s persistent state. These layers differ in access pattern as well as durability, since archival artifacts can tolerate slower reads while credentials are typically read at boot. They also answer different questions, such as what the user prefers, which step comes next, and where the completed document lives. An explicit state schema keeps those answers separate instead of asking the model to infer them from old messages.

How workflow-layer persistence protects conversation memory, checkpoints, and tool outputs

Durable execution protects the layers above the compute boundary by journaling each step before it runs and recording its result when it returns. That record lets the workflow survive a crash, retry, or long pause without treating every resumption as new work. Consider a payment that has already completed before the workflow resumes. The required exactly-once guarantee ensures that replay uses the recorded outcome and issues the payment only once. An email send has the same requirement, since replaying it can produce a duplicate message.

A checkpointer alone does not establish that guarantee. Saving conversation state, graph position, or a serialized approval gate is not the same as protecting side effects across replay. Inngest uses step memoization, persisting completed results and injecting them when a function re-executes so that completed steps are skipped. AWS announced Lambda Durable Functions in December 2025 with steps, waits, checkpoints, replay, retries, and long suspensions. The relevant comparison is therefore not simply persistent infrastructure versus anything called serverless, but which durability guarantees the execution layer actually supplies.

Durable waits also separate workflow lifetime from the lifetime of a running thread. Google’s ADK tutorial demonstrates an event-driven dormancy gate that suspends an onboarding workflow until an approval arrives, leaving the thread free and eliminating polling. The workflow remains unfinished, but the wait consumes no orchestration compute. That distinction makes human-in-the-loop work economically practical when a response takes hours or days.

How VM-level snapshots protect working files, running processes, and compute state

Workflow-layer persistence cannot protect the compute environment itself. Its journal does not keep the installed packages, a browser session that is running, process memory, or the filesystem that holds a repository after edits. VM-level snapshot-restore complements durable execution by preserving the environment in which the recorded work takes place.

Firecracker restores a snapshot by memory-mapping the snapshot file, loading CPU state, and resuming execution where it stopped. It does not boot a kernel, run init, or restart the agent process. An agent editing a cloned repository or building a vector index can therefore retain its working environment without reconstructing it from workflow records.

Maritime gives each agent an isolated Firecracker micro-VM on bare metal, with a persistent disk, a real kernel, package installation privileges, and browser sessions. The isolation boundary also differs from a shared-kernel container because crossing it requires a guest-to-host break through KVM or Firecracker itself. Persistent disk protects files across sleep and redeploy, while snapshot-restore protects suspended execution. Neither role replaces the workflow journal’s record of completed actions.

Snapshot-restore scheduling as the mechanism that makes idle cost near zero

With a large fleet, keeping every agent fully booted makes the compute bill grow with the total number of agents, even when they have no work to do. That is a poor fit for agents that spend most of their time waiting on users, tools, or other processes. Snapshot-restore scheduling changes the unit of paid compute from an allocated agent to an active agent. An overnight wait for a signature then incurs only storage costs.

The scheduler hibernates an idle agent by saving its memory and disk state and stopping compute billing. On the next request, it restores the saved environment with files, processes, and memory in place. Restore’s initial time and RAM cost follow only the pages the guest touches between resume and readiness.

Under Maritime’s scheduling model, the flat rate works out to roughly $1 per agent per month because costs track when agents are in use. That price reflects how the scheduling model works, with storage costs still in place. Keeping one persistent agent per end user is easier to afford when idle agents use only storage and release reserved compute. Each user can keep an isolated workspace even when it stops running during a pause.

What wake latency requirements mean for the restore path

For a user-triggered agent, sub-second wake is a product requirement because a delay of several seconds can make the agent feel unresponsive. The restore path must therefore avoid the startup work that dominates a cold boot. Memory mapping supports that goal by demand-faulting pages as the guest needs them, deferring the cost of loading untouched pages.

Maritime reports a median of 674 ms on Firecracker and describes agents as waking in about a second. That is an observed characteristic without a formally stated product guarantee. The distinction matters because a measured median does not establish a bound for every wake. Even so, a restore path built to respond in sub-second time lets agents hibernate more often after short idle periods. That leaves less need to keep agents warm just so users do not have to wait through startup latency.

Durable state storage options for the layers snapshot-restore does not cover

A VM snapshot preserves an execution environment, but it is not the right store for every artifact an agent produces. Large amounts of conversation history, shared operational records, large files, and semantic memory need to be accessed from beyond one VM. Storage selection therefore follows the layer’s role, how often it is read, and whether other agents need the same data.

A mounted volume is a good home for working files, checkpoints, and small local databases such as SQLite. It offers low latency and a simple local interface, but remains tied to one machine unless networked storage is used. Databases such as Postgres, MongoDB, and Redis fit conversation history, task queues, job status, and per-user memory. Shared records also require queries, transactions, and a consistent view when multiple agents touch the same data. Without that coordination, agents that try to work together can cause race conditions.

Object storage such as S3, Cloudflare R2, and GCS fits large downloads, archival artifacts, and backups of vector indexes. Its higher latency makes it a poor match for state read on every inference call. A checkpoint file serves a narrower purpose by serializing task progress to a volume or object store after a completed step. External memory services such as Pinecone, Weaviate, and Qdrant provide semantic retrieval at scale, at the cost of another dependency. Each additional store also creates another place where related state can drift out of sync.

For an isolated agent, including one deployed by Maritime, persistent disk is the natural home for working files and local checkpoints. Conversation memory can live in local SQLite or Redis if that suits how it is read and written, while larger archives live elsewhere. Persistence still fails operationally if the agent never loads the saved state again. On boot, a durable agent should check for unfinished work and existing memory before beginning new work.

Credentials and secrets as a special case requiring injection, not persistence

Credentials differ from every other layer because surviving redeploy does not mean copying them into the agent’s saved environment. A secret embedded in a disk image or snapshot can be extracted from that artifact. The appropriate pattern is injection from a secret store at boot or wake, rather than letting the agent write credentials to its own persistent disk. A mounted credential store can provide startup access without making the agent’s working directory the source of truth.

Fresh injection also allows a rotated or revoked credential to take effect on the next wake without rebuilding the VM image. Copy-on-write forks make this distinction more important because a credential baked into the parent snapshot would travel into every child. Per-agent VM isolation supplies a separate protection by placing a kernel boundary between one agent’s secrets and another agent’s execution environment. Snapshotting alone does not satisfy both requirements.

How the layers compose into a complete sleep-and-redeploy cycle

At sleep, the workflow engine first journals the current step and marks the thread suspended. The VM snapshot then captures process memory, CPU state, and the working environment, with durable storage protecting files and in-progress artifacts. Conversation memory and tool-call history already saved to the durable backend do not need to be written again just because sleep begins. Credentials remain outside the snapshot and are supplied again at wake. Compute billing stops while storage billing continues.

At wake, a user message, event signal, or timer reaches the scheduler, which restores the snapshot through memory mapping. Fresh credentials are injected from the secret store. The workflow engine then picks up from the journaled step and uses saved results without making completed tool calls again. Working memory is reconstructed from the durable backend as needed, without replaying the full conversation to guess the task’s position. When the agent needs to boot instead of using snapshot resume, it still recovers from the durable checkpoint and saved files.

Google’s ADK onboarding example demonstrates the workflow portion of this sequence. The agent sends a welcome packet, suspends at an event-driven gate while documents are signed, and resumes at IT provisioning days later. VM snapshots extend that continuity to the process and working environment beneath the workflow. Together, these mechanisms preserve what was said, what was done, what was produced, and where execution stopped, while restoring access separately. When the restore path meets the latency requirement, the user sees the intended result, an agent that wakes in under a second without losing a step.

Sources

  1. Build Long-running AI agents that pause, resume, and never lose context with ADK - Google Developers Blog

More in Persistent Agents