anomalyco / anomalyco/opencode
tui: token rate uses the final metadata burst instead of model-call duration
@kommander is already working on this.
Since Sep 2, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
The V2 TUI can report implausibly high token throughput when a provider delivers generated usage in an atomic final event.
packages/tui/src/routes/session/rows.ts calculates turn throughput as total output tokens divided by the sum of assistant.time.streamed - assistant.time.created. This excludes the interval before the assistant record/first streamed event.
For an encrypted-thinking Bedrock response, the model worked for 71.051 seconds and returned 4,096 output tokens atomically. The assistant timing span was only 29 ms, so the footer displayed:
1m 11s · 141241.4 tok/s
The number is exactly 4096 / 0.029, even though the full call rate was about 57.6 tokens/s. The duration and throughput therefore use incompatible time spans.
Expected: use a model-call/output-generation span that includes time spent producing an atomic response, or suppress TPS when incremental generation timing is unavailable.
Actual: metadata-only/atomic streams can produce meaningless six-digit TPS values.
Plugins
No response
OpenCode version
opencode2 v0.0.0-dev-18900; current V2 source af332a2363 remains affected.
Steps to reproduce
- Construct a user message at time 0.
- Construct its assistant response with time.created = 71022, time.streamed = 71051, time.completed = 71051, and tokens.output = 4096.
- Render the session footer with session.tps enabled.
- Observe 1m 11s · 141241.4 tok/s.
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
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.