Skip to content

fix(models): reuse prepared plugin metadata - #117131

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
sasan1200:fix/model-registry-plugin-snapshot-per-model
Aug 1, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
sasan1200:fix/model-registry-plugin-snapshot-per-model

Conversation

@sasan1200

@sasan1200 sasan1200 commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #117130

What Problem This Solves

models list already loads one plugin metadata snapshot, but provider resolution dropped its manifest registry and discovery before bundled-plugin activation. Model compatibility normalization also dropped the model registry's exact provider-owner generation. Those losses forced per-model metadata discovery. The remaining input-free attribution fallback had no prepared fact to consume and rescanned the same process-stable metadata.

On a 3,000-model catalog the reported command performed 6,124 completed plugins.metadata.scan spans and took 99.1 seconds in the contributor's isolated packaged benchmark.

Why This Change Was Made

  • carry the prepared manifest registry and discovery through provider activation
  • carry exact provider-owner maps through model discovery, prepared registries, and compatibility normalization
  • consume the canonical attached owner map when a model already carries one
  • retain one bounded process memo only for the unavoidable input-free attribution fallback
  • clear that memo through the existing plugin-metadata lifecycle reset
  • avoid the previous config/env identity cache and its stale-generation risk

This keeps metadata ownership at the plugin lifecycle boundary and makes the hot path consume prepared facts instead of rediscovering them.

Evidence

Representative models list --plain run with 3,000 configured models:

build output completed plugins.metadata.scan spans
reported before fix 3,000 models 6,124
rewritten branch 3,008 lines 23

That is 6,124 -> 23 scans, a 99.6% reduction (about 266x fewer scans).

The contributor's isolated packaged benchmark measured 99.1s -> 12.3s. I did not claim an independent Testbox wall-time comparison: the source checkout resolves official external plugins from workspace TypeScript trees, where each scan costs several seconds and dominates wall time. The diagnostic span count is the stable invariant for this regression.

Validation:

  • final focused lifecycle/runtime/prepared-registry suite: 120/120 passed
  • previous production rewrite changed gate: exit 0 on Blacksmith Testbox
  • exact head: f7de523101af001370e06458d680bf90dbffc9d0
  • exact tree: 1d05e67b6d59e404e089c2423d3be18beef49f54
  • frozen base: 02419ed1998feeaeaca21a92de7d23e805742f13
  • signed commit verified with Vincent Koc's ED25519 key
  • packaged build completed during benchmark preparation
  • git diff --check: clean
  • formatting: all touched files clean
  • full source clone integrity: git fsck --no-dangling clean

Testbox run: https://github.com/openclaw/openclaw/actions/runs/30687803223
Focused run: https://github.com/openclaw/openclaw/actions/runs/30687373568

The final exact-head GitHub matrix is running. A prior exact-head check-test-types failure exposed an under-typed test double; the mock now explicitly carries PluginMetadataSnapshotOwnerMaps | undefined, and the focused contract suite is green.

Scope

Production: +85/-20, net +65. Tests: +158. Total: +243/-20.

The production growth is the explicit prepared-fact plumbing plus the lifecycle-owned fallback memo. It replaces per-model rediscovery without adding a second config/env cache or fallback stack.

Co-authored-by: Sasan Sotoodehfar [email protected]

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:39 AM ET / 07:39 UTC.

ClawSweeper review

What this changes

This PR reuses prepared plugin metadata while OpenClaw builds and normalizes model catalogs, avoiding repeated manifest scans for every model.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal maintainer review. The patch directly removes the current-main per-call plugin metadata fallback, forwards the lifecycle-owned manifest/discovery and provider-owner facts, and adds focused generation/reset coverage; the exact-head CI matrix is still running, so it is not ready for a final merge verdict yet.

Priority: P2
Reviewed head: f7de523101af001370e06458d680bf90dbffc9d0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows the lifecycle-owned metadata architecture, has focused reset/generation coverage, and includes strong runtime evidence; final exact-head CI is the remaining merge gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides an after-fix packaged benchmark with a directly relevant diagnostic-span reduction and linked exact-head focused/Testbox evidence; the remaining matrix is validation, not missing behavior proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides an after-fix packaged benchmark with a directly relevant diagnostic-span reduction and linked exact-head focused/Testbox evidence; the remaining matrix is validation, not missing behavior proof.
Evidence reviewed 7 items Current-main defect remains: Comparing the supplied current-main SHA with the PR head shows that current main falls back directly to loadPluginMetadataSnapshot({ config: {} }) whenever no prepared or current snapshot exists; the PR replaces that repeated fallback with a lifecycle-cleared process memo.
Canonical lifecycle handoff: The activation path accepts the caller's manifest registry and discovery result, preferring them over ambient snapshot lookup and forwarding them through both bundled activation-resolution calls.
Generation-safe provider compatibility: Compatibility normalization uses an explicitly supplied owner map or the owner map attached to the model, then passes that exact map to provider capability resolution rather than reloading metadata.
Findings None None.
Security None None.

How this fits together

Model listing and gateway startup assemble configured and plugin-provided models, then resolve plugin activation and provider compatibility for each row. This patch carries metadata prepared by the plugin lifecycle into those steps so model normalization does not rediscover process-stable plugin manifests.

flowchart LR
  A[Configured and plugin models] --> B[Prepared plugin metadata snapshot]
  B --> C[Model registry assembly]
  C --> D[Provider activation]
  D --> E[Provider compatibility normalization]
  E --> F[Model listing and gateway startup]
  B --> G[Lifecycle cache reset]
  G --> B
Loading

Before merge

  • Resolve merge risk (P1) - The patch changes which plugin metadata generation activation and compatibility consume; its new lifecycle-reset tests mitigate stale-state risk, but the exact-head CI matrix must finish before merge.
  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main, so maintainers should use the final merge result and exact-head checks rather than relying on the earlier frozen-base benchmark alone.
  • Complete next step (P2) - No mechanical repair is identified; maintainers should wait for the exact-head matrix and then make the ordinary merge decision on the current merge result.
Agent review details

Security

None.

PR surface

Source +65, Tests +158. Total +223 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 85 20 +65
Tests 4 158 0 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 243 20 +223

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/agent-model-discovery.ts, vector/embedding metadata: src/agents/prepared-model-registry.test.ts, vector/embedding metadata: src/agents/provider-attribution.test.ts, vector/embedding metadata: src/agents/provider-attribution.ts, vector/embedding metadata: src/plugins/activation-context.test.ts, vector/embedding metadata: src/plugins/provider-model-compat.prepared.test.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117130
Summary: This PR is the concrete candidate repair for the large-catalog model-list metadata-rescan report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the lifecycle-boundary change after CI (recommended)
    Once the exact-head matrix is green, merge the tested metadata-generation propagation and lifecycle-cleared fallback memo as the narrowest repair for the repeated scans.

Technical review

Best possible solution:

Land the tested prepared-fact propagation after the exact-head checks are green and the merge result still preserves the lifecycle-reset behavior; keep the linked performance issue open until this PR merges.

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

Yes. The linked report supplies a packaged models list scenario, and the pre-patch source directly reloaded plugin metadata on the input-free provider-attribution fallback that catalog normalization can repeatedly reach.

Is this the best way to solve the issue?

Yes. Passing lifecycle-owned manifest, discovery, and owner-map facts is a better fix than adding config-identity caching because it preserves the existing metadata lifecycle as the authoritative invalidation boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against dccb1b90138a.

Labels

Label justifications:

  • P2: The patch addresses a real but catalog-size-dependent slowdown in model listing and startup rather than an emergency availability or security failure.
  • merge-risk: 🚨 compatibility: Provider activation and compatibility now consume the caller's exact plugin metadata generation, so a lifecycle mismatch could affect existing plugin-derived provider behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides an after-fix packaged benchmark with a directly relevant diagnostic-span reduction and linked exact-head focused/Testbox evidence; the remaining matrix is validation, not missing behavior proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an after-fix packaged benchmark with a directly relevant diagnostic-span reduction and linked exact-head focused/Testbox evidence; the remaining matrix is validation, not missing behavior proof.

Evidence

What I checked:

  • Current-main defect remains: Comparing the supplied current-main SHA with the PR head shows that current main falls back directly to loadPluginMetadataSnapshot({ config: {} }) whenever no prepared or current snapshot exists; the PR replaces that repeated fallback with a lifecycle-cleared process memo. (src/agents/provider-attribution.ts:183, f7de523101af)
  • Canonical lifecycle handoff: The activation path accepts the caller's manifest registry and discovery result, preferring them over ambient snapshot lookup and forwarding them through both bundled activation-resolution calls. (src/plugins/activation-context.ts:147, f7de523101af)
  • Generation-safe provider compatibility: Compatibility normalization uses an explicitly supplied owner map or the owner map attached to the model, then passes that exact map to provider capability resolution rather than reloading metadata. (src/plugins/provider-model-compat.ts:72, f7de523101af)
  • Lifecycle reset regression coverage: The focused attribution test verifies that the no-snapshot fallback scans once across ten calls, then scans again only after clearPluginMetadataLifecycleCaches() resets the lifecycle. (src/agents/provider-attribution.test.ts:292, f7de523101af)
  • Commit provenance: Blame attributes the new fallback memo, lifecycle clear registration, and owner-map compatibility propagation to the PR head; the surrounding provider-owner resolution originates from the current model-catalog work. (src/agents/provider-attribution.ts:183, f7de523101af)
  • Patch hygiene: The exact PR commit has no whitespace errors, and the checkout remained clean throughout the read-only inspection. (src/plugins/providers.runtime.ts:254, f7de523101af)

Likely related people:

  • SunnyShu: The current provider/model catalog behavior around the prepared owner-map path is attributed to the model browse-view change that predates this PR. (role: current behavior introducer; confidence: high; commits: cbdbf6802b96; files: src/agents/provider-attribution.ts, src/agents/agent-model-discovery.ts, src/plugins/provider-model-compat.ts)
  • Vincent Koc: The PR head introduces the memo and exact-generation propagation, and repository history also shows prior merged provider/plugin maintenance work by this contributor. (role: recent provider and plugin lifecycle contributor; confidence: high; commits: f7de523101af, 0426f238c363, f565138ddc91; files: src/agents/provider-attribution.ts, src/plugins/activation-context.ts, src/plugins/provider-model-compat.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the exact-head CI matrix to complete successfully, then refresh the merge result if current main has advanced.

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 (4 earlier review cycles)
  • reviewed 2026-08-01T00:47:44.517Z sha ad401a65db1af9b90740f089388e220a1a781533 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T06:46:53.366Z sha 6ef1a733f5b249bf12ae958747367d0194ce3286 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T07:01:32.372Z sha 64ef934fd55cd37402f5675802b870ba19b2f8f3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T07:12:51.406Z sha c646869ed8c2481b701dea69d2927b443ed96174 :: needs maintainer review before merge. :: none

@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@vincentkoc
vincentkoc force-pushed the fix/model-registry-plugin-snapshot-per-model branch from ad401a6 to 6ef1a73 Compare August 1, 2026 06:41
@vincentkoc vincentkoc changed the title fix: model listing stalls for minutes on installs with large model catalogs fix(models): reuse prepared plugin metadata Aug 1, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 1, 2026
@vincentkoc
vincentkoc force-pushed the fix/model-registry-plugin-snapshot-per-model branch 2 times, most recently from c219cb1 to 64ef934 Compare August 1, 2026 06:50
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 1, 2026
@vincentkoc
vincentkoc force-pushed the fix/model-registry-plugin-snapshot-per-model branch from 64ef934 to c646869 Compare August 1, 2026 07:06
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 1, 2026
Carry lifecycle-owned manifest, discovery, and provider owner facts through model normalization instead of rescanning plugin metadata per model.

Co-authored-by: Sasan Sotoodehfar <[email protected]>
@vincentkoc
vincentkoc force-pushed the fix/model-registry-plugin-snapshot-per-model branch from c646869 to f7de523 Compare August 1, 2026 07:34
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 13a52c5 into openclaw:main Aug 1, 2026
195 of 199 checks passed
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (41 commits)
  test(ci): update memory helper routing expectation (#117295)
  fix(canvas): emit successful control results in JSON mode (#117297)
  fix(imessage): settle native inbound reply delivery (#117282)
  fix(agents): reject invalid UTF-8 LSP responses (#117271)
  fix(line): centralize card and template message alt text (#117280)
  fix(release): validate candidates before Docker publication (#117252)
  fix(media): validate provider-owned generated media downloads (#117281)
  fix(feishu): restore custom HTTPS API domains (#117278)
  fix(models): reuse prepared plugin metadata (#117131)
  fix(agents): stop fallback after delivered-but-failed attempts (#114628)
  fix(memory): reuse targeted session corpus snapshot (#117247)
  fix(matrix): reconcile durable sends after response loss
  test(release): repair full validation regressions (#116931)
  fix(linux-canvas): report socket watcher fallback (#109502)
  fix(codex): preserve authoritative turn completion (#117185)
  fix(canvas): preserve widgets across derived-name collisions (#117132)
  fix(channels): config validation rejects documented channels.<id>.configWrites on 13 channels (#117206)
  fix(msteams): prevent duplicate final replies (#116398)
  fix(doctor): session SQLite restore installs an empty session index over the valid archive (#117221)
  fix(plugins): preserve workspace plugins across CLI and control UI (#117265)
  ...
@sasan1200
sasan1200 deleted the fix/model-registry-plugin-snapshot-per-model branch August 1, 2026 18:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
Carry lifecycle-owned manifest, discovery, and provider owner facts through model normalization instead of rescanning plugin metadata per model.

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (41 commits)
  test(ci): update memory helper routing expectation (openclaw#117295)
  fix(canvas): emit successful control results in JSON mode (openclaw#117297)
  fix(imessage): settle native inbound reply delivery (openclaw#117282)
  fix(agents): reject invalid UTF-8 LSP responses (openclaw#117271)
  fix(line): centralize card and template message alt text (openclaw#117280)
  fix(release): validate candidates before Docker publication (openclaw#117252)
  fix(media): validate provider-owned generated media downloads (openclaw#117281)
  fix(feishu): restore custom HTTPS API domains (openclaw#117278)
  fix(models): reuse prepared plugin metadata (openclaw#117131)
  fix(agents): stop fallback after delivered-but-failed attempts (openclaw#114628)
  fix(memory): reuse targeted session corpus snapshot (openclaw#117247)
  fix(matrix): reconcile durable sends after response loss
  test(release): repair full validation regressions (openclaw#116931)
  fix(linux-canvas): report socket watcher fallback (openclaw#109502)
  fix(codex): preserve authoritative turn completion (openclaw#117185)
  fix(canvas): preserve widgets across derived-name collisions (openclaw#117132)
  fix(channels): config validation rejects documented channels.<id>.configWrites on 13 channels (openclaw#117206)
  fix(msteams): prevent duplicate final replies (openclaw#116398)
  fix(doctor): session SQLite restore installs an empty session index over the valid archive (openclaw#117221)
  fix(plugins): preserve workspace plugins across CLI and control UI (openclaw#117265)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: models list rescans plugin manifests once per model and takes minutes on large catalogs

2 participants