Commit b23d27d
committed
🤖 fix: accumulate output tokens across steps in cost tracking
In multi-step mode (tool use), the AI SDK emits per-step usage where:
- inputTokens: Current context window (grows each step)
- outputTokens: Tokens generated in that step only
The aggregator was replacing usage on each step, losing earlier output
tokens. Now we accumulate output/reasoning tokens while keeping the
latest input tokens (which correctly represent the growing context).
This fixes the issue where costs appeared to increment by only ~2¢
at a time instead of reflecting cumulative output costs.
_Generated with mux_1 parent a2a417e commit b23d27d
File tree
3 files changed
+38
-143
lines changed- src/browser/utils/messages
3 files changed
+38
-143
lines changed
0 commit comments