Skip to content

fix: reuse plugin captures during model catalog refresh - #153041

Merged
shakkernerd merged 1 commit into
mainfrom
fix/catalog-generation-scope
Sep 19, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/catalog-generation-scope

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Refs #152689

What Problem This Solves

Repeated model catalog refreshes for multiple agents can create additional copies of the same plugin source. The loader's lookup cache is bounded, but earlier captures remain available to their live inventory. Cycling enough workspace/provider combinations therefore keeps adding copies and can exhaust constrained temporary storage.

User Impact

Final model normalization reuses the plugin generation already selected for the catalog request. It keeps the source files required by that generation available and continues publishing executable models discovered through refreshed credentials. The updated Gateway uses this repair when its catalog workers start. No configuration change or migration is required.

This addresses the duplicate-loading path in the reported storage growth. The separate Codex closed-client warning and the size of legitimate initial plugin captures are outside this contribution.

Why This Change Was Made

The model registry normalizes provider models and transports lazily in getAll(). Catalog preparation ran inside the selected generation, but this final read happened after that scope had ended. Provider hooks could consequently fall back to loading another registry for each workspace.

The worker now performs that read inside its existing pluginGenerationScope, which already contains any registry selected by widened discovery. The change adds no cache, lifetime owner, or capture deletion policy. It follows zl0nline's allocation trace, independently reproduced through the actual worker path.

Evidence

Validated on a7932939c0ba:

  • The existing four-agent worker regression loads five distinct copied runtime paths with the unchanged worker on base 21b9d735160f, then one with this change, including forced refreshes. Source-version and per-agent credential assertions remain in place.
  • With 15 agents and eight synthetic providers, all three agent passes and both provider-scope passes remain at eight captures. Captured source bytes survive source rewriting; releasing generations and closing the prepared runtime removes worker scratch.
  • 111 maintained cases passed across worker reuse, source/built artifacts, durable and external auth, SecretRefs, empty/disabled/failed owners, model/transport normalization, and all three ClawRouter discovery cases. All 30 selected checks, production types, 20 test-type graphs, and runtime build/import guards passed.
  • The published [email protected] updater successfully installed the frozen candidate in the custom-plugin-siblings scenario. Actual Doctor and private Gateway-canary executions loaded the plugin, its original source and enablement were preserved, and all 10,261 application payload files matched the candidate. This cell used --no-restart; it does not claim a managed-service restart.
  • Exact-commit AutoReview found no actionable findings. ClawSweeper rated this head Platinum.

Hosted CI reported a speech-to-music fixture cleanup failure also reproduced on the unchanged base. The aggregate CI/security-review gates reflect that result. The separate repair, #153064, is merged; this contribution's checks and behavior passed independently.

The additional all-release generated-artifact check reported UI/native locale drift on unchanged inputs. Its failed result is retained separately; package integrity and the installed-updater check passed.

@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 2:25 PM ET / 18:25 UTC (Revision 2).

ClawSweeper review

What this changes

Keeps final model normalization within the catalog’s selected plugin generation and adds regression checks for capture reuse and discovered model routes.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. No actionable introduced defects were found; the patch addresses the traced allocation path without expanding capture ownership or cleanup policy.

Priority: P1
Reviewed head: a7932939c0ba89eb400da209609c990301c5c0e5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and documented validation; no blocking correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports worker allocation recovery and published-updater/Doctor/Gateway-canary validation, with no managed-service restart claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports worker allocation recovery and published-updater/Doctor/Gateway-canary validation, with no managed-service restart claim.
Evidence reviewed 9 items Introduced production change: The final getAll call now runs inside the existing pluginGenerationScope, whose registry is updated when credential discovery widens the provider set. No new cache, disposal policy, or public API is introduced.
Lazy normalization and registry fallback: agent-model-discovery.ts overrides getAll to normalize each model. Normalization calls provider hooks; providers.runtime-core.ts consumes the selected generation and avoids fallback registry loading when that generation exists. This is an OpenClaw-owned path; the patch does not depend on the separate Codex client protocol.
Regression coverage: The existing four-agent test now records actual loaded runtime paths and requires one distinct capture through forced refreshes, while retaining source-version and per-agent credential assertions. The ClawRouter cases additionally check executable transport metadata, including discovery through refreshed credentials.
Findings None None.
Security None None.

How this fits together

Gateway catalog workers combine agent credentials and plugin discovery into available model inventories. Provider normalization determines the executable model routes returned to the Gateway.

flowchart TD
  A[Agent credentials and configuration] --> B[Catalog worker]
  C[Captured plugin generation] --> B
  B --> D[Provider discovery]
  D --> E[Normalize models within selected generation]
  C --> E
  E --> F[Gateway model inventory]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +23. Total +27 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 3 23 0 +23
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 28 1 +27

Review metrics

Metric Value Why it matters
Reported capture reuse 5 distinct runtime paths before; 1 after The four-agent regression measures the duplicate-allocation mechanism through forced refreshes.

Technical review

Best possible solution:

Use the existing selected generation for final normalization while preserving inventory-owned captures and task-local credentials.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the unscoped lazy-normalization path, and the submitted worker regression reports a before/after allocation difference. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes. Restoring the existing generation scope at the escaping read is a narrow repair that avoids another cache or capture-deletion policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1e8ba48c32a8.

Labels

Label justifications:

  • P1: Repeated catalog allocations contribute to reported temporary-storage exhaustion and broken agent workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports worker allocation recovery and published-updater/Doctor/Gateway-canary validation, with no managed-service restart claim.

Evidence

What I checked:

  • Introduced production change: The final getAll call now runs inside the existing pluginGenerationScope, whose registry is updated when credential discovery widens the provider set. No new cache, disposal policy, or public API is introduced. (src/agents/prepared-model-catalog.worker.ts:369, a7932939c0ba)
  • Lazy normalization and registry fallback: agent-model-discovery.ts overrides getAll to normalize each model. Normalization calls provider hooks; providers.runtime-core.ts consumes the selected generation and avoids fallback registry loading when that generation exists. This is an OpenClaw-owned path; the patch does not depend on the separate Codex client protocol. (src/agents/agent-model-discovery.ts:98, a7932939c0ba)
  • Regression coverage: The existing four-agent test now records actual loaded runtime paths and requires one distinct capture through forced refreshes, while retaining source-version and per-agent credential assertions. The ClawRouter cases additionally check executable transport metadata, including discovery through refreshed credentials. (src/agents/prepared-model-catalog-worker.pool.integration.test.ts:219, a7932939c0ba)
  • Current-main necessity: Fetched main still calls facts.templateModelRegistry.getAll outside the generation scope. The supplied verified test-merge comparison contains only the four introduced files; unrelated endpoint drift is not attributed to this PR. (src/agents/prepared-model-catalog.worker.ts:369, 1e8ba48c32a8)
  • Latest release check: The v2026.9.5 worker also performs the final model read without the generation wrapper. GitHub contents inspection supplied the release source after the local historical blob could not be read. (src/agents/prepared-model-catalog.worker.ts:350, ec9c1a13db89)
  • Independent allocation trace: zl0nline’s linked investigation traces the exact lazy-read-to-capture path and reports bounded capture counts after a broader local release hotfix. It explicitly leaves the Codex client-close warning unresolved: Codex resident catalog retry loop after 2026.9.5 fills os.tmpdir() with repeated 342 MB plugin captures #152689 (comment). That release hotfix is corroborating evidence, not exact-head proof for this narrower branch.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-19T16:49:28.540Z sha a793293 :: needs maintainer review before merge. :: none

@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: model catalog refreshes reuse the selected plugin generation's captured source files.

@safrano9999

Copy link
Copy Markdown
Contributor

🦞 Confirming the pre-fix symptoms on 2026.9.5: the catalog worker copied Codex dependencies at about 95% of one CPU core and retained 5 GiB in scratch storage; this fix is not yet deployed here.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
)

Reuse the selected plugin generation during final model catalog normalization so repeated refreshes do not create duplicate source captures.

Refs openclaw#152689.
yozakura-ava pushed a commit to yozakura-ava/openclaw that referenced this pull request Sep 22, 2026
…l generation

The parentPort branch in prepared-model-catalog.worker.ts retained every
distinct PluginRegistry it ever produced (retainedRegistries: Set<...>) and
called discardPreparedPluginGeneration in finally. On abnormal worker
lifecycle events (crash, SIGKILL, restartOnError, pool teardown failure)
the scratch tree rooted at data.sourceCaptureDirectory survived across
all retained registries — each openclaw-model-catalog-* dir holds dozens
to hundreds of openclaw-plugin-build-* captures and never gets reclaimed.

Replace the Set with a single 'current' slot keyed on
generationFingerprint. A replacement acquisition is held in 'attempted'
until the run commits an 'ok' result, then swapped into 'current'; the
previous generation is released only after the swap holds. Failed
acquisitions never enter the retained slot, so request floods cannot pile
scratch-tree captures. Also wrap facts.templateModelRegistry.getAll() in
withPluginRuntimeGenerationScope so lazy normalization keeps provider
hooks on the selected catalog generation.

Adapted from openclaw#153038 and openclaw#153041. The fork diverges from
upstream by ~4,950 commits at this base, so a direct cherry-pick would
require resolving conflicts in seven files across two PRs plus introducing
retainPreparedPluginRegistry and a WorkerGeneration.discovery slot that
this fork does not need (loadAgentRuntimePluginRegistryHandle already
binds synchronously inside the request scope).

Docs: docs/fork/2026.9.5-catalog-tmp-leak-bound-captures.md

No public API changes. Worker-thread internal lifecycle only.

Refs: openclaw#153038, openclaw#153041
DELEG-REF: catalog-tmp-leak-bound-captures-2026-09-22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants