-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Feature: Graceful Gateway Restart with Session Recovery #57425
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Type
Fields
Priority
None yet
Problem
When the gateway restarts — whether from
openclaw gateway restart, a config change, SIGUSR1, or a crash — all in-flight work is silently killed. There is no mechanism for sessions to know they were interrupted, no way for parent sessions to learn their subagents died, and no recovery path other than waiting for the next heartbeat or manual intervention.This is the single biggest reliability gap in multi-agent OpenClaw deployments.
What happens today
Real-world impact
Running 7 agents across Discord + iMessage + cron, a single gateway restart can:
The blast radius scales with agent count. This is not a solo-agent problem.
Existing community reports
gateway restartfrom agent session causes self-decapitation on macOS (launchd) #43311 — Self-decapitation: agent-triggered restart kills its own sessionPrior art: Hermes Agent
Hermes (Nous Research) is building this in their multi-agent architecture (issue #344):
~/.hermes/checkpoints/after each tool call. On failure, resume from checkpoint.Proposed solution
1. Pre-restart session manifest
Before sending SIGTERM to workers, the gateway should enumerate active sessions and write a manifest:
{ "timestamp": "2026-03-29T23:25:30Z", "reason": "config-change", "triggeredBy": "agent:main:guild-agent-birthing", "activeSessions": [ { "key": "agent:main:main", "status": "processing", "lastUserMessage": "Can you check the garden plan?", "activeSubagents": ["agent:sage:guild-gardening"], "channel": "discord", "channelTarget": "user:344256406146383874" } ], "activeCronRuns": [ { "jobId": "5a820e42-...", "jobName": "Pulse: Nightly Ecosystem Scan", "startedAt": "2026-03-29T23:20:00Z", "status": "running" } ] }2. Post-restart session recovery
After startup, read the manifest and for each interrupted session, inject a system event:
For interrupted cron runs, re-queue with a retry flag. For sessions with active subagents, notify the parent that its subagent was killed.
3. Restart readiness gate
When
gateway restartis called:--forceto skip the check4. Drain-aware message queuing
Messages received during drain should be queued and replayed after restart, not rejected. The current
resetAllLanes()mechanism should be made reliable.5. Configuration
{ "gateway": { "restart": { "sessionRecovery": true, "cronRetryOnInterrupt": true, "readinessGate": true, "readinessGateThreshold": 0, "drainQueueMessages": true, "manifestPath": "restart-manifest.json" } } }What this does NOT solve (and shouldn't)
Current workaround
We've built a 3-layer userspace workaround that validates the approach:
openclaw sessions --all-agents --active 10 --json, writesrestart-manifest.jsonThis works (tested twice, clean results both times), but it's fragile — the manifest capture is best-effort, BOOT.md runs in a fresh context with no memory of what sessions were doing, and the entire thing bypasses OpenClaw's session management.
Environment