Skip to content

fix(gateway): Gateway crash-loops when restart recovery replays the turn that crashed it - #160434

Closed
masatohoshino wants to merge 2 commits into
openclaw:mainfrom
masatohoshino:fix/144772-crash-loop-recovery-pause
Closed

masatohoshino wants to merge 2 commits into
openclaw:mainfrom
masatohoshino:fix/144772-crash-loop-recovery-pause

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #144772

What Problem This Solves

Fixes: the Gateway crash-loops forever when a main-session turn that was in flight during a crash crashes the process again each time startup restart recovery replays it (#144772).

User Impact

User impact: once the restart-loop breaker trips (3 unclean boots within 5 minutes), the Gateway stays up instead of replaying the crashing turn on every boot. The interrupted session and its transcript are kept and stay marked for recovery; the operator can inspect it, then resume it by sending a new message in that session, or let the first Gateway start after the breaker recovers resume it automatically. No session has to be deleted to break the loop.

Why This Change Was Made

A turn that reaches its runtime refreshes the main-session recovery allowance, which is intentional so planned restarts keep long work alive. The same refresh means a turn that crashes the Gateway after it starts is never exhausted, and the crash-loop breaker only suppressed channel auto-start, so replay continued.

This follows the recommendation in ClawSweeper's review on the issue ("Extend crash-loop containment: use the existing boot-lifecycle breaker to pause automatic session replay and provide explicit operator recovery without deleting transcripts"), which the reporter also endorsed there. A boot that starts with the breaker tripped still runs startup orphan marking but skips automatic dispatch and logs a warning that says how to resume. Explicit resume reuses the existing path: a new message in an interrupted session already resumes its turn through reply admission. The documented safe-mode contract in docs/gateway/restart-recovery.md and docs/gateway/index.md now lists this.

Deliberately left out: the allowance refresh on started turns and the three-attempt budget are unchanged, so healthy planned restarts behave as before; no new config, state field, or tombstone rule is added; the underlying native abort from the report is not addressed here. The startup scheduling call moved from server-startup-post-attach.ts into a small sibling module so that file does not grow past its line-cap ratchet.

Trade-off for maintainers to decide: if a breaker-tripped Gateway stays up for the whole breaker window, the breaker restores channel auto-start in that same process, but this PR does not resume the paused sessions there. Those interrupted turns stay unfinished until someone sends a new message in the session or the Gateway starts again after the window; nothing replays them on its own in the meantime. The alternative, replaying them automatically when channels come back, would re-run the turn that just crashed the Gateway inside the process that has only just proven stable, and would restart the loop. This PR chooses containment over automatic completion. If same-process replay after recovery is preferred, it could hang off the breaker's existing in-process recovery point; this PR does not change that behavior.

Evidence

Tested at ef7c6c66419 (base upstream/main 988be486074); the later head 8b378a98eb6 only fixes a docs paragraph break.

Linux x64, Node 24, built CLI, an isolated Gateway profile and state directory on loopback, and a keyless OpenAI-compatible mock model on loopback that streams slowly. A chat.send to agent:main:main starts a long exec turn and the Gateway is SIGKILLed mid-turn. Each following boot is SIGKILLed as soon as the recovered turn sends its model request (a stand-in for the reported process abort during the replayed turn); a boot that sends no model request within 25 s is left running. Session state is read read-only from the agent database.

Before (base 988be486074), boot 3 with the breaker tripped; boots 4 to 6 are identical with chargedAttempts/startedAttempt climbing to 6/6:

== boot 3: recovered turn reached the model: yes
[gateway] restart-loop breaker tripped: 3 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=3 startedAttempt=3 tombstoned=false

After (this PR), same steps:

== boot 3: recovered turn reached the model: no
[gateway] restart-loop breaker tripped: 3 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] restart-loop breaker tripped; automatic main-session restart recovery paused. Interrupted sessions stay marked: a new message in a session resumes its interrupted turn, and the first Gateway start after the breaker recovers resumes the rest.
   Gateway still running after 25 s (pid alive: yes)
session agent:main:main: status=running abortedLastRun=true chargedAttempts=2 startedAttempt=2 tombstoned=false
== explicit resume: send a new message to the paused session
   model requests after the message: 1

== done

Observed result: on the base every boot replays the turn, including every breaker-tripped boot, and the allowance never drains. With this change boots 1 and 2 still replay, boot 3 trips the breaker and only marks the session (abortedLastRun=true), the Gateway keeps running, and a new message in the session resumes it and the session settles (status=done).

Upgrade from the published release with existing interrupted state

Published driver [email protected] (current latest) installed with npm into an isolated global prefix, with its own HOME, OPENCLAW_PROFILE, loopback ports, and the same mock model. The published build seeds the interrupted turn and crash-loops on its replay until the breaker trips. Then the published updater installs the candidate package (this branch at ef7c6c66419, packed with scripts/package-openclaw-for-docker.mjs) in place with openclaw update --tag <candidate.tgz> --yes --json --no-restart, and the candidate Gateway starts on the same state (service management is skipped for an isolated profile, so the restart is manual). Session and boot-lifecycle rows are read read-only.

== published driver
   installed: OpenClaw 2026.9.6 (eb377ac)
== seed (published): start a long turn in agent:main:main, SIGKILL the Gateway mid-turn
   session agent:main:main: status=running abortedLastRun=false chargedAttempts=undefined startedAttempt=undefined tombstoned=false transcriptEvents=5 userMessages=1 seedMessageKept=true
== published boot 1: recovered turn reached the model: yes   (SIGKILL; chargedAttempts=1)
== published boot 2: recovered turn reached the model: yes   (SIGKILL; chargedAttempts=2)
== published boot 3: recovered turn reached the model: yes
   [gateway] restart-loop breaker tripped: 3 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. ...
   [main-session-restart-recovery] started interrupted main session: agent:main:main
   (SIGKILL: crash during the replayed turn)
   session agent:main:main: status=running abortedLastRun=false chargedAttempts=3 startedAttempt=3 tombstoned=false transcriptEvents=11 userMessages=4 seedMessageKept=true
   boot lifecycle rows=4 never-completed=4
== update: published updater installs the candidate tarball in place (--no-restart)
   Gateway down before update: yes
   update exit=0 in 77s
   installed: OpenClaw 2026.9.6 (ef7c6c6)
   steps: package-install, candidate-state-snapshot, candidate-doctor, candidate-doctor-lint, candidate-config, candidate-plugins, candidate-recovery, candidate-gateway-startup, package-swap, openclaw doctor, finalize:plugins, managed-service-reconciliation, post-plugin-doctor-lint: all exit 0
   session agent:main:main: status=running abortedLastRun=false chargedAttempts=3 startedAttempt=3 tombstoned=false transcriptEvents=11 userMessages=4 seedMessageKept=true
   boot lifecycle rows=4 never-completed=4
== candidate boot on the published state
   recovered turn reached the model: no
   [gateway] restart-loop breaker tripped: 4 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. ...
   [main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
   [main-session-restart-recovery] restart-loop breaker tripped; automatic main-session restart recovery paused. Interrupted sessions stay marked: a new message in a session resumes its interrupted turn, and the first Gateway start after the breaker recovers resumes the rest.
   Gateway still running after 25 s: yes
   session agent:main:main: status=running abortedLastRun=true chargedAttempts=3 startedAttempt=3 tombstoned=false transcriptEvents=11 userMessages=4 seedMessageKept=true
== explicit resume: new message in the paused session
   model requests after the message: 1
   session agent:main:main: status=done abortedLastRun=false chargedAttempts=undefined startedAttempt=undefined tombstoned=false transcriptEvents=15 userMessages=5 seedMessageKept=true

Observed result: the candidate reads the breaker history and the recovery marks the published build wrote. The unclean boots recorded by 2026.9.6 trip the breaker on the first candidate boot, so it pauses instead of replaying the crashing turn a fourth time. The update and the paused boot keep every transcript event, including the original seeded message, and do not change the recovery counters. A new message then resumes the session and it settles; the transcript only grows. The published build, on the other hand, replays on its breaker-tripped boot 3.

Not covered: the reported macOS descriptor abort itself (SIGKILL stands in for it), a launchd- or systemd-supervised restart loop and an updater-driven service restart (the upgrade cell restarts manually), and a channel-delivered resume message (the resume was sent with chat.send; channels are suppressed while the breaker is tripped).

CI failures on the first run (https://github.com/openclaw/openclaw/actions/runs/36419819269) are unrelated to this change; each is a timeout or flake in code this PR does not touch:

CI failures on the second run (https://github.com/openclaw/openclaw/actions/runs/36433302448, head 8b378a98eb6) are also unrelated. That head differs from ef7c6c66419 only in docs/gateway/restart-recovery.md, and every test below passed on the first run with the same code. None of these tests trips the crash-loop breaker, so the new pause branch (pauseAutomaticDispatch) never runs in them; with the breaker untripped, the moved scheduling call passes the same arguments as before.

Full before/after output and focused tests

Before:

== seed: start a long turn in agent:main:main, then SIGKILL the Gateway mid-turn
session agent:main:main: status=running abortedLastRun=false chargedAttempts=undefined startedAttempt=undefined tombstoned=false
== boot 1: recovered turn reached the model: yes
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=1 startedAttempt=1 tombstoned=false
== boot 2: recovered turn reached the model: yes
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=2 startedAttempt=2 tombstoned=false
== boot 3: recovered turn reached the model: yes
[gateway] restart-loop breaker tripped: 3 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=3 startedAttempt=3 tombstoned=false
== boot 4: recovered turn reached the model: yes
[gateway] restart-loop breaker tripped: 4 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=4 startedAttempt=4 tombstoned=false
== boot 5: recovered turn reached the model: yes
[gateway] restart-loop breaker tripped: 5 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=5 startedAttempt=5 tombstoned=false
== boot 6: recovered turn reached the model: yes
[gateway] restart-loop breaker tripped: 6 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=6 startedAttempt=6 tombstoned=false
== explicit resume: send a new message to the paused session
   (no running Gateway)
== done

After:

== seed: start a long turn in agent:main:main, then SIGKILL the Gateway mid-turn
session agent:main:main: status=running abortedLastRun=false chargedAttempts=undefined startedAttempt=undefined tombstoned=false
== boot 1: recovered turn reached the model: yes
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=1 startedAttempt=1 tombstoned=false
== boot 2: recovered turn reached the model: yes
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] started interrupted main session: agent:main:main
[main-session-restart-recovery] main-session restart recovery startup complete: started=1 settled=0 failed=0 skipped=0
   (SIGKILL: crash during the replayed turn)
session agent:main:main: status=running abortedLastRun=false chargedAttempts=2 startedAttempt=2 tombstoned=false
== boot 3: recovered turn reached the model: no
[gateway] restart-loop breaker tripped: 3 unclean boot(s) within 300000ms; suppressing channel/provider account auto-start. Inspect the stability bundle and fix the startup crash before restarting the service. 
[main-session-restart-recovery] marked 1 startup-orphaned main session(s) for restart recovery
[main-session-restart-recovery] restart-loop breaker tripped; automatic main-session restart recovery paused. Interrupted sessions stay marked: a new message in a session resumes its interrupted turn, and the first Gateway start after the breaker recovers resumes the rest.
   Gateway still running after 25 s (pid alive: yes)
session agent:main:main: status=running abortedLastRun=true chargedAttempts=2 startedAttempt=2 tombstoned=false
== explicit resume: send a new message to the paused session
   model requests after the message: 1

== done

Focused tests:

  • src/agents/main-session-recovery/main-session-restart-recovery-admission.test.ts: new case "marks but does not replay interrupted sessions while the crash-loop breaker is tripped" (8/8 pass). It fails on the base (callGateway is called once by automatic replay). Cost: pnpm test src/agents/main-session-recovery/main-session-restart-recovery-admission.test.ts --maxWorkers=1 wall 53.3 s for the whole file; the new case takes about 1.5 to 1.9 s, in line with its sibling startup-recovery cases. CI (run https://github.com/openclaw/openclaw/actions/runs/36419819269, job checks-node-changed-compact-large-14): 18.3 s for the file's 8 cases, 1.4 s for the new case.
  • src/gateway/server-startup-post-attach.test.ts: 115/115 pass (unchanged; covers the moved scheduling call).
  • pnpm check:changed --base upstream/main: pass. pnpm build: pass.
  • Local review with the autoreview skill on the branch: no findings.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 1:12 PM ET / 17:12 UTC (Revision 4).

ClawSweeper review

What this changes

The branch pauses automatic replay of interrupted main-session turns on a breaker-tripped Gateway boot, while retaining session marking, explicit resume, and recovery guidance.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful fix for a demonstrated Gateway crash loop. The patch has no discrete correctness finding, and its published-release upgrade trace supports the containment behavior. Maintainer acceptance is still needed for leaving paused turns unfinished when channels recover in the same running Gateway.

Priority: P0
Reviewed head: 8b378a98eb6ee6f622adfbdd4fc80b0b18f67785
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level code, a regression test, and real before/after and published-upgrade traces provide strong evidence; the remaining blocker is the recovery-policy choice.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR's isolated real Gateway run exercises startup recovery with a loopback model endpoint: before the patch a breaker-tripped boot replays and is killed; afterward it stays alive, retains interrupted state, and resumes through chat.send. A published 2026.9.6 updater-to-candidate trace exercises existing interrupted state and observes the same pause. The native macOS abort and supervised restart remain outside that proof. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR's isolated real Gateway run exercises startup recovery with a loopback model endpoint: before the patch a breaker-tripped boot replays and is killed; afterward it stays alive, retains interrupted state, and resumes through chat.send. A published 2026.9.6 updater-to-candidate trace exercises existing interrupted state and observes the same pause. The native macOS abort and supervised restart remain outside that proof. No stored-data contract changes.
Evidence reviewed 7 items Introduced pause: The pinned introduced diff adds a pause branch after startup orphan marking and before automatic replay.
Startup wiring: Gateway startup passes the existing channel crash-loop-breaker decision to the recovery scheduler.
Current main still replays: Fetched current main schedules startup recovery without a pause input, so the proposed containment remains necessary.
Findings None None.
Security None None.

How this fits together

Gateway startup reads persisted boot history to decide whether its crash-loop breaker has tripped. Main-session recovery then marks interrupted turns and either replays them or leaves them for a later message or Gateway start.

flowchart TD
  A[Persisted boot history] --> B[Crash-loop breaker]
  B --> C[Gateway startup]
  C --> D[Mark interrupted sessions]
  D --> E{Breaker tripped?}
  E -->|Yes| F[Pause automatic replay]
  E -->|No| G[Replay interrupted turns]
  F --> H[New message or later boot resumes]
Loading

Decision needed

Question Recommendation
Should a Gateway that survives the breaker window leave paused main-session turns unfinished until a new message or later Gateway start? Accept the containment contract: Keep paused turns marked and require explicit session activity or a later Gateway start, avoiding automatic replay of the turn that may crash the process again.

Why: The PR deliberately favors containment over automatic completion, and source confirms that channel auto-start can recover in the same process without rescheduling those turns.

Before merge

  • Resolve merge risk (P1) - On an existing installation, a breaker-tripped boot can leave interrupted turns unfinished after channels recover in the same running Gateway. Completion then requires a new message in each session or another Gateway start; maintainers must accept that recovery contract before merge.
  • Complete next step (P2) - A maintainer must accept or revise the behavior that leaves paused turns unfinished when channels recover in the same running Gateway.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +51, Tests +47, Docs +10. Total +108 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 71 20 +51
Tests 1 47 0 +47
Docs 2 12 2 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 130 22 +108

Review metrics

Metric Value Why it matters
Production versus test growth production +51 net lines, tests +47 lines The production growth is largely a moved startup scheduler; the added test covers the new pause boundary.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144772
Summary: This PR is a candidate containment fix for the linked crash-loop report; the report also describes a native macOS abort that this branch does not repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept paused turns after channel recovery (recommended)
    Land the documented containment behavior with paused sessions awaiting a new message or later boot.
  2. Set a guarded resume policy
    Pause merge while defining when the running Gateway may safely replay paused turns after the breaker clears.

Technical review

Best possible solution:

Keep crash-loop containment in the existing boot and session-recovery owners, preserve transcripts and explicit resume, and provide a visible Doctor or Fix path for operators to find paused sessions.

Do we have a high-confidence way to reproduce the issue?

Yes for the replay loop: current-main source still schedules recovery without consulting the breaker, and the PR records a pre-fix Gateway run that repeatedly replays the turn. The specific macOS descriptor abort was not reproduced.

Is this the best way to solve the issue?

Yes for crash-loop containment: the patch uses the existing breaker and recovery owners without changing the retry allowance or stored schema. The same-process completion policy still needs maintainer acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 46a227c51867.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The addressed failure can repeatedly crash the Gateway and leave channels unavailable until an operator intervenes.
  • merge-risk: 🚨 compatibility: Existing installations would stop automatically replaying interrupted turns on breaker-tripped boots.
  • merge-risk: 🚨 session-state: Interrupted sessions remain marked and unfinished until explicit activity or a later Gateway start.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR's isolated real Gateway run exercises startup recovery with a loopback model endpoint: before the patch a breaker-tripped boot replays and is killed; afterward it stays alive, retains interrupted state, and resumes through chat.send. A published 2026.9.6 updater-to-candidate trace exercises existing interrupted state and observes the same pause. The native macOS abort and supervised restart remain outside that proof. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR's isolated real Gateway run exercises startup recovery with a loopback model endpoint: before the patch a breaker-tripped boot replays and is killed; afterward it stays alive, retains interrupted state, and resumes through chat.send. A published 2026.9.6 updater-to-candidate trace exercises existing interrupted state and observes the same pause. The native macOS abort and supervised restart remain outside that proof. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Galin Iliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-28T12:14:26.362Z sha ef7c6c6 :: blocked before merge. :: [P3] Separate the paused-recovery paragraph from the channel guidance
  • reviewed 2026-09-28T14:13:03.443Z sha 8b378a9 :: blocked before merge. :: none
  • reviewed 2026-09-28T16:58:05.446Z sha 8b378a9 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 28, 2026
steipete added a commit that referenced this pull request Oct 7, 2026
…tripped (#166238)

* fix(gateway): pause restart recovery while the crash-loop breaker is tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes #160434.

Co-authored-by: Masato Hoshino <[email protected]>

* fix(gateway): break the channel autostart recovery import cycle

* fix(gateway): type autostart recovery suppression by identity

* test(agents): await recovery admission before testing suspended stop

The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.

* fix(gateway): scope restart preparation to active crash-loop suppression

Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.

---------

Co-authored-by: Masato Hoshino <[email protected]>
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Thank you @masatohoshino! Your crash-loop recovery pause landed as part of #166238 (squash 49c1815), with you credited as co-author. That version keeps your core idea: restart recovery is quarantined while the restart-loop breaker is tripped. It also adds the automatic in-process re-arm when the breaker window clears, which was the open semantics question here, and it rebuilds the change on current main. Closing this one as superseded.

@steipete steipete closed this Oct 7, 2026
RomneyDa pushed a commit that referenced this pull request Oct 7, 2026
…tripped (#166238)

* fix(gateway): pause restart recovery while the crash-loop breaker is tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes #160434.

Co-authored-by: Masato Hoshino <[email protected]>

* fix(gateway): break the channel autostart recovery import cycle

* fix(gateway): type autostart recovery suppression by identity

* test(agents): await recovery admission before testing suspended stop

The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.

* fix(gateway): scope restart preparation to active crash-loop suppression

Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.

---------

Co-authored-by: Masato Hoshino <[email protected]>

Backport notes (release/2026.10.1): no prerequisites taken. Startup orphan
marking still lives in startGatewaySidecars on this line, so the crash-loop
suppression guard is applied there, extracted to
server-startup-main-session-orphans.ts to keep the over-cap file from growing
(regression test in
server-startup-main-session-orphans.test.ts), and the release-only
main-session-restart-dispatch-capacity.test.ts fixture gains prepareRestartRecovery. The recovery runtime keeps the release
structure and takes only this fix's gate, pause loop, and rotation handler;
state registries and the worker inventory take only the gatewayBoot entries.

(cherry picked from commit 49c1815)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…tripped (openclaw#166238)

* fix(gateway): pause restart recovery while the crash-loop breaker is tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes openclaw#160434.

Co-authored-by: Masato Hoshino <[email protected]>

* fix(gateway): break the channel autostart recovery import cycle

* fix(gateway): type autostart recovery suppression by identity

* test(agents): await recovery admission before testing suspended stop

The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.

* fix(gateway): scope restart preparation to active crash-loop suppression

Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.

---------

Co-authored-by: Masato Hoshino <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS gateway crash loop: EXC_GUARD abort on guarded fd close, restart-recovery replays the crashing session forever

2 participants