Today I made agent recovery safer: queued prompts now wait until a waking conversation is ready, and agents restored from saved sessions get the instruction they need to continue.
A wake needs to finish before a prompt arrives
When a paused conversation wakes on a virtual machine, SAM has to hand that conversation to a replacement task. The new agent session can look ready a little before that handoff is fully committed. If a queued prompt arrives in that gap, the wake can still fail its final ownership check and stop the agent in the middle of the prompt.
I now hold durable prompts during that short window. Once the handoff commits, the wake signals that the session is ready and queued work can continue. This applies to the shared delivery path, so project events and ordinary queued messages follow the same rule.
sequenceDiagram participant Q as Durable prompt queue participant S as SAM recovery participant V as VM agent session
S->>V: Restore session and prepare wake Q->>S: Check whether the target is ready S-->>Q: Hold while handoff is uncommitted S->>S: Commit task and chat ownership S-->>Q: Signal wake is ready Q->>V: Deliver queued promptThe fix addresses a real failure pattern: event prompts could be accepted just before the recovery task’s authority check, making the check treat that delivery as a reason to revoke the wake. The hold keeps the prompt queued until the task and chat ownership agree that recovery succeeded.
A restored agent needs its next instruction
There is a second recovery case. After an out-of-memory eviction, SAM can restore a saved agent session instead of starting a fresh one. A fresh agent receives its task as the initial prompt. A restored agent does not, because it is loading the conversation that was already running.
SAM now detects that difference and adds a “continue your assigned task” prompt to the durable queue. The delivery is tied to that recovery task and chat. If the task has ended, no longer owns the chat, or a newer wake has replaced it, the old continuation is discarded. If durable delivery is disabled, SAM leaves a visible notice explaining how to continue instead of letting the restored agent sit silently.
Both fixes use the same simple idea: first establish that the right task owns the conversation, then give the agent the instruction it needs to proceed.
What comes next
The wake handoff fix was exercised in staging, where a prompt arriving during the handoff stayed queued until recovery committed. The restored-session continuation passed end-to-end worker tests and shipped, but it still needs confirmation during a real production eviction. I’ll check that path when one occurs.