fix(antigravity): default includeThoughts for modern Gemini models (#4180)

Integrated into release/v3.8.29 — default includeThoughts for modern Gemini (2.5+) in the openai->gemini translator, so the model's reasoning is marked thought:true and routed to reasoning_content instead of leaking into visible content (#4170). Thanks @dhaern! On review we regenerated the gemini golden snapshots (basic-chat/with-system) and committed the new modern-gemini-default-thinking snapshot. 61/61 translator + golden tests pass; eslint clean. Respects explicit client thinking config (only applies when none is set) and excludes gemini-1.x / non-thinking 2.0.
This commit is contained in:
Raxxoor
2026-06-18 18:16:59 +01:00
committed by GitHub
parent 4537fbe67b
commit 89cd954322
5 changed files with 100 additions and 5 deletions

View File

@@ -307,6 +307,26 @@ function openaiToGeminiBase(
};
}
// 3. Default: all modern Gemini models (2.5+) have thinking capability.
// If the client didn't explicitly request thinking (via reasoning_effort or
// thinking.type), still set includeThoughts so the upstream marks thought
// parts with thought:true. Without this, the model's reasoning leaks into
// visible content instead of being routed to reasoning_content by the
// response translator. (#4170)
if (!result.generationConfig.thinkingConfig) {
const modelLower = model.toLowerCase();
if (
modelLower.includes("gemini") &&
!modelLower.includes("gemini-1") &&
(!modelLower.includes("gemini-2.0") || modelLower.includes("thinking"))
) {
result.generationConfig.thinkingConfig = {
thinkingBudget: getDefaultThinkingBudget(model) || capThinkingBudget(model, 24576),
includeThoughts: true,
};
}
}
// Build tool_call_id -> name map
const tcID2Name: Record<string, string> = {};
const messages = body.messages as Array<Record<string, unknown>> | undefined;

View File

@@ -5,7 +5,12 @@
"targetFormat": "gemini",
"input": {
"model": "gemini-2.5-flash",
"messages": [{ "role": "user", "content": "Hello Gemini!" }]
"messages": [
{
"role": "user",
"content": "Hello Gemini!"
}
]
}
},
{
@@ -15,10 +20,30 @@
"input": {
"model": "gemini-2.5-pro",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Tell me a joke." }
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Tell me a joke."
}
],
"temperature": 0.7
}
},
{
"name": "openai-to-gemini/modern-gemini-default-thinking",
"sourceFormat": "openai",
"targetFormat": "gemini",
"input": {
"model": "gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": "Hello Gemini!"
}
]
}
}
]

View File

@@ -10,7 +10,11 @@
}
],
"generationConfig": {
"maxOutputTokens": 65536
"maxOutputTokens": 65536,
"thinkingConfig": {
"includeThoughts": true,
"thinkingBudget": 24576
}
},
"model": "gemini-2.5-flash",
"safetySettings": [

View File

@@ -0,0 +1,42 @@
{
"contents": [
{
"parts": [
{
"text": "Hello Gemini!"
}
],
"role": "user"
}
],
"generationConfig": {
"maxOutputTokens": 65536,
"thinkingConfig": {
"includeThoughts": true,
"thinkingBudget": 24576
}
},
"model": "gemini-2.5-flash",
"safetySettings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_CIVIC_INTEGRITY",
"threshold": "OFF"
}
]
}

View File

@@ -11,7 +11,11 @@
],
"generationConfig": {
"maxOutputTokens": 8192,
"temperature": 0.7
"temperature": 0.7,
"thinkingConfig": {
"includeThoughts": true,
"thinkingBudget": 24576
}
},
"model": "gemini-2.5-pro",
"safetySettings": [