Skip to content

fix(tui): bill Anthropic cache-write tokens at published rates (#4318)#4348

Open
knqiufan wants to merge 1 commit into
Hmbown:mainfrom
knqiufan:fix/4318-cache-write-pricing
Open

fix(tui): bill Anthropic cache-write tokens at published rates (#4318)#4348
knqiufan wants to merge 1 commit into
Hmbown:mainfrom
knqiufan:fix/4318-cache-write-pricing

Conversation

@knqiufan

@knqiufan knqiufan commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep Anthropic cache_creation_input_tokens as Usage::prompt_cache_write_tokens instead of folding them into cache-miss.
  • Extend TUI CurrencyPricing with cache_write_per_million and publish 5-minute write rates for Anthropic/Qwen rows (e.g. claude-fable-5 at 12.50).
  • Wire token_usage_for_pricing and turn-cost math so cache-write is no longer hardcoded to 0, fixing undercounted cost estimates.

Closes #4318

Testing

  • cargo fmt --all -- --check (via cargo fmt -p codewhale-tui)
  • cargo clippy --workspace --all-targets --all-features
  • cargo test -p codewhale-tui --bin codewhale-tui --locked pricing::tests
  • Anthropic usage mapping / SSE fixture / session_usage_cache_* / turn-metadata tests
  • cargo test --workspace --all-features
  • Spot-check a Claude turn with cache creation in the TUI cost estimate

Checklist

  • Updated docs or comments as needed
  • Added or updated tests where relevant
  • Verified TUI behavior manually if UI changes
  • Harvested/co-authored credit uses a GitHub numeric noreply address (N/A — original authorship)

@knqiufan knqiufan requested a review from Hmbown as a code owner July 11, 2026 12:37
@github-actions

Copy link
Copy Markdown

Thanks @knqiufan for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

Keep cache-creation usage separate from cache-miss and wire
CurrencyPricing.cache_write so TUI cost estimates stop undercounting
Anthropic/Qwen write premiums (Hmbown#4318).

Signed-off-by: knqiufan <knqiufan@foxmail.com>
@knqiufan knqiufan force-pushed the fix/4318-cache-write-pricing branch from 7927645 to f0a617b Compare July 11, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pricing: cache-write rates dropped by CurrencyPricing/TokenUsage

1 participant