Repository navigation
fix(usage): stop reporting unavailable model pricing as free - #111175
Conversation
|
Codex review: blocked before merge. Reviewed September 19, 2026, 4:10 PM ET / 20:10 UTC (Revision 27). ClawSweeper reviewWhat this changesDistinguish unavailable model costs from confirmed zero costs across plugin completions, agent usage totals, and cached session reports. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix: current main still reports unpriced completion totals as zero and rejects configured free pricing in session reports. The revised branch addresses the prior concerns without introducing a pricing setting; no blocking correctness finding remains. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw combines model token counts, recorded charges, and configured or catalog prices into usage reports. This change keeps those reports consistent across plugin results, agent accounting, and session summaries. flowchart TD
A[Model usage and recorded charges] --> C[Normalize cost evidence]
B[Configured and eligible catalog prices] --> D[Resolve missing prices]
C --> D
D --> E[Plugin completion and agent totals]
D --> F[Refresh session usage cache]
F --> G[Session logs and summaries]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +33, Tests +151, Docs +5, Other 0. Total +189 across 16 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the existing optional-cost API and shared pricing owner, preserving recorded charges and authored free prices with the supplied fresh-run and warm-cache compatibility proof. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source accepts adapter-default cost.total = 0 as explicit billing, and the supplied baseline loopback run reports that exact failure; this read-only review did not execute target code. Is this the best way to solve the issue? Yes. Reusing the existing pricing resolver and preserving recorded cost evidence repairs the consumer boundary without adding another pricing policy or configuration marker. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cc7e211d146f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (26 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
a71a6c7 to
378a93c
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
The runtime-llm test file exceeded the 1000-line lint cap; move the three pricing-provenance cases (unavailable / marked placeholder-zero / confirmed zero) into runtime-llm.usage-pricing.test.ts with their own minimal mock wiring.
…umers Review finding: runtime completion and session aggregation disagreed on unmarked all-zero pricing (known /bin/bash vs missing). Align both on the same provenance contract: pricing is unknown only when no cost config exists or it is explicitly marked pricingUnavailable; unmarked all-zero is a confirmed /bin/bash (Ollama explicit free pricing, user-configured zeros). Includes exact-head live proof over real HTTP (local OpenAI-compatible SSE endpoint): unknown/confirmed-free/marked/provider-billed.
Direct estimateUsageCost consumers (response usage lines, status, diagnostics) bypassed the two local isModelPricingKnown guards and still turned marked placeholder zeros into a confident $0. Move the check into the shared estimator: marked pricing now yields no estimate everywhere. - estimateUsageCost returns undefined for pricingUnavailable - contract test: live-discovered Codex models without manifest pricing carry the pricingUnavailable marker - direct-estimator cases added to the exact-head live proof - correct the runtime-llm comment to document the unified contract
resolveModelCost rebuilt the cost object with only numeric rates and tiers, silently dropping pricing provenance during ordinary config materialization and turning marked placeholder pricing back into a confident $0 before runtime use. Preserve the marker, add a materialization regression, and export buildOpenAICodexLiveProviderConfig (module-local) so the contract test and producer-to-runtime proof can exercise the real discovery path.
…s under max-lines
…gh defaults The model schema permits an omitted or empty cost block, but applyModelDefaults filled all-zero rates without the pricingUnavailable marker, so the known-pricing predicate reclassified those models as a confident $0. resolveModelCost now treats a cost block with no configured rates (omitted, empty, or marker-free) as unknown pricing; explicit all-zero and partial-rate blocks stay known. Covers the runtime completion and session rollup paths.
ModelDefinitionConfig types cost as required (the post-materialization shape), while the zod schema and real configs allow omitting it; the pre-materialization fixture needs the cast so tsgo test-types accepts the omitted-cost case.
Normalization drops an empty tier list, so cost: { tieredPricing: [] } carries no rates; counting it as configured let the materialized all-zero defaults through as a confident $0. The configured-rate check now requires a non-empty tier list.
…producers Manifest catalog rows without rates (e.g. the claude-cli rows in extensions/anthropic/openclaw.plugin.json) were materialized as unmarked all-zero costs by both static producers, so usage reporting treated them as a confident $0. cloneManifestCatalogCost and modelDefinitionCostFromManifestRow now mark rate-less rows pricingUnavailable, matching the catalog-owned provenance contract, and the usage boundary omits their cost. Explicit all-zero manifest pricing stays unmarked as confirmed free.
…config The provenance marker is runtime/catalog metadata produced by catalog producers and model defaulting; it never shipped as an operator setting. Remove it from the strict user model-cost schema: unknown pricing in user config is expressed structurally by omitting cost rates, and applyModelDefaults derives the marker. models.json keeps carrying the marker (its TypeBox schema allows the extra key and Check() does not strip it).
4396d3a to
226c80d
Compare
|
Both P1 findings are addressed on the rebased head ( 1. Preserve unavailable pricing from static manifests — fixed at the shared producer. 2. Pricing-provenance configuration contract — resolved per the review's recommendation: provenance is catalog-owned. Codex dependency contract — directly inspected in the sibling Also on this push: rebased onto latest main (the head was reported conflicting). The boundary-artifacts freshness commit was dropped because main replaced the hardcoded @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Use existing configured and eligible catalog prices instead of treating adapter-default zeros as billing evidence. Preserve explicit free rates, recorded costs, and provider-billed provenance across complete billed sums. Keep authored model files and config omission unchanged; introduce no new pricing marker or catalog policy. Rework the original proposal against current pricing owners while retaining its contributor ancestry and reproducing the public completion and usage paths. Co-authored-by: thomas.szbay <[email protected]>
…orts Retain existing nonzero cost components as zero-total evidence through normalization and complete recorded sums, without labeling mixed usage as provider-billed. Rebuild derived usage rollups through their existing semantic revision so warm cached summaries observe corrected free pricing. Canonical transcripts, database schemas, and retention are unchanged. Co-authored-by: thomas.szbay <[email protected]>
…ecks Keep explicit aggregate costs when token buckets are unavailable without restoring unpriced adapter zeros accompanied by token usage. Preserve truthful billed provenance and configured-free reporting in existing consumer tests. Use a supported model API in the pricing fixture, remove the incidental cache revision assertion, and shrink the allowance for the three removed casts. Co-authored-by: thomas.szbay <[email protected]>
|
Merged as c188f65. Unavailable pricing is no longer presented as free usage. Authored free prices, provider-billed zeros, recorded cost evidence, and legacy billing-only summaries are preserved; existing usage caches refresh through their normal owner. Verified with real loaded-plugin and agent flows through loopback HTTP/SSE, public usage summaries, and a warm-cache upgrade without another model call. Exact-head review was clean, and PR CI completed successfully (151 passed, 16 skipped). Thanks @xydigit-zt for the contribution. |
Related: #106080
What Problem This Solves
Fixes: completions report
$0when model pricing is unavailable, while session usage can omit deliberately configured free prices.User Impact
Plugin completions and normal agent results now omit unavailable costs instead of claiming free usage. Explicit operator zero pricing and provider-billed zero totals remain
0, and session logs and summaries agree. Recorded positive costs keep their request-time pricing. No configuration changes or migration are required.Why This Change Was Made
Adapter-default zeros are not billing evidence. Cost reporting now uses the existing configured/catalog pricing resolver, preserves recorded cost evidence, and carries provider-billed provenance through a sum only when every contribution is billed. Empty cost objects and empty tier lists cannot establish a price by themselves.
Legacy run summaries that report a cost without token buckets still preserve an explicit zero. Unpriced adapter zeros accompanied by token usage remain unknown.
Recorded zero-cost components survive normalization and aggregation without inventing provider-billed provenance. Existing derived usage summaries refresh through their normal semantic cache revision; stored transcripts, database schemas, and retention are unchanged.
This reworks the earlier marker-based proposal for the current pricing rules established in #114060 and #133695. It does not add
pricingUnavailable, change catalog eligibility, or treat every unmarked generated zero as a free price. Zero-only catalog placeholders remain unknown; authored overrides and authoritative native pricing retain their existing precedence. The broader pricing-cache/discovery issue is not claimed fixed.Evidence
Reproduced on baseline
0b753f1ethrough a normally loaded plugin'sapi.runtime.llm.complete, a real loopback HTTP/SSE adapter, and the normal agent CLI—not injected normalized usage or fabricated transcript records.0before$0.002preserved0preserved, including session logs that omitted it before0, including a model with no configured rates0preservedmodels.jsonoverride$0.004honored; file bytes unchangedFive normal agent runs also passed public log and fresh usage-summary checks. Unknown pricing counted one missing-cost entry; authored-free and billed-zero runs counted none. An unrelated public config mutation preserved the original omitted cost field rather than persisting materialized zeros.
A warm-cache upgrade kept the same configuration and transcript and made exactly one original model request. The old fresh rollup still marked a free-priced entry as missing; the corrected runtime naturally refreshed it to known
0, without deleting the cache or calling the model again.The provider responses were synthetic; this does not claim live vendor billing or budget-enforcement validation.