Uh oh!
There was an error while loading. Please reload this page.
feat(tui): add tokens per second to response footer - #12721
Conversation
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found: PR #5497 - "feat: display tokens per second for assistant messages" Why it's related: This PR appears to be addressing the exact same feature - displaying tokens per second for assistant messages. It likely covers similar functionality for tracking and displaying TPS metrics in the UI. |
787aee0 to
c54f23aCompareAdds TPS calculation and display to message footers. Tracks firstToken timestamp during streaming and calculates throughput for completed text responses. Filters out tool calls and fast responses to avoid noise. Key features: - Shows TPS next to duration: "3.4s · 45 tok/s" - Includes both output and reasoning tokens - 250ms minimum threshold to filter noise - Comprehensive test coverage (34 tests) Tested with Kimi K2.5 showing ~131 tok/s. Fixesanomalyco#5374, Closesanomalyco#6096
c54f23a to
571c49bCompare@adamdotdevin@rekram1-node — the bot flagged this as a duplicate of #5497, so wanted to give some context. I reviewed #5497 before starting. It has merge conflicts against Quick review guide if it helps:
Happy to adjust anything. |
Daltonganger
commented
Feb 14, 2026
Any update on this? |
@rekram1-node I investigated the 3 failing checks on this PR. Root cause:
Proposed minimal fix (single-file change):
I can paste the exact patch here if useful. |
Daltonganger
commented
Feb 16, 2026
@rekram1-node I opened a follow-up PR that includes all changes from this PR plus a minimal ripgrep path fix for the failing checks: Cross-reference: |
JosXa
commented
Feb 20, 2026
Ship it! 🚀 |
Patch opencode with tokens-per-second display from anomalyco/opencode#12721. Shows streaming throughput metrics (e.g., "18.3s · 131 tok/s") in assistant message footers. Built from JohnC0de/opencode feat/tokens-per-second-display branch (commit 4687e48e9) as a standalone Bun binary, fetched at build time via fixed-output derivation to work with pure flake evaluation. Remove this overlay once the feature lands in an upstream release. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FurryWolfX
commented
Mar 14, 2026
I need it |
andrewdunndev
commented
Mar 25, 2026
Nice implementation. The One thing I noticed while building something similar: the TPS calculation can produce jittery values during the first few tokens of a response (small denominator, large variance). A minimum window before displaying (e.g., wait until at least 10 output tokens before showing tok/s) smooths this out without adding latency to the display. Also worth noting that @thdxr has #14493 open for the same feature. Might be worth coordinating to avoid duplicate effort. |
Daltonganger
commented
Mar 25, 2026
When is this imported? @rekram1-node |
com30n
commented
Apr 8, 2026
any updates on this? |
FYI: I wrote a FastAPI proxy for this purpose. It is independent of any coding agent. We will be open-sourcing it soon. |
mirobertod
commented
Jul 15, 2026
Hi, any update on this? Thanks |
Fixes#5374
Closes#6096
Adds a tok/s (TPS) counter to assistant message footers. Shows up right after duration, like:
18.3s · 131 tok/sWhy
I've been switching between providers a lot lately and wanted a quick way to see which models are actually fast vs which just feel fast. Kimi K2.5 clocks ~130 tok/s. Having the number right there makes the difference obvious without needing external tooling.
Screenshot
Kimi K2.5 Free hitting 198 tok/s on a real response
Prior art
#5497 by @edlsh tackled this back in December. It's been sitting for 2+ months now with merge conflicts and CI failures, and a few people in the comments are asking for it to land. Rather than try to rebase that PR, I reimplemented it cleanly on current
devwith a different structure: TPS logic lives incore/tokens/instead oftui/util/so the SDK and other consumers can use it later without pulling in TUI code.How it works
processor.tsrecords afirstTokentimestamp when the firstoutput-deltaarrives during streaming. TPS is then calculated asgeneratedTokens / ((completed - firstToken) / 1000), where generatedTokens includes both output and reasoning tokens. Responses shorter than 250ms, tool calls, and errored responses are filtered out.What I left out
Average/aggregate TPS across a session. Both issues mention it but it felt like scope creep for a first pass. The per-message timestamps are all persisted, so adding a session-level summary later is straightforward.
Testing
34 unit tests cover calculation, edge cases, and filtering. All CI checks pass: typecheck, unit, e2e (linux), pr-standards.