Skip to content

feat: report header and bot caption show tokens, time and real cost - #17

Merged
maxbolgarin merged 2 commits into
mainfrom
claude/gracious-noether-ymzeer
Oct 10, 2026
Merged

maxbolgarin merged 2 commits into
mainfrom
claude/gracious-noether-ymzeer

Conversation

@maxbolgarin

@maxbolgarin maxbolgarin commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

The analyze report header said Кэш: 0/1 попаданий and Стоимость: $0 even though the provider served 7 215 of 26 599 prompt tokens from its cache. The model (openai/gpt-6-luna-pro) has no price in [pricing] or the catalog, so every run on it was billed at $0. The header also showed a meaningless Период: непрочитанные / вся история on a YouTube video.

Report header

  • The pipeline now adds up prompt, cached and completion tokens and the elapsed time across the LLM calls it makes (new AnalysisResult fields).
  • New Tokens row: 26 599 in (7 215 from provider cache, 27%) + 4 607 out.
  • New Time row.
  • The Cache row (local response cache) only appears when that cache actually served a response.
  • The Cost row says unknown — no price for <model> instead of a bare $0. The analysis/enrichment split is localized.
  • The Period row only appears for chats.

Pricing models the catalog doesn't know (unread/ai/live_pricing.py)

  • On a model's first call, chat_complete fetches OpenRouter's public model list once, with no key. The price it finds is remembered in ~/.unread/storage/live_prices.json, so later processes don't need the network. [pricing] and the catalog still win.
  • A miss is remembered for the process, so the list is fetched at most once per unknown model per process.
  • Turned off with [ai] live_pricing = false or UNREAD_AI_LIVE_PRICING=0. Tests run with it off.

Bot caption

  • The spend is shown as ≈$0.0123, or $? when tokens were used but no price is known.

Related issue

n/a

Test plan

  • uv run pytest -q: 2668 passed, including new tests/test_report_meta_usage.py and tests/test_live_pricing.py (fetch mocked, no network)
  • uv run ruff check on the changed files: no new findings
  • uv run ruff format

Checklist

  • PR title uses a Conventional Commits prefix
  • Updated CLAUDE.md if architecture / invariants changed (n/a)
  • Added or updated tests for the change
  • No new network calls inside tests

🤖 Generated with Claude Code

https://claude.ai/code/session_01CWDpwC7PyG5Rh8mvCWdLYx

- Token row with provider prompt-cache share (26 599 in (7 215 cached, 27%) + 4 607 out)
- Time row with the analysis duration
- Local cache row only when it actually served a response, so a provider
  prompt-cache discount no longer reads as '0/1 hits'
- Cost row says 'unknown — no price for <model>' instead of a bare $0
  when the model has no pricing
- Period row only for chats; videos, pages and files are analyzed whole

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CWDpwC7PyG5Rh8mvCWdLYx
…ption

A model missing from [pricing] and the catalog (e.g. openai/gpt-6-luna-pro)
was billed at $0 everywhere. On its first call chat_complete now fetches
OpenRouter's public model list once, remembers the price under
~/.unread/storage/live_prices.json, and prices later calls from there.
[ai] live_pricing = false (or UNREAD_AI_LIVE_PRICING=0) turns it off.

The bot caption shows the spend as ≈$x, or $? when tokens were used
but no price is known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CWDpwC7PyG5Rh8mvCWdLYx
@maxbolgarin maxbolgarin changed the title feat: report header shows tokens, time and real cost; no period for videos feat: report header and bot caption show tokens, time and real cost Oct 10, 2026
@maxbolgarin
maxbolgarin merged commit 508a5b1 into main Oct 10, 2026
8 checks passed
@maxbolgarin
maxbolgarin deleted the claude/gracious-noether-ymzeer branch October 10, 2026 18:55
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants