fix(gemini): support snake_case thinking config fields from Python SDK

Google official Gemini Python SDK sends thinking_level, thinking_budget,
and include_thoughts (snake_case) instead of thinkingLevel, thinkingBudget,
and includeThoughts (camelCase). This caused thinking configuration to be
ignored when using Python SDK.

Changes:
- Extract layer: extractGeminiConfig now reads snake_case as fallback
- Apply layer: Gemini/CLI/Antigravity appliers clean up snake_case fields
- Translator layer: Gemini->OpenAI/Claude/Codex translators support fallback
- Tests: Added 4 test cases for snake_case field coverage

Fixes #1426
This commit is contained in:
neavo
2026-02-04 21:12:47 +08:00
parent 4874253d1e
commit 6c65fdf54b
8 changed files with 135 additions and 35 deletions

View File

@@ -1441,6 +1441,28 @@ func TestThinkingE2EMatrix_Body(t *testing.T) {
expectValue: "medium",
expectErr: false,
},
// Case 9001: thinking_budget=64000 (snake_case) → high (Gemini -> Codex)
{
name: "9001",
from: "gemini",
to: "codex",
model: "level-model",
inputJSON: `{"model":"level-model","contents":[{"role":"user","parts":[{"text":"hi"}]}],"generationConfig":{"thinkingConfig":{"thinking_budget":64000}}}`,
expectField: "reasoning.effort",
expectValue: "high",
expectErr: false,
},
// Case 9002: thinking_level=high (snake_case) → reasoning_effort=high (Gemini -> OpenAI)
{
name: "9002",
from: "gemini",
to: "openai",
model: "level-model",
inputJSON: `{"model":"level-model","contents":[{"role":"user","parts":[{"text":"hi"}]}],"generationConfig":{"thinkingConfig":{"thinking_level":"high"}}}`,
expectField: "reasoning_effort",
expectValue: "high",
expectErr: false,
},
// Case 11: Claude no param → passthrough (no thinking)
{
name: "11",
@@ -1451,6 +1473,17 @@ func TestThinkingE2EMatrix_Body(t *testing.T) {
expectField: "",
expectErr: false,
},
// Case 9003: thinking_budget=8192 (snake_case) → thinking.budget_tokens=8192 (Gemini -> Claude)
{
name: "9003",
from: "gemini",
to: "claude",
model: "level-model",
inputJSON: `{"model":"level-model","contents":[{"role":"user","parts":[{"text":"hi"}]}],"generationConfig":{"thinkingConfig":{"thinking_budget":8192}}}`,
expectField: "thinking.budget_tokens",
expectValue: "8192",
expectErr: false,
},
// Case 12: thinking.budget_tokens=8192 → medium
{
name: "12",
@@ -1524,6 +1557,19 @@ func TestThinkingE2EMatrix_Body(t *testing.T) {
// gemini-budget-model (Min=128, Max=20000, ZeroAllowed=false, DynamicAllowed=true)
// Case 9004: thinking_budget=8192 (snake_case) → passthrough+normalize to thinkingBudget (Gemini -> Gemini)
{
name: "9004",
from: "gemini",
to: "gemini",
model: "gemini-budget-model",
inputJSON: `{"model":"gemini-budget-model","contents":[{"role":"user","parts":[{"text":"hi"}]}],"generationConfig":{"thinkingConfig":{"thinking_budget":8192}}}`,
expectField: "generationConfig.thinkingConfig.thinkingBudget",
expectValue: "8192",
includeThoughts: "true",
expectErr: false,
},
// Case 18: No param → passthrough
{
name: "18",