Repository navigation
perf(agents): carry prepared plugin load context into per-attempt tool construction - #118398
Conversation
|
Codex review: needs changes before merge. Reviewed August 2, 2026, 11:47 PM ET / August 3, 2026, 03:47 UTC. ClawSweeper reviewWhat this changesCarries lifecycle-prepared plugin load context and registry facts into per-attempt agent tool construction to avoid repeatedly resolving plugin metadata and auto-enable state. Merge readinessNeeds one correction before merge: the prepared path can select tools using metadata captured before auto-enable, while the cold path selects from metadata compatible with the auto-enabled configuration. That can silently omit an auto-enabled plugin tool on prepared configured turns, so this PR remains necessary but is not ready to merge. Priority: P1 Review scores
Verification
How this fits togetherPrepared model runtimes build plugin registry and metadata facts once for configured agent turns. Per-attempt tool construction consumes those facts to choose and instantiate enabled plugin tools, with a cold resolver retained for incompatible contexts. flowchart LR
A[Configured agent turn] --> B[Prepared runtime owner]
B --> C[Plugin registry and metadata]
C --> D[Prepared load context]
D --> E[Per-attempt tool construction]
E --> F{Compatible context?}
F -->|Yes| G[Reuse prepared facts]
F -->|No| H[Cold plugin resolution]
G --> I[Selected plugin tools]
H --> I
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +114, Tests +160. Total +274 across 16 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical resolved metadata snapshot after auto-enable, carry that final snapshot with the prepared load context, and add a regression that proves prepared and cold tool selection agree when auto-enable adds a tool plugin. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: configure metadata so auto-enable adds a plugin tool, then compare a compatible prepared runtime with the cold resolver. The branch routes the prepared selection through the pre-auto-enable snapshot while the cold path resolves final-compatible metadata. Is this the best way to solve the issue? No. Reusing lifecycle-owned facts is the right owner boundary, but the carrier must retain the final metadata snapshot produced after auto-enable rather than reattach the initial snapshot. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c89e57dd4517. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
c73adcd to
ead3f7d
Compare
|
Maintainer review complete. The latest ClawSweeper metadata move is intentionally skipped: the carried metadata snapshot is the lifecycle owner's complete manifest inventory, while auto-enable state comes from the prepared resolved config; incompatible config/env/workspace identities retain the canonical cold path. Re-resolving metadata would reopen the cold discovery path guarded by the unchanged Gateway startup invariant. Exact-head CI is green. The original |
|
Merged via squash.
|
…l construction (openclaw#118398) * perf(plugins): carry prepared load context into tools * fix(agents): keep prepared context setter private * fix(agents): reuse prepared plugin metadata context * refactor(agents): relocate prepared plugin context wiring * test(agents): cover prepared plugin context owner path * refactor(plugins): remove duplicate metadata type exports
What Problem This Solves
The follow-up named in #118334: per-attempt plugin tool construction still re-ran the plugin load-context resolver + auto-enable orchestration once per tool-constructing attempt (call chain run-orchestrator → attempt-tool-base-prepare → agent-tools → openclaw-plugin-tools → plugins/tools → runtime/load-context). Measured at 14.0-15.6 ms per attempt, 117 ms aggregate in an N=8 bench (~1.8% of turn time), repeated again on retries.
Why This Change Was Made
Prepared facts now travel with the lifecycle owner instead of being rediscovered (#117768's seam, extended): prepared-runtime acquisition resolves the plugin load context once after registry construction and attaches it to the lifecycle-owned plugin registry via a module-private symbol (
prepared-model-runtime.plugin-context.ts) — no Plugin SDK type changes; all 149 SDK subpaths unchanged. Tool construction uses the prepared context only under strict reference-identity compatibility (raw/resolved config, env, workspaceDir all identical), falling back to the cold resolver otherwise. Incompatible, standalone, CLI, status, and sandbox paths keep the original cold path; one resolution implementation remains.User Impact
No behavior change (same plugins, same tools, same registries — six ownership/forwarding/metadata-reuse regressions incl. zero per-attempt resolution under a prepared owner). Configured turns stop paying per-attempt load-context resolution: bench A/B turns 6391 → 6219 ms (−2.7%), in-load readyz/sessions p50 38.7/38.5 → 7.6/7.4 ms.
Evidence
Completes the follow-up track from #118027 (#118192, #118207, #118193, #118334, #118349, #118364).