feat: show live token usage during streaming
Token counts only showed up after messages finished, so you had no idea how many tokens were being used until it was done.
Now token usage shows live while streaming:
-
IN↓/OUT↑format shows what you're sending vs receiving -
~X tokestimates appear immediately and update in real-time -
~X thinkshows reasoning token usage separately -
Tool results are now properly counted when sent back to the API
-
Added
sentEstimateandcontextEstimatefields to track what's actually being sent
Makes it way easier to keep an eye on token budget instead of being surprised at the end.
Showcase
I like this :+1:
looking forward to it!
@rekram1-node any plans to include this feature in upcoming releases?
@arsham - found a bug in this one while using it in my fork:
the upstream code has:
assistantMessage.finish = "tool-calls" assistantMessage.time.completed = Date.now() await Session.updateMessage(assistantMessage) if (result && part.state.status === "running") { await Session.updatePart({ ...part, state: { status: "completed", // ... rest of completed state }, } satisfies MessageV2.ToolPart) }
But your commit 7faa5e2cbc ("feat: real-time token tracking in TUI") accidentally removed completion handling code when refactoring the subtask execution.
The implication of the bug is that custom /commands that have subtask: true set will complete it's task and then spawn another task trying to do the same thing, over and over until manual intervention