Agent checkpoint to object storage: whose bucket, whose integrity

Part of: Agent Runtimes

Agent checkpoint to object storage is how Agent Substrate parks RAM and disk. The runtime should decide when to commit. The storage path should own integrity.

Agent checkpoint to object storage is how Agent Substrate parks an actor’s RAM and disk so the worker slot can go to someone else. The runtime should decide what belongs in the snapshot and when that snapshot is the committed one. The storage path should move the bytes, retry idempotently, and prove what it stored.

I treat that split as a contract, not a bucket name. Mix those jobs and you will debug a 403 in the control plane logs. The lifecycle that produces the object is suspend and resume agents. This post is the object.

In the lab the snapshots were compressed zstd blobs in an in-cluster store. Production is a bucket you already operate. The worker is a fixture. The snapshot is the record. That is the same lesson as the sandbox is the fixture, not the record, written onto object storage instead of a conversation table.

What belongs in an agent checkpoint, and what does not?

Process memory the sandbox owns. Filesystem the actor was allowed to write. Nothing else on purpose.

I tried to break it with an exclusive flock(). The actor opened /data/pinned.lock, took fcntl.flock(lock_fd, fcntl.LOCK_EX), and served a tiny status endpoint. Applying the ActorTemplate made the in-cluster controller drive a one-time golden-actor lifecycle: boot, checkpoint, snapshot. Both the lock-holding actor and a no-lock control checkpointed with err=null. The lock-holding run took 550ms on that cluster. The lock was sentry state, not the host kernel. Writeup.

That made me more careful, not less. gVisor’s sentry is a user-space reimplementation of the Linux interface, including file locking. A flock() inside the sandbox never touched the host lock table, so it serialized like any other sentry-managed resource. I set out to test “a resource that cannot be checkpointed” and tested a resource gVisor had already made checkpointable by construction.

Keep out:

  • Long-lived secrets. A checkpoint is a copy. Mint at restore with proof of agent identity, not at rest in the object.
  • GPU memory. It lives on the device. GPUs for agents on Kubernetes. If the actor held the GPU, suspend would drop that state or pin the device.
  • “The whole node.” HostNetwork sockets, bind-mounted host devices, shared memory with a process outside the sandbox. None of those were the flock() experiment. They are the next class I would test, and the class I would not put in a snapshot today.

The workspace the agent writes is the snapshot filesystem. If you add a second storage story “for files,” you will desync from checkpoint. That is why the Agent Substrate environment API should read and write the same tree the snapshot captures.

How do you prove a checkpoint actually restores?

Suspend on node A. Confirm the worker is free. Delete nothing in Kubernetes except by parking. Restore on node B. Confirm the workspace files and the session id.

If you cannot do that in a lab, you do not have checkpoint. You have a backup script.

On a two-worker pool the same drill is: turn on worker-0, park, restore on worker-1. I have watched an actor leave one bay and come back on the other. kubectl get pods will show two calm workers the whole time. Watch the workers list, or watch Substrate Scope.

Integrity: etag or a hash you verify on restore, not a comment in helm values. If restore succeeds and the files are wrong, that is worse than a failed restore. A failed restore is an error. A silent wrong tree is a corrupted session you will trust.

A test plan I would run, using only claims I have already measured or watched:

  1. Golden bake. Apply the template. Confirm checkpoint succeeds. In the kagent lab, first reconcile took about a minute per agent.
  2. Cross-node restore. Session id and a known file match after landing on the other worker.
  3. Sentry-owned resource. A held flock() is the one I actually tried. It survived golden checkpoint. Live suspend/resume of that lock still needed kubectl-ate with a bearer token I did not complete in that session, so I do not claim the live cycle for it here.
  4. Sentry-unowned resource. Do not skip this because flock() passed. Host sockets are the interesting failure.
  5. Wrong-object failure. Flip a bit, restore, demand a checksum error. A restore that returns 200 with the wrong files is the incident.

atelet is the process that actually pushes and pulls checkpoint bytes. When restore is slow, I look there and at the bucket, not at the Kubernetes scheduler. I mapped that in Agent Substrate dataplane.

Who should own snapshot integrity?

The storage implementation.

Substrate decides inclusion and commit. Storage moves bytes, retries puts idempotently, and can prove the object it stored. If ateapi also hashes, also retries, and also interprets a 403, a storage incident becomes a control-plane incident. You will page the wrong people.

In my lab ateapi sat on Valkey. Live assignment (which actor is on which worker) lives there, not in etcd as Pod status. Snapshots live in the bucket. Those are different failure domains on purpose. A Valkey blip should not be the same runbook as a missing object.

IAM: atelet needs put/get on that prefix, not on the whole account. Actors should not have the bucket credential at all. The actor is untrusted code with a shell. Giving it the snapshot key is how a prompt becomes a fleet-wide delete.

What production storage choices actually matter?

Use the bucket you already encrypt, version, and retain. Do not invent a second object store because the helm chart shipped rustfs for kind.

Lifecycle rules for abandoned snapshots. Suspended actors pile up. Every completed session leaves a Suspended actor entry behind. Mine passed 900 entries in a day on the actors list, and later passed through thousands and started returning partial results. Storage will grow the same way if you never expire. Retention is a product decision: destroy on session end, keep as a forensic artifact, or expire after a window. I already wanted freeze-and-keep in stopping an agent without losing evidence. That only works if the snapshot is in a bucket you can still read after the worker is gone.

Latency: checkpoint time is on the user path if you suspend between turns. I would not promise a number I have not measured on your snapshot size. The 24.7s no-lock control in my lock experiment was an unexplained outlier, 45x slower than the 550ms lock-holding run on the same path. That cluster had no OTel collector, atelet logged dial tcp [::1]:4317: connect: connection refused, and trace-export timeouts landed around both Checkpoint calls. Do not copy 24.7s into an SLO. Do not copy 550ms either. What is load-bearing is that both checkpoints succeeded.

I also timed raw object-storage round trips against rustfs with a port-forward and the S3 API. Twenty iterations of a ~300-byte object showed write p50 around 1080ms and read p50 around 1000ms, with multi-second maxima. Object size barely moved the number: 300 bytes and 8MB landed in the same range, which told me the measurement was dominated by aws-cli startup and the tunnel, not rustfs itself. Worth having as a floor. Not worth quoting as “bucket write latency.”

Size the pool as if snapshots are cheap and workers are not. How many agents per Kubernetes pod: live sessions equal workers, registered agents equal snapshots. Nine agents on two workers in the first lab, 18 on the same two later, reserved capacity about 4.5x lower than always-on pods. That ratio is idle time sitting in this bucket. If checkpoint is slow or restore is wrong, you will go back to pod per agent and pay the reservation.

Running Agent Substrate in production is the rest of the list. Field guide: Agent Substrate. The internals this checkpoint path sits on are in the lab post.

Frequently asked questions

Where does an Agent Substrate checkpoint go?

Object storage you control. Memory and filesystem of the actor are written as a snapshot, then restored onto a worker later, maybe on another node. The bucket is part of the production design, not a lab default.

Who should own snapshot integrity?

The storage implementation. The runtime decides what to include and when a snapshot is committed. If the control plane also hashes and also retries puts, a storage incident becomes an ateapi incident.

Does checkpoint survive things like file locks?

A held flock() survived in my gVisor lab because the sentry virtualized it. GPU memory and host sockets are the class I would not expect to survive. Test the resource you actually care about.

Is a checkpoint the same as a backup script?

No. A checkpoint is a committed snapshot the runtime can restore onto any free worker as the same session. If you cannot suspend on node A and resume on node B with the same session id and workspace files, you have a backup script, not checkpoint.

What production storage choices matter for agent snapshots?

Use a bucket you already encrypt, version, and retain. Give atelet put/get on that prefix only. Actors should not hold the bucket credential. Add lifecycle rules, because suspended actors pile up and storage will too if you never expire.

Disagree or have a war story? Reply on X