8 Comments
User's avatar
Rohan's avatar

pausing agents while they wait on a person makes so much sense. how long do snapshots take to restore?

Bilgin Ibryam's avatar

the stated goal is 100 ms at the 95th percentile.

That said, right now it seems to be around 1s https://github.com/agent-substrate/substrate/issues/2635

Rohan's avatar

10x off target is a big gap. is restore time mostly the memory snapshot or the network setup?

Nan Deng's avatar

Substrate releasing the worker after a snapshot is the cattle version of a sandbox: the environment can die, and the session has to come back on whatever worker is free. The conversation checkpoint and the memory-plus-filesystem snapshot are then two copies of that session, and they are not written by the same component. If a tool call is in flight when the harness decides the pause is safe, the checkpoint can still say the call has not returned while the filesystem snapshot already contains a partial write. I'd want restore to treat that pair as inconsistent rather than bring the agent back as if the sandbox had never been killed.

Bilgin Ibryam's avatar

Kubernetes has shown that it is possible to build a reliable distributed system, but it takes time. I don't think what agents are doing is unsolvable. Snapshotting at safe points and restoring is a solved problem

Nan Deng's avatar

Agree the snapshot primitive is solved. The gap is the two writers: the harness checkpoint and the sandbox filesystem don't share one commit. A tool call can still be mid-write in the sandbox while the harness has already recorded that the call has not returned. Restore is safe only if those two records freeze together, not if each side snapshots whenever it thinks the pause is safe.

Bilgin Ibryam's avatar

Since we are talking in general terms here: it is never black and white. There are some many ways to do dual write (with different tradeoffs) without doing a distributed transaction.

Same here, what if the harness sygnals operation completed and it is safe to snapshot?

The point is, 90% of agent time is spent waiting, there no reason to keep that resource wasted. I'm 100% the majority of the agents will run in suspend/resume with snapshotting, this is just the start.

Nan Deng's avatar

If the harness only snapshots after it has signaled that the operation completed, that closes the in-flight case, as long as the sandbox write is frozen after the last byte and not when the model merely says it is done. A dual write without a transaction can still drop the second record if the worker is reclaimed between that signal and the snapshot upload. I'd treat "safe to snapshot" as a barrier the runtime waits on, so suspend-and-resume doesn't resume a session whose filesystem and checkpoint disagree.