SessionUsage cache fields default to 0 when API omits cache data
Description
When the API response does not include prompt_cache_hit_tokens or prompt_cache_miss_tokens, SessionUsage silently shows cache_creation_input_tokens=0 and cache_read_input_tokens=0.
This is indistinguishable from "zero cache hits/misses." The model then reports "cache hit rate 0%" or "cache miss" as if the data was observed — when in fact the API simply did not report it.
Steps to reproduce
- Use a model or response path that omits cache telemetry from the API response
- Check session usage: cache fields will show
0instead ofnull/unknown - The model may claim "cache hit rate 0%" based on this data
Expected behavior
Cache fields should be null/None when the API did not report them, so consumers can distinguish "zero" from "unknown."
Actual behavior
Cache fields default to 0, which is indistinguishable from a genuine zero.
Thanks for the report. Could you confirm if this issue still reproduces on the newly released v0.8.27?
Resolved in v0.8.28 via PR #1392. SessionUsage cache fields now correctly use Option