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
[Idea] Show a session's total tokens in the context readout
#4527
What are you trying to do, and what gets in the way?
I want to know how many tokens a session has used in total. The context readout in the header tells me how full the context window is right now, which is a different question: once a session has been running a while, that percentage barely moves even though every turn is spending tokens, so I have no idea what the session has actually cost me in tokens.
What I do now is guess from the Stats page, or add up numbers by hand from individual turns. Both are wrong in the way that matters - the Stats page is per model and per session across everything I have ever run, and a turn-by-turn sum only covers the history that happens to be loaded.
What would you like to happen instead?
One more line in the context readout's tooltip, next to the existing ones: the session's total tokens so far.
The useful part is that this should not cost anything to compute. OpenCode already keeps a running token total on the session itself, right beside cost, and pushes it live over the event stream - the session list the app already has contains it. So I am asking for a line of UI, not for a new endpoint or a background job, and specifically not for the app to page in the whole message history to sum it up.
Two questions I would rather ask now than get wrong in review:
Where does it belong? I put it in the same tooltip as used tokens, context limit, output limit and cost, and only when it is above zero. I could also argue for the context panel, or for showing it next to the percentage. The tooltip seemed like the only place that is already about tokens.
What should the number count? I summed what the model reported: input + output + reasoning + cache read + cache write, so it lines up with what cost is computed from. The alternative is to exclude cache reads, which would make the number smaller and arguably more like "tokens I paid for", but then it stops matching cost. I went with matching cost.
Anything that shows what you mean
Not much to show, which is the point - it is a number that should appear in a tooltip that already exists. For context: a session here is around 27% context and 40.8K tokens in one line, and today there is no way to see that 40.8K from the chat at all.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
What are you trying to do, and what gets in the way?
I want to know how many tokens a session has used in total. The context readout in the header tells me how full the context window is right now, which is a different question: once a session has been running a while, that percentage barely moves even though every turn is spending tokens, so I have no idea what the session has actually cost me in tokens.
What I do now is guess from the Stats page, or add up numbers by hand from individual turns. Both are wrong in the way that matters - the Stats page is per model and per session across everything I have ever run, and a turn-by-turn sum only covers the history that happens to be loaded.
What would you like to happen instead?
One more line in the context readout's tooltip, next to the existing ones: the session's total tokens so far.
The useful part is that this should not cost anything to compute. OpenCode already keeps a running token total on the session itself, right beside
cost, and pushes it live over the event stream - the session list the app already has contains it. So I am asking for a line of UI, not for a new endpoint or a background job, and specifically not for the app to page in the whole message history to sum it up.Two questions I would rather ask now than get wrong in review:
Anything that shows what you mean
Not much to show, which is the point - it is a number that should appear in a tooltip that already exists. For context: a session here is around 27% context and 40.8K tokens in one line, and today there is no way to see that 40.8K from the chat at all.
Would you want to build it?
I'd like to build it if we agree on the shape
All reactions