From 9c09128e00d2f384bd248c54bec8d62be25c0134 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:12:55 +0800 Subject: [PATCH 1/2] feat(registry): add explicit thinking support config for antigravity models --- internal/registry/model_definitions.go | 13 ++++++++- .../runtime/executor/antigravity_executor.go | 28 ++++++++----------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/internal/registry/model_definitions.go b/internal/registry/model_definitions.go index 36aa83bb..64e78199 100644 --- a/internal/registry/model_definitions.go +++ b/internal/registry/model_definitions.go @@ -943,8 +943,19 @@ func GetQwenModels() []*ModelInfo { } } -// GetIFlowModels returns supported models for iFlow OAuth accounts. +// GetAntigravityThinkingConfig returns the Thinking configuration for antigravity models. +// Keys use the ALIASED model names (after modelName2Alias conversion) for direct lookup. +func GetAntigravityThinkingConfig() map[string]*ThinkingSupport { + return map[string]*ThinkingSupport{ + "gemini-2.5-flash": {Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, + "gemini-2.5-flash-lite": {Min: 0, Max: 24576, ZeroAllowed: true, DynamicAllowed: true}, + "gemini-3-pro-preview": {Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true}, + "gemini-claude-sonnet-4-5-thinking": {Min: 1024, Max: 200000, ZeroAllowed: false, DynamicAllowed: true}, + "gemini-claude-opus-4-5-thinking": {Min: 1024, Max: 200000, ZeroAllowed: false, DynamicAllowed: true}, + } +} +// GetIFlowModels returns supported models for iFlow OAuth accounts. func GetIFlowModels() []*ModelInfo { entries := []struct { ID string diff --git a/internal/runtime/executor/antigravity_executor.go b/internal/runtime/executor/antigravity_executor.go index 9fc4e722..ed9207f0 100644 --- a/internal/runtime/executor/antigravity_executor.go +++ b/internal/runtime/executor/antigravity_executor.go @@ -366,29 +366,25 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c } now := time.Now().Unix() + thinkingConfig := registry.GetAntigravityThinkingConfig() models := make([]*registry.ModelInfo, 0, len(result.Map())) - for id := range result.Map() { - id = modelName2Alias(id) - if id != "" { + for originalName := range result.Map() { + aliasName := modelName2Alias(originalName) + if aliasName != "" { modelInfo := ®istry.ModelInfo{ - ID: id, - Name: id, - Description: id, - DisplayName: id, - Version: id, + ID: aliasName, + Name: aliasName, + Description: aliasName, + DisplayName: aliasName, + Version: aliasName, Object: "model", Created: now, OwnedBy: antigravityAuthType, Type: antigravityAuthType, } - // Add Thinking support for thinking models - if strings.HasSuffix(id, "-thinking") || strings.Contains(id, "-thinking-") { - modelInfo.Thinking = ®istry.ThinkingSupport{ - Min: 1024, - Max: 100000, - ZeroAllowed: false, - DynamicAllowed: true, - } + // Look up Thinking support from static config using alias name + if thinking, ok := thinkingConfig[aliasName]; ok { + modelInfo.Thinking = thinking } models = append(models, modelInfo) } From a174d015f243973a329773a5bf0048578aff132a Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sun, 7 Dec 2025 19:14:05 +0800 Subject: [PATCH 2/2] feat(openai): handle thinking.budget_tokens from Anthropic-style requests --- .../chat-completions/antigravity_openai_request.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go b/internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go index d1914ec8..82e71758 100644 --- a/internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go +++ b/internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go @@ -88,6 +88,20 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _ } } + // Claude/Anthropic API format: thinking.type == "enabled" with budget_tokens + // This allows Claude Code and other Claude API clients to pass thinking configuration + if !gjson.GetBytes(out, "request.generationConfig.thinkingConfig").Exists() && util.ModelSupportsThinking(modelName) { + if t := gjson.GetBytes(rawJSON, "thinking"); t.Exists() && t.IsObject() { + if t.Get("type").String() == "enabled" { + if b := t.Get("budget_tokens"); b.Exists() && b.Type == gjson.Number { + budget := util.NormalizeThinkingBudget(modelName, int(b.Int())) + out, _ = sjson.SetBytes(out, "request.generationConfig.thinkingConfig.thinkingBudget", budget) + out, _ = sjson.SetBytes(out, "request.generationConfig.thinkingConfig.include_thoughts", true) + } + } + } + } + // For gemini-3-pro-preview, always send default thinkingConfig when none specified. // This matches the official Gemini CLI behavior which always sends: // { thinkingBudget: -1, includeThoughts: true }