Skip to content

fix(compact): add gemini-3.x and gpt-4.1 to contextWindowFor lookup table#158

Open
zjshen14 wants to merge 1 commit into
mainfrom
fix/issue-157
Open

fix(compact): add gemini-3.x and gpt-4.1 to contextWindowFor lookup table#158
zjshen14 wants to merge 1 commit into
mainfrom
fix/issue-157

Conversation

@zjshen14
Copy link
Copy Markdown
Owner

Summary

  • contextWindowFor() in src/core/compact.ts was missing entries for gemini-3.x and gpt-4.1 model families, causing both to fall back to DEFAULT_CONTEXT_WINDOW = 100_000
  • gemini-3.1-flash-lite-preview is the default model and the default Gemini compaction model (COMPACTION_MODELS in factory.ts); its actual context window is 1,048,576 tokens
  • gpt-4.1-mini is the OpenAI compaction model; its actual context window is 128,000 tokens
  • The /context command 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%+ remaining

Changes

src/core/compact.ts — add two entries to MODEL_CONTEXT_WINDOWS:

["gemini-3", 1_048_576],  // gemini-3.x family
["gpt-4.1",   128_000],   // gpt-4.1, gpt-4.1-mini, gpt-4.1-nano

src/core/compact.test.ts — add 5 new contextWindowFor tests 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 returns 1_048_576
  • contextWindowFor("gpt-4.1-mini") now returns 128_000
  • Existing tests for gemini-2.5, gemini-2.0, claude-, gpt-4o, and unknown models unaffected

Generated by Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(compact): contextWindowFor missing gemini-3.x and gpt-4.1 entries — default model falls back to wrong 100K limit

2 participants