Merge pull request #1816 from sususu98/fix/antigravity-adaptive-effort
fix(antigravity): pass through adaptive thinking effort level instead of always mapping to high
This commit is contained in:
@@ -441,15 +441,18 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.includeThoughts", true)
|
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.includeThoughts", true)
|
||||||
}
|
}
|
||||||
case "adaptive", "auto":
|
case "adaptive", "auto":
|
||||||
// Adaptive/auto thinking:
|
// For adaptive thinking:
|
||||||
// - If output_config.effort is present, pass it through as thinkingLevel.
|
// - If output_config.effort is explicitly present, pass through as thinkingLevel.
|
||||||
// - Otherwise, default to "high".
|
// - Otherwise, treat it as "enabled with target-model maximum" and emit high.
|
||||||
// ApplyThinking later normalizes/clamps and may convert level → budget per target model.
|
// ApplyThinking handles clamping to target model's supported levels.
|
||||||
effort := ""
|
effort := ""
|
||||||
if v := gjson.GetBytes(rawJSON, "output_config.effort"); v.Exists() && v.Type == gjson.String {
|
if v := gjson.GetBytes(rawJSON, "output_config.effort"); v.Exists() && v.Type == gjson.String {
|
||||||
effort = strings.ToLower(strings.TrimSpace(v.String()))
|
effort = strings.ToLower(strings.TrimSpace(v.String()))
|
||||||
}
|
}
|
||||||
if effort != "" {
|
if effort != "" {
|
||||||
|
if effort == "max" {
|
||||||
|
effort = "high"
|
||||||
|
}
|
||||||
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", effort)
|
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", effort)
|
||||||
} else {
|
} else {
|
||||||
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", "high")
|
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", "high")
|
||||||
|
|||||||
@@ -1199,3 +1199,64 @@ func TestConvertClaudeRequestToAntigravity_ToolAndThinking_NoExistingSystem(t *t
|
|||||||
t.Errorf("Interleaved thinking hint should be in created systemInstruction, got: %v", sysInstruction.Raw)
|
t.Errorf("Interleaved thinking hint should be in created systemInstruction, got: %v", sysInstruction.Raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertClaudeRequestToAntigravity_AdaptiveThinking_EffortLevels(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
effort string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"low", "low", "low"},
|
||||||
|
{"medium", "medium", "medium"},
|
||||||
|
{"high", "high", "high"},
|
||||||
|
{"max", "max", "high"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
inputJSON := []byte(`{
|
||||||
|
"model": "claude-opus-4-6-thinking",
|
||||||
|
"messages": [{"role": "user", "content": [{"type": "text", "text": "Hello"}]}],
|
||||||
|
"thinking": {"type": "adaptive"},
|
||||||
|
"output_config": {"effort": "` + tt.effort + `"}
|
||||||
|
}`)
|
||||||
|
|
||||||
|
output := ConvertClaudeRequestToAntigravity("claude-opus-4-6-thinking", inputJSON, false)
|
||||||
|
outputStr := string(output)
|
||||||
|
|
||||||
|
thinkingConfig := gjson.Get(outputStr, "request.generationConfig.thinkingConfig")
|
||||||
|
if !thinkingConfig.Exists() {
|
||||||
|
t.Fatal("thinkingConfig should exist for adaptive thinking")
|
||||||
|
}
|
||||||
|
if thinkingConfig.Get("thinkingLevel").String() != tt.expected {
|
||||||
|
t.Errorf("Expected thinkingLevel %q, got %q", tt.expected, thinkingConfig.Get("thinkingLevel").String())
|
||||||
|
}
|
||||||
|
if !thinkingConfig.Get("includeThoughts").Bool() {
|
||||||
|
t.Error("includeThoughts should be true")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConvertClaudeRequestToAntigravity_AdaptiveThinking_NoEffort(t *testing.T) {
|
||||||
|
inputJSON := []byte(`{
|
||||||
|
"model": "claude-opus-4-6-thinking",
|
||||||
|
"messages": [{"role": "user", "content": [{"type": "text", "text": "Hello"}]}],
|
||||||
|
"thinking": {"type": "adaptive"}
|
||||||
|
}`)
|
||||||
|
|
||||||
|
output := ConvertClaudeRequestToAntigravity("claude-opus-4-6-thinking", inputJSON, false)
|
||||||
|
outputStr := string(output)
|
||||||
|
|
||||||
|
thinkingConfig := gjson.Get(outputStr, "request.generationConfig.thinkingConfig")
|
||||||
|
if !thinkingConfig.Exists() {
|
||||||
|
t.Fatal("thinkingConfig should exist for adaptive thinking without effort")
|
||||||
|
}
|
||||||
|
if thinkingConfig.Get("thinkingLevel").String() != "high" {
|
||||||
|
t.Errorf("Expected default thinkingLevel \"high\", got %q", thinkingConfig.Get("thinkingLevel").String())
|
||||||
|
}
|
||||||
|
if !thinkingConfig.Get("includeThoughts").Bool() {
|
||||||
|
t.Error("includeThoughts should be true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user