[codex] Reuse scoped runtime plugin registries#96231
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 9:28 PM ET / 01:28 UTC. Summary PR surface: Source +80, Tests +192. Total +272 across 8 files. Reproducibility: yes. with caveat: the linked tracker and PR body contain live timing/log evidence, and the source path from Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this narrow startup-scoped registry reuse only after maintainer review confirms the compatibility contract and build proof is added or intentionally waived; keep provider-hook and plugin-tool cross-workspace reuse on separate, better-proven work. Do we have a high-confidence way to reproduce the issue? Yes, with caveat: the linked tracker and PR body contain live timing/log evidence, and the source path from Is this the best way to solve the issue? Yes, as a narrow merge shape: the PR only reuses an already-loaded compatible startup registry and preserves caller-workspace fallback on miss. The safer alternative to the broad draft is exactly this split, with maintainer compatibility review and build proof before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a21144d8a606. Label changesLabel justifications:
Evidence reviewedPR surface: Source +80, Tests +192. Total +272 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@/var/folders/ks/54l0_v5j441gbf_8nbz9kgb80000gn/T/tmp.gp8Pu8Syl7 |
What Problem This Solves
The iMessage/source-reply latency investigation showed repeated runtime plugin registry work on hot paths after gateway startup. The broad investigation branch proved the direction, but it bundled tracing, iMessage monitor changes, Codex/source-reply fixes, provider-hook reuse, and tool lookup reuse.
This PR keeps only the smallest safe runtime-registry reuse piece: startup-scoped runtime plugin loads can reuse the active gateway startup registry when the existing cache-key and plugin-scope compatibility checks prove it is the same effective registry.
Fixes part of #96148.
Why This Change Was Made
The gateway startup registry already records which plugin ids were loaded for startup-scoped runtime work. Agent turns can request that same startup-scoped set from a turn workspace. Previously, those calls could miss the active gateway registry and rebuild scoped runtime plugin state.
This change tracks the active registry plugin-id scope and lets compatible subset loads reuse the active startup registry. The cross-workspace path is reuse-only: it first checks for a compatible loaded registry and falls back to loading from the caller's original workspace on a miss.
Provider-hook and plugin-tool cross-workspace reuse were intentionally left out of this PR after review because they need stronger compatibility contracts.
User Impact
For users with many configured plugins, agent turns should avoid some redundant startup-scoped runtime plugin reloads after gateway startup. This is a narrow performance improvement, not the full broad-branch optimization.
The live investigation evidence is on #96148 and the superseded draft #96199. The clean broad-branch matched test showed
20.797s -> 17.529s, but this PR claims only the smallest safe subset from that work.Focused live proof on this PR shows the remaining iMessage latency is mostly outside this small change. With cron disabled on commit
a397a64, startup prewarm loaded149runtime plugins in3980.8ms(4022msgateway phase) and provider auth prewarm took2679ms. A live Omar-to-Lobster iMessage turn then took20504msend-to-end:20391msdispatch,13583msmodel/main lane. The same turn still loaded provider/runtime plugin sets on the hot path:1plugin in7.0ms,9plugins in1268.6ms,51plugins in2281.7ms, and agent tools22plugins in120.4ms.That run also hit
incomplete turn detected, but this branch does not include the Codex message-tool/source-reply terminal fix from #95942. Treat the incomplete-turn evidence here only as proof that this perf branch was missing that correctness fix, not as evidence against #95942.Normal Lobster steady-state follow-up also showed the separate provider catalog-hook cache idea was not a real iMessage hot-path win: model catalog work converged after startup and
augmentModelCatalogWithProviderPlugins()did not repeat per message. That branch has been shelved separately and is not part of this PR.Evidence
node scripts/run-vitest.mjs src/agents/runtime-plugins.test.ts src/agents/runtime-plugins.registry-reuse.test.ts src/plugins/loader.runtime-registry.test.tspnpm tsgo:prodgit diff --check origin/main...HEAD.agents/skills/autoreview/scripts/autoreview --mode local --prompt "Review this minimal OpenClaw performance patch after the reuse-only fix. Scope: reuse active gateway startup registries only on a compatible cache hit for startup-scoped runtime plugin loads; fallback loads must use the caller workspace. Provider-hook and plugin-tools cross-workspace reuse are intentionally absent. Focus on cross-workspace safety, cache key correctness, and test coverage for cache miss fallback."OPENCLAW_SKIP_CRON=1 OPENCLAW_LOG_LEVEL=debug OPENCLAW_VERBOSE=1 pnpm openclaw gateway, commita397a64:20504mstotal message processing,20391msdispatch,13583msmodel/main lane; remaining hot-path plugin loads were7.0ms + 1268.6ms + 2281.7ms + 120.4ms.incomplete turn detectedlog is not a verdict on the Codex source-reply fix.