Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions internal/registry/antigravity_model_fallbacks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package registry

import (
"encoding/json"
"slices"
"testing"
)

func TestAntigravityModelFallbacksYieldToRemoteCatalog(t *testing.T) {
original := getModels()
t.Cleanup(func() {
modelsCatalogStore.mu.Lock()
modelsCatalogStore.data = original
modelsCatalogStore.mu.Unlock()
})

var remote map[string][]map[string]any
if err := json.Unmarshal(embeddedModelsJSON, &remote); err != nil {
t.Fatal(err)
}
remote["antigravity"] = []map[string]any{
{"id": "gemini-4-argon-high", "display_name": "Remote Argon"},
{"id": "gemini-4-neon-high", "display_name": "Remote Neon"},
}
data, err := json.Marshal(remote)
if err != nil {
t.Fatal(err)
}
if _, err := publishCatalogBytes(data); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low · Shadowed publish error violates the repository naming rule

This initializer shadows the err declared by data, err := json.Marshal(remote) at line 25. AGENTS.md explicitly requires method-suffixed names for shadowed variables. Use a call-specific name such as errPublish for this new error binding.

t.Fatal(err)
}

models := make(map[string]*ModelInfo)
for _, model := range GetAntigravityModels() {
if models[model.ID] != nil {
t.Fatalf("duplicate model %q", model.ID)
}
models[model.ID] = model
}
for id, name := range map[string]string{
"gemini-4-argon-high": "Remote Argon",
"gemini-4-neon-high": "Remote Neon",
} {
if model := models[id]; model == nil || model.DisplayName != name {
t.Fatalf("%s = %+v, want remote display name %q", id, model, name)
}
}
for _, tier := range []string{"low", "medium"} {
model := models["gemini-4-neon-"+tier]
if model == nil || model.Thinking == nil || !slices.Equal(model.Thinking.Levels, []string{tier}) {
t.Fatalf("missing Neon %s fallback or incorrect reasoning levels: %+v", tier, model)
}
}
}
23 changes: 14 additions & 9 deletions internal/registry/model_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,41 @@ func GetCodexFreeModels() []*ModelInfo {

// GetCodexTeamModels returns model definitions for the Codex team plan tier.
func GetCodexTeamModels() []*ModelInfo {
return WithCodexBuiltins(withCodexPaidModelFallbacks(cloneModelInfos(getModels().CodexTeam)))
return WithCodexBuiltins(withModelFallbacks(cloneModelInfos(getModels().CodexTeam), codexPaidModelFallbacks))
}

// GetCodexPlusModels returns model definitions for the Codex plus plan tier.
func GetCodexPlusModels() []*ModelInfo {
return WithCodexBuiltins(withCodexPaidModelFallbacks(cloneModelInfos(getModels().CodexPlus)))
return WithCodexBuiltins(withModelFallbacks(cloneModelInfos(getModels().CodexPlus), codexPaidModelFallbacks))
}

// GetCodexProModels returns model definitions for the Codex pro plan tier.
func GetCodexProModels() []*ModelInfo {
return WithCodexBuiltins(withCodexPaidModelFallbacks(cloneModelInfos(getModels().CodexPro)))
return WithCodexBuiltins(withModelFallbacks(cloneModelInfos(getModels().CodexPro), codexPaidModelFallbacks))
}

//go:embed models/codex_paid_model_fallbacks.json
var embeddedCodexPaidModelFallbacksJSON []byte

var codexPaidModelFallbacks = parseCodexPaidModelFallbacks(embeddedCodexPaidModelFallbacksJSON)
var codexPaidModelFallbacks = parseModelFallbacks("codex_paid_model_fallbacks.json", embeddedCodexPaidModelFallbacksJSON)

func parseCodexPaidModelFallbacks(data []byte) []*ModelInfo {
func parseModelFallbacks(filename string, data []byte) []*ModelInfo {
var models []*ModelInfo
if err := json.Unmarshal(data, &models); err != nil {
log.Warnf("registry: failed to parse embedded codex_paid_model_fallbacks.json: %v", err)
log.Warnf("registry: failed to parse embedded %s: %v", filename, err)
return nil
}
return models
}

func withCodexPaidModelFallbacks(models []*ModelInfo) []*ModelInfo {
func withModelFallbacks(models, fallbacks []*ModelInfo) []*ModelInfo {
present := make(map[string]struct{}, len(models))
for _, model := range models {
if model != nil {
present[model.ID] = struct{}{}
}
}
for _, fallback := range codexPaidModelFallbacks {
for _, fallback := range fallbacks {
if _, exists := present[fallback.ID]; !exists {
models = append(models, cloneModelInfo(fallback))
}
Expand All @@ -117,9 +117,14 @@ func GetKimiModels() []*ModelInfo {
return cloneModelInfos(getModels().Kimi)
}

//go:embed models/antigravity_model_fallbacks.json
var embeddedAntigravityModelFallbacksJSON []byte

var antigravityModelFallbacks = parseModelFallbacks("antigravity_model_fallbacks.json", embeddedAntigravityModelFallbacksJSON)

// GetAntigravityModels returns the standard Antigravity model definitions.
func GetAntigravityModels() []*ModelInfo {
return cloneModelInfos(getModels().Antigravity)
return withModelFallbacks(cloneModelInfos(getModels().Antigravity), antigravityModelFallbacks)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Preserve fallback metadata for aliased Neon routes

When Neon is registered only under an OAuth alias with fork:false or a model prefix, execution resolves back to an upstream ID absent from the dynamic registry. LookupStaticModelInfo still scans raw data.Antigravity, so it cannot find these fallbacks. A reproduced high-effort Neon request consequently emits thinkingBudget:24576 instead of thinkingLevel:"high", bypassing the new level-only normalization. The effective fallback definitions also need to be available through static lookup.

}

var staticDevinModels = []*ModelInfo{
Expand Down
74 changes: 74 additions & 0 deletions internal/registry/models/antigravity_model_fallbacks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"id": "gemini-4-neon-low",
"object": "model",
"type": "antigravity",
"owned_by": "antigravity",
"name": "gemini-4-neon-low",
"display_name": "Gemini 4 Neon (Low)",
"context_length": 1048576,
"max_completion_tokens": 262144,
"thinking": {
"levels": [
"low"
]
},
"supportedInputModalities": [
"text",
"image",
"audio",
"video"
],
"supportedOutputModalities": [
"text"
]
},
{
"id": "gemini-4-neon-medium",
"object": "model",
"type": "antigravity",
"owned_by": "antigravity",
"name": "gemini-4-neon-medium",
"display_name": "Gemini 4 Neon (Medium)",
"context_length": 1048576,
"max_completion_tokens": 262144,
"thinking": {
"levels": [
"medium"
]
},
"supportedInputModalities": [
"text",
"image",
"audio",
"video"
],
"supportedOutputModalities": [
"text"
]
},
{
"id": "gemini-4-neon-high",
"object": "model",
"type": "antigravity",
"owned_by": "antigravity",
"name": "gemini-4-neon-high",
"display_name": "Gemini 4 Neon (High)",
"context_length": 1048576,
"max_completion_tokens": 262144,
"thinking": {
"levels": [
"high"
]
},
"supportedInputModalities": [
"text",
"image",
"audio",
"video"
],
"supportedOutputModalities": [
"text"
]
}
]
Loading