✨ feat: Surface Claude prompt cache savings in tapes deck#153
Open
✨ feat: Surface Claude prompt cache savings in tapes deck#153
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tapes deckTUIclaude prompt cache: 92% read · saved $18.42line below the session metrics gridInspired 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— AddCacheReadTokensandCacheWriteTokenstoSessionSummarypkg/deck/query.go— Accumulate cache tokens inbuildSessionSummaryFromNodesand session groupingpkg/deck/pricing.go— AddCacheSavings()(uncached cost vs actual cost) andIsClaudeModel()helperspkg/deck/pricing_test.go— 7 new Ginkgo specs covering savings math and model detectioncmd/tapes/deck/tui_session.go— Render cache savings line below metrics gridcmd/tapes/deck/tui.go+deck.go— ThreadPricingTableto the TUI modelTest plan
CacheSavingsandIsClaudeModeltapes deckagainst a SQLite store with Claude sessions