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
[FEATURE]:Token Usage & Cache Hit Dashboard per Session #42295
Add a live token usage and cache analytics panel visible during an active OpenCode session. This would display:
Total tokens consumed in the current session (input + output separately)
Cache hit count and cache hit ratio as a percentage
Estimated cost for the current session based on the model being used
A per-message breakdown showing tokens used per exchange
Right now there is no visibility into how much context is being consumed during a session. This creates two problems. First, developers have no idea when they are approaching context limits until the model starts degrading in quality. Second, there is no way to evaluate whether caching is actually working effectively across a session.
A token usage panel solves both. It helps developers make informed decisions about when to start a new session, which parts of their workflow are token-heavy, and whether their cache configuration is performing as expected.
This is especially useful for long agentic sessions where token consumption compounds quickly and cost visibility matters.
A per-session version of this exists as a plugin: /context-breakdown renders a
per-category dashboard (system prompt, tool schemas, user/assistant, reasoning,
tool args, residual) for the session and all its subagent sessions. The new /cx
panel in the terminal TUI adds a largest-contributors view — which message,
tool call or tool result eats the most, measured from the live message list.
Cache read/write participates in the native overflow metric, though the category
breakdown doesn't split it out separately yet.
opencode-context-indicator — still in a testing stage; with your help and
feedback we can make it better together. Dual V1 + V2, tested against 2.0.22,
everything local (no uploads, no extra LLM calls).
The desktop app shows session-level totals today (e.g. 101k · $4.55 next to the context ring, added by #53785), and the Review → Context panel aggregates the session. But there is still no way to see per-message token usage anywhere in the app.
This is exactly the "per-message breakdown showing tokens used per exchange" that this issue asks for. I'd like to request it for the desktop app specifically:
For each assistant message, show its own:
input (uncached)
output
reasoning
cache read / write
cost
My use case: I'm on a free/metered token quota and need to know which individual messages are consuming the most tokens. Session totals don't tell me that — I need the per-message figure to find the outliers.
The data already exists per message (session_message.data.tokens in the V2 database, and message.data.tokens in V1), so this is purely a presentation gap.
A per-message row in the session view, or a click-to-expand on each message, would be ideal. Thanks!
Thanks for the request, @GuixJoy! To restate it: you'd like a live usage panel for the current session that shows input and output tokens separately, how often the cache was hit and the hit ratio, the estimated cost, and the tokens used by each exchange. Maintainers will consider it.
Some of this already exists in v2:
The TUI sidebar's Context block shows the current context size, the % of the model's context window used, and the session cost.
Setting "debug": { "turn_tokens": true } in ~/.config/opencode/cli.json adds a per-turn table of new and cached tokens under each response, and flags likely cache busts.
The desktop app's Context panel shows input, output, reasoning and cache read/write tokens and the cost.
Until then, you can get the rest in the TUI with a small plugin. It adds a Usage block to the session sidebar with input and output totals, cache read/write, cache hits per turn, the share of prompt tokens served from cache, the cost, and the last few turns:
To install it, save the file as tui.tsx in a folder such as ~/.config/opencode/plugins/session-usage/. Then add that folder's absolute path to plugins in ~/.config/opencode/cli.json and restart the TUI. The turns option sets how many recent turns are listed, and 0 hides the list:
The input and output totals add up every assistant step in the session. "% of prompt" is cache reads divided by all prompt tokens (fresh input plus cache read and write).
Thanks! This asks for the same per-session, per-message token and cost breakdown as #41915, so I'm closing it as a duplicate. Some of it already exists: the desktop header shows session tokens and cost (#53785), and the TUI's debug.turn_tokens setting shows new vs cached tokens per step. A cache hit rate in the desktop Context panel is tracked in #58024.
Activity
github-actions commentedon Aug 13, 2026
This issue might be a duplicate of existing issues. Please check:
/usage— dedicated session token & cost report (alias/cost) — very similar request for a per-session token/cost breakdown command/contextin Claude) — overlapping request for context/token usage panelVladSmr commentedon Oct 2, 2026
A per-session version of this exists as a plugin: /context-breakdown renders a
per-category dashboard (system prompt, tool schemas, user/assistant, reasoning,
tool args, residual) for the session and all its subagent sessions. The new /cx
panel in the terminal TUI adds a largest-contributors view — which message,
tool call or tool result eats the most, measured from the live message list.
Cache read/write participates in the native overflow metric, though the category
breakdown doesn't split it out separately yet.
opencode-context-indicator — still in a testing stage; with your help and
feedback we can make it better together. Dual V1 + V2, tested against 2.0.22,
everything local (no uploads, no extra LLM calls).
https://github.com/VladSmr/opencode-context-indicator
npm: opencode-context-indicator
Songwanci commentedon Oct 28, 2026
Per-message token breakdown in the desktop app
The desktop app shows session-level totals today (e.g.
101k · $4.55next to the context ring, added by #53785), and the Review → Context panel aggregates the session. But there is still no way to see per-message token usage anywhere in the app.This is exactly the "per-message breakdown showing tokens used per exchange" that this issue asks for. I'd like to request it for the desktop app specifically:
For each assistant message, show its own:
My use case: I'm on a free/metered token quota and need to know which individual messages are consuming the most tokens. Session totals don't tell me that — I need the per-message figure to find the outliers.
Context / related:
The data already exists per message (
session_message.data.tokensin the V2 database, andmessage.data.tokensin V1), so this is purely a presentation gap.A per-message row in the session view, or a click-to-expand on each message, would be ideal. Thanks!
opencodejr commentedon Oct 28, 2026
Thanks for the request, @GuixJoy! To restate it: you'd like a live usage panel for the current session that shows input and output tokens separately, how often the cache was hit and the hit ratio, the estimated cost, and the tokens used by each exchange. Maintainers will consider it.
Some of this already exists in v2:
"debug": { "turn_tokens": true }in~/.config/opencode/cli.jsonadds a per-turn table of new and cached tokens under each response, and flags likely cache busts.Until then, you can get the rest in the TUI with a small plugin. It adds a Usage block to the session sidebar with input and output totals, cache read/write, cache hits per turn, the share of prompt tokens served from cache, the cost, and the last few turns:
To install it, save the file as
tui.tsxin a folder such as~/.config/opencode/plugins/session-usage/. Then add that folder's absolute path topluginsin~/.config/opencode/cli.jsonand restart the TUI. Theturnsoption sets how many recent turns are listed, and0hides the list:{ "plugins": [ { "package": "/home/you/.config/opencode/plugins/session-usage", "options": { "turns": 5 } } ] }The input and output totals add up every assistant step in the session. "% of prompt" is cache reads divided by all prompt tokens (fresh input plus cache read and write).
Related issues:
/usagecommand with per-message and cumulative token and cost accountingdebug.turn_tokensviewneriousy commentedon Nov 13, 2026
Thanks! This asks for the same per-session, per-message token and cost breakdown as #41915, so I'm closing it as a duplicate. Some of it already exists: the desktop header shows session tokens and cost (#53785), and the TUI's
debug.turn_tokenssetting shows new vs cached tokens per step. A cache hit rate in the desktop Context panel is tracked in #58024.