Skip to content

✨ feat: Surface Claude prompt cache savings in tapes deck#153

Open
bdougie wants to merge 2 commits intomainfrom
feat/claude-cache-savings
Open

✨ feat: Surface Claude prompt cache savings in tapes deck#153
bdougie wants to merge 2 commits intomainfrom
feat/claude-cache-savings

Conversation

@bdougie
Copy link
Contributor

@bdougie bdougie commented Mar 10, 2026

Summary

  • Surfaces prompt cache read hit rate and dollar savings for Claude model sessions in the tapes deck TUI
  • Adds a claude prompt cache: 92% read · saved $18.42 line below the session metrics grid
  • Only renders for Claude sessions with cache data; non-Claude sessions are unaffected

Inspired by the cost analysis in papercomputeco/pokemon#7, which showed that prompt caching saved ~$307 (85% reduction on input costs) during the Pokemon agent build. The proxy already captured cache tokens and the pricing engine already used cache-aware rates, but the TUI never exposed this — users had no visibility into how much caching was saving them.

Changes

  • pkg/deck/types.go — Add CacheReadTokens and CacheWriteTokens to SessionSummary
  • pkg/deck/query.go — Accumulate cache tokens in buildSessionSummaryFromNodes and session grouping
  • pkg/deck/pricing.go — Add CacheSavings() (uncached cost vs actual cost) and IsClaudeModel() helpers
  • pkg/deck/pricing_test.go — 7 new Ginkgo specs covering savings math and model detection
  • cmd/tapes/deck/tui_session.go — Render cache savings line below metrics grid
  • cmd/tapes/deck/tui.go + deck.go — Thread PricingTable to the TUI model

Test plan

  • All 192 existing tests pass (178 deck + 14 commander)
  • 7 new specs for CacheSavings and IsClaudeModel
  • Manual verification with tapes deck against a SQLite store with Claude sessions
  • Verify non-Claude sessions (GPT, DeepSeek) do not show the cache line

bdougie added 2 commits March 9, 2026 21:42
The proxy already captures cache_creation_input_tokens and
cache_read_input_tokens per node, and the pricing engine accounts for
cache rates when computing costs. However, the TUI never exposed this
data — users couldn't see how much caching was saving them.

This adds a "claude prompt cache" line below the session metrics grid
showing cache read hit rate and dollar savings. The line only renders
for Claude model sessions that have cache data. Non-Claude sessions
are unaffected.

Changes:
- Add CacheReadTokens/CacheWriteTokens to SessionSummary
- Accumulate cache tokens in buildSessionSummaryFromNodes and session grouping
- Add CacheSavings() and IsClaudeModel() helpers to pricing
- Render cache savings line in the session metrics view
- Thread PricingTable through to the TUI model
- Add 7 Ginkgo specs for CacheSavings and IsClaudeModel

Closes papercomputeco/pokemon#7
Eliminates duplicated cost math by delegating to CostForTokens and
CostForTokensWithCache. Adds a note about mixed-model session behavior.
@bdougie bdougie changed the title Surface Claude prompt cache savings in tapes deck ✨ feat: Surface Claude prompt cache savings in tapes deck Mar 10, 2026
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.

1 participant