fix(proxy): resolve 400 Bad Request for gemini-3.1-pro-high model#187
Open
abhijeetatgit wants to merge 1 commit into
Open
fix(proxy): resolve 400 Bad Request for gemini-3.1-pro-high model#187abhijeetatgit wants to merge 1 commit into
abhijeetatgit wants to merge 1 commit into
Conversation
The upstream Google API rejects 'gemini-3.1-pro-high' as a model name with 400 INVALID_ARGUMENT. This causes all requests using the high-tier Gemini Pro model to fail. Changes: - model-specs.json: Reduce thinking_budget for gemini-3.1-pro-high from 49152 to 32768 to match the API's accepted maximum. - token-manager.service.ts: Prioritize 'gemini-3.1-pro-preview' as the first fallback candidate when 'gemini-3.1-pro-high' or 'gemini-3.1-pro' is requested, since '-preview' is accepted by the upstream API while '-high' is not. The deduplication logic (seen set) ensures that the same model name is never tried twice in the fallback sequence.
Comment on lines
1119
to
1135
| } | ||
| }; | ||
|
|
||
| // Keep requested model first, then fallback across the same family. | ||
| pushCandidate(normalizedModel); | ||
| // When the requested model is gemini-3.1-pro-high or gemini-3.1-pro, | ||
| // prioritize gemini-3.1-pro-preview as the first candidate. The upstream | ||
| // API rejects the '-high' suffix with 400 INVALID_ARGUMENT. | ||
| if (normalizedModel === 'gemini-3.1-pro-high' || normalizedModel === 'gemini-3.1-pro') { | ||
| pushCandidate('gemini-3.1-pro-preview'); | ||
| pushCandidate('gemini-3.1-pro'); | ||
| pushCandidate(normalizedModel); | ||
| } else { | ||
| pushCandidate(normalizedModel); | ||
| } | ||
|
|
||
| pushCandidate('gemini-3.1-pro-preview'); | ||
| pushCandidate('gemini-3-pro-preview'); | ||
| pushCandidate('gemini-3.1-pro-high'); |
There was a problem hiding this comment.
Maintainability Concern:
The candidate model list and prioritization logic are hardcoded, which reduces flexibility and maintainability. If the set of supported models changes, this function will require manual updates. Consider externalizing the candidate list and prioritization rules to configuration or constants, or making the logic more data-driven to facilitate easier updates and reduce risk of errors.
Example improvement:
const proFamilyCandidates = getProFamilyCandidatesFromConfig();
// ...
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
The upstream Google API rejects
gemini-3.1-pro-highas a model name with400 INVALID_ARGUMENT, causing all requests using the high-tier Gemini Pro model to fail.Changes
src/modules/proxy-gateway/antigravity/model-specs.jsonthinking_budgetforgemini-3.1-pro-highfrom49152to32768to match the API's accepted maximum. Values above 32768 trigger a 400 error.src/modules/proxy-gateway/server/token-manager.service.tsbuildDynamicModelCandidates(), prioritizegemini-3.1-pro-previewas the first fallback candidate whengemini-3.1-pro-highorgemini-3.1-prois requested.-previewbut rejects-high, so this ensures requests succeed on the first attempt.seenset) ensures no model name is tried twice in the fallback sequence.Testing
gemini-3.1-pro-highmodel no longer return 400 errors.-previewvariant is functionally equivalent and accepted by the upstream API.