Context window display: cache creation tokens not included in percentage denominator

Resolved 💬 2 comments Opened Mar 26, 2026 by f9bwx44g65-svg Closed Apr 25, 2026

Bug Description

The token breakdown display shows incorrect percentages when cache creation tokens are present.

Observed Behavior

  • Cache creation: 1,016,242 tokens → shown as 946.2%
  • Output: 106,970 tokens → shown as 99.6%
  • Input: 427 tokens → shown as 0.4%

Input + Output sum to 100%, but Cache creation shows >100%.

Root Cause

Percentages are calculated using only (Input + Output) as the denominator. Cache creation tokens are excluded from the base:

  • Cache %: 1,016,242 / (427 + 106,970) = 946.2% ← wrong

Expected Behavior

All types should use the combined total as the denominator:

Total = 1,016,242 + 106,970 + 427 = 1,123,639

  • Cache creation: 90.4%
  • Output: 9.5%
  • Input: 0.04%

Environment

  • Platform: macOS darwin 25.3.0
  • Shell: zsh

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗