Support a per-model input context window override for custom gateways
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with packages/core/src/core/tokenLimits.ts and trace how model configuration reaches token budgeting and compaction. Check the documented modelConfigs settings and the tests covering those paths. Done means a validated per-model contextWindowTokens override is used when supplied, invalid values are rejected, and existing Gemini defaults remain the fallback; test values below and above 1,048,576.
Written by the indexing model from the issue text.
Description
Custom model gateways can advertise their actual context window, but packages/core/src/core/tokenLimits.ts currently gives every unknown model DEFAULT_TOKEN_LIMIT (1,048,576). The function accepts only the model name. The documented modelConfigs settings allow generation settings such as maxOutputTokens, without an input context-window override.
We encountered this while fixing https://github.com/link-assistant/formal-ai/issues/1582. Our symbolic server derives its context capacity from available resources and publishes context_window_tokens through its model metadata. Assuming the fixed Gemini window can trigger premature compaction when the server supports more, or allow a larger context than a smaller server supports.
Reproduction against the current source (not an installed CLI end-to-end test):
- Configure a custom gateway/model named
formal-aiwhose advertised input window is 1,234,567 tokens. - Evaluate
tokenLimit('formal-ai')frompackages/core/src/core/tokenLimits.ts. - It returns 1,048,576 regardless of the gateway's advertised value. The
defaultbranch cannot receive an override.
Expected: a validated per-model input context-window setting, optionally populated from gateway model discovery. Existing Gemini model defaults should remain the fallback when no override is supplied.
Suggested change: add an optional positive integer contextWindowTokens to model configuration, resolve it alongside the existing model-specific generation configuration, and pass it to the token-budget/compaction code before falling back to tokenLimit(model). Reject invalid/non-finite values and test both values below and above 1,048,576. Do not infer an unlimited context from a model name.
Current workaround: use a client exposing an actual context-window override, or keep the gateway within the fixed window while accepting the reduced capacity. maxOutputTokens alone cannot fix the input budget. We have not patched installed Gemini packages or claimed this workaround satisfies our all-clients acceptance criterion.
- Dominant language
- TypeScript
- Stars
- 109k
- Forks
- 15k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 106
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-cli
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30412 · 1 comment ·
Maintainers usually reply within 1 day
-
--acp never answers initialize when a sandbox is enabled (stdin read as a piped prompt before the sandbox hop)Possibly taken @Raamia claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-gemini/gemini-cli#30398 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: `/shells` slash command (and `/bashes`) is documented but was removed in #22740 — tutorial and tip tell users to run a command that doesn't existPossibly taken @DZH166 claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30396 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: System Prompt Override guide links "Persisting Environment Variables" to an anchor that does not exist in authentication.mdxPossibly taken @DZH166 claimed this 2 days ago. Openstatus/need-triage
Difficulty 1/5 Under an hour Newbie friendliness 82/100
google-gemini/gemini-cli#30394 · 2 comments ·
Maintainers usually reply within 1 day
-
core tests: orphan PTY slave fd test fails on Macs where /dev/ttys001 existsPossibly taken @Anoshor claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 2 comments ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-cli
Similar issues
-
qa-manually-tested Status: Triage Type: Bug / Error
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
mermaid-js/mermaid-v13#1158 ·
Maintainers usually reply within 1 day
-
Bug Daily
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Expensify/App#107705 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Changing shipping to country value from storefront homepage creates an invalid URLPossibly taken @Riamus78 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
medusajs/dtc-starter#106 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
digitalfabrik/integreat-app#4558 ·
Maintainers usually reply within 5 days
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
redhat-developer/podman-desktop-ibmcloud-account-ext#755 ·
Maintainers usually reply within 1 day