diff --git a/internal/runtime/executor/antigravity_executor.go b/internal/runtime/executor/antigravity_executor.go index 5433c00c..00959a22 100644 --- a/internal/runtime/executor/antigravity_executor.go +++ b/internal/runtime/executor/antigravity_executor.go @@ -71,8 +71,7 @@ func cloneAntigravityModels(models []*registry.ModelInfo) []*registry.ModelInfo if model == nil || strings.TrimSpace(model.ID) == "" { continue } - clone := *model - out = append(out, &clone) + out = append(out, cloneAntigravityModelInfo(model)) } if len(out) == 0 { return nil @@ -80,6 +79,27 @@ func cloneAntigravityModels(models []*registry.ModelInfo) []*registry.ModelInfo return out } +func cloneAntigravityModelInfo(model *registry.ModelInfo) *registry.ModelInfo { + if model == nil { + return nil + } + clone := *model + if len(model.SupportedGenerationMethods) > 0 { + clone.SupportedGenerationMethods = append([]string(nil), model.SupportedGenerationMethods...) + } + if len(model.SupportedParameters) > 0 { + clone.SupportedParameters = append([]string(nil), model.SupportedParameters...) + } + if model.Thinking != nil { + thinkingClone := *model.Thinking + if len(model.Thinking.Levels) > 0 { + thinkingClone.Levels = append([]string(nil), model.Thinking.Levels...) + } + clone.Thinking = &thinkingClone + } + return &clone +} + func storeAntigravityPrimaryModels(models []*registry.ModelInfo) bool { cloned := cloneAntigravityModels(models) if len(cloned) == 0 { diff --git a/internal/runtime/executor/antigravity_executor_models_cache_test.go b/internal/runtime/executor/antigravity_executor_models_cache_test.go index 94c0ef09..be49a7c1 100644 --- a/internal/runtime/executor/antigravity_executor_models_cache_test.go +++ b/internal/runtime/executor/antigravity_executor_models_cache_test.go @@ -44,7 +44,15 @@ func TestLoadAntigravityPrimaryModels_ReturnsClone(t *testing.T) { resetAntigravityPrimaryModelsCacheForTest() t.Cleanup(resetAntigravityPrimaryModelsCacheForTest) - if updated := storeAntigravityPrimaryModels([]*registry.ModelInfo{{ID: "gpt-5", DisplayName: "GPT-5"}}); !updated { + if updated := storeAntigravityPrimaryModels([]*registry.ModelInfo{{ + ID: "gpt-5", + DisplayName: "GPT-5", + SupportedGenerationMethods: []string{"generateContent"}, + SupportedParameters: []string{"temperature"}, + Thinking: ®istry.ThinkingSupport{ + Levels: []string{"high"}, + }, + }}); !updated { t.Fatal("expected model cache update") } @@ -53,6 +61,15 @@ func TestLoadAntigravityPrimaryModels_ReturnsClone(t *testing.T) { t.Fatalf("expected one cached model, got %d", len(got)) } got[0].ID = "mutated-id" + if len(got[0].SupportedGenerationMethods) > 0 { + got[0].SupportedGenerationMethods[0] = "mutated-method" + } + if len(got[0].SupportedParameters) > 0 { + got[0].SupportedParameters[0] = "mutated-parameter" + } + if got[0].Thinking != nil && len(got[0].Thinking.Levels) > 0 { + got[0].Thinking.Levels[0] = "mutated-level" + } again := loadAntigravityPrimaryModels() if len(again) != 1 { @@ -61,4 +78,13 @@ func TestLoadAntigravityPrimaryModels_ReturnsClone(t *testing.T) { if again[0].ID != "gpt-5" { t.Fatalf("expected cached model id to remain %q, got %q", "gpt-5", again[0].ID) } + if len(again[0].SupportedGenerationMethods) == 0 || again[0].SupportedGenerationMethods[0] != "generateContent" { + t.Fatalf("expected cached generation methods to be unmutated, got %v", again[0].SupportedGenerationMethods) + } + if len(again[0].SupportedParameters) == 0 || again[0].SupportedParameters[0] != "temperature" { + t.Fatalf("expected cached supported parameters to be unmutated, got %v", again[0].SupportedParameters) + } + if again[0].Thinking == nil || len(again[0].Thinking.Levels) == 0 || again[0].Thinking.Levels[0] != "high" { + t.Fatalf("expected cached model thinking levels to be unmutated, got %v", again[0].Thinking) + } }