Repository navigation
fix(google): cap max_tokens at 65536 on the Gemini 3.8 Live models - #591
Merged
Merged
Conversation
Kamilbenkirane
added a commit
that referenced
this pull request
Nov 9, 2026
Kamilbenkirane
added a commit
that referenced
this pull request
Nov 9, 2026
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.
gemini-3.8-liveandgemini-3.8-live-extended-thinkingset nomax_tokensconstraint, so celeste sends any value. Google documents a fixed output limit for both. The model pages (Gemini 3.8 Live, Gemini 3.8 Live Extended Thinking) each list "Input token limit 131,072 / Output token limit 65,536".GET /v1beta/models/{id}returnsoutputTokenLimit: 65536for both. The GenerateContent reference definesmaxOutputTokensas "The maximum number of tokens to include in a response candidate. Note: The default value varies by model, see theModel.output_token_limitattribute". The Live API reference takes aGenerationConfiginBidiGenerateContentSetup.generationConfigand does not listmaxOutputTokensamong the unsupported fields. On Google Cloud, the Gemini 3.8 Live page lists "Maximum output tokens 64K", the same 65,536. This is a documented output figure, which is what CLAUDE.md's MAX_TOKENS rule requires.The constraint has an effect because
max_tokensalready reaches the setup frame.MaxTokensMapper(GOOGLE_PARAMETER_MAPPERS, wireMaxOutputTokensMapper) writesgenerationConfig.maxOutputTokens, andGoogleLiveClient._build_requestputs the result undersetup. The existing wire-contract row covers this mapping.Fix:
src/celeste/modalities/live/providers/google/models.py:LiveParameter.MAX_TOKENS: Range(min=1, max=65536)on both entries. This is the same shape as the Google text models.test_parameter_wire_contracts.pyalready has the LivemaxOutputTokensrow.Validation:
make cipasses (762 unit tests).Live, Gemini API key. One turn per case through
celeste.live.connect(...)onwss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent, prompt "Say hello in one short sentence.":max_tokens=65536: the setup frame carriesgenerationConfig.maxOutputTokens: 65536,setupCompletearrives, and the turn ends withturnComplete(audio plus transcript).max_tokens=65537: rejected locally withConstraintViolationError: Must be between 1 and 65536, got 65537.The field is honored on
gemini-3.8-live, with the prompt "Tell me a long, detailed story about a lighthouse keeper":max_tokensAPI reference vs. live serving (recorded per CLAUDE.md): the Live setup only checks that the value is positive.
maxOutputTokens: 0, sent throughextra_bodyto skip celeste's check, closes the socket with 1007 "max_output_tokens must be positive". That confirmsmin=1.65537and1000000sent the same way are accepted, and the turn completes normally.max=65536. The cap comes from the documented output-token limit andoutputTokenLimit, as it does for the Google text models.max_tokens=20ongemini-3.8-live, the server sendssetupCompleteand then nomodelTurnorturnCompletefor 45 s. The small budget seems to go entirely to thinking tokens.aiplatform.endpoints.predict.