Skip to content

perf(agents): reuse unchanged catalog executor entries - #137703

Merged
steipete merged 1 commit into
mainfrom
codex/perf7-catalog-executor-rebind
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf7-catalog-executor-rebind

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tool Search catalog reuse rebuilt every entry record even when its fingerprint, exact IDs and executor functions were unchanged. Those copies were discarded on the common unchanged path.

Why This Change Was Made

Check executor identity against the existing entries first and reuse the entry array when no binding changed. Changed executors still trigger the existing complete rebind, so fresh tool implementations are never hidden by catalog reuse.

User Impact

Repeated preparation of an unchanged catalog avoids copying all entry records. Tool schema, order, policy and execution semantics are preserved.

Evidence

Fourteen public-owner scenarios and 24 execution dispatches matched before and after. A 128-entry catalog reused 25 times eliminated 3,200 discarded row copies. The existing reuse subset passed 15 tests, with another 23 tests covering catalog lifetime and prompt-policy siblings. Independent Codex review found no actionable P0–P2 issue; the full changed gate passed in 297.76 seconds with unchanged source and verified cleanup.

Production +12/−12, net zero; tests unchanged. No new cache, public API, configuration or persistence policy. Timing and RSS from the functional probe are not performance claims.

Combined live verification

The final isolated twenty-change composite passed ten admitted real OpenAI Gateway turns across Code Mode and Tool Search, with web fetches, exact synthetic file reads, bounded Unicode output, four persisted-history checks and clean unforced shutdown. Independent audit accepted all fourteen stages, fifty memory observations and sixty saved command captures. One fixed run per revision showed post-idle RSS of 492.375 MiB (Code Mode) and 478.297 MiB (Tool Search), versus baseline 497.453125 and 481.53125 MiB. Main-isolate heap differed by only −107,976 and −264,016 bytes. Against the earlier twelve-change composite, Code Mode RSS rose 7.4375 MiB; sampled allocation results were mixed. These observations describe the composition and do not establish per-PR or consistent overall memory savings. The individual owner proofs above carry the effect claim. Exact-head required CI remains a landing gate.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 2:03 AM ET / 06:03 UTC.

ClawSweeper review

What this changes

The PR reuses unchanged Tool Search catalog entry descriptors when their IDs and executor objects match, while cloning and rebinding entries when an executor changes.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. The introduced optimization preserves the existing same-run behavior and current main still allocates the discarded descriptors; this maintainer-authored, protected PR needs exact-head CI completion and a maintainer landing decision.

Priority: P3
Reviewed head: 957db4c48c02ae04b3fe690d23efed40a9c68b88
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral optimization with preserved executor rebinding and relevant existing behavioral coverage; remaining landing work is CI and maintainer disposition.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body nevertheless describes after-fix catalog and Gateway validation, while this review independently verified the source-level execution boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body nevertheless describes after-fix catalog and Gateway validation, while this review independently verified the source-level execution boundary.
Evidence reviewed 5 items Introduced reuse condition: The pinned PR delta adds the exact-executor identity check and returns the existing entry array only when every catalog ID resolves to the same tool object; changed executors retain the established clone-and-rebind path.
Current-main comparison: Fetched current main retains the pre-PR implementation, which maps every entry into a discarded descriptor before conditionally retaining the prior array; the optimization is therefore not already implemented on main.
Execution owner and caller boundary: Both Tool Search and OpenClaw Code Mode converge on the shared compactor, while the runtime resolves a catalog entry and invokes its executor at call time; unchanged executor identity retains the same callable object and a changed one is rebound.
Findings None None.
Security None None.

How this fits together

Tool Search turns an agent run’s callable tools into a catalog used by Tool Search and OpenClaw Code Mode. The shared compactor registers that catalog before the runtime resolves an entry and invokes its current executor.

flowchart LR
  A[Agent run tools] --> B[Shared catalog compactor]
  C[Existing run catalog] --> D{Fingerprint, IDs, and executors match?}
  B --> D
  D -->|Yes| E[Reuse entry descriptors]
  D -->|Executor changed| F[Clone and rebind entries]
  E --> G[Tool Search runtime]
  F --> G
  G --> H[Current tool execution]
Loading

Decision needed

Question Recommendation
After exact-head checks complete, should this maintainer-authored allocation-only catalog optimization land? Land after green checks: Accept the same-run descriptor reuse because unchanged and changed-executor paths preserve the established catalog behavior.

Why: Source review finds no semantic regression, but accepting internal performance complexity and landing a protected maintainer PR requires maintainer disposition.

Before merge

  • Resolve merge risk (P1) - Exact-head required CI is still in progress in the supplied check state, so this PR is not ready to land yet.
  • Complete next step (P2) - Wait for exact-head required CI to complete, then obtain maintainer disposition on landing the allocation-only optimization.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source 0. Total 0 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 12 12 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 12 12 0

Review metrics

Metric Value Why it matters
Production versus tests production +12/-12 (net 0); tests unchanged The PR changes only the allocation behavior of the existing catalog-reuse branch and adds no public surface or stored state.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the shared exact-identity fast path and the existing clone-and-rebind fallback, then land only after exact-head CI passes and a maintainer accepts the allocation-only optimization.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the shared exact-identity fast path and the existing clone-and-rebind fallback, then land only after exact-head CI passes and a maintainer accepts the allocation-only optimization.

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

Not applicable: this is an allocation optimization rather than a report of broken user behavior; source inspection establishes the unchanged and rebound execution paths.

Is this the best way to solve the issue?

Yes. The shared compactor is the canonical owner, and exact executor identity preserves the old retained state while avoiding copies; differing executors still take the established rebind path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal allocation optimization with no demonstrated user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body nevertheless describes after-fix catalog and Gateway validation, while this review independently verified the source-level execution boundary.

Evidence

What I checked:

  • Introduced reuse condition: The pinned PR delta adds the exact-executor identity check and returns the existing entry array only when every catalog ID resolves to the same tool object; changed executors retain the established clone-and-rebind path. (src/agents/tool-search-catalog.ts:71, 957db4c48c02)
  • Current-main comparison: Fetched current main retains the pre-PR implementation, which maps every entry into a discarded descriptor before conditionally retaining the prior array; the optimization is therefore not already implemented on main. (src/agents/tool-search-catalog.ts:79, bd4c647ccff7)
  • Execution owner and caller boundary: Both Tool Search and OpenClaw Code Mode converge on the shared compactor, while the runtime resolves a catalog entry and invokes its executor at call time; unchanged executor identity retains the same callable object and a changed one is rebound. (src/agents/tool-surface-plan.ts:94, 957db4c48c02)
  • Existing regression coverage: Existing tests cover same-reference reuse versus a fresh run, invoke the second executor after same-run rebinding, and reject reuse for duplicate-ID reordering and schema changes. (src/agents/tool-search.test.ts:3863, 957db4c48c02)
  • Feature history: Recent path history identifies the run-owned catalog refactor and executor-rebind repair; unavailable promisor blobs prevented a raw-parent source-line introduction claim for the earlier rebind commit. (src/agents/tool-search-catalog.ts, 3a04cac872d0)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Trey Lawrence: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-04T00:38:01.436Z sha 68a3b54 :: blocked before merge. :: none
  • reviewed 2026-09-04T00:52:35.649Z sha 68a3b54 :: blocked before merge. :: none
  • reviewed 2026-09-04T02:04:11.412Z sha 3583560 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T04:13:06.979Z sha a5066a8 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/perf7-catalog-executor-rebind branch from 68a3b54 to 3583560 Compare September 4, 2026 01:56
@steipete

steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Investigated the current compact-large1 failure at head 358356010139078720b1e33a95e29224c06b741c. The failing setup request is sessions.delete in the replacement case of src/gateway/local-request-context.session-tools.test.ts; its original 10-second request deadline remains unchanged.

A local Node 26.8.1 run of that exact fixture passed all 14 cases. Temporary timing observations localized its cold cleanup delay to the Browser cleanup call in src/gateway/session-reset-service.ts. The embedded/MCP imports and the later plugin/ACP/harness cleanup did not account for the delay.

One controlled composition with all nine exact files from #137671 at 0807123eb2cc12447a686c7d898eaa8852d0402f preserved the same fixture, assertions, request deadlines, diagnostics and isolated test invocation:

node scripts/run-vitest.mjs src/gateway/local-request-context.session-tools.test.ts

Both arms passed all 14 cases. The driver's child-and-process-group interval fell from 90.853 to 26.567 seconds; this excludes the later source rehash, temporary-runtime removal and receipt publication. Cold Browser cleanup fell from 63,019.545 to 2,699.558 ms; the three warm calls fell from 1,026–1,048 ms to 133–139 ms. During the cold call, process RSS growth was 1,394,982,912 bytes before and 168,755,200 bytes with the Browser patch; heapUsed growth was 445,662,632 and 169,214,296 bytes respectively.

These are local Vitest-process snapshots, without forced GC. They are not retained-heap or live-Gateway measurements, and the local fixture passing in both arms does not prove the exact hosted Linux timeout's cause. The replacement case itself took 2,247 ms before and 1,333 ms with the composition. No request timeout was increased and no assertion was weakened. The Browser fix already has its own PR and will be reused rather than duplicated here.

The comparison's source hashes stayed stable; both supervised processes joined and their process groups and temporary runtimes were absent afterward. Hosted CI remains required, including the separately failing npm advisory audit.

A separate bounded observation run checked the candidate's actual execution path, because cleanup warnings can otherwise be swallowed. All four Browser calls entered the candidate maintenance surface, selected zero tracked tabs in the candidate registry, and returned normally with 0; no cleanup warning was observed. Runtime module locations selected this checkout's Browser source and the installed Jiti 2.7.0 loader. All 14 unchanged fixture cases passed. The Node executable's resolved path and hash were stable before/after this additional run. It supplies path/result evidence only and does not replace the timing pair or establish the hosted timeout's cause.

@steipete
steipete force-pushed the codex/perf7-catalog-executor-rebind branch from a5066a8 to 957db4c Compare September 4, 2026 05:55
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer decision under the user-authorized performance campaign: land the same-run descriptor reuse. Exact catalog IDs and tool object identity remain mandatory; any changed executor retains complete rebinding. No new cache, stored state or public surface is introduced.

Exact-head CI run 33842286598 passed all selected gates; 134 successful,42 skipped,1 neutral checks and none failed or pending in the terminal snapshot.

Advisory clearance was not obtained: the inspected security job ended three audit attempts with HTTP503 and continued under the existing availability policy. No security/test gate was changed or waived here.

@steipete
steipete merged commit 7e46e5a into main Sep 4, 2026
177 checks passed
@steipete
steipete deleted the codex/perf7-catalog-executor-rebind branch September 4, 2026 06:18
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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