mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-26 21:47:20 +00:00
2390987e12
The Anthropic client logged cache_creation_input_tokens and cache_read_input_tokens and then returned only input_tokens and output_tokens, so every cached Patrol run reached the usage ledger, the cost preview, the budget check and the weekly digest with its cache buckets missing. Pulse #2350 reproduced the loss on both the Chat and ChatStream paths, and #2118's reporter was told to trust the provider's billing view over Pulse's totals until this was fixed. Both response paths now carry the two buckets as fields disjoint from InputTokens (streaming assigns them from message_start and the final cumulative message_delta rather than summing). The agentic loops, Patrol responses and run records sum them beside the ordinary totals, the usage ledger and its persisted copies keep them, and cost.EstimateUsageUSD prices each bucket at Anthropic's published cache rates (5-minute write 1.25x, read 0.1x of the input rate), falling back to the input rate for providers without a known cache price. Spend summaries, the digest spend, the cost projection medians and the usage export expose the buckets and price them the same way. InputTokens keeps its meaning everywhere, so the telemetry token buckets are unchanged.