fix: calculate contextTokens as cumulative sum of all conversation tokens#6007
Closed
roomote[bot] wants to merge 1 commit intomainfrom
Closed
fix: calculate contextTokens as cumulative sum of all conversation tokens#6007roomote[bot] wants to merge 1 commit intomainfrom
roomote[bot] wants to merge 1 commit intomainfrom
Conversation
…kens - Changed contextTokens calculation to sum all tokens in conversation history - Properly handles condense_context messages by resetting to new context size - Fixes issue where token counter showed unrealistic values like 0 or under 100 - Updates tests to verify correct cumulative token calculation Fixes #6004
Member
|
Should be solved by #6019 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the incorrect token counting in the context window display that was causing users to see unrealistic values like 0 or under 100 tokens.
Problem
The
contextTokenscalculation ingetApiMetricswas only looking at the last API request's tokens instead of calculating the actual cumulative context window usage. This led to:Solution
Changed the
contextTokenscalculation to:condense_contextmessages by resetting to the new context sizeChanges
src/shared/getApiMetrics.tsto calculate cumulative context tokenssrc/shared/__tests__/getApiMetrics.spec.tsto verify correct behaviorTesting
Fixes #6004
Important
Fixes
contextTokenscalculation ingetApiMetricsto sum all conversation tokens and handlecondense_contextmessages correctly.contextTokenscalculation ingetApiMetricsto sum tokens from all API requests.contextTokensaftercondense_contextmessages and continues accumulation.getApiMetrics.tsto track cumulative context tokens and handlecondense_contextmessages.getApiMetrics.spec.tsto verify cumulative token calculation andcondense_contexthandling.condense_contextmessage handling.This description was created by
for efcd3e0. You can customize this summary. It will automatically update as commits are pushed.