Repository navigation
fix(gateway): config changes no longer exhaust session discovery with GitHub publication refreshes - #195679
Conversation
…bered sessions Serialize background GitHub publication fact refreshes per discovery instance so config, identity, and profile invalidations do not launch up to 256 concurrent preparations on the session target discovery lane at once. Fixes openclaw#195649
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesSerialize background GitHub publication preparation so config changes do not flood shared session discovery. Example: Add an agent while 256 remembered GitHub-bound sessions refresh and foreground chat requests arrive.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current producer-side overload bug, resolves the earlier queue-stall finding, and has credible Gateway proof; no actionable defects remain, while exact-head CI is still running. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway discovery owner consumes session demand and config or identity invalidations, prepares workspace and GitHub facts through shared workers, and publishes cached facts for worker-turn admission. flowchart TD
A[Session demand] --> C[Gateway discovery owner]
B[Config and identity changes] --> C
C --> D[Serialized preparation queue]
D --> E[Shared session discovery workers]
E --> F[Published GitHub facts]
F --> G[Worker turn admission]
Technical reviewBest possible solution: Keep serialization in the existing discovery owner, preserving synchronous reads, immediate credential retirement, and progress when active entries are replaced. Do we have a high-confidence way to reproduce the issue? Current-main source retains the concurrent refresh producer, and supplied baseline Gateway output demonstrates publication loss and foreground refusals; this read-only review ran no target code. Is this the best way to solve the issue? The patch fixes admission pressure at its producer with a small instance-owned queue, and the centralized cache-write operation correctly handles the previously reported demand-replacement stall. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7ce2d10eced5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +42, Tests +30. Total +72 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 18, 2026, 12:53 PM ET / 17:53 UTC (Revision 2). |
Demand replacement, removal and LRU eviction all write the discovery cache through one store() owner, which frees the serialized refresh queue when the preparing entry is no longer current. The stale preparation still finishes on its own and never publishes. Keeps openclaw#195679's one-at-a-time refresh waves; restores the test file's spacing.
|
Proof for 0215ea4 (this head) against main e08aa74 (merge base; Gateway from TypeScript source (pinned Bun runtime, Regression |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @ElNeMeR70 for the fix and @609NFT for the report. This is merged in 2272edc: a config change no longer refreshes every remembered GitHub publication fact at once. Refreshes now run one session at a time, so the shared session-lookup worker no longer overflows, publication facts are no longer dropped, and user reads such as chat history are no longer refused during the refresh. |
… GitHub publication refreshes (openclaw#195679) Root cause: src/gateway/github-publication-discovery.ts:135-146 (main d161105) `refreshAll` schedules a preparation for every remembered session (up to 256) at `delayMs: 0`, and the scheduler starts them all at once. Each preparation reads the session-store inventory on the one-worker, 128-pending "Session target discovery" lane, so one config change fills that lane, refuses user reads with `worker task capacity reached`, and leaves the refused sessions' publication facts unavailable. Fixes openclaw#195649 Thanks @609NFT for the report and the production numbers, and @ElNeMeR70 for the serialization fix this builds on. ## What Problem This Solves Fixes: user turns and session reads fail with `worker task capacity reached`, and GitHub publication becomes unavailable for many sessions, right after an agent add or other config change on a Gateway with more than about 128 recently active GitHub-bound sessions. ## User Impact A config change (agent add, model switch) or a GitHub identity change no longer refuses user work on busy Gateways. Publication facts refresh in the background one session at a time, as before at the same ids and times, and all of them come back. ## Why This Change Was Made Discovery now prepares one session at a time, per discovery instance (@ElNeMeR70's commit). On top of that, every write to the discovery cache goes through one `store()` owner. When the session being prepared is replaced by demand, its binding is removed, or it is evicted from the cache, the queue moves on right away. The stale preparation still finishes on its own and its result is never published. In the first commit only some replacement paths released the queue, so a demand replacement (a new session id for the same key) left the next session waiting behind obsolete work. No new limits or config; worker admission is unchanged. ## Evidence Gateway run from source with local model and GitHub API fixtures, 256 managed-worktree sessions with publication facts, an agent add through `config.patch` while user turns (`chat.send`) and session opens (`chat.history`) arrive every 10 ms. Full observed output: openclaw#195679 (comment) - main d161105: one agent add left 131 of 256 publication facts unavailable (refused by the 128-pending lane); in another run 19 `chat.history` requests failed with `UNAVAILABLE` `WorkerTaskError: worker task capacity reached: code=overloaded`. - This head: 0 capacity refusals, 150/150 turns and 150/150 session opens succeed, all 256 facts prepared again (39 s). - Controls on this head: one remembered session refreshes in 0.76 s as before; a second agent add 1.1 s into a wave replaces it cleanly (all 256 prepared at 47.8 s, no second full wave, no refusals). - Regression test fails on main (200 concurrent preparations) and on the first commit (queue stuck behind the replaced session), passes here; `src/gateway/github-publication-discovery.test.ts` 12/12. Merge danger: two-way door. Process-local scheduling only; no stored state, config or protocol changes, and a revert restores the concurrent refresh. Blast radius: GitHub publication discovery on the Gateway (when publication facts refresh after config, identity or profile changes). Co-authored-by: Ayaan Zaidi <[email protected]>
… GitHub publication refreshes (#195679) Root cause: src/gateway/github-publication-discovery.ts:135-146 (main e08aa74) `refreshAll` schedules a preparation for every remembered session (up to 256) at `delayMs: 0`, and the scheduler starts them all at once. Each preparation reads the session-store inventory on the one-worker, 128-pending "Session target discovery" lane, so one config change fills that lane, refuses user reads with `worker task capacity reached`, and leaves the refused sessions' publication facts unavailable. Fixes #195649 Thanks @609NFT for the report and the production numbers, and @ElNeMeR70 for the serialization fix this builds on. ## What Problem This Solves Fixes: user turns and session reads fail with `worker task capacity reached`, and GitHub publication becomes unavailable for many sessions, right after an agent add or other config change on a Gateway with more than about 128 recently active GitHub-bound sessions. ## User Impact A config change (agent add, model switch) or a GitHub identity change no longer refuses user work on busy Gateways. Publication facts refresh in the background one session at a time, as before at the same ids and times, and all of them come back. ## Why This Change Was Made Discovery now prepares one session at a time, per discovery instance (@ElNeMeR70's commit). On top of that, every write to the discovery cache goes through one `store()` owner. When the session being prepared is replaced by demand, its binding is removed, or it is evicted from the cache, the queue moves on right away. The stale preparation still finishes on its own and its result is never published. In the first commit only some replacement paths released the queue, so a demand replacement (a new session id for the same key) left the next session waiting behind obsolete work. No new limits or config; worker admission is unchanged. ## Evidence Gateway run from source with local model and GitHub API fixtures, 256 managed-worktree sessions with publication facts, an agent add through `config.patch` while user turns (`chat.send`) and session opens (`chat.history`) arrive every 10 ms. Full observed output: #195679 (comment) - main e08aa74: one agent add left 131 of 256 publication facts unavailable (refused by the 128-pending lane); in another run 19 `chat.history` requests failed with `UNAVAILABLE` `WorkerTaskError: worker task capacity reached: code=overloaded`. - This head: 0 capacity refusals, 150/150 turns and 150/150 session opens succeed, all 256 facts prepared again (39 s). - Controls on this head: one remembered session refreshes in 0.76 s as before; a second agent add 1.1 s into a wave replaces it cleanly (all 256 prepared at 47.8 s, no second full wave, no refusals). - Regression test fails on main (200 concurrent preparations) and on the first commit (queue stuck behind the replaced session), passes here; `src/gateway/github-publication-discovery.test.ts` 12/12. Merge danger: two-way door. Process-local scheduling only; no stored state, config or protocol changes, and a revert restores the concurrent refresh. Blast radius: GitHub publication discovery on the Gateway (when publication facts refresh after config, identity or profile changes). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2272edc) Co-authored-by: RomneyDa <[email protected]>
… GitHub publication refreshes (openclaw#195679) Root cause: src/gateway/github-publication-discovery.ts:135-146 (main e08aa74) `refreshAll` schedules a preparation for every remembered session (up to 256) at `delayMs: 0`, and the scheduler starts them all at once. Each preparation reads the session-store inventory on the one-worker, 128-pending "Session target discovery" lane, so one config change fills that lane, refuses user reads with `worker task capacity reached`, and leaves the refused sessions' publication facts unavailable. Fixes openclaw#195649 Thanks @609NFT for the report and the production numbers, and @ElNeMeR70 for the serialization fix this builds on. ## What Problem This Solves Fixes: user turns and session reads fail with `worker task capacity reached`, and GitHub publication becomes unavailable for many sessions, right after an agent add or other config change on a Gateway with more than about 128 recently active GitHub-bound sessions. ## User Impact A config change (agent add, model switch) or a GitHub identity change no longer refuses user work on busy Gateways. Publication facts refresh in the background one session at a time, as before at the same ids and times, and all of them come back. ## Why This Change Was Made Discovery now prepares one session at a time, per discovery instance (@ElNeMeR70's commit). On top of that, every write to the discovery cache goes through one `store()` owner. When the session being prepared is replaced by demand, its binding is removed, or it is evicted from the cache, the queue moves on right away. The stale preparation still finishes on its own and its result is never published. In the first commit only some replacement paths released the queue, so a demand replacement (a new session id for the same key) left the next session waiting behind obsolete work. No new limits or config; worker admission is unchanged. ## Evidence Gateway run from source with local model and GitHub API fixtures, 256 managed-worktree sessions with publication facts, an agent add through `config.patch` while user turns (`chat.send`) and session opens (`chat.history`) arrive every 10 ms. Full observed output: openclaw#195679 (comment) - main e08aa74: one agent add left 131 of 256 publication facts unavailable (refused by the 128-pending lane); in another run 19 `chat.history` requests failed with `UNAVAILABLE` `WorkerTaskError: worker task capacity reached: code=overloaded`. - This head: 0 capacity refusals, 150/150 turns and 150/150 session opens succeed, all 256 facts prepared again (39 s). - Controls on this head: one remembered session refreshes in 0.76 s as before; a second agent add 1.1 s into a wave replaces it cleanly (all 256 prepared at 47.8 s, no second full wave, no refusals). - Regression test fails on main (200 concurrent preparations) and on the first commit (queue stuck behind the replaced session), passes here; `src/gateway/github-publication-discovery.test.ts` 12/12. Merge danger: two-way door. Process-local scheduling only; no stored state, config or protocol changes, and a revert restores the concurrent refresh. Blast radius: GitHub publication discovery on the Gateway (when publication facts refresh after config, identity or profile changes). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2272edc) Release adaptation: Exact source queue ownership and 200-session regression; added30-line test cost allocation. Red11/12 expected200vs1 then green12/12. Format and type-aware lint green. Co-authored-by: RomneyDa <[email protected]>
… GitHub publication refreshes (#195679) Baseline adaptation: Serialize the existing keyed refresh scheduler and release superseded entries without publishing stale results; retain the shipped projection and incognito behavior. (cherry picked from commit 2272edc) Co-authored-by: RomneyDa <[email protected]>
Root cause: src/gateway/github-publication-discovery.ts:135-146 (main e08aa74)
refreshAllschedules a preparation for every remembered session (up to 256) atdelayMs: 0, and the scheduler starts them all at once. Each preparation reads the session-store inventory on the one-worker, 128-pending "Session target discovery" lane, so one config change fills that lane, refuses user reads withworker task capacity reached, and leaves the refused sessions' publication facts unavailable.Fixes #195649
Thanks @609NFT for the report and the production numbers, and @ElNeMeR70 for the serialization fix this builds on.
What Problem This Solves
Fixes: user turns and session reads fail with
worker task capacity reached, and GitHub publication becomes unavailable for many sessions, right after an agent add or other config change on a Gateway with more than about 128 recently active GitHub-bound sessions.User Impact
A config change (agent add, model switch) or a GitHub identity change no longer refuses user work on busy Gateways. Publication facts refresh in the background one session at a time, as before at the same ids and times, and all of them come back.
Why This Change Was Made
Discovery now prepares one session at a time, per discovery instance (@ElNeMeR70's commit). On top of that, every write to the discovery cache goes through one
store()owner. When the session being prepared is replaced by demand, its binding is removed, or it is evicted from the cache, the queue moves on right away. The stale preparation still finishes on its own and its result is never published. In the first commit only some replacement paths released the queue, so a demand replacement (a new session id for the same key) left the next session waiting behind obsolete work. No new limits or config; worker admission is unchanged.Evidence
Gateway run from source with local model and GitHub API fixtures, 256 managed-worktree sessions with publication facts, an agent add through
config.patchwhile user turns (chat.send) and session opens (chat.history) arrive every 10 ms. Full observed output: #195679 (comment)chat.historyrequests failed withUNAVAILABLEWorkerTaskError: worker task capacity reached: code=overloaded.src/gateway/github-publication-discovery.test.ts12/12.Merge danger: two-way door. Process-local scheduling only; no stored state, config or protocol changes, and a revert restores the concurrent refresh. Blast radius: GitHub publication discovery on the Gateway (when publication facts refresh after config, identity or profile changes).