Support a per-model input context window override for custom gateways

Aperta
#30,333 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
ai, cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status/need-triage

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):

  1. Configure a custom gateway/model named formal-ai whose advertised input window is 1,234,567 tokens.
  2. Evaluate tokenLimit('formal-ai') from packages/core/src/core/tokenLimits.ts.
  3. It returns 1,048,576 regardless of the gateway's advertised value. The default branch 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.

Lingua principale
TypeScript
Stelle
109k
Fork
15k
Merge medio
1g 1h
PR unite (30g)
106

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google-gemini/gemini-cli

Tutte le issue di google-gemini/gemini-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.