Repository navigation
fix(plugins): Gateway memory grows on every cold tool inventory in multi-agent setups - #178596
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 real behavior proof before merge. What this changesThis PR reuses immutable installed native ESM plugin code within a Gateway inventory and releases retained captures after its final inspection borrower retires. Example: Two cold tools.effective inspections use the same npm-installed plugin in the research agent workspace.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still permits repeated native ESM evaluation during cold workspace-mismatched inspections, and this maintainer-engaged repair addresses that defect. Both previous P2 findings are resolved; no new actionable code findings were identified. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe plugin loader turns installed entries and workspace metadata into executable inspection registries; native admission owns retained source custody, while plugin instances own registration and callback authority. flowchart TD
A[Cold tool inventory] --> B[Workspace inspection registry]
C[Published Gateway inventory] --> D[Native admission owner]
D --> E[Retained plugin code and captures]
B --> E
E --> F[Instance scoped registration]
B --> G[Borrower release]
G --> D
Technical reviewBest possible solution: Retain this inventory-owned repair while preserving independent registration authority, editable-install freshness and cleanup after the final borrower. Do we have a high-confidence way to reproduce the issue? The linked report supplies release-specific measurements and a repeatable multi-agent scenario; current-main source independently confirms workspace-mismatched lending falls back to inspections excluded from native ESM reuse. No target code was executed during this review. Is this the best way to solve the issue? The repair uses the existing admission lifecycle to bound code custody without lending another workspace's registry, and all substantive additions support reuse, invalidation or cleanup; no smaller complete correction was established. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7bad8ec61de9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +258, Tests +332, Docs +2. Total +592 across 12 files. Added test files: 1. View PR surface stats
Review metrics
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 (6 earlier review cycles)
Reviewed October 21, 2026, 8:09 AM ET / 12:09 UTC (Revision 7). |
|
Added the requested proof in 925ed66 and updated the PR body:
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…e plugins on the main thread Related: openclaw#178548
…ion generation authority Move the inspection-registry lookup to the module runtime caller so plugin-instance-module-loader keeps its runtime import closure, and add a real-loader regression for neighboring and retired generations using a retained replacement API.
925ed66 to
1ee1e29
Compare
…le installs Global discovery also covers local, archive, and path installs that can be edited in place. Require an npm install record with integrity, key reuse on that install identity, and cover edited sources for archive installs and npm reinstalls.
|
Addressed the P1 finding in 33e9ac6 (and rebased onto current main, keeping
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…lti-agent setups (openclaw#178596) * fix(plugins): stop cold tool inventories re-importing installed native plugins on the main thread Related: openclaw#178548 * fix(plugins): keep the PR wrapper closure unchanged and prove inspection generation authority Move the inspection-registry lookup to the module runtime caller so plugin-instance-module-loader keeps its runtime import closure, and add a real-loader regression for neighboring and retired generations using a retained replacement API. * fix(plugins): share inspection code only for installer-proven immutable installs Global discovery also covers local, archive, and path installs that can be edited in place. Require an npm install record with integrity, key reuse on that install identity, and cover edited sources for archive installs and npm reinstalls. * fix(plugins): preserve inspection loader import boundaries Keep immutable installation identity with its existing owner so Gateway metadata publication does not introduce an unlisted runtime dependency into the restricted PR-wrapper source extraction. Keep admission lifetime types in the leaf artifact contract and concrete retained modules in the loader, avoiding a type import cycle through the cache owner. --------- Co-authored-by: Peter Steinberger <[email protected]>
…lti-agent setups (#178596) * fix(plugins): stop cold tool inventories re-importing installed native plugins on the main thread Related: #178548 * fix(plugins): keep the PR wrapper closure unchanged and prove inspection generation authority Move the inspection-registry lookup to the module runtime caller so plugin-instance-module-loader keeps its runtime import closure, and add a real-loader regression for neighboring and retired generations using a retained replacement API. * fix(plugins): share inspection code only for installer-proven immutable installs Global discovery also covers local, archive, and path installs that can be edited in place. Require an npm install record with integrity, key reuse on that install identity, and cover edited sources for archive installs and npm reinstalls. * fix(plugins): preserve inspection loader import boundaries Keep immutable installation identity with its existing owner so Gateway metadata publication does not introduce an unlisted runtime dependency into the restricted PR-wrapper source extraction. Keep admission lifetime types in the leaf artifact contract and concrete retained modules in the loader, avoiding a type import cycle through the cache owner. --------- Co-authored-by: Peter Steinberger <[email protected]> Release adaptation: stable has no main-thread artifact prepare step (plugin-generation-worker) or the admission transfer/adoption helpers; ported only the inspection-retention path: immutable npm install identity, published inspection policy on the admission state with disposal, and inspection-scoped retained native ESM reuse in the module loader. The authority test drops main's prepare-step spies and inlines the gateway fixture helper. (cherry picked from commit 63f386b)
Adapt 21 audited fixes to release-native ownership and recovery. Retain strict temporary environment isolation and provider-only cooldowns. Original-source provenance and contributor credit: #179144 5a97c90 — Peter Steinberger <[email protected]> #180280 442c2f7 — Jason (Json) <[email protected]> #178596 63f386b — Braden Guliano <[email protected]> #181804 d75915e — Peter Steinberger <[email protected]> #181140 b4031b2 — Peter Steinberger <[email protected]> #182207 b8fae65 — Peter Steinberger <[email protected]> #180792 d2c70dd — Peter Steinberger <[email protected]> #179205 c08aa6d — Peter Steinberger <[email protected]> #179997 f178dd9 — mali <[email protected]> #181270 e204484 — Peter Steinberger <[email protected]> #179031 855b0aa — Peter Steinberger <[email protected]> #179726 3d51d00 — Peter Steinberger <[email protected]> #179249 b617d97 — Josh Avant <[email protected]> #182385 bb13bcd — Peter Steinberger <[email protected]> #182615 411bac2 — Peter Steinberger <[email protected]> #181300 765c2f1 — Peter Steinberger <[email protected]> #179549 09ba994 — Peter Steinberger <[email protected]> #179445 ac5587b — Peter Steinberger <[email protected]> #181127 25dde25 — Josh Lehman <[email protected]> #173209 ebccf57 — Peter Steinberger <[email protected]> #175289 e579f09 — Peter Steinberger <[email protected]> Proof: targeted owner/regression tests; Qwen15 and catalog pool13 pass. Final integrated lint/type/format pass remains pending under user direction. Co-authored-by: RomneyDa <[email protected]>
Fixes #178548
Related: #173021
What Problem This Solves
Fixes growing Gateway memory when cold
tools.effectiveinspections repeatedly load an installed native ESM plugin in an agent workspace that differs from the Gateway workspace.User Impact
Repeated cold inspections reuse unchanged installed plugin code within their Gateway inventory. Workspace isolation and registration authority remain intact. The first inspection still pays source preparation cost; no configuration changes or migration are required. Node retains evaluated ESM modules until process exit, including older graphs after an explicit plugin replacement.
Why This Change Was Made
Workspace mismatch correctly prevents borrowing the Gateway registry, but the fallback creates an uncached inspection and evaluates a fresh captured native ESM graph on each request. Catalog workers already retain those graphs within their worker lifetime.
The maintainer rewrite retains the contributor's immutable npm install identity and preparation reuse, but moves main-thread retention out of the process-global map. The existing native admission owner now holds the entries, bounded by the published inventory's installed execution paths, configured workspaces, SDK selection, and prepared read/write storage views. Inventory replacement and final borrower release dispose source captures, compiled helpers, and preparation workers. Editable installations and explicit recovery preserve their independent source custody.
The real-loader regressions are consolidated into one suite. Thanks to @bguliano for the reproduction, original fix, measurements, and regression coverage; contributor commits remain in the branch history.
Evidence
src/plugins/loader.main-inspection-authority.test.ts, includingreuses only published workspace code while preserving inspection authority and capture lifetimeandloads edited sources for the next inspection of $name(archive and npm replacement). It covers evaluation/preparation counts, concurrent capture disposal, lazy imports, workspace/SDK separation, stale authority, and final borrower cleanup.git diff --check: passed.b77dbec960d194ff09e6933105edd9a17b532978: 61 successful jobs, 29 skipped, one inherited failing test shard and its failing aggregate gate. All three new regression cases passed; architecture, wrapper extraction, lint, types, and all UI E2E shards passed.memory-background-reload.test.ts. The same four cases fail in the latest scheduled Full Release Validation Nightly, downstream checks-node-agentic-plugins, on maina984f7723914e75c5a5a9a23c802aa356faedb95. The detached cases also share the exactsession-startup-catchup: sync completionstall. Main commit fix(memory): resume background reindex after foreground turns #178979 routed background work throughsyncBackground, while three failing cases still wait onsyncspies; the fourth timeout is matched to main but its exact stalled wait is not localized. The fixture and memory implementation are unchanged by this PR, and bundled loads bypass the new retention path. No retries or weakened assertions were used.The contributor's prior-head measurements reported main heap ending at 341 MiB instead of 546 MiB over 24 cold calls, with warm inspection latency falling to 0–1 seconds. These are historical contributor measurements, not a measurement of the maintainer rewrite.