Repository navigation
fix(gateway): prevent post-ready catalog warmup from stalling RPCs - #119377
Conversation
|
Codex review: found issues before merge. Reviewed August 4, 2026, 11:11 PM ET / August 5, 2026, 03:11 UTC. ClawSweeper reviewWhat this changesThis PR batches Gateway context-cache warming and request-time catalog projection, then atomically swaps the completed cache maps to keep the event loop responsive. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The updated head fixes the prior request-time starvation finding, but it deliberately returns no configured context value while a large catalog stages; Gateway session defaults can fall back to 200k and cron can persist that fallback instead of the configured value. Priority: P1 Review scores
Verification
How this fits togetherGateway startup publishes a prepared model catalog, then warms process-local context-window metadata used by session displays and agent runs. Health/RPC/channel work shares the same event loop, so warming must yield without making configured model limits temporarily unavailable. flowchart LR
A[Gateway ready] --> B[Published model catalog]
B --> C[Context cache warmup]
C --> D{Large catalog}
D --> E[Bounded event-loop batches]
E --> F[Cache generation publish]
D --> G[Immediate configured lookup]
F --> H[Gateway sessions and agent runs]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +265, Tests +405. Total +670 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep a synchronous configured-context source valid throughout cooperative staging, while continuing to batch only the optional discovered-cache work; add coverage for Gateway session defaults and cron session persistence during that window. Do we have a high-confidence way to reproduce the issue? Yes: a 1,025-model request-time load reaches the changed branch, and the exact-head tests show the configured lookup returns undefined until the cooperative work finishes. Is this the best way to solve the issue? No: yielding catalog projection is the right owner-level fix for starvation, but withholding configured values during that work breaks existing synchronous consumers; preserve the configured source while staging. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 866dade2462f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): prevent post-ready catalog warmup from stalling RPCs This is item 1/1 in the current shard. Shard 13/44. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Merged via squash.
|
…penclaw#119377) * fix(gateway): keep context cache warmup responsive * fix(gateway): yield request-time context projection * Revert "fix(gateway): yield request-time context projection" This reverts commit ce37a8f. * Revert "fix(gateway): keep context cache warmup responsive" This reverts commit 940ffa2. * fix(gateway): stop prewarming session catalogs
AI-assisted: yes. The implementation, lifecycle ownership, and validation evidence were independently reviewed before publication.
What Problem This Solves
Fixes an issue where Gateways could appear hung after readiness because optional session-catalog prewarming ran provider-owned discovery on the Gateway event loop. On the affected host, sequential per-agent catalog phases took 11-15 seconds and unrelated metadata, branch, health, and readiness RPCs waited 16-70 seconds.
Why This Change Was Made
Session catalogs are request data, not process-stable startup metadata: providers may scan local databases, query nodes, or invoke external CLIs. This removes their speculative post-ready prewarm and the now-unused headless helper while retaining bounded session-list and process-stable plugin warmups. The authoritative
sessions.catalog.listhandler, its request cache, progress fanout, and concurrency admission remain unchanged.The context-window cache hypothesis was tested and falsified for this incident. In the representative red run,
post-ready.gateway-data.session-catalog.mainoccupied the Gateway for 114.7 seconds before context prewarm began. The historicalrecentPhasescontext label was stale diagnostic history, not causal proof.User Impact
New Gateway work is no longer blocked for tens of seconds by low-priority session-catalog preparation after readiness. The first explicit session-catalog request remains authoritative and may perform its normal provider work.
Evidence
Red control
Blacksmith Testbox with 100,000 prepared catalog models:
post-ready.gateway-data.session-catalog.main: 114,732.3 mschat.metadata: timed out at 60 secondsProduction logs independently showed six sequential session-catalog phases of 11-15 seconds,
active=0, event-loop utilization 1, and unrelated RPC/liveness delays.Proposed head
Same Gateway fixture and observation point on code commit
df38a55e0c5:chat.metadata: 104 ms, correct selected model and 128,000-token contextmodels.list: 18 ms, correct selected modelThe published PR head
fe382f639a1adds only current-main QA Lab commits; they do not touch the Gateway owner, fixture, callers, dependencies, or runtime configuration, so they do not invalidate the proof.Tests and review
pnpm check:changedpassed on Blacksmith Testbox: https://github.com/openclaw/openclaw/actions/runs/30982774526pnpm checkpassed.pnpm testrun reached the wrapper's 30-minute process cap; two earlier failures were in untouched state-database permission-injection tests.git diff --checkand formatting passed.Prior ClawSweeper review
The durable ClawSweeper comment reviewed the superseded context-cache implementation at
ce37a8f1eb4a. Its three rank-up moves are intentionally not carried into this incident-owner patch:ce37a8f1eb4abenchmark is superseded by the red/green Gateway runs above for the selected session-catalog owner and proposed implementation.The context-cache path remains separate follow-up work because it was falsified as the owner of the August 4 incident.