Repository navigation
Add the day's API value to the hourly summary - #21
Conversation
hourly-summary.json carried the day's tokens only, so a bar widget that wanted the day's estimated API value had to run `collector.py report --days 1` and read the report's summary. The snapshot now prices the events it already counts, with the report's own price(), and adds `value` and `unpricedTokens`. It reads each event's recorded speed tier too, so a Codex Fast turn is valued as the report values it. Schema version 1 is kept: the fields are additive. Checked with a test that the snapshot's value and unpriced tokens match `report(days=1)`'s summary for the same day, including a Fast turn, and that a day with no rates is all unpriced.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Hi Tyler! This one is a feature request, so feel free to close it if it's not aligned with the project.
hourly-summary.jsonhas the day's tokens but not what they are worth. A program that wants today's estimated API value outside the dashboard, such as a bar widget or a status script, has to runcollector.py report --days 1and read the report's summary.That's my case. Agent Pulse feeds the AI panel in my Omarchy bar, which was inspired a lot by Ceiling: I really missed being able to peek at the bar and see my current usage, the way I could on Windows. The panel's foot shows the day's tokens and their estimated API value, with a link back to Agent Pulse. Today it gets the value by running the report each time the panel opens; with this change it reads it from the summary, like the tokens.
The snapshot now prices the events it already counts, using the report's own
price(), and adds two fields:value: the estimated API value of the same eventstokenscounts.unpricedTokens: the part oftokensthat no rate covers.It reads each event's recorded speed tier as well, so a Codex Fast turn is valued the way the report values it.
schemaVersionstays 1 because the fields are only additions, and readers that ignore them see no change. The changelog entry is underUnreleased, and VERSION is left for the release.Checks:
python3 -m unittest discover -s tests: 248 tests OK. A new test checks that for the same day the snapshot'stokens,valueandunpricedTokensequalreport(days=1)'s summary, with a priced model, an unpriced model and a Fast turn. It also checks that a day with no rates comes out all unpriced.py_compileandbash -nchecks from the CI workflow.