anomalyco / anomalyco/opencode
tui: tok/s excludes reported reasoning tokens in V2
@simonklee is already working on this.
Since Sep 12, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
OpenCode V2's tok/s indicator excludes reported reasoning tokens from the numerator. This understates total generated-token throughput for reasoning-heavy responses.
The footer sums assistant.tokens.output, which is populated from Usage.visibleOutputTokens. That value is the provider's inclusive output count minus its reported reasoning count; reasoning is stored separately in assistant.tokens.reasoning.
The indicator should count both non-reasoning output and reasoning tokens, using a duration that covers the generation of both. For providers such as OpenAI, the raw API output count already includes reasoning, so the calculation must use OpenCode's normalized counters without double-counting the provider total.
Plugins
No plugins are required for the code-level reproduction below.
OpenCode version
V2, upstream source at 2df00955cb933e977427535d2505e50cbc689c69.
Steps to reproduce
- Construct a completed assistant message with
tokens.output = 20,tokens.reasoning = 80, and a 10-second interval betweentime.createdandtime.streamed. - Pass it to
turnTokensPerSecondinpackages/tui/src/routes/session/rows.ts, with no other assistant messages in the current prompt's history. - The calculation returns
2 tok/s:20 / 10. Counting all 100 generated tokens over the same interval would give10 tok/s.
This isolates the missing reasoning count from provider-specific timing behavior. In normal use, it affects the footer whenever a provider reports reasoning tokens separately and the tok/s indicator is enabled.
Screenshot and/or share link
Session usage normalization:
https://github.com/anomalyco/opencode/blob/2df00955cb933e977427535d2505e50cbc689c69/packages/core/src/session/usage.ts#L11-L19
Operating System
macOS (Darwin 25.6.0, arm64); the calculation is platform-independent.
Terminal
iTerm2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.