Suspend and resume agents by checkpointing the actor’s memory and filesystem to object storage, freeing the worker slot, then restoring that snapshot onto any free worker when the next request arrives. Kubernetes has no Pod primitive for this; Agent Substrate is the runtime I run that does it. A Deployment restart is not the same thing: it kills the process.
You are not pausing a Pod. You are parking an actor. The worker is a bay. The snapshot is the agent. I have watched this on a two-worker pool: the actor leaves the bay, lands on the shelf, and comes back on the other worker for the next turn. Substrate Scope makes that visible. kubectl is lying to you if you try to see it with get pods.
What is the suspend and resume lifecycle for agents?
Four steps. If you skip the last one, you have a pod with extra machinery.
- Golden snapshot. First reconcile runs the image, waits for ready, checkpoints. In my kagent lab that took about a minute per agent. Do this once. The published lab baked nine of them that way. Change the model later and you re-bake: golden snapshots freeze the resolved model config.
- Restore. A request arrives, a free worker takes the snapshot, the actor is live. One actor per worker. Always, in what I have run.
- Turn. The agent talks to the model and tools. This is the only window it holds a slot.
- Checkpoint. Session ends, or you suspend between tool calls if that is the policy. Bytes go to object storage. Slot frees.
Idle policy is part of running Agent Substrate in production. If nothing ever parks an idle actor, workers stay warm and you have paid for density you are not taking.
On the laptop cluster the density was real because this loop actually ran. Nine agents on two worker pods in the first lab, then 18 on the same two workers later, over a thousand real chat sessions, reserved capacity about 4.5x lower than the same agents as always-on pods. Each of kagent’s default always-on agents held about 204 MiB resident and requested 50m CPU while doing nothing. Nine of those is roughly 1.8 GiB and 450m CPU reserved around the clock. Suspended actors do not hold that reservation.
Worker-0 in that cluster served 50+ sessions across nine different agents in an afternoon. That is time-multiplexing, not packing two shells into one sandbox.
Where does agent state go when you suspend it?
Yours. Object storage you control. Not the node’s disk. Not emptyDir.
I want a hard line: Substrate decides what moves and when a snapshot is committed. The storage implementation moves bytes idempotently and proves integrity. If the runtime also hashes and also retries puts, you will debug the same incident in two repos.
Agent checkpoint to object storage is the storage post. The drill is the same here, because without it you do not have suspend and resume. You have a backup script:
- Send a turn. Record the session id and a workspace file the agent wrote.
- Suspend on node A. Confirm the worker is free. Delete nothing in Kubernetes except by parking.
- Restore on node B, or on the other worker in a two-pod pool.
- Confirm the workspace files and the session id. Same session, different bay.
If step 4 fails, stop. Do not scale the pool. Fix restore first.
This is the same split Ramp described as sandbox-as-a-tool: the session record lives in durable storage, the compute is a fixture you can swap. I wrote that as the sandbox is the fixture, not the record. Substrate’s snapshot is a thicker record than a conversation row in Postgres. It is still a record. The worker is still a fixture.
What should you leave out of an agent snapshot?
Secrets. A checkpoint is a copy. Copies leak. Mint credentials at restore via proof of agent identity. If the actor still holds a cloud key across a checkpoint, you have serialized a secret into the bucket. If it holds a user OAuth refresh token, you have stored the user’s session next to the snapshot. I want the actor to start empty and ask the exchange for a credential scoped to this turn.
GPUs. GPU memory is not a filesystem. The runtime checkpoints process memory and files the sandbox owns. GPU memory lives on the device. If the actor held the GPU, suspend would drop that state or pin the device, which is the opposite of multiplexing. I keep inference outside the actor. GPUs for agents on Kubernetes.
The live TCP session to a slow tool. Suspend cuts the connection in the versions I have run. The worker is gone, the netns is gone, the peer sees a reset. If the agent is waiting on a long call, I do not suspend it. Suspend-safe networking. Drain, then park. Finish the tool call. Checkpoint. Free the slot. The next turn restores cold to the network and dials again.
gVisor-managed state is a better story than I expected. I tried to break checkpoint with an exclusive flock(). It survived: 550ms, no error, lock intact, because gVisor’s sentry already virtualizes flock() as sentry state, not an entry in the host kernel’s lock table. Writeup. That did not make me reckless. It made me more precise about what the sentry does not own: hostNetwork sockets, bind-mounted host devices, shared memory held with a process outside the sandbox. Those are the class I still would not put in a snapshot.
What tradeoffs does suspend and resume force?
Restore latency versus reserved RAM. You pick. Warm workers exist so restore is not a cold container start. They still cost a pod. Size the pool to simultaneous sessions, not to total agents. How many agents per Kubernetes pod is two numbers: live sessions equal workers, registered agents equal snapshots. If every agent is busy, the ratio collapses to 1:1 and you should have used a pod per agent.
I would not promise a restore SLO I have not measured on your snapshot size. Golden bake was about a minute. Later restores are better and still not free. On the laptop lab, after switching the model off a local 4B, sessions went to 1.5 to 2 seconds end to end, restore included. That number is mine, on that cluster, with that model. Do not copy it into a customer SLA.
The other tradeoff is resume races. Two requests for the same agent, one slot. The runtime I have used does not queue at the pool. When it is full you get substrate worker pool has no free workers. Your caller retries. Whoever lands first wins. That is packing, not scheduling. I wrote the gap in agent runtimes have an autoscaler, not a scheduler. Put a session lock in the control plane if “the same agent, two places” is a correctness bug.
A third tradeoff sits in idle policy. Suspend between turns when the human is idle. Do not make it a religion on every exec until you measured it. Maximum density wants a park after every tool call. Restore then has to be fast enough that a cat does not feel like a cold start. Long-lived environment, suspend on idle only, is easier on the network and holds a slot while the human thinks, which is the cost Substrate exists to avoid. Idle timeout is the compromise. That is the Agent Substrate environment question.
How do you test suspend and resume before you trust it?
A checklist I would actually run, using only behavior I have already seen:
- Golden path. Apply the agent. Wait for the golden snapshot. Confirm the actor is parked and the worker is free.
- Cross-worker restore. Turn on worker A. Park. Restore on worker B. Same session id, same workspace files.
- Secrets stay out. After restore, the actor can call the exchange. The snapshot object does not contain the long-lived key.
- No mid-call park. Start a slow tool. Confirm the policy does not suspend until the call returns. If you suspend anyway, expect a reset, not a resumed TCP session.
- Full pool. Fill both workers. Third resume is rejected. Caller retries. No second copy of the same actor.
- Ghost slot. Kill a session mid-flight. If the pool says
no free workerswhile it looks idle, reset the WorkerPool. Snapshots survive because they were never in the pods. Ghost actors pin your workers. - Watch the right list. Assignments come from the workers list, not the actors list. Finished sessions leave Suspended entries behind. Mine passed 900 in a day.
If you cannot do the cross-worker restore in a lab, you do not have suspend and resume. You have a process that happens to write files somewhere.
Field guide: Agent Substrate.