mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
8e0e9ac319
Some Anthropic-compatible SSE providers (e.g. qwen, minimax) report the full context (fresh + cached) as input_tokens in message_start, double counting the cached portion that is also reported in cache_read_input_tokens. This inflated the cacheable-input denominator and pushed the displayed cache hit rate artificially low. When a message_delta carries a smaller positive input_tokens, prefer it over the message_start value and adopt the cache counts from the same usage block to avoid double counting; fall back to the start cache values when the delta omits them. Native Claude (no input in delta) and OpenRouter-converted (input only in delta) paths are unchanged. Refs #3580