CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Usage & Spend drops Claude from the total when a day only has unpriced (OpenRouter) models

Open DevilVed opened this issue 1 month ago • 2 comments

On 0.76.0 the Usage & Spend headline leaves Claude out completely: no dollar amount on the Claude row, and "Estimated spend" covers only the other providers. The per-model rows under Claude still have prices though.

My numbers (All):

  • Claude row: "242M tokens", no cost
  • claude-opus-5-5 $127.93, claude-sonnet-5-5 $6.72, opus-4-8 $0.47, haiku-5-5 $0.09
  • Estimated spend: ~$65.21, which is just Codex ($44.10) + Antigravity ($21.11)
  • Header says "2 of 3 subscriptions have spend"

codexbar cost --provider claude --period all --json gives totals.totalCost = 135.50, so the CLI is fine with it.

I traced it to two days where I ran Claude Code against OpenRouter models:

2026-09-16  z-ai/glm-5.3-flash, moonshotai/kimi-k3, deepseek/deepseek-v4.1-flash  (190K tokens, no price)
2026-09-30  z-ai/glm-5.3-flash                                                     (29K tokens, no price)

Those days come back with totalCost: null and no unpricedRequestCount. In SpendDashboardModel.hasConsistentCostHistory a null day only counts as "known unpriced" via hasOnlyIncompleteRequests, the ledger check, or unpricedRequestCount > 0. For Claude none of those apply, so the whole history is treated as inconsistent and completeCostSum returns nil. Roughly 220K unpriced tokens end up hiding $135 of priced usage.

This looks like the Claude version of #4273. I'd expect the same treatment Codex gets: show ≥ $135.50 with the partial marker. It also hits the 30d view right now because Sep 30 is still inside the window.

DevilVed avatar Oct 16 '26 09:10 DevilVed

Codex review: this still needs some work.

Summary This issue establishes a current reporting bug: Claude’s missing unpriced-usage metadata causes the dashboard to discard an otherwise computed spend subtotal.

Reproducibility: Source establishes the failure with a priced Claude day and a completed unknown-model day: the scanner omits unpricedRequestCount, the snapshot retains the summary subtotal, and dashboard consistency rejects it; no tests or live reproduction were run.

Next step Fix Claude’s unpriced-usage metadata and establish a failing scanner-to-dashboard regression showing a priced subtotal surviving an unpriced-only day.

Review details

Best possible solution:

Emit trustworthy Claude unpriced-usage coverage so existing dashboard logic retains the priced subtotal with a lower-bound marker.

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

Source establishes the failure with a priced Claude day and a completed unknown-model day: the scanner omits unpricedRequestCount, the snapshot retains the summary subtotal, and dashboard consistency rejects it; no tests or live reproduction were run.

Is this the best way to solve the issue?

Repairing producer coverage metadata uses the existing list-price lower-bound path and is safer than relaxing dashboard checks for arbitrary nil costs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 667dd3a58729.

Label changes

Label changes:

  • add P2: A bounded spend-reporting defect hides computed Claude estimates without blocking provider usage.
  • add impact:ux-friction: The dashboard omits Claude dollars despite priced model rows and an available CLI subtotal, making the headline misleading.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: A bounded spend-reporting defect hides computed Claude estimates without blocking provider usage.
  • impact:ux-friction: The dashboard omits Claude dollars despite priced model rows and an available CLI subtotal, making the headline misleading.
Evidence reviewed

Acceptance criteria:

  • make test-fast FILTER='CostUsageScannerClaudeProxyIdentityTests|CostUsageClaudeReportContextTests|SpendDashboardClaudePartialPricingTests|SpendDashboardPartialCostTests|SpendDashboardLowerBoundPropagationTests'
  • Scripts/regenerate-codex-parser-hash.sh --check
  • make check

What I checked:

  • Current main and repository policy: GitHub’s default branch is main, its SHA matches the clean checkout, and the complete root AGENTS.md was read and applied; no nested AGENTS.md files were found. (AGENTS.md:1, 667dd3a58729)
  • Claude drops known unpriced coverage: The builder computes unpricedCount from recorded samples but emits it only when dayIncompleteCount is positive; ordinary completed unknown-model records therefore lack this metadata, while the summary still sums priced days. (Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+Claude.swift:1017, 667dd3a58729)
  • Dashboard rejects the subtotal: A nil-cost day must carry explicit unpriceable evidence to pass aggregate consistency checks; without that evidence, the provider’s total becomes nil and the headline sums only the remaining providers. (Sources/CodexBar/SpendDashboardModel.swift:1005, 667dd3a58729)
  • Affected release verified: The v0.76.0 source contains the same conditional unpricedRequestCount assignment, matching the reporter’s named release. (Sources/CodexBarCore/Vendored/CostUsage/CostUsageScanner+Claude.swift:1017, 2d8b1409a164)
  • Existing partial-cost contract: Dashboard tests already retain an estimated subtotal beside an explicitly unpriced day and mark it partial; this provides a narrow repair pattern without treating every missing cost as safe. (Tests/CodexBarTests/SpendDashboardPartialCostTests.swift:207, 667dd3a58729)
  • Related work does not own this repair: The owner credits gabrielrojasc and luochen211 for the Codex-only repair in https://github.com/steipete/CodexBar/issues/4273; its merged implementation does not change Claude aggregation. The open https://github.com/steipete/CodexBar/pull/4578 adds model prices and explicitly leaves scanner logic unchanged. Searches found no open PR referencing this issue or implementing its metadata repair.
How this review workflow works
  • 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; those execution lanes are retired.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Reviewed October 16, 2026, 5:11 AM ET / 09:11 UTC.

clawsweeper[bot] avatar Oct 16 '26 09:10 clawsweeper[bot]

Fixed in #4588 (540880f8c3d1). Thanks @DevilVed! Completed requests with no known price (like OpenRouter models) are now counted as unpriced coverage instead of dropping Claude from the total, so Usage & Spend keeps the priced subtotal and marks it as a lower bound. Fully priced history is unchanged. It will be in the next release.

steipete avatar Oct 22 '26 07:10 steipete