fix: FindModel reverse fuzzy match for date-suffixed model IDs
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Add step between exact ID match and forward fuzzy match that checks
if registry model ID starts with the requested name. Fixes models like
'gpt-5.4-mini' not matching 'gpt-5.4-mini-2026-04-01' in registry.
This commit is contained in:
2026-04-26 21:09:56 -04:00
parent 5e0c10db01
commit 1c3b1c6fe9
3 changed files with 31 additions and 2 deletions
+1 -1
View File
@@ -2,5 +2,5 @@
"files": {}, "files": {},
"turnCycles": 0, "turnCycles": 0,
"maxCycles": 3, "maxCycles": 3,
"lastUpdated": "2026-04-26T18:55:13.038Z" "lastUpdated": "2026-04-27T01:09:48.183Z"
} }
+10 -1
View File
@@ -56,7 +56,16 @@ func (r *ModelRegistry) FindModel(modelID string) *ModelMetadata {
} }
} }
// Try fuzzy matching (e.g. gpt-4o-2024-05-13 matching gpt-4o) // Try reverse fuzzy matching (e.g. 'gpt-5.4-mini' matching 'gpt-5.4-mini-2026-04-01')
for _, provider := range r.Providers {
for id, model := range provider.Models {
if strings.HasPrefix(id, modelID) {
return &model
}
}
}
// Try fuzzy matching (e.g. 'gpt-4o-2024-05-13' matching 'gpt-4o')
for _, provider := range r.Providers { for _, provider := range r.Providers {
for id, model := range provider.Models { for id, model := range provider.Models {
if strings.HasPrefix(modelID, id) { if strings.HasPrefix(modelID, id) {
+20
View File
@@ -58,3 +58,23 @@ func TestModelRegistry_FindModel_NotFound(t *testing.T) {
t.Fatal("expected nil for nonexistent model") t.Fatal("expected nil for nonexistent model")
} }
} }
func TestModelRegistry_FindModel_ReverseFuzzy(t *testing.T) {
r := &ModelRegistry{
Providers: map[string]ProviderInfo{
"openai": {
Models: map[string]ModelMetadata{
"gpt-5.4-mini-2026-04-01": {ID: "gpt-5.4-mini-2026-04-01", Name: "GPT-5.4 Mini"},
},
},
},
}
// Reverse fuzzy: "gpt-5.4-mini" should match "gpt-5.4-mini-2026-04-01"
m := r.FindModel("gpt-5.4-mini")
if m == nil {
t.Fatal("expected reverse fuzzy match")
}
if m.Name != "GPT-5.4 Mini" {
t.Fatalf("expected GPT-5.4 Mini, got %s", m.Name)
}
}