Repository navigation
fix(gateway): Control UI reconnects freeze the Gateway while plugins reload - #167374
Conversation
Cold tools.effective refreshes acquired a read-only prepared runtime with loadRuntimePlugins but without allowGatewaySubagentBinding, so prepared registry borrowing (#161267) never applied. Each Control UI reconnect past the 120s cache synchronously reloaded the provider, memory-slot and context-engine plugins (9-14s with large external plugins), stalling every in-flight request. Refs #167351
|
🦞👀 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. Reviewed October 8, 2026, 2:33 PM ET / 18:33 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch lets cold tool-inventory model lookups borrow compatible plugin instances from their admitting Gateway. Example: The user reconnects Control UI with knowledge and lossless-claw installed.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: current main still reloads plugins on the cold inventory path. The recorded live comparison supports the fix, and the newly recorded exact-head build resolves the previous review’s blocker; no blocking patch defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherControl UI asks the Gateway which tools are available for a session’s selected model. The inventory resolver prepares model facts and returns filtered tool descriptions; plugin borrowing lets that preparation reuse the Gateway’s already-loaded instances. flowchart TD
A[Control UI reconnect] --> B[Cold tool inventory request]
B --> C[Prepare selected model facts]
C --> D{Compatible live Gateway plugins?}
D -->|Yes| E[Borrow existing instances]
D -->|No| F[Load separate instances]
E --> G[Return filtered tool inventory]
F --> G
Technical reviewBest possible solution: Use the existing Gateway borrowing owner for cold inventory preparation while keeping broader naming and tool-selection repairs in their linked work. Do we have a high-confidence way to reproduce the issue? Yes: current source shows the cold dynamic-model lease omitting the flag required for Gateway borrowing, and the contributor records a failing real-Gateway baseline with large plugins; this read-only review did not execute it. Is this the best way to solve the issue? Yes: passing the existing hosting marker repairs the missed reuse at its caller without adding another cache, loader, public API, or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6b73b9e932c8. Provenance checked
TestingProof path: shipped entry point. Added test files: 2. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +67. Total +70 across 4 files. View PR surface stats
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)
|
|
On the low-value test note for The bug wasn't in the loader. #161267's suites (
Only the module evaluation below that boundary is stubbed, and the existing borrow suites already own that. It isn't a mirror of the change either:
The |
|
Merged via squash.
|
…penclaw#167374) Cold tools.effective refreshes acquired a read-only prepared runtime with loadRuntimePlugins but without allowGatewaySubagentBinding, so prepared registry borrowing (openclaw#161267) never applied. Each Control UI reconnect past the 120s cache synchronously reloaded the provider, memory-slot and context-engine plugins (9-14s with large external plugins), stalling every in-flight request. Refs openclaw#167351
…167374) Cold tools.effective refreshes acquired a read-only prepared runtime with loadRuntimePlugins but without allowGatewaySubagentBinding, so prepared registry borrowing (#161267) never applied. Each Control UI reconnect past the 120s cache synchronously reloaded the provider, memory-slot and context-engine plugins (9-14s with large external plugins), stalling every in-flight request. Refs #167351 (cherry picked from commit cc8a38f)
Adapt openclaw#167374 for the extended-stable runtime. Co-authored-by: RomneyDa <[email protected]>
Related: #167351
What Problem This Solves
Fixes: the Gateway freezes for about 9–14 s whenever a Control UI tab connects or reconnects. During the freeze every request on the page stalls, and
sessions.github.optionstimes out and shows "Publication status unavailable".User Impact
User impact: Control UI reconnects no longer stall the Gateway when large external plugins (for example a
memoryorcontextEngineslot plugin) are installed. On the cold path,tools.effectivenow finishes in about half a second.Why This Change Was Made
A cold
tools.effectiverefresh resolves the session's dynamic runtime model through a read-only prepared runtime withloadRuntimePlugins: true. That lease never setallowGatewaySubagentBinding. Since #161267, that flag is what lets a prepared runtime borrow the admitting Gateway's live plugin instances. Without it, every cold refresh synchronously loaded the provider, memory-slot, and context-engine plugins on the event loop. Reconnects more than 120 s after the last refresh, or on a new session, always took the cold path.The lease now sets the flag, which makes it borrow like the other Gateway-hosted prepared loads. The main inventory call in the same file already passes it. The flag's name is misleading: it is effectively the "Gateway-hosted load" marker. #167351 tracks the rename and an audit of the other callers.
Evidence
knowledgeandlossless-clawplugins loaded. Each run calledtools.effectivecold on a freshly created session:res ✓ tools.effective 9731msres ✓ tools.effective 528ms, with no plugin load during the request[plugins] loaded 3 plugin(s)events in one day, each 8.7–14 s and each triggered by a webchat connect. 12 of 13sessions.github.optionstimeouts that day completed 10–30 ms after one of these loads.src/agents/tools-effective-inventory.gateway-borrow.test.ts. It runs the real lookup inside a Gateway request scope and asserts that the plugin load receivesborrowRegistry. It fails onmain(borrowRegistry: undefined) and passes with this change.pnpm test <file> --maxWorkers=1: 64 s wall, 30 s Vitest duration, mostly transform; the test body takes about 1 s. It runs in the database-worker project because the prepared runtime needs the host SQLite broker.tools-effective-inventory*(including the real-plugincold-providersuite),prepared-model-runtime.registry-borrow, andserver-methods/tools-effective.pnpm check:changed: everything passed except core lint, which flagged only a dangling_contextname in the new test. That is fixed and the touched files lint clean; the full lint lane was not rerun afterwards.pnpm buildon the reviewed head0ea25eb48c7: exit 0 in 9m42s. The UI bundle report lists a startup JS gzip budget violation (364.9 KiB vs 364.7 KiB); this PR touches no UI code, so that comes from the base.