-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: calculate header percentage based on available input space #11054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: calculate header percentage based on available input space #11054
Conversation
The percentage in the collapsed task header was showing 45% when it should show ~19%. This was because the formula incorrectly calculated: (tokensUsed + reservedForOutput) / contextWindow * 100 Instead of the correct formula: tokensUsed / (contextWindow - reservedForOutput) * 100 The correct formula shows the percentage of available input space that is currently used. The reserved output tokens should not be counted towards the used percentage since they are reserved for the model response. Example with 50.4k tokens, 128k reserved, 400k context window: - Old (incorrect): (50.4k + 128k) / 400k = 44.6% - New (correct): 50.4k / (400k - 128k) = 18.5% Fixes EXT-675
All issues have been resolved. The test now properly mocks
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Review complete. The core formula fix is correct, but the test needs improvement.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Fixed the test to properly verify percentage calculation by mocking |
|
Tested it. Works |
Follow-up to #11034
Fixes the percentage calculation in the collapsed task header to show the correct value.
Problem
The percentage in the header was showing 45% when it should show ~19%. For example, with:
The old formula calculated:
(tokensUsed + reservedForOutput) / contextWindow * 100=(50.4k + 128k) / 400k * 100= 44.6% (incorrect)Solution
The new formula calculates:
tokensUsed / (contextWindow - reservedForOutput) * 100=50.4k / (400k - 128k) * 100= 18.5% (correct)This represents the percentage of available input space that is currently used. The reserved output tokens should not be counted towards the used percentage since they are reserved for the model response.
Changes
TaskHeader.tsxto use the correct formulaTesting
View task on Roo Code Cloud
Important
Fixes percentage calculation in
TaskHeader.tsxto correctly compute available input space usage, with updated tests inTaskHeader.spec.tsx.TaskHeader.tsxto usetokensUsed / (contextWindow - reservedForOutput) * 100.TaskHeader.spec.tsxfor new percentage calculation logic.TaskHeader.tsxto reflect new calculation logic.This description was created by
for 51e062c. You can customize this summary. It will automatically update as commits are pushed.