Over 100% context usage #4273

Open
opened 2026-02-16 17:43:15 -05:00 by yindo · 1 comment
Owner

Originally created by @Vekram1 on GitHub (Jan 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I encountered a situation where the context information in the sidebar of the TUI was reporting a context usage of greater than 100%.

I assume this is because:
const total = last.tokens.input + last.tokens.output + last.tokens.reasoning + last.tokens.cache.read + last.tokens.cache.write

result += " " + Math.round((total / model.limit.context) * 100) + "%"

I was thinking a better option to represent prompt window capacity:

const usedTokens = input.message.tokens.input + input.message.tokens.cache.read

and then obviously divide that by model.limit.context to obtain result.

Let me know what you are thinking of trying to measure and I would be happy to submit a PR.

Plugins

No response

OpenCode version

1.0.220

Steps to reproduce

I used GPT-4 to review my code, just to get acquainted with OpenCode.

The codebase was 55.1 MB large.

Screenshot and/or share link

Image

Operating System

macOS 26.1

Terminal

Ghostty

Originally created by @Vekram1 on GitHub (Jan 5, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I encountered a situation where the context information in the sidebar of the TUI was reporting a context usage of greater than 100%. I assume this is because: const total = last.tokens.input + last.tokens.output + last.tokens.reasoning + last.tokens.cache.read + last.tokens.cache.write result += " " + Math.round((total / model.limit.context) * 100) + "%" I was thinking a better option to represent prompt window capacity: const usedTokens = input.message.tokens.input + input.message.tokens.cache.read and then obviously divide that by model.limit.context to obtain result. Let me know what you are thinking of trying to measure and I would be happy to submit a PR. ### Plugins _No response_ ### OpenCode version 1.0.220 ### Steps to reproduce I used GPT-4 to review my code, just to get acquainted with OpenCode. The codebase was 55.1 MB large. ### Screenshot and/or share link <img width="329" height="302" alt="Image" src="https://github.com/user-attachments/assets/93780eea-4af2-4455-8b23-5df20d3a3c15" /> ### Operating System macOS 26.1 ### Terminal Ghostty
yindo added the opentuibug labels 2026-02-16 17:43:15 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 5, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #3322: web and tui reports token usage differently - This discusses how TUI calculates token usage, which appears to be related to the calculation logic you've identified showing over 100% context usage.
  • #6152: [FEATURE]: Session context usage - While this is a feature request for a context breakdown dialog, it's also addressing the underlying concern about understanding context window usage and how it's being calculated.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 5, 2026): This issue might be a duplicate of existing issues. Please check: - #3322: web and tui reports token usage differently - This discusses how TUI calculates token usage, which appears to be related to the calculation logic you've identified showing over 100% context usage. - #6152: [FEATURE]: Session context usage - While this is a feature request for a context breakdown dialog, it's also addressing the underlying concern about understanding context window usage and how it's being calculated. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4273