Skip to content

fix(gateway): preserve active turns across event-loop stalls - #131966

Merged
obviyus merged 7 commits into
openclaw:mainfrom
PollyBot13:fix/131046-event-loop-stall-restart
Aug 29, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
PollyBot13:fix/131046-event-loop-stall-restart

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #131046

AI-assisted by Codex.

What Problem This Solves

Fixes an issue where a long Gateway event-loop stall could be mistaken for a host sleep/wake cycle and immediately restart channel connections while a reply or agent startup was still active.

Why This Change Was Made

Timer-gap recovery still reconnects channels for real sleep, VM pause, SIGSTOP, and other unmanaged host pauses. Before doing that disruptive step, it now atomically closes new Gateway work admission and checks the existing active-work inventory. If tracked work is still active, only the reconnect stays pending and retries on a later maintenance tick; event-loop reset, health refresh, and presence refresh remain single-shot for that timing-gap episode. Once idle, the same admission fence remains closed until channel recovery completes.

Inspection failures reopen admission. Stop or startup-handoff failures retain only the affected account targets, so successful siblings are not restarted again by a deferred retry. A newly detected thaw always merges a fresh running-account snapshot with older failures. Startup success comes from the channel manager's typed task-handoff result: transient pre-handoff ownership conflicts remain retryable, while disabled, unconfigured, manually stopped, suppressed, unsupported, or removed accounts complete as intentional skips. Deferred recovery rechecks the current account snapshot both before and after its awaited stop, so hot-reload removal cannot accidentally start an obsolete account ID against root channel configuration. Failures after handoff remain owned by the existing restart supervisor. Closed recovery outcomes keep active-work deferral, closed admission, and incomplete account recovery distinct in logs.

This preserves the unmanaged-sleep recovery contract without adding a platform wake API, config setting, protocol change, or dependency.

User Impact

An active reply or agent startup is no longer aborted merely because the Gateway event loop was busy. Real host pauses still reconnect stale channel sockets as soon as the Gateway is quiescent. Transient account-level failures remain eligible for targeted retry, while accounts intentionally disabled or made unconfigured during recovery do not enter an indefinite retry loop.

Evidence

  • Current head: 62c311937af0eacb13179fbf97179f771e0b0962 (current main integrated after its CI shard split).
  • Production-boundary regressions cover active-to-idle deferral, retry-only maintenance ticks, suspend-admission fencing, inspection-failure cleanup, per-account stop/preflight failure retry, fresh-thaw resnapshot/merge, timed-out stop recovery, typed startup handoff, disabled/unconfigured intentional skips, and deferred-target removal.
  • pnpm exec vitest run src/gateway/host-thaw-recovery.test.ts src/gateway/server-maintenance.test.ts src/gateway/server-channels.test.ts src/infra/gateway-suspend-coordinator.test.ts — 199 passed on the current head.
  • pnpm check:changed --base upstream/main -- <12 changed files> passed formatting, lint, production/test typechecking, boundary, dependency, database, import-cycle, dead-code, and repository guards on the current head.
  • pnpm build passed on the current head. OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build also passed to stage the repository's private isolated-Gateway QA runtime.
  • ClawSweeper's prior P2 finding is addressed by the typed ChannelAccountStartOutcome; only transient ownership conflicts retain a thaw target. Its subsequent P1 security-boundary finding is addressed by discarding targets absent from the current account snapshot before and after the recovery stop. Focused regressions cover disabled, unconfigured, and removed accounts.

Exact-head isolated-Gateway trace: active to idle

Real built Gateway child, qa-channel, and mock provider on 62c311937af0eacb13179fbf97179f771e0b0962:

  • unmanaged SIGSTOP/SIGCONT pause: 80,001 ms;
  • timing-gap recovery logged host thaw channel restart deferred: gateway still has active work;
  • agent.wait timed out while recovery was pending, then completed ok; the reply persisted in chat.history;
  • channel lastStartAt stayed exactly 1787962898784 during active recovery;
  • after idle, the pending recovery restarted the channel and advanced lastStartAt to 1787963075075.

Exact-head isolated-Gateway trace: intentional skip

A second real-Gateway run held a turn active across an 80,002 ms pause, queued thaw recovery, then changed channels.qa-channel.enabled to false while channel reload was waiting for the turn to become idle:

  • thaw recovery remained deferred while the run was active;
  • the config hot reload committed after the run completed;
  • qa-channel/default settled at enabled=false, running=false, lastStartAt=1787962898784;
  • after two more maintenance ticks it remained disabled and stopped with lastStartAt unchanged;
  • no host-thaw restart failed or one or more channel accounts remain pending lines appeared.

No real external channel account was used. The isolated QA transport exercises the production channel-manager and Gateway maintenance boundaries without credentials or network delivery.

Owner acceptance card

  • Intended behavior: timer-only stalls defer channel reconnect while tracked work is active; diagnostics refresh once; unmanaged host pauses still reconnect once idle; transient account failures retry without re-churning successful siblings; intentional non-starts clear the target.
  • Boundary / blast radius: Gateway maintenance, suspend admission, and channel lifecycle handoff only; no public protocol or persistent state.
  • Strongest evidence: two exact-head isolated-Gateway traces covering active-to-idle restart and disabled-account intentional skip, plus focused current-head regression tests.
  • Falsifier: an idle unmanaged pause that does not advance a running channel generation; a new thaw that omits a running account because an older failure is pending; a failed pre-handoff start that clears retry; a disabled/unconfigured/removed account that remains pending; or admission remaining closed after inspection/restart failure.
  • Rollback: revert this PR.
  • Reviewability: 12 files, 680 additions, 67 deletions; one lifecycle invariant with focused tests and documentation.

Maintainer live red/green proof (2026-08-29)

The same isolated built-Gateway contract ran against frozen current main and this exact head. Each run started the QA channel and mock provider, admitted a real tool-using turn, confirmed the provider request, paused the Gateway process for 80.5 seconds with SIGSTOP, resumed it with SIGCONT, then checked channel generation and persisted chat history.

  • Current main feb1161a1e6456050bd495452aaf8a9409053296 was red: channel lastStartAt advanced during recovery 236 ms before the active turn reached its terminal timestamp.
  • PR head 62c311937af0eacb13179fbf97179f771e0b0962 was green: lastStartAt stayed unchanged after resume, the Gateway logged host thaw channel restart deferred: gateway still has active work, the turn completed and persisted its unique marker, then the next idle maintenance tick advanced lastStartAt.
  • Anti-cheat: the mock provider recorded the revision-specific prompt, the real exec tool completed, agent.wait returned ok, and chat.history contained the revision-specific final marker.
  • Cleanup: both isolated Gateway children, QA buses, mock providers, tool processes, and exact-revision worktrees were stopped or removed.

Maintainer acceptance of lifecycle growth

Maintainers accept the justified +231 net production-line growth. The new state belongs to the single canonical thaw-recovery flow: Gateway maintenance owns the atomic admission fence and active-work snapshot, while the ChannelManager owns typed account handoff and targeted retry outcomes. This avoids a parallel recovery path and keeps protocol, configuration, and persistence surfaces unchanged.

Rank-up move disposition

Skipped the requested rebase and duplicate live proof. The PR is CLEAN; the landing workflow merges BEHIND heads and rebases only CONFLICTING heads. Fresh origin/main at 116425e9b3044c88c20c8727360663b6ce9eeed9 changed none of the Gateway maintenance, thaw recovery, channel manager, startup wiring, active-work, admission, or recovery-doc files since the proven main SHA. The exact PR patch is unchanged, its live proof is under 24 hours old, and exact-head CI is green.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@PollyBot13
PollyBot13 marked this pull request as ready for review August 28, 2026 17:26
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 10:58 PM ET / August 29, 2026, 02:58 UTC.

ClawSweeper review

What this changes

The PR prevents Gateway timing-gap recovery from restarting active channel work until the Gateway is idle, while retrying only channel accounts whose recovery was incomplete.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: current main still restarts channels unconditionally after a timer gap, while this PR adds a coherent idle/admission fence and targeted recovery retries. The supplied exact-head Gateway traces satisfy the internal reliability proof bar, and no blocking patch defect was found.

Priority: P1
Reviewed head: 62c311937af0eacb13179fbf97179f771e0b0962

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-evidenced lifecycle repair with meaningful but owner-aligned complexity and no remaining blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed production owners are Gateway maintenance, admission control, and the channel manager; the supplied exact-head built-Gateway traces exercise an injected unmanaged pause through those owners and record that an active reply completes before deferred reconnect, plus that an intentionally disabled account is not retried.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owners are Gateway maintenance, admission control, and the channel manager; the supplied exact-head built-Gateway traces exercise an injected unmanaged pause through those owners and record that an active reply completes before deferred reconnect, plus that an intentionally disabled account is not retried.
Evidence reviewed 7 items Current-main behavior remains affected: The fetched main revision still treats a qualifying timer gap as host thaw and invokes channel restart before health and presence refresh, so the central problem is not already implemented on main.
Atomic idle fence: The introduced maintenance path closes suspend admission, synchronously inspects the shared active-work inventory, rolls back when work exists, and only commits the channel restart while idle.
Channel-owner recovery contract: The PR has the channel manager return a closed handoff/retry/intentional-skip outcome, allowing thaw recovery to retain only transient failures instead of inferring lifecycle success from snapshots.
Findings None None.
Security None None.

How this fits together

Gateway maintenance detects long timer gaps and coordinates channel recovery with active-work admission. Its decisions affect live channel connections, health snapshots, and whether in-flight replies continue uninterrupted.

flowchart LR
  A[Maintenance timer] --> B[Timing-gap detection]
  B --> C[Admission and active-work check]
  C --> D[Deferred channel recovery]
  C --> E[Health and presence refresh]
  D --> F[Channel manager]
  F --> G[Channel connections]
  E --> H[Gateway clients]
Loading

Before merge

  • Resolve merge risk (P1) - The bug fix adds 230 net production lines to a lifecycle-sensitive path; the typed handoff and per-account retry state are justified by the channel-manager ownership boundary, but maintainers should preserve this as the single thaw-recovery flow.
  • Complete next step (P2) - No narrow automated repair remains; this is ready for ordinary maintainer review of the current coherent patch.
Agent review details

Security

None.

PR surface

Source +231, Tests +379, Docs +3. Total +613 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 289 58 +231
Tests 3 386 7 +379
Docs 1 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 680 67 +613

Review metrics

Metric Value Why it matters
Production versus test delta production +230 net; tests/test support +380 net; docs +3 net The production growth implements the explicit admission, account-handoff, and retry ownership needed to avoid aborting active turns; regression coverage exceeds the new lifecycle surface.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #131046
Summary: This PR is a direct candidate fix for the linked report’s timer-gap channel-restart behavior; it remains open and unmerged.

Members:

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

Merge-risk options

Maintainer options:

  1. Keep the canonical recovery flow (recommended)
    Accept the justified lifecycle complexity only if this typed admission-and-channel-manager path remains the sole owner of deferred thaw recovery.

Technical review

Best possible solution:

Land the single admission-gated thaw-recovery path with its typed channel-manager outcomes, rather than adding a parallel restart mechanism or a configuration switch.

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

Yes, source-reproducible: fetched main unconditionally restarts channels after a qualifying timer gap, and the linked report supplies the active-turn scenario. I did not execute the untrusted contributor branch locally.

Is this the best way to solve the issue?

Yes. Reusing the existing global admission fence and active-work inventory while retaining restart outcomes at the channel-manager owner is the narrowest coherent repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5d8ef653cd71.

Labels

Label justifications:

  • P1: A long event-loop stall can interrupt an active reply or agent startup and suppress a user-visible response.
  • merge-risk: 🚨 other: The PR materially expands Gateway lifecycle coordination and must remain one canonical recovery path to avoid divergent restart state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owners are Gateway maintenance, admission control, and the channel manager; the supplied exact-head built-Gateway traces exercise an injected unmanaged pause through those owners and record that an active reply completes before deferred reconnect, plus that an intentionally disabled account is not retried.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owners are Gateway maintenance, admission control, and the channel manager; the supplied exact-head built-Gateway traces exercise an injected unmanaged pause through those owners and record that an active reply completes before deferred reconnect, plus that an intentionally disabled account is not retried.

Evidence

What I checked:

  • Current-main behavior remains affected: The fetched main revision still treats a qualifying timer gap as host thaw and invokes channel restart before health and presence refresh, so the central problem is not already implemented on main. (src/gateway/host-thaw-recovery.ts:30, 5d8ef653cd71)
  • Atomic idle fence: The introduced maintenance path closes suspend admission, synchronously inspects the shared active-work inventory, rolls back when work exists, and only commits the channel restart while idle. (src/gateway/server-maintenance.ts:131, 62c311937af0)
  • Channel-owner recovery contract: The PR has the channel manager return a closed handoff/retry/intentional-skip outcome, allowing thaw recovery to retain only transient failures instead of inferring lifecycle success from snapshots. (src/gateway/server-channels.ts:248, 62c311937af0)
  • Boundary regression coverage: Focused tests cover active-work deferral, failed idle retry, admission cleanup after inspection failure, removed targets, intentional skips, and timed-out stop replacement at the relevant maintenance and channel-manager boundaries. (src/gateway/server-maintenance.test.ts:188, 62c311937af0)
  • Real behavior proof: The supplied exact-head PR evidence reports two built isolated-Gateway runs: an 80-second SIGSTOP/SIGCONT stall that preserved and completed an active reply before restarting at idle, and a deferred account disabled by hot reload that remained intentionally stopped without retry churn. (62c311937af0)
  • Feature provenance: The pre-PR thaw recovery lines blame to the available history boundary attributed to Vincent Koc; local history is shallow beyond that boundary, so this is routing evidence rather than a causal attribution. (src/gateway/host-thaw-recovery.ts:62, ec3a8343c5de)

Likely related people:

  • Vincent Koc: The available blame boundary attributes the unconditional thaw-recovery flow to this author; deeper predecessor history is unavailable locally. (role: pre-PR behavior author; confidence: medium; commits: ec3a8343c5de; files: src/gateway/host-thaw-recovery.ts, src/gateway/server-maintenance.ts)
  • Peter Steinberger: Available shortlog history shows substantial contribution volume across the thaw/maintenance/channel lifecycle paths, though the shallow checkout prevents a more specific commit trail. (role: historical area contributor; confidence: low; files: src/gateway/host-thaw-recovery.ts, src/gateway/server-maintenance.ts, src/gateway/channel-thaw-restart.ts)

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-28T19:10:41.715Z sha 7e4b17d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T19:22:37.072Z sha 7e4b17d :: found issues before merge. :: [P2] Retry only the deferred channel restart
  • reviewed 2026-08-28T21:48:49.752Z sha 8f52de6 :: needs changes before merge. :: [P2] Preserve retries after channel-account restart failures
  • reviewed 2026-08-28T22:50:15.384Z sha 9613a4ad8cb75ca7cc6aa7798ec11acf829c7746 :: needs real behavior proof before merge. :: [P2] Do not retry intentional channel non-starts indefinitely
  • reviewed 2026-08-28T23:47:54.394Z sha 9f9a0bb :: needs changes before merge. :: [P1] Skip removed accounts in deferred thaw recovery
  • reviewed 2026-08-29T00:07:27.321Z sha 0786873 :: needs changes before merge. :: [P1] Skip removed accounts in deferred thaw recovery
  • reviewed 2026-08-29T00:34:10.139Z sha 62c3119 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T00:42:56.666Z sha 62c3119 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 28, 2026
@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the durable PR body for exact head 7e4b17dc6c951503bfa9e02ea5abe9406e713fa1 with the requested direct active-to-idle proof: a real Gateway chat run stayed active across an 80-second unmanaged process pause, recovery deferred without changing the channel generation, the run then completed normally with its reply persisted, and the pending restart ran on the first idle maintenance tick. Focused validation remains 175/175 passing, and the exact-head CI gate is green.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 28, 2026
@PollyBot13 PollyBot13 changed the title fix(gateway): event-loop stalls no longer restart channels fix(gateway): preserve active turns across event-loop stalls Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 28, 2026
@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Final head 078687371c8d7788ca7d98285589ac2793e529b2 integrates current main after its CI shard split. The PR-owned patch is unchanged (identical stable patch ID; still 12 files, +630/−69).

The prior P2 remains addressed with typed start outcomes: disabled/unconfigured/manual/suppressed/unsupported accounts are intentional skips, while only transient pre-handoff ownership conflicts retain a thaw target.

The PR body now contains fresh redacted exact-head isolated-Gateway traces for both requested cases:

  • active-to-idle: 80,003 ms unmanaged pause, active run retained and completed, reply persisted, channel restart deferred until idle;
  • intentional skip: account disabled while thaw recovery was pending, then remained disabled/stopped with unchanged lastStartAt across two maintenance ticks and no retained-target failure logs.

Integrated-head verification: 198 focused tests passed; pnpm check:changed, private-QA build, and the upstream ui-pages-e2e shard-boundary check passed.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@PollyBot13

PollyBot13 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact head: 62c311937af0eacb13179fbf97179f771e0b0962

Addressed the P1 removed-account security-boundary finding: deferred thaw recovery now requires the account to remain present in the current runtime snapshot both before and after its awaited stop, and discards removed targets instead of explicitly starting an obsolete account ID. Added a focused removed-target regression.

Current-head verification: 199 focused tests, full check:changed, private-QA build, and both real Gateway-child 80-second stall proofs pass.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer acceptance: this exact admission-fenced, ChannelManager-owned targeted-retry flow is the permanent canonical recovery policy for long timer gaps. The +231 net production-line growth is justified because it keeps admission, active-work inspection, account handoff, and retry state in one owner path without protocol, configuration, or persistence changes.

@obviyus
obviyus enabled auto-merge (squash) August 29, 2026 03:20
@obviyus
obviyus merged commit 7e2111e into openclaw:main Aug 29, 2026
287 of 289 checks passed
@obviyus

obviyus commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @PollyBot13!

Proof: The same isolated built-Gateway scenario ran on current main and this exact head. A real tool-using turn stayed active across an 80.5-second process pause. Main restarted the QA channel 236 ms before the turn ended. This head kept the channel generation unchanged, completed and persisted the reply, then reconnected on the next idle maintenance tick.

  • Bug: A long event-loop delay looked like host sleep and restarted channels while a reply or agent startup was still active.
  • Fix: Gateway maintenance now closes admission, checks the canonical active-work inventory, and defers only channel reconnect until idle while the ChannelManager owns targeted account retry.

Example

Before After
An 80.5-second event-loop pause restarts the channel before the active turn ends. The active turn finishes and persists its reply, then the channel reconnects on the next idle tick.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…w#131966)

Prevent timer-only Gateway stalls from restarting channel connections while replies or agent startup work remains active. Recovery now closes admission, defers reconnect until the canonical active-work inventory is idle, and retries only incomplete account handoffs.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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]: host-thaw detector treats event-loop stalls as suspension and restarts channels during active turns

2 participants