1 Commits

Author SHA1 Message Date
jiarung
8cbc05ae1f feat(usage-log): record inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens
The recordTokenUsage function previously only persisted the aggregate tokensUsed
total, discarding the input/output breakdown that was already available via
getUsageTotals(). This meant token-usage.json had no per-record IO split,
making it impossible to analyse input vs output token costs in dashboards.

Changes:
- Add inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens optional
  fields to TokenUsageRecord type in usage-log.ts (new file)
- Write these fields (when non-zero) into each usage entry
- Fields are omitted (not null) when unavailable, keeping existing records valid
- Wire up recordTokenUsage() call in attempt.ts after llm_output hook

This is a purely additive change; existing consumers that only read tokensUsed
are unaffected.
2026-03-13 06:35:38 +00:00