You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d64acad
Browse filesBrowse the repository at this point in the historyBrowse files
feat(adapter): report 1h cache writes in JSON model breakdowns
Claude logs split cache writes into `ephemeral_5m_input_tokens` and
`ephemeral_1h_input_tokens`, and the cost calculation already prices
the two tiers separately. Every report path, however, collapsed the
split into one `cacheCreationTokens` count before it reached
`ModelBreakdown`, so the TTL tier the server picked was invisible even
though it changes the bill.
`ModelBreakdown` now carries an optional `cache_creation_1h_tokens`,
serialized as `cacheCreation1hTokens` only when at least one record
reported the split. Records without a `cache_creation` object are
billed at the 5-minute rate, so `cacheCreationTokens -
cacheCreation1hTokens` is always the 5-minute part and no separate 5m
field is needed. Other agents never report a split and keep their
existing JSON shape.
The field had to be threaded through five hand-written copies of the
per-model accumulation (Claude daily, core summaries, monthly/weekly
merges, and the two all-agents merges). Those copies now go through
`ModelBreakdown::add_usage` and `ModelBreakdown::merge`, so a future
field cannot be dropped by one path while the others carry it.
Fixes#2015
Co-authored-by: XixianWasTaken <[email protected]>
Copy file name to clipboardExpand all lines: docs/guide/json-output.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,6 +302,22 @@ In `auto` [cost mode](/guide/cost-modes), an entry's `cost` can add together cos
302
302
}
303
303
```
304
304
305
+
## Cache Write TTL Split
306
+
307
+
Claude records whether each cache write used the 5-minute or the 1-hour cache TTL, and the two tiers are billed at different rates. Each `modelBreakdowns` entry where at least one record reported that split carries `cacheCreation1hTokens`, the part of `cacheCreationTokens` written with the 1-hour TTL; `cacheCreationTokens - cacheCreation1hTokens` is the 5-minute part. Entries whose records never reported a split, including every other agent, omit the key.
0 commit comments