Expand description
Restart recovery: bring a freshly-spawned agent back to its persisted running state so the daemon resumes it where it stopped.
When the daemon restarts, the CLI reloads each non-terminal run’s blueprint
and spawns a fresh agent, then calls restore_agent to overlay the persisted
context, jump to the persisted stage + iteration, and restore token totals. The
agent keeps the ReadyToInfer marker spawn_agent set, so any inference
that was in flight when the daemon stopped is re-issued on the next tick -
nothing is left stuck awaiting a job that died with the old process.
A tool batch that was in flight is not blindly re-issued, though: when the run
journal holds a dispatched-but-unapplied batch, restore_pending_batch
reconstructs its assistant turn in the window first - real journaled results
for calls that completed, a verify-first INTERRUPTED_TOOL_RESULT for calls
that didn’t - so the re-issued inference sees exactly what already ran and
completed side effects never run twice (issue #96).
Enums§
- Restore
Priority - How urgently a persisted run should be brought back on restart. Ordered so a
higher value restores first (see
triage_restores).
Constants§
- INTERRUPTED_
TOOL_ RESULT - The synthesized result for a call whose completion never reached the journal. It tells the model plainly that the effect may or may not have landed, so the re-issued turn verifies before re-running side-effecting work.
Functions§
- classify_
restore - Classify one persisted run for restart recovery from its on-disk status and
whether it is parked mid fan-out (a
<run_dir>/fanout.jsonis present). - restore_
agent - Restore a just-spawned
entityto the persisted state captured insnapshot(its context),stage_index+iteration(its position), andtotals(its running token/tool counts). The agent staysActive+ReadyToInferso it resumes on the next tick. - restore_
pending_ batch - Replay a tool batch that was dispatched but never applied before the crash
(folded from the run journal as a
PendingToolBatch): land the assistant turn plus one result per call in the context window, exactly asapply_tool_resultswould have - real journaled results for calls that finished,INTERRUPTED_TOOL_RESULTfor calls that didn’t. The turn is always fully paired, so the request assembler’s orphan sanitizer keeps it, and the re-issued inference sees precisely what already ran instead of blindly re-executing the whole batch (issue #96). - triage_
restores - Triage a set of persisted runs into the order they should be restored on
restart: drop terminal runs, then rank the rest actionable-first
(
RestorePriority::ActivebeforeBlocked), breaking ties by most-recently updated. Each input is(meta, parked_on_fanout)whereparked_on_fanoutis whether the run has afanout.json(seeclassify_restore); the returnedRunMetas are ready to reload in order.