From ea8104c6a25e69ebabd2112cb36e57b12189ec4a Mon Sep 17 00:00:00 2001 From: cagedbird043 Date: Tue, 24 Feb 2026 20:30:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20antigravity=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=A1=A5=E5=85=A8=20gemini-3-flash=20=E9=80=8F=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/service/account.go | 18 ++++++++++ .../internal/service/account_wildcard_test.go | 35 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/backend/internal/service/account.go b/backend/internal/service/account.go index 51ab84dd..6ac185dc 100644 --- a/backend/internal/service/account.go +++ b/backend/internal/service/account.go @@ -372,6 +372,9 @@ func (a *Account) GetModelMapping() map[string]string { } } if len(result) > 0 { + if a.Platform == domain.PlatformAntigravity { + ensureAntigravityDefaultPassthrough(result, "gemini-3-flash") + } return result } } @@ -382,6 +385,21 @@ func (a *Account) GetModelMapping() map[string]string { return nil } +func ensureAntigravityDefaultPassthrough(mapping map[string]string, model string) { + if mapping == nil || model == "" { + return + } + if _, exists := mapping[model]; exists { + return + } + for pattern := range mapping { + if matchWildcard(pattern, model) { + return + } + } + mapping[model] = model +} + // IsModelSupported 检查模型是否在 model_mapping 中(支持通配符) // 如果未配置 mapping,返回 true(允许所有模型) func (a *Account) IsModelSupported(requestedModel string) bool { diff --git a/backend/internal/service/account_wildcard_test.go b/backend/internal/service/account_wildcard_test.go index 90e5b573..c78ce554 100644 --- a/backend/internal/service/account_wildcard_test.go +++ b/backend/internal/service/account_wildcard_test.go @@ -267,3 +267,38 @@ func TestAccountGetMappedModel(t *testing.T) { }) } } + +func TestAccountGetModelMapping_AntigravityEnsuresGemini3FlashPassthrough(t *testing.T) { + account := &Account{ + Platform: PlatformAntigravity, + Credentials: map[string]any{ + "model_mapping": map[string]any{ + "gemini-3-pro-high": "gemini-3.1-pro-high", + }, + }, + } + + mapping := account.GetModelMapping() + if mapping["gemini-3-flash"] != "gemini-3-flash" { + t.Fatalf("expected gemini-3-flash passthrough to be auto-filled, got: %q", mapping["gemini-3-flash"]) + } +} + +func TestAccountGetModelMapping_AntigravityRespectsWildcardOverride(t *testing.T) { + account := &Account{ + Platform: PlatformAntigravity, + Credentials: map[string]any{ + "model_mapping": map[string]any{ + "gemini-3*": "gemini-3.1-pro-high", + }, + }, + } + + mapping := account.GetModelMapping() + if _, exists := mapping["gemini-3-flash"]; exists { + t.Fatalf("did not expect explicit gemini-3-flash passthrough when wildcard already exists") + } + if mapped := account.GetMappedModel("gemini-3-flash"); mapped != "gemini-3.1-pro-high" { + t.Fatalf("expected wildcard mapping to stay effective, got: %q", mapped) + } +}