Skip to content

perf(agents): reuse active Gateway plugin generation - #127278

Merged
vincentkoc merged 1 commit into
mainfrom
fix/runtime-generation-reuse-replacement
Aug 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/runtime-generation-reuse-replacement

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Corrects the active Gateway generation reuse that landed in #126630 while this replacement was under review. The landed version inferred built-artifact preference from active-registry identity and allowed an undefined active workspace to match any prepared workspace. This replacement keeps generation reuse, slot-probing metadata resolution, and delta-only plugin loading while restoring explicit lifecycle ownership.

Supersedes the implementation in #126630 while preserving Peter Steinberger's co-author credit.

Why This Change Was Made

The prepared runtime reuses the active Gateway registry only when the caller has Gateway binding authority, uses the default process environment, matches the active workspace and bindable mode, supplies the exact current metadata object, and matches the active registry records to that metadata generation.

Selected runtime plugins load as a delta seeded from imported inbound plugin IDs, so deferred records remain eligible for their scoped load. preferBuiltPluginArtifacts remains owned by the prepared generation introduced in #125957; this change removes the duplicate extendsActiveGatewayGeneration inference.

User Impact

Gateway startup keeps the reuse optimization while stale, mismatched, isolated, and custom-environment runtimes continue through the existing independent load path. No config or public API changes.

Evidence

  • Restacked exact head: aa25d4ebf888bab6172a370c5a51ac6aabcf8fe1
  • Focused exact-head proof: 7 files across 2 Vitest shards, 85 tests passed
  • Covers accepted current-generation reuse and rejection for stale generation, custom env, non-bindable mode, workspace mismatch, and manifest mismatch
  • Proves selected-runtime seeding excludes deferred plugin records
  • git diff --check: passed
  • Corrective diff against current main: production +11/-25 (net -14); tests +64/-52 (net +12)
  • Pre-restack equivalent implementation proof on Blacksmith Testbox tbx_01m0jjw54pmrrgwmcspxcakvfr: pnpm build, singleton packaging, and explicit changed gates passed
  • Same-Testbox isolated Gateway startup, 3 runs per implementation, preparedRuntimeScaleMany:
    • branch-cut main a2f0b84e8adad3c29e11d6510809779963d748ee: readyz median 9247ms; model-runtime median 371.9ms; plugin imports 4; source transforms 0
    • reviewed implementation: readyz median 8118ms; model-runtime median 349.2ms; plugin imports 4; source transforms 0
    • delta: readyz -12.2%; model-runtime -6.1%; no import or source-transform regression
  • Testbox Actions lease: https://github.com/openclaw/openclaw/actions/runs/32503768585

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 2:29 PM ET / 18:29 UTC.

ClawSweeper review

What this changes

This PR restricts prepared model runtimes to reusing only the exact active Gateway plugin generation, while loading selected runtime plugins as a delta that leaves deferred plugins eligible for scoped loading.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still contains the merged reuse implementation this PR corrects; the exact-head patch adds the missing strict workspace-generation guard and retains lifecycle-owned artifact selection. No blocking patch defect was found.

Priority: P2
Reviewed head: aa25d4ebf888bab6172a370c5a51ac6aabcf8fe1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, preserves the established lifecycle owner, and includes real startup proof plus targeted regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides Testbox Gateway startup traces with before/after measurements plus exact-head focused test evidence for the changed runtime behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides Testbox Gateway startup traces with before/after measurements plus exact-head focused test evidence for the changed runtime behavior.
Evidence reviewed 6 items Current-main unsafe condition: Current main permits an active registry with no recorded workspace to match any prepared workspace; this PR changes that check to require exact workspace equality before reuse.
Patch owner boundary: The exact head requires Gateway binding authority, default environment, matching active workspace, exact current metadata identity, and a matching manifest before registry reuse.
Lifecycle artifact ownership: Prepared-runtime build groups already carry built-artifact preference from the lifecycle-selected generation, so removing the duplicate active-registry inference preserves the canonical owner.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127278-tCG8XV/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 113.11 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.9s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4311ms (slowest: built plugin control-plane loads 3558ms)

OpenClaw 2026.8.1 (aa25d4e) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Gateway publishes a process-wide plugin registry and metadata generation during startup. Prepared model runtimes consume those facts to load provider and tool plugins, either safely reusing the active generation or independently loading an isolated registry.

flowchart LR
  A[Gateway startup] --> B[Published plugin metadata]
  A --> C[Active plugin registry]
  D[Prepared model runtime] --> E[Generation and workspace checks]
  B --> E
  C --> E
  E -->|Exact match| F[Reuse inbound registry]
  E -->|Mismatch| G[Independent registry load]
  F --> H[Selected plugin delta]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - An incorrect reuse match can hand a prepared runtime a stale or wrong-workspace registry and leave it unready; merge should retain the exact-head startup and deferred-plugin checks as gates.
  • Complete next step (P2) - No concrete automated repair remains; await exact-head CI and normal maintainer merge review.
Agent review details

Security

None.

PR surface

Source -14, Tests +12. Total -2 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 25 -14
Tests 3 64 52 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 75 77 -2

Review metrics

Metric Value Why it matters
Production versus test LOC production +11/-25 (net -14); tests +64/-52 (net +12) The corrective change reduces production surface while expanding regression coverage for reuse eligibility and deferred-plugin loading.

Root-cause cluster

Relationship: canonical
Canonical: #127278
Summary: This PR is the canonical corrective follow-up for the unsafe active-generation reuse introduced by the merged implementation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Land with exact-head runtime gates (recommended)
    Accept the bounded startup-risk change only after the focused Gateway startup and deferred-plugin checks pass on this exact head.

Technical review

Best possible solution:

Land the strict generation/workspace reuse guard after exact-head checks confirm both Gateway startup and deferred scoped-plugin loading remain healthy.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main's workspace condition accepts an undefined active workspace, while the exact-head guard rejects it and the focused tests exercise incompatible reuse paths.

Is this the best way to solve the issue?

Yes. The patch fixes reuse at the lifecycle owner with exact workspace and metadata identity checks, while leaving built-artifact preference with the prepared generation that owns it.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ee79b0a49ae4.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded corrective change to Gateway/model-runtime startup behavior rather than an emergency outage.
  • merge-risk: 🚨 availability: A faulty active-generation match could stop a prepared model runtime from becoming ready during Gateway startup.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides Testbox Gateway startup traces with before/after measurements plus exact-head focused test evidence for the changed runtime behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides Testbox Gateway startup traces with before/after measurements plus exact-head focused test evidence for the changed runtime behavior.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged Gateway-generation reuse implementation that this PR corrects. (role: introduced current-main behavior; confidence: high; commits: c6d6706d8e4f; files: src/agents/prepared-model-runtime.inbound-registry.ts, src/agents/runtime-plugins.ts)
  • RomneyDa: Authored the merged prepared-runtime artifact-selection work whose lifecycle-owned preference this PR preserves. (role: adjacent lifecycle owner; confidence: high; commits: ef91c818c421; files: src/agents/prepared-model-runtime.build.ts, src/agents/prepared-model-runtime.facts.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-21T16:41:22.684Z sha 44e91fc :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T17:12:59.842Z sha 44e91fc :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review August 21, 2026 17:06
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 21, 2026
Reuse the active Gateway registry only for the exact current metadata generation and matching runtime authority. Seed selected-runtime loading from imported inbound plugin IDs so deferred records remain eligible for their scoped load, while the generation owner continues to supply built-artifact preference.

Co-authored-by: Peter Steinberger <[email protected]>
@vincentkoc
vincentkoc force-pushed the fix/runtime-generation-reuse-replacement branch from 44e91fc to aa25d4e Compare August 21, 2026 18:23
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 21, 2026
@vincentkoc
vincentkoc merged commit 35175c3 into main Aug 21, 2026
239 checks passed
@vincentkoc
vincentkoc deleted the fix/runtime-generation-reuse-replacement branch August 21, 2026 18:51
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
Reuse the active Gateway registry only for the exact current metadata generation and matching runtime authority. Seed selected-runtime loading from imported inbound plugin IDs so deferred records remain eligible for their scoped load, while the generation owner continues to supply built-artifact preference.

Co-authored-by: Peter Steinberger <[email protected]>
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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant