Skip to content

fix(agents): preserve built plugin artifacts in prepared runtimes - #125957

Merged
vincentkoc merged 12 commits into
mainfrom
fix/prepared-runtime-built-plugin-artifacts
Aug 21, 2026
Merged

vincentkoc merged 12 commits into
mainfrom
fix/prepared-runtime-built-plugin-artifacts

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • keep lifecycle-selected prepared plugin registries on built artifacts
  • preserve that artifact mode in the attached lifecycle context, including deferred first-turn tool plugins
  • leave standalone source/dev plugin loads unchanged

Root cause

Gateway startup selected built plugin artifacts, but prepared model-runtime publication lost that mode at two adjacent owner boundaries:

  1. the initially prepared registry did not retain built-artifact selection when given lifecycle metadata;
  2. the immutable load context attached to that registry omitted the same selection, so a deferred tool plugin missing from the prepared registry fell back to source/jiti on the first turn.

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 deferred teams-meetings tool 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):

Late full-validation sibling evidence from SHA 97a4d324f5c8f32b9c106d6a6e9ed33c180a5fcb:

  • CLI backend and Claude prompt-cache both fail the exact owner guard prepared reply dispatch runtime was not published for dev; both are directly covered by preserving built-artifact selection through prepared publication and deferred loads.
  • Anthropic live models spends 302 seconds inside ensureOpenClawModelsJson provider-catalog preparation before the existing 180-second stage bound fires. This is the same plugin source-recompile owner; no timeout increase is proposed.
  • Subagent announce loses its Gateway connection after the first prepared parent turn runs for about 182 seconds. This is a likely cascade from the same owner, not independently claimed proof; if it persists on exact-head validation it needs a named follow-up.

The Gateway chat/image timeout is addressed separately by #125969.

Scope

  • runtime production: +8/-1, net +7
  • focused tests: +8/-3, net +5
  • build-smoke/test support: +27/-17, net +10
  • no config, protocol, storage, Plugin SDK, or public API change
  • no eager plugin preload, threshold, timeout, retry, or assertion weakening
  • no local tests, builds, formatting, or dependency setup were run; GitHub is authoritative

Agent transcript omitted.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 18, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 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 exact_review_queue).
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 7:24 AM ET / 11:24 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 2 items remain

The 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
Reviewed head: 1d010d5e82cba3d648f0714e8a54da7583c26d8b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary fix and focused regression coverage are strong; exact-head CI completion remains the material final confidence step.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This MEMBER-authored internal runtime repair is exempt from the external-contributor proof gate; the PR body nevertheless records emitted-artifact and focused runtime evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal runtime repair is exempt from the external-contributor proof gate; the PR body nevertheless records emitted-artifact and focused runtime evidence.
Evidence reviewed 6 items Current-main defect: Current main creates the prepared registry and attaches its load context without passing a built-artifact choice; the context therefore defaults to source selection for later scoped loads.
Lifecycle-owner repair: The branch derives selection from the configured Gateway group or a reused immutable generation, then supplies it to both registry creation and attached context publication.
Deferred-load consumer: The tool resolver reuses a prepared load context for matching runtime environments and projects it directly into scoped plugin-load options, so carrying the preference through this context reaches deferred tool plugins.
Findings None None.
Security None None.

Live Verification

Command: pnpm test:build:singleton

Result: FAIL (partial) — step 2 expect_output [build-smoke] built plugin singleton smoke passed: expected terminal output was not visible within 30 seconds: "[build-smoke] built plugin singleton smoke passed"

pnpm test:build:singleton
runner@runnervm76f27:/tmp/clawsweeper-live-proof-125957-5DdMUb/target$ pnpm test:build:singleton
$ node --import tsx scripts/test-built-plugin-singleton.mts
node:internal/modules/run_main:107
    triggerUncaughtException(
    ^

AssertionError [ERR_ASSERTION]: missing build output: /tmp/clawsweeper-live-proof-125957-5DdMUb/target/dist/plugins/build-smoke-entry.js
    at ‹anonymous› (/tmp/clawsweeper-live-proof-125957-5DdMUb/target/scripts/test-built-plugin-singleton.mts:15:8)
    at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
    at async node:internal/modules/esm/loader:643:26
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==',
  diff: 'simple'
}

Node.js v24.19.0
[ELIFECYCLE] Command failed with exit code 1.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-125957-5DdMUb/target$ pnpm test:build:singleton
$ node --import tsx scripts/test-built-plugin-singleton.mts
node:internal/modules/run_main:107
    triggerUncaughtException(
    ^

AssertionError [ERR_ASSERTION]: missing build output: /tmp/clawsweeper-live-proof-125957-5DdMUb/target/dist/plugins/build-smoke-entry.js
    at ‹anonymous› (/tmp/clawsweeper-live-proof-125957-5DdMUb/target/scripts/test-built-plugin-singleton.mts:15:8)
    at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
    at async node:internal/modules/esm/loader:643:26
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==',
  diff: 'simple'
}

Node.js v24.19.0
[ELIFECYCLE] Command failed with exit code 1.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-125957-5DdMUb/target$







Assertions:

  • FAIL expect_output: [build-smoke] built plugin singleton smoke passed

How this fits together

Gateway 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]
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should this maintainer-owned runtime-selection repair be merged as the canonical fix for prepared Gateway plugin loads? Merge after exact-head CI: Accept the generation-owned artifact-selection propagation once the current head's focused runtime and build-singleton checks are green.

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

  • Resolve merge risk (P1) - This changes artifact-versus-source selection in a Gateway hot path; merge only after current-head build-singleton and prepared-runtime checks complete, because packaged startup regressions would be availability-impacting.
Agent review details

Security

None.

PR surface

Source +41, Tests +18, Other +6. Total +65 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 9 47 6 +41
Tests 4 26 8 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 23 17 +6
Total 14 96 31 +65

Review metrics

Metric Value Why it matters
Production versus test delta production +47/-6; focused tests +26/-8; build-smoke support +23/-17 The production growth carries one immutable lifecycle fact across the actual registry and deferred-load owner boundaries; the focused coverage protects both built and source-default modes.

Stored data model

Persistent data-model change detected: persistent cache schema: scripts/test-built-plugin-singleton.mts, vector/embedding metadata: src/agents/runtime-plugins.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the packaged runtime path before merge (recommended)
    Wait for the current head's build-singleton and prepared-runtime checks to pass so emitted artifacts, not source transforms, are exercised under the repaired lifecycle.
  2. Pause for a replacement comparison
    Pause this PR only if maintainers select fix(agents): keep gateway prepared runtimes on built plugin artifacts #126226 as the preferred canonical implementation.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require green exact-head runtime and build-singleton checks before merge.

Technical review

Best 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.

Labels

Label justifications:

  • P1: Prepared Gateway turns can otherwise fall back to synchronous plugin source transforms on a hot startup/first-turn path.
  • merge-risk: 🚨 availability: The PR changes packaged plugin resolution in Gateway-prepared runtimes, where a wrong selection can reintroduce costly startup or first-turn work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored internal runtime repair is exempt from the external-contributor proof gate; the PR body nevertheless records emitted-artifact and focused runtime evidence.

Evidence

What I checked:

Likely related people:

  • RomneyDa: Authored the branch's substantive lifecycle and plugin-loader repair commits, including the scope and generation-reuse corrections. (role: prepared-runtime repair contributor; confidence: medium; commits: 8742143b4806, fab0f376f93b, 08efc760f5b9; files: src/agents/prepared-model-runtime.facts.ts, src/agents/prepared-model-runtime.build.ts, src/plugins/runtime/load-context.ts)
  • ampagent: Authored the latest focused test update and the current checked-out merge tip. (role: recent branch updater; confidence: low; commits: c8d207d4888e, 1d010d5e82cb; files: src/agents/prepared-model-runtime.plugin-context.test.ts)

Rank-up moves

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

  • Let the current head's build-singleton and prepared-runtime checks finish green before merge.

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 (8 earlier review cycles)
  • reviewed 2026-08-18T19:41:33.712Z sha de27ab4 :: found issues before merge. :: [P1] Carry the preference through the load-context contract
  • reviewed 2026-08-18T20:46:35.424Z sha 3cdfdb9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T21:18:31.859Z sha 45492e1 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T21:39:30.040Z sha 45492e1 :: needs changes before merge. :: [P1] Preserve source selection for standalone prepared runtimes
  • reviewed 2026-08-21T02:38:14.281Z sha fab0f37 :: found issues before merge. :: [P1] Preserve artifact selection across reused plugin generations
  • reviewed 2026-08-21T02:55:59.435Z sha 34478a9 :: found issues before merge. :: [P1] Preserve artifact selection on reused plugin generations
  • reviewed 2026-08-21T03:26:33.881Z sha 34478a9 :: needs changes before merge. :: [P1] Preserve artifact selection on reused plugin generations
  • reviewed 2026-08-21T03:51:25.213Z sha f4c2f16 :: needs maintainer review before merge. :: none

@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 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 exact_review_queue).
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 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S and removed size: XS labels Aug 18, 2026
@RomneyDa
RomneyDa force-pushed the fix/prepared-runtime-built-plugin-artifacts branch 2 times, most recently from efb1567 to 45492e1 Compare August 18, 2026 21:10
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 18, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

Addressed the current-head P1 at fab0f376f93b4f44edeef1a518cc7ec986aa3c8d.

  • Built-artifact selection is now an explicit fact from the configured Gateway publication group; metadata presence alone no longer enables it.
  • Standalone/direct prepared runtimes retain source-default selection even when they carry an explicit metadata snapshot.
  • Added focused regressions at both the registry-load and attached prepared-context boundaries.
  • Rebased onto current main; oxfmt and diff checks pass; branch autoreview is clean (overall correct, 0.91). Exact-head CI is now running the focused/runtime/build singleton coverage because this isolated worktree has no dependency tree.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 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 exact_review_queue).
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 rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 21, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 21, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

Exact-head owner repair: f4c2f16c610c63110af3eb7d7dfdfed1c1d84fbb

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:

  • prepared inbound/context suites: 16/16
  • full pnpm build passed
  • pnpm test:build:singleton passed against emitted artifacts
  • focused oxlint clean
  • structured autoreview clean, correct 0.97
  • judged delta: production +47/-6; tests +48/-25

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 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 exact_review_queue).
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 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 21, 2026
@vincentkoc vincentkoc self-assigned this Aug 21, 2026
@vincentkoc
vincentkoc merged commit ef91c81 into main Aug 21, 2026
225 checks passed
@vincentkoc
vincentkoc deleted the fix/prepared-runtime-built-plugin-artifacts branch August 21, 2026 16:10
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

steipete added a commit that referenced this pull request Aug 21, 2026
…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.
steipete added a commit that referenced this pull request Aug 21, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…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.
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S 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.

3 participants