fix(context): align isItemTooBig budget with the message compiler#12515
Open
MukundaKatta wants to merge 1 commit into
Open
fix(context): align isItemTooBig budget with the message compiler#12515MukundaKatta wants to merge 1 commit into
MukundaKatta wants to merge 1 commit into
Conversation
isItemTooBig reserved the full configured maxTokens when deciding whether a context item fits, but compileChatMessages only reserves min(MIN_RESPONSE_TOKENS, maxTokens) plus the counting safety buffer. On small context windows, or on models with no known completion limit (where maxTokens defaults to 4096), this made a single @file item look too big to include even though the compiler would have accepted it. Extract the compiler's budget into getAvailableInputTokens and use it in both places so the "too big" check matches what actually gets sent. Fixes continuedev#12165
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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.
Description
@filerejects items that@CurrentFileaccepts.Core.isItemTooBigreserves the fullmaxTokens(contextLength - maxTokens) when deciding whether a context item fits, butcompileChatMessagesonly reservesmin(MIN_RESPONSE_TOKENS, maxTokens)plus the counting safety buffer. On small context windows, or on models with no known completion limit wheremaxTokensdefaults to 4096, a single file looks too big even though the compiler would include it.@CurrentFileskipsisItemTooBigentirely, which is why it was unaffected.This pulls the compiler's budget into
getAvailableInputTokensand uses it in both places so the check matches what actually gets sent.Fixes #12165
Checklist
Tests
Added a
getAvailableInputTokensunit test block incore/llm/countTokens.test.ts: one case for a small window with the default 4096maxTokens, one for whenmaxTokensis below the minimum response allowance. Thecore/llm/countTokensJest suite passes.Summary by cubic
Aligns context-size checks with the message compiler so
@fileno longer gets rejected when the compiler would include it. Uses the compiler’s input budget (safety buffer + minimum response allowance) instead of reserving the fullmaxTokens, fixing false “too big” results on small windows and models with unknown completion limits.getAvailableInputTokens(contextLength, maxTokens)to mirror compiler budgeting (safety buffer +min(1000, maxTokens)).Core.isItemTooBigto use it;@filenow matches@CurrentFile.maxTokensscenarios.Written for commit 6e5827b. Summary will update on new commits.
Review in cubic