Repository navigation
Commit 3499b08
committed
fix: Include cache tokens in live usage token count calculations
Previously, the live usage monitor and blocks command only counted input and output tokens, excluding cache_creation_input_tokens and cache_read_input_tokens from the total. This caused inaccurate token usage reporting, especially when cache creation tokens (which cost more than input tokens) were significant.
Changes:
- Add getTotalTokens() helper function to sum all four token types
- Update live rendering display to use getTotalTokens() for accurate counts
- Fix burn rate calculation to include cache tokens in tokens/minute metric
- Fix usage projection to include cache tokens in projected totals
- Update blocks command to count cache tokens in all calculations
- Add unit tests verifying cache tokens are included in calculations
- Fix UI alignment issues in live display (SESSION and Models lines)
This ensures users see accurate total token usage that matches their actual costs.
Fixes #1791 parent d56374f commit 3499b08
1 file changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
| |||
93 | 107 | | |
94 | 108 | | |
95 | 109 | | |
96 | | - | |
| 110 | + | |
97 | 111 | | |
98 | 112 | | |
99 | 113 | | |
| |||
144 | 158 | | |
145 | 159 | | |
146 | 160 | | |
147 | | - | |
| 161 | + | |
148 | 162 | | |
149 | 163 | | |
150 | 164 | | |
| |||
330 | 344 | | |
331 | 345 | | |
332 | 346 | | |
333 | | - | |
| 347 | + | |
334 | 348 | | |
335 | 349 | | |
336 | 350 | | |
| |||
0 commit comments