@@ -11,8 +11,9 @@ Restarting the gateway does not lose agent state. Conversations, transcripts,
1111scheduled jobs, background task records, and queued outbound messages all live
1212on disk, and work that was interrupted mid-turn is detected and resumed
1313automatically after the gateway comes back up. Recovery is always on and
14- normally needs no manual intervention. Repeatedly failing recovery is bounded
15- and may quarantine one session until you inspect or replace it.
14+ normally needs no manual intervention. Exhausted infrastructure retries, or a
15+ missing durable message-action authority claim, may quarantine one session
16+ until you inspect or replace it.
1617
1718This page describes what survives a restart, how interrupted work is detected,
1819and what the automatic resume looks like.
@@ -54,19 +55,12 @@ Three complementary mechanisms mark sessions whose turn did not finish:
5455 Commands, attachments, per-turn overrides, pending deliveries, prior abort
5556 hints, plugin-owned sessions, and turns with execution hooks keep their
5657 specialized admission paths.
57- If a ` before_agent_reply ` hook is installed, admission also records its phase.
58- Recovery never replays a hook interrupted mid-call. Once an unhandled hook
59- finishes, its checkpoint records that result, but recovery still fails closed
60- while that hook remains active: a checkpoint cannot prove that the same
61- plugin code and configuration loaded after the restart. A
62- ` before_agent_reply ` hook may declare a host-enforced
63- ` eligibleTriggers ` scope; a hook limited to scheduled ` heartbeat ` or ` cron `
64- turns is not active for a recovered user turn and therefore does not block
65- it. Unscoped or invalid registrations remain active for this safety check.
66- Handled text and silent results are checkpointed separately for deterministic
67- settlement.
68- Durable recovery claims written by older versions have no source-ownership
69- marker, so they receive the same fail-closed hook check during an upgrade.
58+ If a ` before_agent_reply ` hook is installed, admission records enough phase
59+ state to distinguish a completed silent result from an ambiguous side-effect
60+ window. Recovery dispatches an ordinary user-triggered agent turn, so the
61+ currently loaded ` before_agent_reply ` hooks run under their normal trigger
62+ rules. Ambiguous prior hook outcomes resume with restart-safe tools rather
63+ than replaying unrestricted side effects.
7064- ** At shutdown:** during the restart drain, every session with an active run
7165 is stamped with a recovery marker in the session store before the run is
7266 aborted.
@@ -98,17 +92,18 @@ replacement. `openclaw doctor --fix` can repair a stale aborted flag that
9892conflicts with a tombstone, but it does not re-enable that recovery cycle.
9993
10094Every retry reuses one durable dispatch identifier, so an ambiguous connection
101- failure cannot start the same recovery twice. Completed and unresumable Control
102- UI turns also retain bounded durable idempotency tombstones, allowing a
103- reconnecting outbox to retire them without re-executing the request.
95+ failure cannot start the same recovery twice. Completed Control UI turns also
96+ retain bounded durable idempotency tombstones, allowing a reconnecting outbox
97+ to retire them without re-executing the request.
10498
10599Message-tool-only replies use a second durable correlation. Before a terminal
106100same-conversation send reaches the channel, the gateway records an unresolved
107101delivery intent on the exact session and source turn. A confirmed provider
108102success resolves it to a durable delivered receipt; a confirmed failure clears
109103it. Recovery completes a delivered receipt without rerunning tools. If a crash
110- leaves the provider outcome unknown, recovery fails closed instead of replaying
111- an external effect.
104+ leaves the provider outcome unknown, recovery resumes with restart-safe tools
105+ so the model can inspect and report the ambiguity without replaying the
106+ external effect.
112107
113108The delivered reply is also mirrored into the transcript with its source
114109message ID. Terminal mirrors use a distinct receipt key, so a progress send with
@@ -118,20 +113,21 @@ durable channel-ingress claims can restore message-action authority. A resumed
118113run keeps the original source-delivery mode and source correlation, including
119114requester identity and any same-channel/thread restriction, so the same receipt
120115remains authoritative even if another restart happens during recovery. A
121- message-tool-only turn without reconstructable channel authority is failed
122- closed and receives the one-time resend notice.
123-
124- Before resuming, the gateway checks that the transcript tail is safe to
125- continue from. An aborted turn is the interruption itself, so it resumes on a
126- best-effort basis whatever abort detail the provider or worker recorded with it:
116+ message-tool-only turn without reconstructable channel authority is tombstoned
117+ because OpenClaw cannot safely mint message-action authority without the
118+ original channel-ingress claim. The terminal notice directs the user to start a
119+ replacement with ` /new ` or ` /reset ` .
120+
121+ Before resuming, the gateway classifies the transcript tail to choose the tool
122+ restriction for the continuation. An aborted turn is the interruption itself,
123+ so it resumes on a best-effort basis whatever abort detail the provider or worker recorded with it:
127124partial streamed text stays in the transcript and the continuation picks up from
128125the message beneath it, while a tool call left dangling is dropped from the next
129126provider payload and restricted to restart-safe tools unless it is audited
130- replay-safe. If the tail is genuinely unsafe (for example a provider failure, or
131- a turn that ended on a stale pending approval), the session is not blindly
132- re-run; the agent instead posts a short notice asking the user to resend the
133- last request. For WebChat, that notice is written directly to the session
134- history so it remains visible after reconnect.
127+ replay-safe. Provider failures, completed assistant tails, empty transcripts,
128+ and stale pending approvals also continue from the existing transcript. States
129+ with ambiguous side effects use restart-safe tools; otherwise the model decides
130+ what completed and what remains and can report any uncertainty to the user.
135131
136132OpenClaw can also reconstruct interrupted read-only [ Code Mode] ( /tools/code-mode )
137133work. Code Mode marks these runs as restart-safe and rejects side-effecting
@@ -140,8 +136,9 @@ the `wait` control, the new gateway reconstructs the turn from its transcript
140136and forces the reconstructed execution to remain restart-safe even if the
141137model omits or clears that flag. The host filters the entire reconstructed
142138turn to audited read-only core tools and explicitly replay-safe plugin tools,
143- including when Code Mode is disabled after the restart. Side-effecting work
144- remains guarded by the resend notice rather than risking a duplicate write.
139+ including when Code Mode is disabled after the restart. A non-replay-safe or
140+ unmatched Code Mode checkpoint still resumes for model reconciliation, but
141+ without Code Mode controls and with the restart-safe tool restriction.
145142
146143### Subagents
147144
@@ -234,8 +231,9 @@ channels.start --params '{"channel":"<id>"}'`
234231- ** Logs:** recovery decisions are logged under the
235232 ` main-session-restart-recovery` and ` subagent-interrupted-resume`
236233 subsystems.
237- - ** Reply hooks:** automatically delivered replies from resumed main-session
238- turns run the normal ` reply_payload_sending` hook before channel delivery,
234+ - ** Reply hooks:** resumed turns run currently loaded ` before_agent_reply`
235+ hooks under the normal user-trigger rules. Automatically delivered replies
236+ also run the normal ` reply_payload_sending` hook before channel delivery,
239237 with the recovered session, run, account, and conversation context.
240238
241239# # What is not resumed
@@ -244,8 +242,6 @@ channels.start --params '{"channel":"<id>"}'`
244242 handles them: subagent sessions (subagent recovery), cron sessions (the
245243 scheduler re-runs on schedule), and ACP-managed sessions (the connected IDE
246244 or client owns the resume).
247- - Sessions whose transcript tail cannot be safely continued; these get the
248- resend notice described above instead of a silent re-run.
249245- Work that was never admitted: messages arriving during the drain window are
250246 rejected with an explicit restart error rather than silently queued into a
251247 dying process.
0 commit comments