fix(compact): add gemini-3.x and gpt-4.1 to contextWindowFor lookup table#158
Open
zjshen14 wants to merge 1 commit into
Open
fix(compact): add gemini-3.x and gpt-4.1 to contextWindowFor lookup table#158zjshen14 wants to merge 1 commit into
zjshen14 wants to merge 1 commit into
Conversation
The MODEL_CONTEXT_WINDOWS lookup in compact.ts was missing two model families used by this codebase: - gemini-3.x (e.g. gemini-3.1-flash-lite-preview — the default model and the Gemini compaction model in factory.ts COMPACTION_MODELS) - gpt-4.1 (e.g. gpt-4.1-mini — the OpenAI compaction model) Both fell back to DEFAULT_CONTEXT_WINDOW = 100_000, so /context reported ~10× too-high a percentage for the default Gemini model, making users think they were nearly out of context when they were not. Closes #157 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
contextWindowFor()insrc/core/compact.tswas missing entries forgemini-3.xandgpt-4.1model families, causing both to fall back toDEFAULT_CONTEXT_WINDOW = 100_000gemini-3.1-flash-lite-previewis the default model and the default Gemini compaction model (COMPACTION_MODELSinfactory.ts); its actual context window is 1,048,576 tokensgpt-4.1-miniis the OpenAI compaction model; its actual context window is 128,000 tokens/contextcommand was reporting ~10× too-high a usage percentage for users on the default model, making them think they were nearly out of context when they had 90%+ remainingChanges
src/core/compact.ts— add two entries toMODEL_CONTEXT_WINDOWS:src/core/compact.test.ts— add 5 newcontextWindowFortests covering the two new model families.Related issue
Closes #157
Test plan
npm run typecheck && npm run lint && npm run format:check && npm test— all pass (550 tests, 0 failures)contextWindowFor("gemini-3.1-flash-lite-preview")now returns1_048_576contextWindowFor("gpt-4.1-mini")now returns128_000Generated by Claude Code