Repository navigation
improve: reduce model capability preparation work - #152128
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 18, 2026, 5:23 PM ET / 21:23 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR stops model catalog scanning at the first literal match, preserves existing alias fallbacks, and adds coverage for sparse arrays. Merge readiness⛔ Blocked before merge - 1 item remains The optimization remains useful: current main and the latest release still scan the full catalog before checking literal matches. No actionable correctness or security finding remains, and the recorded benchmark supports the bounded performance claim. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw looks up the selected model in prepared catalogs before assembling an agent run. The selected row supplies image-input and thinking capabilities. flowchart TD
A[Selected provider and model] --> C[Catalog lookup]
B[Prepared and configured catalogs] --> C
C --> D{Literal match found}
D -->|Yes| E[Selected model row]
D -->|No| F[Alias and unique case fallback]
F --> E
E --> G[Agent run capabilities]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +10. Total +20 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the fused lookup with literal precedence and unchanged fallback semantics, keeping performance claims scoped to measured capability preparation. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: source confirms the full-scan cost, and the PR supplies before/after production-caller measurements; this review did not execute them. Is this the best way to solve the issue? Yes. Combining provider filtering with literal matching avoids redundant work without adding caching, changing the public API, or replacing the existing fallback owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dc5b321b5f89. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
adacae2 to
ba00f05
Compare
|
Merged via squash.
|
…n-20260918-v4 * origin/main: (81 commits) fix: retire failed setup plugins without replaying facade initialization (#152026) fix(test): select Node for built runtime recovery fixtures (#152162) refactor(auth): reuse privately assembled choice groups (#152166) fix: preserve chat media delivery and session boundaries (#152079) fix: keep stale Stop messages from canceling replacement sessions (#152116) improve(plugins): reduce mutable argument handling overhead (#152154) fix(scripts): prevent host tooling drift from blocking PR workflows (#152078) improve: reduce model capability preparation work (#152128) fix: stop marking delivered scheduled reports as failed (#152165) fix: start background context maintenance after durable turns (#151936) fix(models): avoid ambient state reads during prepared selection (#152119) feat: recover abandoned Crabbox source staging (#152006) chore(ui): refresh control ui locales (#152098) fix(ui): keep cloud startup prompts and progress in chat (#152024) fix: report completed subprocess cleanup after cancellation (#152107) perf(reply): reuse normalized inbound text (#152110) fix(cron): paused future one-shots disappear after Run now (#152126) perf(sessions): reuse rows and skip discarded terminal labels (#152109) fix(ui): keep keyboard-focused automation controls clear of sticky actions (#152135) fix(ui): load remote images in compact activity previews (#152045) ...
* improve: reduce model capability preparation work * test: preserve sparse catalog lookup coverage
Related: #143686
What Problem This Solves
Preparing model capabilities scans and allocates the complete provider catalog even when the selected model appears near the beginning.
User Impact
Less CPU work preparing agent runs, with the same selected model and capabilities. This measures capability preparation, not total response latency. Whole-process memory peaks were variable; Node 26's mean peak increased by 21 MiB in the benchmark cohort.
Why This Change Was Made
Combine provider filtering and literal matching in one pass that stops on the first literal match. If no literal matches, reuse the collected provider rows for the existing canonical-alias and unique case-insensitive fallbacks. Preserve sparse-array behavior and literal precedence over aliases; no cache or invalidation policy is added.
Evidence
prepareModelRunCapabilitiescaller, Node 24.19.0 and 26.8.2, 24 fresh processes: six alternating baseline/candidate pairs per runtime, three measured blocks per scenario. All outputs and reference-identity contracts match. All adverse pairs retained; independent saved-data audit recomputed every pair and receipt hash.unicorn/no-new-arrayin the new test; the fixture now creates the same holes without that constructor. The separate mainline duplicate-declaration failures are repaired by merged fix: preserve model failure causes and worker fallback runtime #152028 and included in the refreshed base; fix: restore SQLite test collection #152137 was closed as superseded with identical repaired test blobs. Required hosted CI passed on final headba00f051b69f7c8e5005e3a9086aca1ea62df14f, including build, type checking, lint and the required test shards.Benchmark scope and representative timings
Base:
1def359971d0d45129db27c73b5c5a970daf623b. Candidate owner SHA-256:2548569e857beabf86a1af79d57d10a8be77ef21c7669ba13bf48d81315f0873.Synthetic mutable dense catalogs contain 10, 1,000 or 5,000 rows; three quarters of ordinary rows belong to the target provider. Configured catalogs contain one tenth as many rows (minimum two), with the target at the end. Controls include wrong-provider ID collisions, missing IDs, unique case fallback, provider equivalence and empty configured catalogs. Iterations were calibrated once from a fresh baseline and then fixed; the inspector was disconnected during warmup and timing. The cohort measured 31,080,960 calls. No production hit-frequency or full-turn speedup is assumed.
Times below are separately summarized microseconds per complete capability preparation. Percentage changes above are medians of paired percentage changes, so they need not equal ratios of these time medians.
An earlier separate literal-prepass candidate was rejected for repeated fallback regressions. This PR uses the fused pass and its own fresh measurement cohort.