Repository navigation
Description
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
Built-in model cost/usage statistics stopped working after updating 2026.3.13 → 2026.6.10. Token counts are still tracked, but all dollar cost reports as $0 across /usage, sessions.usage, and usage.cost. model_capability_cache never populates. Updating to 2026.6.11 did not fix it.
Steps to reproduce
- Run a gateway on 2026.6.10/2026.6.11 with an Anthropic model (anthropic/claude-sonnet-4-6, api-key auth).
- Generate normal traffic so session logs accrue tokens.
- Query cost: openclaw gateway call sessions.usage --json --params '{"startDate":"","endDate":"","agentScope":"all"}'
- Observe totals.totalTokens is correct but totals.totalCost is 0 and missingCostEntries > 0.
- Check pricing cache: sqlite3 state/openclaw.sqlite "SELECT count(*) FROM model_capability_cache;" → 0.
Expected behavior
totalCost reflects real cost, computed from the external pricing catalog (as it did on 2026.3.13). model_capability_cache is populated for the active model.
Actual behavior
totalCost = 0 for all date ranges after the update; model_capability_cache has 0 rows. Persists across multiple gateway restarts and after updating to 2026.6.11.
OpenClaw version
2026.6.11 (also reproduced on 2026.6.10)
Operating system
macOS (Darwin 25.x)
Install method
npm (global)
Model
anthropic/claude-sonnet-4-6
Provider / routing chain
anthropic provider, api-key auth, default routing
Additional provider/model setup details
Model catalog is a custom/aggregated catalog that includes non-Anthropic providers alongside Anthropic. The bundled anthropic plugin's modelPricing policy points to OpenRouter with modelIdTransforms: ["version-dots"].
Logs
config-health / gateway warnings (repeat on every restart):
- plugins.entries.openrouter: plugin openrouter: plugin id mismatch (manifest uses "openrouter", entry hints "openrouter-provider")
- plugins.entries.litellm: plugin litellm: plugin id mismatch (manifest uses "litellm", entry hints "litellm-provider")Screenshots, recordings, and evidence
Verified the pricing source is healthy and reachable, so the failure is on the gateway-population side:
- OpenRouter catalog reachable; contains anthropic/claude-sonnet-4.6 (version-dots transform of the model id) with correct pricing (prompt 3e-6, completion 15e-6, input_cache_read 3e-7, input_cache_write 3.75e-6).
- LiteLLM catalog likewise reachable with matching pricing.
- anthropic, openrouter, litellm plugins all show enabled.
- Despite this, model_capability_cache = 0 rows and sessions.usage.totals.totalCost = 0.
Impact and severity
All cost analytics/reporting built on usage.cost / sessions.usage report $0 (token counts unaffected). Any automated cost report silently shows $0 for periods after the update.
Additional information
Suspected cause: the persistent id mismatch for the two external-pricing-source plugins (openrouter, litellm) may prevent their pricing catalog fetchers/policies from registering, so getCachedGatewayModelPricing returns nothing and cost computes as 0. Also unclear whether cost is recomputed retroactively once pricing is available or only baked at write time — clarification appreciated.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 13, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 13, 2026, 2:31 AM ET / 06:31 UTC.
Summary
Keep this issue open: the latest shipped release has a concrete regression report, current main still depends on a background external-pricing bootstrap, and no merged fix or canonical replacement was found. The empty SQLite table is not by itself proof of the cause because current gateway cost lookup uses an in-memory pricing map, but the reported zero-cost behavior remains actionable.
Reproducibility: no. current-main live reproduction was established, but the reporter supplies a concrete released-version path with token totals, missingCostEntries, and repeated restarts. The source confirms the downstream zero/missing-cost behavior when no pricing reaches the runtime cache.
Ways to help us reproduce this
Next step
A maintainer should first reproduce the exact custom-catalog and plugin-entry state on current main and identify which bootstrap stage stays empty before assigning a repair boundary.
Review details
Best possible solution:
Make external pricing bootstrap reliably resolve the active model through canonical manifest metadata, expose a clear degraded-health reason when no price is loaded, and add regression coverage showing existing session usage gains correct costs after pricing becomes available.
Do we have a high-confidence way to reproduce the issue?
No current-main live reproduction was established, but the reporter supplies a concrete released-version path with token totals, missingCostEntries, and repeated restarts. The source confirms the downstream zero/missing-cost behavior when no pricing reaches the runtime cache.
Is this the best way to solve the issue?
Unclear. The suggested plugin-ID mismatch is plausible but not yet proven; the best investigation must distinguish persistent capability rows from the in-memory pricing map and trace bootstrap health, active manifests, selected refs, transforms, and fetch results.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against ab8cbfd73c42.
Label changes
Label changes:
P2: Cost analytics are silently incorrect for a reported released configuration, but token accounting and core model execution continue to work.impact:other: The issue affects maintainer-visible usage and cost analytics without matching the data-loss, session, delivery, auth, availability, or UX-blocker categories.issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.Label justifications:
P2: Cost analytics are silently incorrect for a reported released configuration, but token accounting and core model execution continue to work.impact:other: The issue affects maintainer-visible usage and cost analytics without matching the data-loss, session, delivery, auth, availability, or UX-blocker categories.Evidence reviewed
What I checked:
docs/gateway/configuration-reference.md. (docs/gateway/configuration-reference.md, ab8cbfd73c42)src/gateway/model-pricing-cache.ts, ab8cbfd73c42)src/gateway/model-pricing-cache-state.ts, ab8cbfd73c42)src/utils/usage-format.ts, ab8cbfd73c42)src/gateway/model-pricing-cache.test.ts, ab8cbfd73c42)Likely related people:
src/gateway/model-pricing-cache.ts,src/plugins/plugin-metadata-snapshot.ts,src/plugins/plugin-metadata-snapshot.types.ts)src/utils/usage-format.ts,src/gateway/server-methods/usage.ts)src/gateway/model-pricing-cache.ts,src/plugins/installed-plugin-index-record-builder.ts,src/plugins/manifest-registry-installed.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.dltlaos11 commentedon Jul 15, 2026
Thanks for the triage. Good catch on the in-memory pricing map — you're right that
the empty
model_capability_cacheSQLite table isn't proof by itself. I re-checkedagainst the runtime path (the CLI
gateway callRPC, not the web UI), and it alsoreturns
totalCost: 0— so the runtime pricing resolution itself is yielding nothingfor this model, not just the SQLite table or the dashboard. Answering the repro asks
and adding evidence that should narrow which bootstrap stage stays empty.
Reproduction (released version)
Env: OpenClaw 2026.6.11 (also 2026.6.10), npm install, macOS, local gateway.
Model:
anthropic/claude-sonnet-4-6, api-key auth.Command (same RPC the dashboard reads, so it isolates the dashboard out):
totals.totalCostreflects tokens × model pricing (as it did before ~2026-06-29).totals.totalTokens = 18,763,485(correct, matches the dashboard), buttotals.totalCost = 0, and everybyAgent[].totals.totalCost/byModel[].totals.totalCostis 0.The attached dashboard screenshot shows the same window: 18.8M tokens · $0.00 · 39 sessions.
itself — this is not a dashboard/WebSocket/field-mapping issue.
Narrowing: the external source is healthy — the break is local to the pricing pipeline
The bundled
anthropicplugin'smodelPricingpolicy points to OpenRouter withmodelIdTransforms: ["version-dots"], i.e.claude-sonnet-4-6→claude-sonnet-4.6.I fetched both catalogs directly from the same host:
/api/v1/models): reachable (200), containsanthropic/claude-sonnet-4.6with pricing
prompt 0.000003,completion 0.000015,input_cache_read 0.0000003,input_cache_write 0.00000375.So the source data is present, reachable, correctly keyed, and the id transform matches.
The break is therefore local to the gateway's pricing pipeline — and the health probe below pins the stage further.
For the catalog state mentioned in the next step: the agent model catalog on this host is
a custom/aggregated one that includes non-Anthropic providers alongside Anthropic (as noted
in the issue body).
Update — health probe + code path narrow the empty stage:
openclaw gateway call healthreports
"modelPricing": {"state": "ok", "sources": []}(stable across restarts). Persrc/gateway/model-pricing-cache.ts,sourceslists recorded fetch failures, and everyfailure path (
openrouter,litellm,bootstrap,refresh) both records a failure(→ state
"degraded") andlog.warns — yet health is"ok", no pricing warnings appearin logs, and cost is 0 for all configured models (both the Anthropic and OpenAI refs).
So no fetch error ever occurred; the bootstrap exits through a silent-empty path.
The most direct candidate is the early-return:
(the other silent possibility — a successful fetch that matches zero refs — lands in the
same policy/transform wiring). Either way, the empty stage is the ref/policy collection
(plugin
modelPricingpolicies → refs → id transforms), not the fetch itself — consistentwith the persistent
openrouter/litellmplugin id-mismatch warnings noted underAdditional signals below.
Additional signals
external-pricing-source plugins:
plugins.entries.openrouter: plugin openrouter: plugin id mismatch (manifest uses "openrouter", entry hints "openrouter-provider")litellm(litellmvslitellm-provider).Might be worth checking as a reason the bootstrap doesn't wire up the pricing fetchers.
non-zero
totalCost(matches tokens × published rates to the cent). From ~2026-06-29onward,
totalCost = 0. The transition coincides with the 2026.3.13 → 2026.6.x updateon this host. Some post-boundary windows also show
missingCostEntries > 0.boundary shows native
totalCostlower than tokens × rate would give (e.g. $17.46 vs$19.07 for one week) — i.e. the aggregate sums baked per-message cost, and post-update
messages were baked at 0.
models.providers.anthropic.models[].cost(a valid
{id, name, cost}entry that passesconfig validate) and restarting did notrepopulate cost for existing data — consistent with the baked-per-message behavior above.
Multiple restarts (including a fresh process after the 6.11 update) also had no effect.
Happy to run any additional
gateway callprobes if that helps identify the empty stage.dltlaos11 commentedon Jul 23, 2026
Root cause found — instrumented the gateway and traced it end-to-end. This supersedes
parts of my previous comment (corrections noted below).
TL;DR: The pricing fetch/bootstrap pipeline is actually fine. The defect is that
per-message cost baking never reads any pricing source that exists on a default install —
so every built-in-model message is written with
cost: 0at generation time, and allaggregates (
/usage,sessions.usage,usage.cost) just sum those baked zeros. On adefault 2026.6.x install, no built-in Anthropic model can ever produce a nonzero cost.
1. The bootstrap works — my earlier "empty ref/policy stage" hypothesis was wrong
I added temporary debug logging to
refreshGatewayModelPricingCacheandstartGatewayModelPricingRefreshOnDemand(installed dist, reverted afterwards) andrestarted. In the gateway process, at startup:
So: refs are collected, plugin
modelPricingpolicies load (8), OpenRouter/LiteLLM fetchsucceeds, and the in-memory map is committed with the correct sonnet-4.6 pricing.
The plugin id-mismatch warnings I flagged earlier appear unrelated to this issue.
2. The break: cost baking can't reach that map
With the map confirmed populated, subsequent agent turns (scheduled heartbeats over
the following hours) still baked
usage.cost.total = 0in their session transcripts —9/9 samples. So the write-time path (
buildUsage→resolveModelCostConfig({provider, model, config})) never benefits from the gateway's fetched pricing.3. Even bundled catalog cost doesn't reach the bake path
Two independent data points:
extensions/anthropic/openclaw.plugin.json),only
claude-fable-5still has acostblock —claude-sonnet-4-6,claude-opus-4-6/4-7/4-8,claude-haiku-4-5have none.resolveModelCostConfig({provider:'anthropic', model:'claude-fable-5', config:{}})returns
undefined. So restoring catalog costs alone would not fix baking either.With models.json and
config.models.providersempty by default, the bake-time lookupchain has no reachable source at all for built-in models → bakes 0 → zeros are
permanent (aggregation sums baked values; windows spanning the regression boundary
confirm no recompute).
4. Correction: the config workaround DOES fix new messages
My earlier "config workaround does not restore it" only tested retroactive data.
Re-tested properly: seeding
passes
config validate, and after a restart new messages bake correct costs(verified: a test turn baked $0.0774 = exactly tokens × seeded rates, and it appears in
sessions.usage). Existing data stays $0, as expected from baked-per-message semantics.(Seeding the agent-dir
models.jsoninstead is not viable: the model registry loaderrejects cost-only providers —
"baseUrl" is required when defining custom models.)Suggested fix directions (maintainers' call)
resolveModelCostConfigable to reach the bundled plugin catalogcost and/or the gateway pricing cache (or bake tokens only and price at read time).
costblocks for the non-fable models in the bundled anthropic catalog.writing
cost: 0— this regression was invisible precisely because zero-cost bakingis treated as success everywhere (health "ok", no logs).
Happy to test a patch build against this host's data.
steipete commentedon Jul 27, 2026
Thank you for the detailed follow-up isolating the actual pricing-resolution failure. Current main fixes zero-valued hosted-model usage through #114060 (5347285). The production resolver now sources bundled and centrally hosted model pricing before fallback, correctly records new model usage, and repairs confidently mispriced historical zero-cost totals without changing genuinely provider-billed zero. Regression coverage verifies hosted catalog prices, configured precedence, provider aliases, and historical-zero recovery; the merged proof validates 39 hosted providers and 212 priced models. The retired model_capability_cache is intentionally not recreated. Closing as completed on main.
fix(usage): stop reporting unavailable model pricing as free (#111175)
fix(usage): stop reporting unavailable model pricing as free (opencla…