fix(ai): send LOW to disable thinking on gemini-3.7-flash - #8383
Open
jingtao-wisdomgraph wants to merge 3 commits into
Open
fix(ai): send LOW to disable thinking on gemini-3.7-flash#8383jingtao-wisdomgraph wants to merge 3 commits into
jingtao-wisdomgraph wants to merge 3 commits into
Conversation
getDisabledThinkingConfig picked the level from an id regex, so gemini-3.7-flash got MINIMAL — which Google rejects with 400 INVALID_ARGUMENT on every call. The catalog already records what each model supports, but the adapter never read it, so a correction there could not reach the request. Read thinkingLevelMap via getSupportedThinkingLevels instead, and mark 3.7-flash as not supporting minimal. Behaviour-preserving for every other Google model — compared old vs new across all 22 in the catalog, identical.
Self-review of the first commit found two problems. It defined the same ascending-levels constant in both Google adapters — new duplication, in a change whose whole point was removing a duplicated regex — and wrapped a 7-element array in a Set. getSupportedThinkingLevels already returns ascending order, so neither was needed: the lookup now lives once in google-shared.ts as lowestSupportedThinkingLevel and each adapter is three lines. Adds four cases to google-thinking-level-map.test.ts, which already owned the opposite direction (which level is sent when thinking IS requested) and whose helpers only needed their two knobs made optional. They assert the thinkingConfig actually put on the wire, so they need no API key.
Reverts the catalog-driven rewrite from the previous commits in favour of the smallest change that fixes the bug. getDisabledThinkingConfig keeps its existing shape; only the flash branch learns that the floor moved. Google dropped MINIMAL for gemini-3.7-flash — sending it returns 400 INVALID_ARGUMENT on every call. gemini-3.6-flash still accepts it, so the predicate is per-version rather than family-wide. Verified against the live API: MINIMAL 400s, LOW/MEDIUM/HIGH and omitting the field all return 200.
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.
Problem
Disabling thinking on
gemini-3.7-flashfails every call:getDisabledThinkingConfigsendsthinkingLevel: MINIMALfor anything matchingisGemini3FlashModel. Google has since raised that floor for 3.7-flash — checked againstgenerativelanguage.googleapis.comon 2026-08-19:thinkingLevelChange
The flash branch of
getDisabledThinkingConfignow picks LOW for the versions that droppedMINIMAL, in both Google adapters. Per-version, not family-wide: 3.6-flash still takes MINIMAL,
and moving the whole family up would cost the others their lowest setting.
Tests
Three cases in
google-thinking-level-map.test.ts, which already owned the opposite direction(which level is sent when thinking is requested); its helpers only needed their two arguments
made optional. They assert the
thinkingConfigactually put on the wire, so they need no APIkey, and against the current code they fail with
expected { thinkingLevel: 'MINIMAL' } to deeply equal { thinkingLevel: 'LOW' }.Live API, patched adapter:
packages/ai: 24 failed / 970 passed, against 25 failed / 966 passed onmain— same failureset (Ollama, z.ai, qwen), none related.
Note
The id predicates here (
isGemini3FlashModeland friends) duplicate the ones inscripts/generate-models.ts, which independently records the same capability asthinkingLevelMap—gemini-3.1-pro-previewcarries{off: null, minimal: null, low: "LOW", …}while
getDisabledThinkingConfigre-derives LOW from a regex. Reading the catalog on this pathwould remove the second source of truth, but that is a larger change than this fix needs and is
left for you to decide on.