Repository navigation
fix(gateway): Gateway stalls after startup recapturing plugins for model catalog updates - #167544
Conversation
|
🦞👀 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 changesRun scheduled model catalog adoption within the live Gateway plugin registry scope so unchanged plugins reuse their existing instances. Example: A running Gateway adopts a newer hosted model catalog with an external context-engine plugin installed.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR remains useful: current main still lacks the scheduler connection to the established plugin borrowing owner. No actionable patch defect or unresolved product decision was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway downloads model catalogs and prepares replacement model runtimes before publishing them. Its plugin registry scope identifies the live Gateway whose unchanged plugin instances those runtimes can borrow. flowchart TD
A[Gateway becomes ready] --> B[Scheduled catalog check]
B --> C[New catalog available]
C --> D[Live Gateway registry scope]
D --> E[Prepare replacement model runtime]
E --> F{Unchanged plugin and live owner?}
F -->|Yes| G[Borrow existing instance]
F -->|No| H[Load separate instance]
Technical reviewBest possible solution: Use the existing live-registry borrowing owner for scheduled adoption and retain the broader capture-performance investigation as separate work. Do we have a high-confidence way to reproduce the issue? Yes: current main's missing registry scope explains the second capture, and the supplied parent Gateway runs consistently demonstrate that trigger. This review did not execute the runtime. Is this the best way to solve the issue? Yes: connecting scheduled adoption to the established borrowing owner matches hot reload and removes the missed scope without adding a competing cache or lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fd2fa6b904a2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +7, Tests +35. Total +42 across 4 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 (4 earlier review cycles)
Reviewed October 9, 2026, 12:51 AM ET / 04:51 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 41b4607. Bug: after startup, the scheduled remote model catalog refresh rebuilt prepared runtimes with no Gateway registry scope. With no lender to borrow from, it copied and cold-loaded every external plugin a second time, which stalled the Gateway. Fix: scheduled catalog adoption now runs inside the live Gateway registry scope, the same way config hot reload does. Prepared rebuilds borrow the unchanged Gateway plugin instances. Proof: same hosted catalog applied in every run. The parent recaptured after ready in 5/5 runs, this change in 0/7. Each instance is still disposed exactly once through hot reload and stop. The new regression test fails without the fix. Full CI is green on the merged head. |
…del catalog updates (openclaw#167544) Related: openclaw#160959 ## What Problem This Solves Fixes: shortly after every Gateway start, the scheduled remote model catalog refresh copies every external plugin a second time and loads it cold. With a large plugin, this blocks the Gateway for as long as the startup capture did. ## User Impact User impact: when the hosted model catalog is newer than the installed build (the normal case for released versions), adopting it no longer re-copies or re-evaluates external plugins. The Gateway stays responsive after startup. Prepared turns keep using the Gateway's unchanged plugin instances, as they already do after config hot reloads. ## Why This Change Was Made openclaw#161267 made prepared model runtimes borrow unchanged plugin instances from the admitting Gateway. The lender is resolved from the Gateway registry scope of the work that triggers the rebuild. Hot reloads already run their prepared-runtime refresh inside that scope (`server-reload-hot.ts`). The post-ready `update.remote-model-catalog` scheduler job calls `applyRemoteModelCatalogUpdate` with no registry scope. The prepared rebuild therefore finds no lender, and its inbound registry cold-loads every plugin. This change runs scheduled catalog adoption inside the live Gateway registry scope, the same way the hot-reload refresh does. No new cache, manager or module sharing is added. Each registry keeps its own load and dispose lifecycle, and borrowing follows the existing openclaw#161267 contract. ## Evidence **Trigger proven on origin/main 618f4d2.** Runs were isolated Gateways with an external plugin used as the context engine, each held 60 s after `ready`, with scratch probes outside the repo: - Catalog refresh enabled: 8/8 runs captured and loaded the plugin a second time after ready. The probe at `loadPreparedInboundPluginRegistry` logged `lender=false requestScope=false` during `applyRemoteModelCatalogUpdate`, followed by `remote model catalog applied`. - Catalog refresh disabled (`models.catalogRefresh.enabled: false`): 3/3 runs had no second load. - Full stack of the second capture: `buildSnapshotBatch → prepareWorkspacePluginRegistries → loadPreparedInboundPluginRegistry → loadAgentRuntimePluginRegistryHandle → loadOpenClawPlugins`. - Cost on main with an 8k-file plugin: `startup.maintenance.plugin-registry` took 46.2 s and 57.7 s with event-loop max 45.2 s and 57.3 s, plus a 78 s post-ready reload in another run. **With this change.** Same harness: - On 618f4d2 with this patch: 7/7 runs had 0 loads after ready. In each run the catalog was refreshed (`status: updated`) and applied, and the probe logged `inbound lender=true requestScope=true`. - On this PR's exact head versus its exact parent: these builds are newer than the current hosted catalog, so the runs serve the same hosted catalog with a newer `generatedAt` from a loopback `models.catalogRefresh.url`. Each run was held 60 s after ready, and the catalog was refreshed (`status: updated`) and applied in every run. The parent loaded the plugin a second time after ready in 5/5 runs; this head did so in 0/7 runs. **Lifecycle:** on 618f4d2 with this patch, the catalog was adopted (borrowing the Gateway instance), then a config hot reload of the plugin (`Plugin replacement applied`) ran, then the Gateway stopped. Each instance evaluated once and was disposed exactly once (`count=1`), and no capture directories remained. **Tests:** - New regression `adopts scheduled remote catalogs inside the live Gateway registry scope` fails without the production change (Expected the Gateway registry, received `undefined`) and passes with it. - `server-startup-update-check.test.ts`: 7 passed. `update-startup-request-adoption.test.ts`: 3 passed. oxlint on the changed files passes. `codex review`: clean. No overlap with Pash/Sarah changes. **Merge risk:** two-way door. The change touches no persisted state, config or published contract, and a revert restores the scheduler's unscoped adoption. The blast radius is Gateways with external plugins when a hosted model catalog is adopted. Those catalog rebuilds now borrow Gateway instances under the accepted openclaw#161267 behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
…del catalog updates (#167544) Related: #160959 ## What Problem This Solves Fixes: shortly after every Gateway start, the scheduled remote model catalog refresh copies every external plugin a second time and loads it cold. With a large plugin, this blocks the Gateway for as long as the startup capture did. ## User Impact User impact: when the hosted model catalog is newer than the installed build (the normal case for released versions), adopting it no longer re-copies or re-evaluates external plugins. The Gateway stays responsive after startup. Prepared turns keep using the Gateway's unchanged plugin instances, as they already do after config hot reloads. ## Why This Change Was Made #161267 made prepared model runtimes borrow unchanged plugin instances from the admitting Gateway. The lender is resolved from the Gateway registry scope of the work that triggers the rebuild. Hot reloads already run their prepared-runtime refresh inside that scope (`server-reload-hot.ts`). The post-ready `update.remote-model-catalog` scheduler job calls `applyRemoteModelCatalogUpdate` with no registry scope. The prepared rebuild therefore finds no lender, and its inbound registry cold-loads every plugin. This change runs scheduled catalog adoption inside the live Gateway registry scope, the same way the hot-reload refresh does. No new cache, manager or module sharing is added. Each registry keeps its own load and dispose lifecycle, and borrowing follows the existing #161267 contract. ## Evidence **Trigger proven on origin/main 6070074.** Runs were isolated Gateways with an external plugin used as the context engine, each held 60 s after `ready`, with scratch probes outside the repo: - Catalog refresh enabled: 8/8 runs captured and loaded the plugin a second time after ready. The probe at `loadPreparedInboundPluginRegistry` logged `lender=false requestScope=false` during `applyRemoteModelCatalogUpdate`, followed by `remote model catalog applied`. - Catalog refresh disabled (`models.catalogRefresh.enabled: false`): 3/3 runs had no second load. - Full stack of the second capture: `buildSnapshotBatch → prepareWorkspacePluginRegistries → loadPreparedInboundPluginRegistry → loadAgentRuntimePluginRegistryHandle → loadOpenClawPlugins`. - Cost on main with an 8k-file plugin: `startup.maintenance.plugin-registry` took 46.2 s and 57.7 s with event-loop max 45.2 s and 57.3 s, plus a 78 s post-ready reload in another run. **With this change.** Same harness: - On 6070074 with this patch: 7/7 runs had 0 loads after ready. In each run the catalog was refreshed (`status: updated`) and applied, and the probe logged `inbound lender=true requestScope=true`. - On this PR's exact head versus its exact parent: these builds are newer than the current hosted catalog, so the runs serve the same hosted catalog with a newer `generatedAt` from a loopback `models.catalogRefresh.url`. Each run was held 60 s after ready, and the catalog was refreshed (`status: updated`) and applied in every run. The parent loaded the plugin a second time after ready in 5/5 runs; this head did so in 0/7 runs. **Lifecycle:** on 6070074 with this patch, the catalog was adopted (borrowing the Gateway instance), then a config hot reload of the plugin (`Plugin replacement applied`) ran, then the Gateway stopped. Each instance evaluated once and was disposed exactly once (`count=1`), and no capture directories remained. **Tests:** - New regression `adopts scheduled remote catalogs inside the live Gateway registry scope` fails without the production change (Expected the Gateway registry, received `undefined`) and passes with it. - `server-startup-update-check.test.ts`: 7 passed. `update-startup-request-adoption.test.ts`: 3 passed. oxlint on the changed files passes. `codex review`: clean. No overlap with Pash/Sarah changes. **Merge risk:** two-way door. The change touches no persisted state, config or published contract, and a revert restores the scheduler's unscoped adoption. The blast radius is Gateways with external plugins when a hosted model catalog is adopted. Those catalog rebuilds now borrow Gateway instances under the accepted #161267 behavior. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 41b4607)
Related: #160959
What Problem This Solves
Fixes: shortly after every Gateway start, the scheduled remote model catalog refresh copies every external plugin a second time and loads it cold. With a large plugin, this blocks the Gateway for as long as the startup capture did.
User Impact
User impact: when the hosted model catalog is newer than the installed build (the normal case for released versions), adopting it no longer re-copies or re-evaluates external plugins. The Gateway stays responsive after startup. Prepared turns keep using the Gateway's unchanged plugin instances, as they already do after config hot reloads.
Why This Change Was Made
#161267 made prepared model runtimes borrow unchanged plugin instances from the admitting Gateway. The lender is resolved from the Gateway registry scope of the work that triggers the rebuild. Hot reloads already run their prepared-runtime refresh inside that scope (
server-reload-hot.ts).The post-ready
update.remote-model-catalogscheduler job callsapplyRemoteModelCatalogUpdatewith no registry scope. The prepared rebuild therefore finds no lender, and its inbound registry cold-loads every plugin. This change runs scheduled catalog adoption inside the live Gateway registry scope, the same way the hot-reload refresh does. No new cache, manager or module sharing is added. Each registry keeps its own load and dispose lifecycle, and borrowing follows the existing #161267 contract.Evidence
Trigger proven on origin/main 6070074. Runs were isolated Gateways with an external plugin used as the context engine, each held 60 s after
ready, with scratch probes outside the repo:loadPreparedInboundPluginRegistryloggedlender=false requestScope=falseduringapplyRemoteModelCatalogUpdate, followed byremote model catalog applied.models.catalogRefresh.enabled: false): 3/3 runs had no second load.buildSnapshotBatch → prepareWorkspacePluginRegistries → loadPreparedInboundPluginRegistry → loadAgentRuntimePluginRegistryHandle → loadOpenClawPlugins.startup.maintenance.plugin-registrytook 46.2 s and 57.7 s with event-loop max 45.2 s and 57.3 s, plus a 78 s post-ready reload in another run.With this change. Same harness:
status: updated) and applied, and the probe loggedinbound lender=true requestScope=true.generatedAtfrom a loopbackmodels.catalogRefresh.url. Each run was held 60 s after ready, and the catalog was refreshed (status: updated) and applied in every run. The parent loaded the plugin a second time after ready in 5/5 runs; this head did so in 0/7 runs.Lifecycle: on 6070074 with this patch, the catalog was adopted (borrowing the Gateway instance), then a config hot reload of the plugin (
Plugin replacement applied) ran, then the Gateway stopped. Each instance evaluated once and was disposed exactly once (count=1), and no capture directories remained.Tests:
adopts scheduled remote catalogs inside the live Gateway registry scopefails without the production change (Expected the Gateway registry, receivedundefined) and passes with it.server-startup-update-check.test.ts: 7 passed.update-startup-request-adoption.test.ts: 3 passed. oxlint on the changed files passes.codex review: clean.Merge risk: two-way door. The change touches no persisted state, config or published contract, and a revert restores the scheduler's unscoped adoption. The blast radius is Gateways with external plugins when a hosted model catalog is adopted. Those catalog rebuilds now borrow Gateway instances under the accepted #161267 behavior.