sessions.changed has no debounce: 1169 triggers, 0 requests sent
Summary
Every sessions.changed broadcast from the gateway triggers an immediate, unthrottled, un-coalesced re-request of the full sessions list. There is no debounce anywhere in the gateway client.
The measured effect on a single session: 1169 triggers, 0 requests actually sent, each of which still ran a full local rebuild.
Root cause
src/OpenClaw.Shared/OpenClawGatewayClient.cs:3515
case "sessions.changed":
...
// Gateway broadcasts this after session mutations (patch, send, etc.).
// Re-request the full sessions list so we pick up model/thinking changes.
_logger.Info("[EVENT] sessions.changed received - refreshing sessions list");
_ = RequestSessionsAsync(); // line 3525 -- fire-and-forget, discarded
break;
Two problems:
- No debounce/coalescing. A grep for
Debounce/ThrottleacrossOpenClawGatewayClient.csreturns zero matches. The gateway broadcasts this after every session mutation, so an agent run emits them continuously. - The task result is discarded (
_ =). IfRequestSessionsAsyncthrows, the exception is never observed and never logged.
The same pattern also appears in HandleSessionEvent at line 4345.
Evidence
From a 2.8 day log of 2026.9.4.0:
| Metric | Count |
|---|---|
sessions.changed received - refreshing sessions list |
1169 |
Sending frame: sessions.list |
0 |
| Peak rate | 25 in a single minute |
The 1169:0 ratio is the interesting part. RequestSessionsAsync goes through SendTrackedRequestAsync, which bails out early when the connection is not ready (TryGetReadyConnectionGeneration, line 2251):
if (!TryGetReadyConnectionGeneration(out var connectionGeneration))
{
_logger.Debug($"[GatewayClient] {method} suppressed before handshake");
return false;
}
That rejection is logged at Debug level, so in production it is invisible. The net effect: the UI performs 1169 full session-list rebuilds while zero network requests go out.
Each rebuild is not cheap. ParseSessions (line 4470) fires SessionsUpdated, which lands in src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:1139:
private void OnSessionsUpdated(object? sender, SessionInfo[] sessions)
{
if (_state.IsDisposed) return;
var transition = _state.ApplySessions(sessions ?? [], ProjectionContext());
Publish(transition.Snapshot); // full snapshot republish
...
}
So every broadcast triggers a full apply-and-publish cycle on the chat timeline.
Why this matters together with #1568
This is a force multiplier for the UI thread hang reported in #1568:
agent runs tool calls
-> gateway broadcasts sessions.changed (no throttle)
-> session list + chat timeline full rebuild
-> layout change in the chat ItemsView
-> OnLayoutUpdated -> StartBringItemIntoView (#1568)
-> self-sustaining spin -> UI thread at 100% CPU
Fixing only #1568 leaves the trigger frequency untouched. Fixing only this issue leaves the spin engine in place. Both are needed for the hang to actually stop recurring.
Suggested direction
- Debounce
sessions.changed(coalesce a burst into one re-request). A short window (100-300ms) would collapse the observed 25/min bursts while staying well under thetickinterval. - Do not discard the task. Either
awaitit with a try/catch, or attach a continuation that logs failures. A silently swallowed exception in a request path makes this class of problem invisible. - Consider raising the suppression log at line 2253 from Debug to Warn, or at least surface a counter. A 1169:0 trigger-to-send ratio is exactly the kind of thing that should be visible.
HandleSessionEvent(line 4345) should share the same coalescing path rather than duplicating the bare call.
Impact
Steady UI churn proportional to agent activity, with no network benefit. Directly amplifies the hang in #1568. Not a crash on its own, but it degrades the timeline under load.
Required proof pools
UI(chat)connection(gateway client request path)
Validation
Report, not a code change. Counts derived from the shipped 2026.9.4.0 openclaw-tray.log across 2026-09-29 to 2026-10-01, with the trigger/send ratio cross-checked against the per-method Sending frame: distribution.
Codex review: this still needs some work.
Summary Keep open: current main retains uncoalesced session refreshes, and an open draft fixing PR explicitly closes this issue.
Reproducibility: Current source establishes one request attempt per admitted session event and potentially unobserved failures; related discussion supplies released-build amplification evidence, but this read-only review ran no reproduction or tests.
Next step Review and validate https://github.com/openclaw/openclaw-windows-node/pull/1885 (fix: coalesce session refreshes during event bursts), then let its merge close this issue.
Review details
Best possible solution:
Use one lifecycle-bound event-refresh scheduler that bounds automatic requests, observes failures, preserves explicit refreshes, and reconciles trailing changes.
Do we have a high-confidence way to reproduce the issue?
Current source establishes one request attempt per admitted session event and potentially unobserved failures; related discussion supplies released-build amplification evidence, but this read-only review ran no reproduction or tests.
Is this the best way to solve the issue?
Shared event-only coalescing fits the established defect; the linked PR should validate burst handling, trailing freshness, failure recovery, lifecycle fencing, and unchanged explicit refreshes.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- The reported 1169:0 ratio and one-rebuild-per-suppressed-request explanation are unsupported by the actual send path.
- Native chat hang causality remains unverified; the linked fixing PR also excludes a hang-fix claim.
Codex review notes: model internal, reasoning medium; reviewed against ed1444b0de69.
Label changes
Label changes:
- add
clawsweeper:linked-pr-open: Current issue advisory state selects this label. - remove
clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label. - remove
clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label. - remove
clawsweeper:needs-product-decision: Current issue advisory state no longer selects this label.
Label justifications:
P2: Source-proven redundant roster requests warrant repair, without established message loss or a directly attributable blocked workflow.impact:other: The supported impact is excess session-roster traffic, processing overhead, and unobserved refresh failures.
Evidence reviewed
What I checked:
- Verified current main and repository policy: GitHub main matches the checkout. The complete root AGENTS.md was read and relevant ownership guidance applied; no files changed, builds, tests, review helpers, or secondary reviewers ran. (
AGENTS.md:1, ed1444b0de69) - Uncoalesced event requests remain: sessions.changed discards RequestSessionsAsync at line 3627, and HandleSessionEvent repeats it at line 4509; RequestSessionsAsync directly sends sessions.list without an event scheduler. (
src/OpenClaw.Shared/OpenClawGatewayClient.cs:3627, ed1444b0de69) - Send-count inference and failure propagation: The Sending frame message belongs to the response-request sender, whereas session refreshes use SendTrackedRequestAsync. Readiness suppression returns without parsing or rebuilding sessions; admitted transport failures can propagate into discarded refresh tasks. (
src/OpenClaw.Shared/OpenClawGatewayClient.cs:2339, ed1444b0de69) - Downstream publication already coalesces: OnSessionsUpdated applies returned rosters, while Publish retains the latest pending snapshot and schedules a dispatcher drain; this downstream mechanism does not coalesce upstream roster requests. (
src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:1951, ed1444b0de69) - Open fixing PR owns the repair: https://github.com/openclaw/openclaw-windows-node/pull/1885 (fix: coalesce session refreshes during event bursts) is open, draft, and explicitly closes this issue for uncoalesced requests and discarded errors; its body proposes a fixed 250 ms window and reports focused loopback regressions, with Windows closeout pending. (2037e2fa2e7b)
- Independent released-build amplification evidence: HerbertHuerto reports official Companion 2026.9.4 yielding 92 Companion-attributed roster responses versus 25 with private coalescing during 100 successful label patches: https://github.com/openclaw/openclaw-windows-node/issues/906#issuecomment-5702569518; these are contributor observations, not this review's runtime proof.
How this review workflow works
- 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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
- Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Reviewed October 26, 2026, 10:24 PM ET / October 27, 2026, 02:24 UTC.
🦞🔧 ClawSweeper is automatically building a fix for this issue.
The issue review finished and no active implementation pull request was found.
Automatic implementation progress:
- State: Planning
- Detail: Codex is reading the issue and repository, choosing an implementation, and planning validation.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/36839856877
- Updated: 2026-10-01T09:00:35.938Z
- Opt out: add
clawsweeper:manual-onlyorclawsweeper:human-review.