Repository navigation
refactor(runtime): defer unused model pricing lookup - #189893
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: needs maintainer review before merge. What this changesThis PR resolves model prices only when plugin completion accounting needs an estimated cost. Example: A plugin completion reports a provider-billed total of $0.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored draft open: it removes unused pricing work through the existing accounting owner, with no introduced correctness or security defect found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared plugin accounting owner receives completion usage, model identity, and configuration, then returns normalized counters and cost while notifying logging and diagnostic consumers. flowchart TD
A[Plugin completion] --> C[Shared usage accounting]
B[Accepted decision result] --> C
C --> D[Explicit billed cost]
C --> E[Fallback price resolution]
D --> F[Normalized usage]
E --> F
F --> G[Caller and diagnostics]
Technical reviewBest possible solution: Retain the lazy lookup in the shared accounting owner while preserving billed-cost precedence and both estimation modes. Do we have a high-confidence way to reproduce the issue? Current-main source unconditionally resolves prices for direct and aggregate accounting before checking explicit billed cost; no target code was executed during this read-only review. Is this the best way to solve the issue? Moving the existing resolver into the estimation fallback is the smallest complete change: it removes unnecessary work without introducing another owner, cache, API, or billing policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ffbaf04726a5. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -1, Tests +40, Other +2. Total +41 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 31, 2026, 8:38 PM ET / November 1, 2026, 00:38 UTC. |
|
Merged via squash auto-merge.
|
Related: #188252
What Problem This Solves
Plugin completion accounting resolves configured and catalog prices even when an explicit billed cost already takes precedence.
User Impact
No intended result or billing-policy change. Recorded costs, including billed zero, retain precedence; missing costs keep direct or aggregate estimation, and unavailable costs stay unavailable.
Why This Change Was Made
Resolve prices only inside the existing estimation fallback. Keep the shared accounting owner, price arguments, usage callbacks and sparse diagnostic semantics unchanged. No cache, API, SDK or configuration change is introduced.
Production decreases by one line. The existing host-dispatch case also protects billed zero through returned usage and logging; two owning cases independently assert direct and aggregate configured-price fallback. Tests grow 40 lines with an exact separate allocation.
Evidence
03f2b2d44c04ee6aa805fb998c458a97628e0c9e..3599e3e5c632487e6f9ce1bc41a2cad658ee4478found no actionable findings (confidence 0.95).72943b04f5aba1337efd4e59a13e68103c9e72b4; the observed final PR rollup had 60 successes, 153 skips and one neutral result, with no failures. Native completion is recorded. No production latency, CPU, RSS or physical-allocation gain is claimed.Matched work and cost
The acceptance rule was published before measurement: five serial interleaved baseline/candidate pairs, retain the first baseline and every point, unchanged outputs, fewer billed-path lookups, unchanged necessary fallback lookups. Any 20% adverse measured cell stops the sequence. No additional or replacement samples were run; the largest adverse paired cell was 15.812%.
Committed workload:
Use Node 26.13.0, Vitest 5.0.5, Darwin arm64, the frozen qualified install, one worker, fresh processes and distinct fresh filesystem-module caches, with native V8 coverage. Normal native compiler-output reuse is unchanged. The production file is restored after every command. Observed one-minute host load ranged from 8.030 to 14.248.
All ten runs passed the same four literal-output cases. Actual worker profiles contained both the pricing resolver and its lower implementation even at zero: billed host lookups fell 2→0, while direct/aggregate configured fallback stayed 2→2. Every run retained four accounting completions and two host dispatches. This exercises the real runtime accounting consumer with provider I/O isolated; it is not live-provider latency evidence.
All durations below are seconds. A is baseline, B is candidate; unit-fast owns the two configured-fallback rows and plugins owns the two billed host-dispatch rows.
P95 uses nearest rank over all five samples. Wrapper ranges were 75.011–79.722s and 68.398–82.336s.
Maintainer cost decision: accept the observed instrumented-wrapper median increase of 1.780%, p95 increase of 3.279%, and unit-fast p95 increase of 1.419% for the verified removal of unused pricing work with unchanged outputs. The cause of these timing movements remains unresolved; rounded transform shares and cache state do not establish causation. This accepts the measured diagnostic-test cost, makes no production/provider speed claim and waives no native or CI gate.