Skip to content

fix(interface): clarify cached vs new input token breakdown#692

Open
not-knope wants to merge 1 commit into
usestrix:mainfrom
not-knope:fix/token-usage-cached-display
Open

fix(interface): clarify cached vs new input token breakdown#692
not-knope wants to merge 1 commit into
usestrix:mainfrom
not-knope:fix/token-usage-cached-display

Conversation

@not-knope

Copy link
Copy Markdown

Closes #658

What changed

  • When cached input tokens are present, the stats panel now shows a three-part breakdown: Input (total), Cached (in total), and New input (uncached portion).
  • When there is no cache activity, the final report keeps the simpler Input Tokens label (no redundant cache row).
  • In live TUI mode with cached_tokens = 0, the cache row is still shown (Cached (in total) 0) so the sidebar metric remains visible during an active scan — same intent as before, with clearer labeling when cache is non-zero.
  • Added tests/test_interface_stats.py with three regression tests covering final stats, live-with-zero-cache, and live-with-cache breakdown.

Why

Users could not tell whether cached tokens were included in the input total or additive (e.g. 20M input + 19M cached = 39M vs 20M with 19M cached). The new labels make the subset relationship explicit and surface the uncached count when caching is in use.

How I tested it

python -m pytest tests/test_interface_stats.py -v

All 3 new tests pass.

I also ran the broader test suite locally. Pre-existing failures in test_hooks.py and test_runner_rate_limit.py are due to missing pytest-asyncio in the local environment (async tests are not collected/run correctly), not related to this change.

Note

This PR was prepared with AI coding assistance (Cursor). All changes were reviewed, tested, and validated by the author before submission.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR clarifies how cached input tokens are shown in usage stats.

  • Adds a total, cached, and new-input breakdown when cached tokens are present.
  • Keeps the simpler final-report input label when no cached tokens are present.
  • Keeps the live cache metric visible at zero during active scans.
  • Adds focused tests for the new stats rendering cases.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
strix/interface/utils.py Updates LLM usage stats rendering to show cached-token breakdowns without changing the underlying usage collection path.
tests/test_interface_stats.py Adds tests for final no-cache output, live zero-cache output, and cached-token breakdown output.

Reviews (1): Last reviewed commit: "fix(interface): clarify cached vs new in..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]

1 participant