The commit before last tells Google's 400 for minimal apart from
thinking_config turned away. It left three ways for a level refusal to
still mark the provider unfit for thinking_config, or to reach the client:
* Only minimal was told apart. Gemini 3 turns away any level a model
hasn't, in the same words (AI Studio's "Thinking level MINIMAL is not
supported for this model. Please retry with other thinking level."
for gemini-3.8-flash). Any other level's 400 names thinking, matched
refusesThinkingConfig, and the provider was marked unfit for
thinking_config: no model on it was asked for its thoughts again
until magpie restarted.
* The check ran only while the model wasn't yet marked as refusing
reasoning off. Claude Code sends its turn, a title and the auto mode
classifier at once. A second 400 for minimal that arrived after the
first had marked the model matched refusesThinkingConfig, and the
provider lost its thoughts the same way.
* Passed through, a Chat client's own reasoning_effort minimal went to
gemini-3.8-flash as sent, and AI Studio's 400 went back to the client
every time. The passthrough asked again only when the error listed the
levels (effortLevelsNamed, Command Code's), and didn't remember that
either.
Now:
* geminiRefusedLevel reads the level from Google's 400, in AI Studio's
words, Vertex AI's ("Thinking level is unsupported:
THINKING_LEVEL_MINIMAL") and generateContent's ("thinking_level
MINIMAL is not supported by this model"). forwardTranslated marks that
level refused for the model (levelRefused) and asks again at the
nearest level the model has left, still for its thoughts, and at that
level from then on. geminiLevels gives the levels left: the model's
own, or Gemini 3's where they aren't known or none of its own is left.
A level turned away a second time in one request, with none left,
goes back to the client as it came. Such a 400 never reaches
refusesThinkingConfig.
* The passthrough asks a none or minimal that Gemini turns away again at
the model's lowest level (onEffort), and from then on sends that level
at the lowest up front (turnedAway). The mark is per level. AI Studio
takes none from gemini-3.8-flash, so none still goes as sent after
minimal was refused. A refusal that lists the levels marks reasoning
off as a whole (offRefused), as the translated route already did,
unless it lists the other off level among those taken
(otherOffNamed: OpenAI's "'minimal' is not supported with the
'gpt-5.1' model. Supported values are: 'none', 'low', 'medium', and
'high'."), which marks only the level refused. It is asked again at
onEffort rather than a fixed low.
* Both routes read and write the same marks. A refusal on one holds for
the other.
Tests, with what the commit before this one (b9fe82b9) gives:
* TestGeminiRefusedLevel: each of the three wordings gives its level.
Gemini's fields turned away, a level named but not turned away
(made up), Command Code's list of levels and an OpenAI unsupported
value give none. (The function is new.)
* TestGeminiThinkingLevelRefused/medium: gemini-3-pro-image-preview
turning away medium is asked again at high with its thoughts, and at
high at once the next turn. gemini-3.8-flash on the same provider still
goes at medium. There: "gemini-3-pro-image-preview: the thoughts
weren't asked for".
* TestGeminiThinkingLevelRefused/no_level_left: a model turning away
every level is asked at each once (minimal twice), and the client gets
Google's 400. The provider's other model still gets its thoughts.
There: "200 at [low ]", the turn asked again without the field.
* TestGeminiMinimalRefusedTwiceAtOnce: two reasoning-off turns at once
are both turned away at minimal. Each is asked again at low, and the
next thinking turn still asks for the thoughts. There: "reasoning off
went at [ low minimal minimal]".
* TestPassthroughGeminiMinimalRefused: a Chat client's minimal to
gemini-3.8-flash goes [minimal low], then [low], and none [none]. Claude
Code's reasoning off then goes at [low]. gemini-3.7-flash, turned away
at minimal by Claude Code's reasoning off, has a Chat client's minimal
go at [low]. gemini-3.5-flash, which takes minimal, has it go as sent.
There: "gemini-3.8-flash at "minimal": 400 at [minimal]".
* TestPassthroughEffortNoneRefused: when Command Code refuses none, the
second turn goes at low in one request. There: "turn 2: ... after 2
calls".
* TestPassthroughMinimalRefusedNoneTaken: on Chat and Responses,
OpenAI's refusal of minimal has minimal go at low, in one request from
the second turn, and none still go as sent. There: "chat turn 2 at
minimal: ... after 2 calls". Marking reasoning off as a whole for it
fails with "chat turn 3 at none: ... last sent ... low".
* TestGeminiThinkingOffAtItsLowest also runs AI Studio's wording. It
shares geminiUpstream with the tests above.
Mutations of the change were each caught by these tests:
* dropping the second-refusal guard, or the fallback to Gemini 3's
levels;
* dropping the refit of an effort;
* dropping the passthrough's up-front step, its mark, or its Gemini
match;
* marking reasoning off as a whole for a Gemini refusal, on either
route;
* narrowing the pattern to one vendor's wording, or loosening it to
any level after "thinking level", lazily or not;
* checking refusesThinkingConfig first;
* turnedAway ignoring offRefused.
Verified on b9fe82b9 with a temporary HOME. gofmt -l, go vet ./...,
go build, GOOS=linux go build -tags nogui and GOOS=windows go build pass.
go test -tags nogui ./... passes, and so does -race -count=20 on the tests
above.
Not tried live. The AI Studio project's prepayment credits were depleted
(402), so the calls never reached the model. The wording for minimal is
AI Studio's, as observed on gemini-3.8-flash. Other levels are taken to be
refused in the same words.