Skip to content

Fix total_saved_tokens to use cumulative totals#100

Merged
TomMaSS merged 1 commit into
mainfrom
fix/total-saved-tokens-cumulative
Mar 22, 2026
Merged

Fix total_saved_tokens to use cumulative totals#100
TomMaSS merged 1 commit into
mainfrom
fix/total-saved-tokens-cumulative

Conversation

@TomMaSS
Copy link
Copy Markdown
Owner

@TomMaSS TomMaSS commented Mar 22, 2026

Summary

  • Replace full_doc_tokens * session_count - total_loaded_tokens formula with cumulative sum from token_estimates table
  • Old formula retroactively inflated/deflated savings when doc size changed between sessions
  • New formula sums actual full_doc_tokens and loaded_tokens recorded per operation, giving true project-level savings

Test plan

  • pytest tests/test_ui_api.py — 92 tests pass
  • Manual: check Stats tab shows correct total_saved_tokens

Use token_estimates table sum instead of full_doc_tokens * session_count
formula, which retroactively inflated/deflated old sessions when doc
size changed.
@TomMaSS TomMaSS merged commit 6469523 into main Mar 22, 2026
1 check passed
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.

1 participant