Repository navigation
perf(plugins): avoid redundant schema hook invocation scopes - #173448
Merged
steipete merged 1 commit intoOct 15, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 15, 2026 20:20
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
deleted the
steipete/perf-micro-plugin-invocation-scope-20260919
branch
October 15, 2026 20:39
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Chat turns allocate avoidable plugin-scope objects while preparing provider tool schemas.
User Impact
Lower allocation in provider tool preparation, with the same schemas, execution behavior, and lifecycle checks. No configuration changes or migration are needed. The measurements below do not establish a whole-turn latency improvement.
Why This Change Was Made
Provider tool-schema preparation invokes the managed function's
.callwrapper, causing nested plugin scope entry and repeated executable result binding. Ordinary tool descriptor copying also opens a scope for each tool even though no plugin code runs there.Invoke the managed schema hook with
Reflect.apply, preserving its receiver and lifecycle admission without traversing managedFunction.prototype.call. Copy descriptors directly after the existing prototype-chain check. Proxy-backed tools, lazy accessors, and execution/preparation callbacks retain their admitted paths. Production LOC delta: -1; test delta: +38.No normalization-result cache: hooks receive the current model, configuration, workspace, and run-bound tools, so provider/registry revision alone is not a valid reuse key. No public API, schema, or stored-format changes.
Evidence
Measurement
Source-mode development Gateway, Node 26.11.1, synthetic 5,000-session/6,000-run state with populated transcripts; identical pristine offline fixture for both processes, fixed 90-second post-ready settle. Twenty completed chat turns per side, each with exactly one read-tool call/result and the full expected final assistant text. Baseline
6401ea6c395e; candidate07086c7d2067.The raw after mean includes a 179.915 MiB first-round outlier overlapping startup handler prewarm, plugin status, catalog, and schema work absent from the baseline capture. It is retained, not filtered out. These results support the targeted allocation reduction; they do not establish a whole-turn mean or latency improvement. The single separate CPU-only turn was 320.678 → 323.717 ms (+0.95%, neutral at this sampling depth). Latency p50 was 697.446 → 732.412 ms on the contended host. Allocation excludes workers/external buffers and includes the event-drain window.
The benchmark initially failed before measurement because its mock port collided with another isolated lane; the mock also assumed every request had JSON. The rerun used a free port pair and explicit mock request handling. Both completed captures passed all turn validation checks. No production Gateway was used.
Validation
node scripts/run-vitest.mjs src/plugins/registry.factory-bindings.test.ts src/plugins/provider-runtime.test.ts src/agents/runtime-plan/tools.test.ts --maxWorkers=1: 98 tests passed, 3 files, 65.16 seconds wall time. Baseline factory-binding file: 12 passed, 53.71 seconds including initial compilation. The new behavior-preservation test also passes on the baseline.git diff --checkpassed. Lint used--tsconfig config/tsconfig/oxlint.core.json --threads=1on only the 3 changed files; an initial root-config invocation was stopped when it selected broad package preparation.