Files
magpie/internal
yetoneandggbdpq cbd379e1b7 gateway: a Gemini request's generationConfig keeps the fields magpie doesn't read (#3937)
parseGemini read a generationConfig of the fields magpie knows —
maxOutputTokens, temperature, topP, stopSequences, the structured output
ones, thinkingConfig, and, since #3820, imageConfig — and
buildCodeAssistSent built one of the same, so a translated request (a
Gemini client's generateContent asked of a Gemini API in one body, and
every request to Code Assist or Antigravity) went upstream without the
rest of what the client asked: topK, seed, candidateCount,
presencePenalty, frequencyPenalty, responseModalities, mediaResolution,
speechConfig, responseFormat (#3937, yinwu01).

The request now carries the keys magpie doesn't read or write
(Request.GenConfig), and one built for an upstream that speaks Gemini's
own API — the Gemini one, and Vertex AI — is sent them beside what magpie
rebuilt, as they were sent, camelCase and all (geminiCamel). A field
magpie sets itself stands: a draw model is still asked for
["TEXT","IMAGE"] whatever the client's own said. Code Assist's and
Antigravity's envelope is sent none of them: their spelling of these
fields isn't documented, and no other API takes Gemini's names.

candidateCount is not carried (changed in the port): magpie reads a
Gemini reply as one answer, and codeAssistDecoder runs every
candidate's parts into it, so a second candidate would be mixed into
the first answer's text. It stays dropped, as before.

Run (mote): go test -tags nogui -count=1 -run
'TestGeminiGenConfig|TestGeminiImageConfig|Gemini|Vertex|CodeAssist'
./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui
./internal/gateway/ clean.
Broken by hand: gemini.go put back to origin/main, both new tests FAIL
(nothing but magpie's own fields reached the relay); candidateCount
taken out of genReadOrBuilt, the reporter's-fields and snake_case cases
FAIL with candidateCount sent.
Not tried: a live Gemini API or Vertex AI key (none here); safetySettings
and cachedContent, top-level fields the issue also names, are still
dropped on a translated request.

Fixes #3937

Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:04:22 +08:00
..
…
…
…
…
…
…