Skip to content

fix(tui): include reasoning tokens in throughput - #48689

Merged
rekram1-node merged 2 commits into
anomalyco:v2from
dukebw:dukebw/stack/0681e582ab9d4b2ab73deedf3a7b43a8
Sep 18, 2026
Merged

rekram1-node merged 2 commits into
anomalyco:v2from
dukebw:dukebw/stack/0681e582ab9d4b2ab73deedf3a7b43a8

Conversation

@dukebw

@dukebw dukebw commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #48705

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Include reasoning tokens in the existing tok/s indicator. Session usage stores visible output and reasoning separately, so the throughput numerator now sums both across assistant steps.

For example, 80 reasoning tokens and 20 visible output tokens over a 3-second request produce 33.3 tok/s instead of 6.7 tok/s.

Update the setting description and retain regression coverage for cross-model aggregation, missing stream boundaries, provider wait, tool settlement, retries, and durable replay.

How did you verify your code works?

  • I've been using it with a patched local opencode 2.0 for a week, with various models.
  • Core session-runner tests: 210 passed.
  • TUI session-row tests: 25 passed, including reasoning-token aggregation and missing stream boundaries.
  • Rendered footer lifecycle regression: 1 passed.
  • Full bun run check passed (lint and repository-wide typechecks).
  • Generated-client consistency, formatting, and diff checks passed.

Screenshots / recordings

The existing footer layout is unchanged; this corrects the value it displays.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Related PR Found:

All other searches returned only the current PR #48689, indicating no other duplicate PRs are present.

@dukebw

dukebw commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@rekram1-node what do you think about accepting this PR? It fixes the same issue as #47125 and also includes reasoning tokens in the numerator for opencode v2.

# What/why

Session usage stores visible output and reasoning tokens separately. Counting
only visible output understates the generated-token throughput in assistant
footers.

# How

Sum output and reasoning tokens across assistant steps using upstream's existing
request-duration calculation. Update the setting description and retain
regression coverage for cross-model aggregation, missing stream boundaries,
provider wait, tool settlement, retries, and durable replay.

# Testing

- Core session-runner tests.
- TUI session-row tests and rendered footer lifecycle regression.
- Full bun run check, generated-client consistency, and formatting checks.

stack-pr-branch: dukebw/stack/0681e582ab9d4b2ab73deedf3a7b43a8
@dukebw
dukebw force-pushed the dukebw/stack/0681e582ab9d4b2ab73deedf3a7b43a8 branch from 2465b84 to 0df0c3b Compare September 17, 2026 15:04
@dukebw dukebw changed the title fix(tui): measure request throughput including reasoning fix(tui): include reasoning tokens in throughput Sep 17, 2026
Updated description for 'tps' to clarify its meaning.
@rekram1-node
rekram1-node merged commit b278ef6 into anomalyco:v2 Sep 18, 2026
8 checks passed
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants