Commit 1492f20
committed
Count the cached tokens instead of throwing them away
The CLI reports cache_creation_input_tokens and cache_read_input_tokens
separately from the fresh input count. The event schema already parsed both,
and usageOf then dropped them on the floor.
That mattered more than it looks. S1 to S4 share one session, so each stage
resumes into the conversation the previous one built and sends most of its
prompt as a cached read. The number this app recorded as a review's input usage
was therefore a small fraction of what the model actually read, and there was no
way to show how much the session chaining saved.
Both counters now reach the stage rows and the review totals. Counted
separately rather than folded into the input count, because a cached read costs
a fraction of a fresh one and adding them together would overstate the price.
The cost figure was always right, because it comes from the CLI's own
total_cost_usd, which already accounts for caching.
The fake CLI now reports non-zero cache counters, because a fixture that only
ever produced zeros could not tell the difference between carrying these
through and dropping them. Mutation checked: restoring the drop fails the test
that follows the counters to the review row.
Caching itself is the CLI's to do. What this app controls is whether
consecutive stages share a session, and they do; the --resume flags that make
it true are already asserted at the command line.1 parent 68729ef commit 1492f20
18 files changed
Lines changed: 1798 additions & 10 deletions
File tree
- docs
- drizzle
- meta
- src
- lib/engine
- server
- db
- repositories
- jobs
- review
- tests
- fixtures
- server
- db
- engine
- review
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments