Token usage: keep cache/reasoning split, count only recorded steps, cost only when positive; captures fixture, docs and notes

This commit is contained in:
2026-11-03 22:16:49 +00:00
parent aa948bdfe4
commit 3227d61caf
19 changed files with 447 additions and 61 deletions
+4
View File
@@ -1448,6 +1448,10 @@ func stageUsage(snapshot stage.BudgetSnapshot) *protocol.StageUsage {
usage.TokensTotal = snapshot.UsedTokens
if snapshot.SplitKnown {
usage.TokensIn, usage.TokensOut, usage.SplitKnown = snapshot.TokensInput, snapshot.TokensOutput, true
// The rest of the component split is kept too: for a caching harness
// most of the total is cache reads, which a client shows as cached
// rather than fresh tokens.
usage.TokensReasoning, usage.CacheRead, usage.CacheWrite, usage.CacheKnown = snapshot.TokensReasoning, snapshot.CacheRead, snapshot.CacheWrite, true
}
}
if snapshot.USDKnown {