Repository navigation
fix(agents): preserve built plugin artifacts in prepared runtimes - #125957
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 7:24 AM ET / 11:24 UTC. ClawSweeper reviewWhat this changesThe PR preserves Gateway-selected built plugin artifacts through prepared runtime generations, reused registries, and deferred tool-plugin loads while leaving standalone runtimes source-default. Merge readinessThe PR is a coherent root-cause repair for a current-main Gateway runtime regression and has no blocking code finding. It remains open because it is maintainer-authored/protected and exact-head CI is still running. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway startup prepares reusable agent runtimes and plugin registries before dispatching turns. Deferred tool loading consumes the prepared registry context later, where it must retain the artifact-selection decision rather than reopening source transforms. flowchart LR
A[Gateway startup] --> B[Prepared runtime generation]
B --> C[Plugin registry]
C --> D[Attached load context]
D --> E[Deferred tool plugin]
E --> F[Built artifact or source transform]
Decision needed
Why: The protected maintainer label and availability-sensitive Gateway loader change require an explicit maintainer merge decision even though source review found no blocker. Before merge
Agent review detailsSecurityNone. PR surfaceSource +41, Tests +18, Other +6. Total +65 across 14 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the generation-owned selection as the single source of truth, preserve the explicit source-default standalone path, and merge after exact-head runtime and emitted-artifact checks are green. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main creates and attaches the prepared registry without carrying the Gateway artifact preference, while deferred tool loading reuses that attached context. Is this the best way to solve the issue? Yes—the immutable prepared generation is the correct owner for this selection; a global loader default would wrongly alter standalone source-development runtimes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 096a9708208a. LabelsLabel justifications:
EvidenceWhat 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 (8 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
efb1567 to
45492e1
Compare
|
Addressed the current-head P1 at
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head owner repair: The built-artifact choice now belongs to the immutable reusable plugin generation. Dynamic runs inherit that generation-owned fact before load-context attachment, so they cannot overwrite a configured Gateway generation with source-default selection. The configured-generation-to-dynamic-run regression observes the retained deferred-load context directly. Proof:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…lection Rebase over #125957, which preserves built-artifact mode for lifecycle-selected prepared registries. Reuse of the active gateway generation and the generation-inherited delta preference compose with that owner's parameter instead of duplicating the forwarding.
…ime (#126630) * perf(agents): reuse gateway plugin generation for prepared model runtime The model-runtime sidecar rebuilt two broad plugin registries on gateway startup: 167 imports across 84 plugins (83 loaded twice) with 82 forced TypeScript transformations, ~39.6s of a ~50s source-checkout startup. - Reuse the active gateway registry for inbound dispatch when the gateway-bindable subagent mode, workspace, and manifest identity of the requesting snapshot generation all match; fall back to isolated loading otherwise. - Seed the runtime registry from the inbound registry's plugin ids instead of a second unscoped broad load. - Prefer built plugin artifacts on the agents lane, matching the gateway loader; externally-packaged plugins no longer force source transforms. Measured (M3 Ultra, dist build, median of 3): sidecars.model-runtime 33.93s -> 0.379s; gateway readiness 41.69s -> 7.58s; plugin imports 167 -> 18; TypeScript transformations 82 -> 0. * fix(agents): keep source artifacts on isolated agent registry loads The full agents lane caught ~20 Code Mode regressions from preferring built artifacts on the agents loader lane: in a source checkout a stale dist silently replaces edited plugin source. The gateway-generation reuse already removes the broad re-imports that made source transforms expensive, so the artifact preference is unnecessary for the startup win and unsafe for dev checkouts. * fix(agents): bind gateway registry reuse to the current metadata generation Reuse authority is identity-based: the requesting snapshot must be the process-current published generation. Bundled manifest records compare by id+origin only, so an equivalence check alone could let an older or leaked active registry serve a different generation's plugins. * perf(agents): resolve prepared-runtime metadata through the current generation The sidecar acquired its snapshot with loadPluginMetadataSnapshot, which always constructs a fresh object, so the generation-identity reuse guard could never hold in the gateway and inbound loads stayed isolated. Resolve through the slot-probing entry instead; the published current generation satisfies the read and registry reuse engages. Test updates: model the current-generation identity in the reuse fixture, drop stale preferBuiltPluginArtifacts expectations from the isolated-load fixtures, and add a negative case proving a non-current generation refuses reuse. * perf(agents): inherit gateway artifact preference when extending its generation The runtime-registry delta load re-imported teams-meetings and zoom-meetings channel graphs through forced source transforms (~9.2s) even though the reused gateway generation had already realized them from built artifacts. When the inbound registry is the active gateway registry, the delta load now inherits the generation owner's built-artifact preference; isolated loads keep source truth, so source-executed tests and dev flows are unaffected. Measured (M3 Ultra, dist build, 3 runs): sidecars.model-runtime 289-331ms (baseline 33,930ms); gateway ready 3.7-4.0s (baseline 41.7s); forced source transforms 0 (baseline 82). * test(agents): count both slot-probing metadata resolutions in static startup The prepared cold plugin context now resolves through the canonical slot-probing entry, joining the model-id normalization lane's existing resolution. Both share the published generation; the eager-work protections remain the catalog laziness assertions. * refactor(agents): compose generation reuse with lifecycle artifact selection Rebase over #125957, which preserves built-artifact mode for lifecycle-selected prepared registries. Reuse of the active gateway generation and the generation-inherited delta preference compose with that owner's parameter instead of duplicating the forwarding.
…enclaw#125957) * fix(agents): preserve built plugin artifacts in prepared runtimes * test(agents): update prepared runtime loader contract * fix(agents): preserve built preference for deferred plugins * fix(plugins): carry artifact preference through load context * fix(plugins): keep artifact context optional * test(plugins): prove prepared built artifact projection * fix(agents): scope built artifacts to gateway runtimes * test(agents): preserve standalone loader call shape * fix(agents): retain prepared artifact choice on reuse * test(plugins): update prepared load context expectation Amp-Thread-ID: https://ampcode.com/threads/T-01a023b8-1041-7686-975f-c9f3ef91755d --------- Co-authored-by: Amp <[email protected]>
…ime (openclaw#126630) * perf(agents): reuse gateway plugin generation for prepared model runtime The model-runtime sidecar rebuilt two broad plugin registries on gateway startup: 167 imports across 84 plugins (83 loaded twice) with 82 forced TypeScript transformations, ~39.6s of a ~50s source-checkout startup. - Reuse the active gateway registry for inbound dispatch when the gateway-bindable subagent mode, workspace, and manifest identity of the requesting snapshot generation all match; fall back to isolated loading otherwise. - Seed the runtime registry from the inbound registry's plugin ids instead of a second unscoped broad load. - Prefer built plugin artifacts on the agents lane, matching the gateway loader; externally-packaged plugins no longer force source transforms. Measured (M3 Ultra, dist build, median of 3): sidecars.model-runtime 33.93s -> 0.379s; gateway readiness 41.69s -> 7.58s; plugin imports 167 -> 18; TypeScript transformations 82 -> 0. * fix(agents): keep source artifacts on isolated agent registry loads The full agents lane caught ~20 Code Mode regressions from preferring built artifacts on the agents loader lane: in a source checkout a stale dist silently replaces edited plugin source. The gateway-generation reuse already removes the broad re-imports that made source transforms expensive, so the artifact preference is unnecessary for the startup win and unsafe for dev checkouts. * fix(agents): bind gateway registry reuse to the current metadata generation Reuse authority is identity-based: the requesting snapshot must be the process-current published generation. Bundled manifest records compare by id+origin only, so an equivalence check alone could let an older or leaked active registry serve a different generation's plugins. * perf(agents): resolve prepared-runtime metadata through the current generation The sidecar acquired its snapshot with loadPluginMetadataSnapshot, which always constructs a fresh object, so the generation-identity reuse guard could never hold in the gateway and inbound loads stayed isolated. Resolve through the slot-probing entry instead; the published current generation satisfies the read and registry reuse engages. Test updates: model the current-generation identity in the reuse fixture, drop stale preferBuiltPluginArtifacts expectations from the isolated-load fixtures, and add a negative case proving a non-current generation refuses reuse. * perf(agents): inherit gateway artifact preference when extending its generation The runtime-registry delta load re-imported teams-meetings and zoom-meetings channel graphs through forced source transforms (~9.2s) even though the reused gateway generation had already realized them from built artifacts. When the inbound registry is the active gateway registry, the delta load now inherits the generation owner's built-artifact preference; isolated loads keep source truth, so source-executed tests and dev flows are unaffected. Measured (M3 Ultra, dist build, 3 runs): sidecars.model-runtime 289-331ms (baseline 33,930ms); gateway ready 3.7-4.0s (baseline 41.7s); forced source transforms 0 (baseline 82). * test(agents): count both slot-probing metadata resolutions in static startup The prepared cold plugin context now resolves through the canonical slot-probing entry, joining the model-id normalization lane's existing resolution. Both share the published generation; the eager-work protections remain the catalog laziness assertions. * refactor(agents): compose generation reuse with lifecycle artifact selection Rebase over openclaw#125957, which preserves built-artifact mode for lifecycle-selected prepared registries. Reuse of the active gateway generation and the generation-inherited delta preference compose with that owner's parameter instead of duplicating the forwarding.
Summary
Root cause
Gateway startup selected built plugin artifacts, but prepared model-runtime publication lost that mode at two adjacent owner boundaries:
The second boundary is the exact source of the remaining concurrency failure. The captured CPU profile spends 9.45 seconds in jiti source transforms under
prepareEmbeddedAttemptToolBase -> createOpenClawTools -> resolvePluginTools -> loadPluginRegistryHandle, beginning at the deferredteams-meetingstool plugin. Carrying the existing lifecycle fact through the attached context lets that lazy, scoped load resolve the built artifact without eagerly loading more plugins or raising startup RSS.Evidence
Pre-fix current-main release performance:
First owner boundary:
Deferred first-turn owner:
Exact production proof:
Exact final-head proof (
45492e1af29bf1284f77eb46b173de1d97631daa):test:build:singletonpassed after discovering the bundled SMS plugin from the source tree, late-projecting the attached prepared load context, and proving the loader used the nativedist-runtimeartifact with no source transformLate full-validation sibling evidence from SHA
97a4d324f5c8f32b9c106d6a6e9ed33c180a5fcb:prepared reply dispatch runtime was not published for dev; both are directly covered by preserving built-artifact selection through prepared publication and deferred loads.ensureOpenClawModelsJsonprovider-catalog preparation before the existing 180-second stage bound fires. This is the same plugin source-recompile owner; no timeout increase is proposed.The Gateway chat/image timeout is addressed separately by #125969.
Scope
Agent transcript omitted.