Skip to content

fix: reuse plugin manifest metadata safely#82814

Merged
shakkernerd merged 6 commits into
mainfrom
fix/plugin-metadata-reuse
May 17, 2026
Merged

fix: reuse plugin manifest metadata safely#82814
shakkernerd merged 6 commits into
mainfrom
fix/plugin-metadata-reuse

Conversation

@shakkernerd

Copy link
Copy Markdown
Member

Summary

  • Reuse prepared plugin manifest metadata through agent startup, plugin runtime loading, model catalog normalization, model selection, fallback resolution, auth lookups, and tool capability checks.
  • Avoid repeated plugin metadata scans on hot startup/turn paths while preserving default model, fallback, catalog, and tool availability behavior.
  • Scope reusable metadata to the proven runtime context so stale plugin snapshots are not reused by unrelated global/read-only callers.
  • Preserve intentional global/read-only catalog behavior, including static read-only catalog paths that avoid metadata scans unless configured provider rows require manifest normalization.
  • Thread runtime context into media/image tool availability so agent and gateway turn execution resolve plugin capabilities from the same prepared metadata path.

Measured impact

From .artifacts/plugin-metadata-regression-fix-report.md, comparing the baseline Kova run to the fixed current-base run for agent-cold-warm-message:

  • Kova went from FAIL 3/3 to PASS 3/3.
  • Metadata scans dropped from 394 to 28 per cold+warm sample: 366 fewer scans, about 92.9% fewer.
  • Metadata scan total dropped from about 14,800ms to 1,142.43ms median: about 13.66s saved, about 92.3% lower.
  • Cold turn median dropped from about 10,640ms to 3,866ms: about 6.77s faster, about 63.7% lower.
  • Warm turn median dropped from about 10,556ms to 3,699ms: about 6.86s faster, about 65.0% lower.
  • Cold pre-provider median dropped from about 10,344ms to 3,754ms: about 6.59s faster, about 63.7% lower.
  • Warm pre-provider median dropped from about 10,100ms to 3,584ms: about 6.52s faster, about 64.5% lower.
  • Provider time stayed effectively unchanged: baseline 0-1ms, fixed 0-2ms.

Live CLI probes after rebasing onto origin/main at 89532d3a92:

  • openclaw --version: 47ms, status 0
  • openclaw plugins list --json: 463ms, status 0
  • openclaw gateway status: 468ms, status 0
  • openclaw config get gateway.port: 302ms, status 1 with expected missing-key result in isolated empty home
  • openclaw sessions --all-agents --active 5 --json: 570ms, status 0

Current branch gateway proof also stayed green: Kova gateway-session-send-turn passed 3/3, with 3 metadata scans per sample, cold turns around 2.29s-2.40s, warm turns around 1.61s-1.63s, and max RSS 695.3 MB.

Verification

  • Rebased cleanly onto origin/main at 89532d3a92.
  • git diff --check origin/main...HEAD: passed.
  • node scripts/run-vitest.mjs ... --run: 16 files, 514 tests passed.
  • Core and core-test tsgo: passed before the final rebase.
  • Kova gateway-session-send-turn: 3/3 PASS.
    • Report: .artifacts/kova/reports/plugin-metadata-gateway-session-send-after-workspace-threading-repeat3/kova-2026-05-17T001010Z.md
    • Covered gateway sessions.create, sessions.send, and chat.history.
  • Kova agent-cold-warm-message: 3/3 PASS.
    • Report: .artifacts/kova/reports/plugin-metadata-agent-cold-warm-after-workspace-threading-repeat3/kova-2026-05-17T001213Z.md
  • pnpm check:changed: passed locally across core, core tests, extension typechecks, lint, guards, and import cycles before the final rebase.

Real behavior proof

Behavior addressed: Plugin-heavy installs avoid repeated manifest metadata scans during model/runtime setup without changing default model selection, fallback handling, catalog visibility, or tool capability behavior.

Real environment tested: Local OpenClaw checkout with Kova mock OpenAI provider scenarios, isolated CLI probes, and local changed-surface checks.

Exact steps or command run after this patch: Kova gateway session-send repeat-3, Kova local agent cold/warm repeat-3, focused Vitest suite, core/core-test tsgo, git diff --check, live CLI probes, and local pnpm check:changed.

Evidence after fix: Gateway session-send and local agent Kova scenarios both passed 3/3, focused tests passed 514/514 after the final rebase, live CLI probes stayed fast with expected status codes, and the artifacted baseline-to-fixed measurements show metadata scan count fell from 394 to 28.

Observed result after fix: Runtime paths reuse prepared metadata, global/read-only paths do not consume stale runtime snapshots, provider latency remains effectively unchanged, and the measured metadata-scan regression did not reappear.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix: reuse plugin manifest metadata safely This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@shakkernerd
shakkernerd force-pushed the fix/plugin-metadata-reuse branch from 9a34af8 to 27d5348 Compare May 17, 2026 00:55
@shakkernerd
shakkernerd merged commit f590439 into main May 17, 2026
19 checks passed
@shakkernerd
shakkernerd deleted the fix/plugin-metadata-reuse branch May 17, 2026 00:55
zeroaltitude added a commit to zeroaltitude/openclaw that referenced this pull request May 22, 2026
…id normalize chain

model-id normalize path so consumers stop consulting the
`current-plugin-metadata-snapshot` single-slot handoff in
`resolveMetadataSnapshotForPolicies`. That eliminated most of the
hot-path `installs.json` disk walks (Kova metadata scans dropped
394 → 28 per cold+warm sample).

The remaining 28 scans come from the runtime plugin-normalize branch.
`model-selection-normalize.ts` already receives `options.manifestPlugins`
from its caller and threads it into the static branch
(`normalizeStaticProviderModelId`); the runtime branch a few lines down
silently drops it, and the chain falls through to the slot-or-load disk
walk in `resolveMetadataSnapshotForPolicies`:

  src/agents/model-selection-normalize.ts:59
    → normalizeProviderModelIdWithRuntime(...)        (no plugins param)
      → normalizeProviderModelIdWithPlugin(params)    (no plugins param)
        → normalizeProviderModelIdWithManifest(params) (params.plugins undefined)
          → loadManifestModelIdNormalizationPolicies   (slot-or-load disk walk)

This change extends the openclaw#82814 pattern into the runtime branch:

- Add optional `plugins` param to `normalizeProviderModelIdWithRuntime`
  and `normalizeProviderModelIdWithPlugin`. Both forward unchanged into
  `normalizeProviderModelIdWithManifest`, which already honors
  `params.plugins` to skip the slot lookup.
- At the call site in `model-selection-normalize.ts`, thread
  `options?.manifestPlugins` into the runtime call. Additive — when
  manifestPlugins is absent the call shape is unchanged.

Architecturally aligned with openclaw#82814's framing (carrying prepared facts
forward) rather than adding another lazy slot-refill path; does not
touch `resolveMetadataSnapshotForPolicies`. All existing callers continue
to work because `plugins` is optional everywhere it was added.

Validation
- tsgo:core: clean
- tsgo:core:test: clean
- run-vitest model-selection.plugin-runtime + model-selection-manifest-workspace
  + model-selection + model-fallback + manifest-model-id-normalization:
  9 files / 349 tests passed
- oxlint affected files: clean

Tests
- New: "forwards manifestPlugins to the runtime normalization call so
  it can skip the slot-or-load disk walk"
- New: "omits plugins from the runtime call when no manifestPlugins
  are prepared (preserves current behavior)"
  (both in src/agents/model-selection.plugin-runtime.test.ts)
steipete pushed a commit to zeroaltitude/openclaw that referenced this pull request Jun 16, 2026
…id normalize chain

model-id normalize path so consumers stop consulting the
`current-plugin-metadata-snapshot` single-slot handoff in
`resolveMetadataSnapshotForPolicies`. That eliminated most of the
hot-path `installs.json` disk walks (Kova metadata scans dropped
394 → 28 per cold+warm sample).

The remaining 28 scans come from the runtime plugin-normalize branch.
`model-selection-normalize.ts` already receives `options.manifestPlugins`
from its caller and threads it into the static branch
(`normalizeStaticProviderModelId`); the runtime branch a few lines down
silently drops it, and the chain falls through to the slot-or-load disk
walk in `resolveMetadataSnapshotForPolicies`:

  src/agents/model-selection-normalize.ts:59
    → normalizeProviderModelIdWithRuntime(...)        (no plugins param)
      → normalizeProviderModelIdWithPlugin(params)    (no plugins param)
        → normalizeProviderModelIdWithManifest(params) (params.plugins undefined)
          → loadManifestModelIdNormalizationPolicies   (slot-or-load disk walk)

This change extends the openclaw#82814 pattern into the runtime branch:

- Add optional `plugins` param to `normalizeProviderModelIdWithRuntime`
  and `normalizeProviderModelIdWithPlugin`. Both forward unchanged into
  `normalizeProviderModelIdWithManifest`, which already honors
  `params.plugins` to skip the slot lookup.
- At the call site in `model-selection-normalize.ts`, thread
  `options?.manifestPlugins` into the runtime call. Additive — when
  manifestPlugins is absent the call shape is unchanged.

Architecturally aligned with openclaw#82814's framing (carrying prepared facts
forward) rather than adding another lazy slot-refill path; does not
touch `resolveMetadataSnapshotForPolicies`. All existing callers continue
to work because `plugins` is optional everywhere it was added.

Validation
- tsgo:core: clean
- tsgo:core:test: clean
- run-vitest model-selection.plugin-runtime + model-selection-manifest-workspace
  + model-selection + model-fallback + manifest-model-id-normalization:
  9 files / 349 tests passed
- oxlint affected files: clean

Tests
- New: "forwards manifestPlugins to the runtime normalization call so
  it can skip the slot-or-load disk walk"
- New: "omits plugins from the runtime call when no manifestPlugins
  are prepared (preserves current behavior)"
  (both in src/agents/model-selection.plugin-runtime.test.ts)
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 size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant