Suspend-safe networking: why I will not park an agent mid-call

Part of: Agent Runtimes

Suspend-safe networking is the missing piece: suspending an actor today cuts its TCP connections, so an agent waiting on a slow call cannot be parked.

Suspend-safe networking is a design where an actor can be checkpointed and restored on another worker without dropping the TCP sessions it was using. I do not have that: I can snapshot memory and disk, and the sockets do not come with it. If the agent was waiting on a slow tool, parking it turns a pause into a failure, so the rule I run with is do not suspend mid-call.

Idle to the model is not idle to the peer. The snapshot is real. The TCP session is not in it.

What is suspend-safe networking?

A design where an actor can be checkpointed and restored on another worker without dropping the TCP sessions it was using.

I have not had that in the versions I have run. Memory and disk go to object storage. I have watched an actor leave a bay, land on the shelf, and come back on the other worker for the next turn. Suspend and resume agents is that lifecycle. This post is the part that lifecycle does not cover: the open call.

Agent Substrate’s density story depends on parking. Nine agents on two workers, over a thousand real chat sessions, reserved capacity about 4.5x lower than always-on pods. Always-on kagent defaults hold about 204 MiB resident and 50m CPU idle. The ratio holds because a suspended agent is a snapshot at near-zero marginal cost. That math assumes you are allowed to park.

You are allowed to park between turns. You are not allowed to park mid-call if you still need the connection.

Why do TCP sockets die when you suspend an actor?

A snapshot is process state plus filesystem, as the sandbox can serialize them. A TCP session is also sequence numbers, a 4-tuple, and kernel (or sentry) socket state bound to a network namespace on a particular worker. Move the actor, the namespace is gone. Even if you restored socket structs, the other end did not freeze.

I already learned that gVisor will serialize some things I thought were “kernel-only,” like flock(). A lock-holding actor checkpointed with no error in 550ms on one cluster, because the lock lived in sentry state, not the host kernel’s lock table. That finding made me more precise, not more reckless. I am not willing to assume sockets are in that set. Pinned resources.

Host-network sockets are worse: they were never in the sandbox. If the actor was on the node’s NIC, checkpointing “the socket” would mean serializing host-kernel state Substrate does not own. Sandboxed networking for agents starts with “no host network” for this reason, among others.

The peer’s view is the part people skip. Your restore can be perfect. The tool host still saw a reset, a timeout, or a half-closed stream. Databases do not freeze their transactions because you wrote a zstd blob. gRPC streams do not pause. WebSockets do not wait on object storage.

atelet moves snapshot bytes. ateom talks to runsc. Neither of those processes is a connection manager for the actor’s outbound calls. Agent Substrate dataplane.

Can I suspend an Agent Substrate actor while it waits on HTTP?

Not if you need that connection.

The worker is gone. The netns is gone. The peer sees a dead connection. Either wait out the call, run the I/O from a proxy that outlives the actor, or accept the retry.

Request/response tools can retry. A database transaction cannot. A multiplexed gRPC stream cannot. A websocket cannot. If your tool protocol looks like a session, treat suspend mid-call as data loss, not as a 503 you can loop on.

Idle policy in suspend and resume agents has to skip actors with open calls. If step 4 of the lifecycle (checkpoint, free the slot) runs while a tool has not returned, you have turned a park into an incident.

This is also why scheduling sandboxes for RL has a fork. Multiplexing during model waits is the case where the sandbox is idle and the wait is the generator. Multiplexing during tool waits needs this post to be untrue. If the environment holds a socket, suspend will drop it.

When the pool is full, Substrate rejects and the caller retries. That is not a queue, and it is not a reason to suspend an in-flight call to steal the slot. Stealing the slot drops the call.

How do I work around the lack of 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. That is fine for request/response tools. It is bad for anything that looks like a session.

Keep long I/O out of the actor. If you must wait on a 30-second upstream, wait on the gateway. The actor submits work, suspends, and resumes when the gateway wakes it. That is a design, not a config flag I can turn on in the versions I have used. The gateway is the process that outlives the bay.

Size workers for in-flight. If a third of your agents are blocked on tools at any time, those slots are busy even though the LLM is idle. The pool covers simultaneous sessions, not total agents. Nine agents on two workers only works if most of those nine are snapshots, not blocked syscalls. Always-on idle reservation (about 204 MiB and 50m CPU each) is what you are trying not to pay. In-flight tool calls still occupy a worker.

Do not put the live TCP session in the snapshot. Agent checkpoint to object storage is the contract for what belongs in the object: process memory the sandbox owns, filesystem the actor was allowed to write. Long-lived secrets, GPU memory, and open TCP the sandbox does not own stay out.

Reattach identity, not just hope the socket comes back. A resumed actor that inherited the wrong connection is a worse bug than a reset. Proof of agent identity. Mint at restore, drop at suspend. Do not serialize a cloud key or a user refresh token into the snapshot next to the “almost a socket.”

What would a real design have to do?

Hold the sockets in a component that does not suspend: a proxy on the worker or a pool-level connection manager. Wake the actor when bytes arrive. Restore onto any worker and reattach. Prove it with an inbound request that is waiting on an outbound call across a suspend.

I would also want identity to reattach, not just the socket. The proxy has to know this byte stream belongs to this agent, this session, after the actor has moved. Worker ServiceAccount is not that name.

Until that exists, sandboxed networking is isolation, not session continuity.

Tradeoff of doing it right: more moving parts next to ateom, and a new failure mode where the proxy holds a connection for an actor that will never resume. Abandoned snapshots already pile up. Abandoned proxy sessions would pile up faster, and they hold file descriptors and upstream load. You would need a lifetime, a reclaim path, and a log that says “held for actor X, actor X never came back.”

Tradeoff of not doing it: you cannot take the density win on the exact agents that are idle-but-waiting, which is a lot of them. Chat agents wait on tools. RL rollouts wait on environments. A 30-second tool call on a worker is a bay you cannot sell to the next restore.

Checklist I run with today

  • Suspend only between turns, after tools return.
  • Treat any open TCP, gRPC stream, or websocket as “do not park.”
  • Put long polls and 30-second upstreams on a gateway that stays up.
  • Size the WorkerPool for in-flight calls plus model turns, not for total agents.
  • Keep hostNetwork off so you are not pretending to snapshot the node’s stack.
  • Mint credentials at restore. Do not checkpoint them next to “the sockets we wish we had.”
  • If you build the proxy-held-socket design, prove it with a call that spans suspend onto a different worker, and prove the identity on the reattached stream is the same agent.

Field guide: Agent Substrate. The multiplexing lab: kagent Agent Substrate.

Frequently asked questions

What is suspend-safe networking?

A design where an actor can be checkpointed and restored on another worker without dropping the TCP sessions it was using. I have not had that in the versions I have run. Suspend cuts sockets.

Can I suspend an Agent Substrate actor while it waits on HTTP?

Not if you need that connection. The worker is gone, the netns is gone, the peer sees a reset. Either wait out the call, run the I/O from a proxy that outlives the actor, or accept the retry.

How do I work around the lack of suspend-safe networking?

Do not suspend mid-flight. Suspend between turns, after tools return. Put long polls on a sidecar or gateway that stays up. Size the pool for in-flight calls, not only for thinking.

Does gVisor checkpoint sockets the way it checkpointed flock()?

I am not willing to assume that. A held flock() survived because the sentry virtualized it. A TCP session is also the peer, which did not freeze, and host-network sockets were never in the sandbox.

Why does this matter for Agent Substrate density?

Density comes from parking idle actors. An agent waiting on a tool is idle to the LLM and busy to the network. Without suspend-safe networking you cannot take the density win on the agents that are idle-but-waiting.

Disagree or have a war story? Reply on X