What changed: #1520 prices the id an entry names as its canonical_model_id, but the capability tables only counted entries listed by an id, so the model behind the id was unknown all the same: gpt-5.6-cyber (OpenAI's gpt-daybreak-red-latest, canonical openai/gpt-5.6-cyber) had no window, reply limit, thinking, images or name — asked as given (WorkBuddy's shape) or behind a relay's prefix. An entry now votes for the canonical id it names too, when no catalog lists that id: one listed by its id keeps the answers it has. The per-entry vote moved into a closure (vote) whose branches are the ones it replaces, keyed the same for a listed id. Review (yetone's session): TestCanonicalOnlyIDCarriesItsMakerWord and the updated TestCanonicalIDIsNeverTakenForAnother fail on the previous catalog.go (window, reply limit, thinking, images and name all empty for gpt-5.6-cyber and claude-gpt-5.6-cyber; 0 and "" for claude-sonnet-4-0) and pass with it. The expectations were moved to the literal catalog: Daybreak Red's window is its input limit, 272000, not the 400000 context (as every listed model's is), and Cortecs's name is "Claude Sonnet 4 (latest)". A sweep of every listed and canonical id (plain, claude-, [1m]) through ContextOf, OutputOf, Thinks, SeesImages, NameOf, EffortsOf, Knows and PricedBy on the local models.dev cache, before and after: no answer for a listed id changed; the 23 canonical-only ids and their renames gained theirs. The full suite, gofmt and the cross-OS vets were run on the series. Author's run: the red/green above; go test -tags nogui ./internal/catalog ./internal/usage ./internal/provider green; go test -tags nogui ./... green but TestOffline (red on the baseline too) and TestSearchFollowsTheSearchersProxy (green alone); gofmt -l clean; go vet, GOOS=linux and GOOS=windows vet on internal/catalog clean. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
317 lines
13 KiB
Go
317 lines
13 KiB
Go
package catalog
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The reporter's own test (#1383, uWydnA): a relay renames
|
|
// deepseek-v4.1-flash claude-deepseek-v4.1-flash[1M], and the renamed
|
|
// model had no levels, no window and no images.
|
|
func TestRelayRenamedIDLosesCapabilities(t *testing.T) {
|
|
writeCatalog(t, `{
|
|
"deepseek": {"models": {"deepseek-v4.1-flash": {"id":"deepseek-v4.1-flash",
|
|
"reasoning_options":[{"type":"effort","values":["low","high","max"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"limit":{"context":1000000,"output":65536}}}}}`)
|
|
|
|
for _, id := range []string{"deepseek-v4.1-flash", "claude-deepseek-v4.1-flash[1M]"} {
|
|
t.Run(id, func(t *testing.T) {
|
|
if got := strings.Join(EffortsOf(id), ","); got != "low,high,max" {
|
|
t.Errorf("EffortsOf(%q) = %q, want low,high,max", id, got)
|
|
}
|
|
if got := ContextOf(id); got != 1000000 {
|
|
t.Errorf("ContextOf(%q) = %d, want 1000000", id, got)
|
|
}
|
|
if !SeesImages(id) {
|
|
t.Errorf("SeesImages(%q) = false, want true", id)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
const renamedCatalog = `{
|
|
"deepseek": {"name":"DeepSeek","models": {
|
|
"deepseek-v4.1-flash": {"id":"deepseek-v4.1-flash","name":"DeepSeek V4.1 Flash",
|
|
"reasoning_options":[{"type":"effort","values":["low","high","max"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"cost":{"input":0.3,"output":1.2},
|
|
"limit":{"context":1000000,"output":65536}}}},
|
|
"anthropic": {"name":"Anthropic","models": {
|
|
"claude-opus-5": {"id":"claude-opus-5","name":"Claude Opus 5","reasoning":true,
|
|
"reasoning_options":[{"type":"effort","values":["low","medium","high"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"cost":{"input":5,"output":25},
|
|
"limit":{"context":200000,"output":64000}}}},
|
|
"elsewhere": {"name":"Elsewhere","models": {
|
|
"opus-5": {"id":"opus-5","name":"Not Claude",
|
|
"reasoning_options":[{"type":"effort","values":["minimal"]}],
|
|
"limit":{"context":32000,"output":4000}},
|
|
"glm-5": {"id":"glm-5","name":"GLM-5","reasoning":true,
|
|
"reasoning_options":[{"type":"effort","values":["low","high"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"limit":{"context":200000,"output":8000}},
|
|
"claude-glm-5": {"id":"claude-glm-5","name":"Claude GLM 5",
|
|
"modalities":{"input":["text"],"output":["text"]},
|
|
"limit":{"context":64000,"output":4000}}}},
|
|
"model-oracle-ai": {"name":"Oracle","models": {
|
|
"model-oracle-ai/auto": {"id":"model-oracle-ai/auto","name":"Auto Router",
|
|
"reasoning_options":[{"type":"effort","values":["none","minimal","low","medium","high","xhigh","max"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"limit":{"context":2000000,"output":100000}}}},
|
|
"openai": {"name":"OpenAI","models": {
|
|
"gpt-5.5": {"id":"gpt-5.5","name":"GPT-5.5",
|
|
"reasoning_options":[{"type":"effort","values":["low","medium","high","xhigh"]}],
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"cost":{"input":1.25,"output":10},
|
|
"limit":{"context":400000,"output":128000}}}}
|
|
}`
|
|
|
|
// A relay's rename is matched by every getter, each of its forms, and a
|
|
// window mark names the window the relay serves it at.
|
|
func TestRelayRenameReachesEveryGetter(t *testing.T) {
|
|
writeCatalog(t, renamedCatalog)
|
|
|
|
for id, window := range map[string]int{
|
|
"claude-deepseek-v4.1-flash[1M]": 1_000_000,
|
|
"claude-deepseek-v4.1-flash[200K]": 200_000,
|
|
"claude-deepseek-v4.1-flash": 1_000_000,
|
|
"deepseek-v4.1-flash[1M]": 1_000_000,
|
|
"relay/claude-DeepSeek-V4.1-Flash": 1_000_000,
|
|
} {
|
|
t.Run(id, func(t *testing.T) {
|
|
if got := strings.Join(EffortsOf(id), ","); got != "low,high,max" {
|
|
t.Errorf("EffortsOf = %q", got)
|
|
}
|
|
if got := ContextOf(id); got != window {
|
|
t.Errorf("ContextOf = %d, want %d", got, window)
|
|
}
|
|
if got := OutputOf(id); got != 65536 {
|
|
t.Errorf("OutputOf = %d", got)
|
|
}
|
|
if !SeesImages(id) || !Thinks(id) || !Knows(id) {
|
|
t.Errorf("SeesImages %v, Thinks %v, Knows %v", SeesImages(id), Thinks(id), Knows(id))
|
|
}
|
|
if p, ok := PricedBy([]string{"deepseek"}, id); !ok || p.Input != 0.3 {
|
|
t.Errorf("PricedBy = %+v, %v", p, ok)
|
|
}
|
|
if e, ok := ListedBy([]string{"deepseek"}, id); !ok || strings.Join(e, ",") != "low,high,max" {
|
|
t.Errorf("ListedBy = %v, %v", e, ok)
|
|
}
|
|
})
|
|
}
|
|
// the name keeps the mark, so two of a relay's models apart by their
|
|
// window alone read apart
|
|
if got := NameOf("claude-deepseek-v4.1-flash[1M]"); got != "DeepSeek V4.1 Flash [1M]" {
|
|
t.Errorf("NameOf marked = %q", got)
|
|
}
|
|
if got := NameOf("claude-deepseek-v4.1-flash"); got != "DeepSeek V4.1 Flash" {
|
|
t.Errorf("NameOf = %q", got)
|
|
}
|
|
}
|
|
|
|
// Claude Code's own [1m] on a Claude model is that model at 1M: the mark
|
|
// comes off, the "claude-" stays (claude-opus-5[1m] is not "opus-5").
|
|
func TestClaude1MMarkIsTheClaudeModel(t *testing.T) {
|
|
writeCatalog(t, renamedCatalog)
|
|
|
|
if got := strings.Join(EffortsOf("claude-opus-5[1m]"), ","); got != "low,medium,high" {
|
|
t.Errorf("EffortsOf = %q", got)
|
|
}
|
|
if got := ContextOf("claude-opus-5[1m]"); got != 1_000_000 {
|
|
t.Errorf("ContextOf [1m] = %d", got)
|
|
}
|
|
if got := ContextOf("claude-opus-5"); got != 200_000 {
|
|
t.Errorf("ContextOf = %d", got)
|
|
}
|
|
if got := OutputOf("claude-opus-5[1m]"); got != 64000 {
|
|
t.Errorf("OutputOf = %d", got)
|
|
}
|
|
if p, ok := PricedBy([]string{"anthropic"}, "claude-opus-5[1m]"); !ok || p.Input != 5 {
|
|
t.Errorf("PricedBy = %+v, %v", p, ok)
|
|
}
|
|
if got := NameOf("claude-opus-5[1m]"); got != "Claude Opus 5 [1m]" {
|
|
t.Errorf("NameOf = %q", got)
|
|
}
|
|
}
|
|
|
|
// canonicalRenameCatalog is models.dev's api.json as fetched on 2026-10-11
|
|
// for the entries in the shape this is about: OpenAI lists its cyber model
|
|
// as gpt-daybreak-red-latest, canonically openai/gpt-5.6-cyber, the id the
|
|
// relays serve it under — and no catalog lists gpt-5.6-cyber by it (one of
|
|
// the canonical-only ids, as deepseek-v4.1-flash was before DeepSeek's own
|
|
// resellers listed it).
|
|
const canonicalRenameCatalog = `{
|
|
"openai": {"name":"OpenAI","models": {
|
|
"gpt-daybreak-red-latest": {"id":"gpt-daybreak-red-latest","name":"Daybreak Red","reasoning":true,
|
|
"modalities":{"input":["text","image"],"output":["text"]},
|
|
"cost":{"input":12.5,"output":75,"cache_read":1.25,"cache_write":15.625},
|
|
"limit":{"context":400000,"input":272000,"output":128000},
|
|
"canonical_model_id":"openai/gpt-5.6-cyber"}}}
|
|
}`
|
|
|
|
// A model models.dev publishes only as another entry's canonical_model_id
|
|
// is a model like a listed one, so a relay's rename of it renames too, and
|
|
// its price and a window mark go with the rename (#1520 on the id
|
|
// #1383's relays put their prefix in front of).
|
|
func TestRelayRenameReachesACanonicalOnlyID(t *testing.T) {
|
|
writeCatalog(t, canonicalRenameCatalog)
|
|
|
|
// the bare canonical id is priced by its maker's entry (#1520)
|
|
if p, ok := PricedBy([]string{"openai"}, "gpt-5.6-cyber"); !ok || p.Input != 12.5 {
|
|
t.Fatalf("PricedBy(gpt-5.6-cyber) = %+v, %v, want 12.5", p, ok)
|
|
}
|
|
for _, id := range []string{"claude-gpt-5.6-cyber", "gpt-5.6-cyber[1m]", "claude-gpt-5.6-cyber[1m]"} {
|
|
if p, ok := PricedBy([]string{"openai"}, id); !ok || p.Input != 12.5 {
|
|
t.Errorf("PricedBy(%q) = %+v, %v, want 12.5", id, p, ok)
|
|
}
|
|
}
|
|
// and the window mark on the renamed id names the window, as a listed
|
|
// model's does
|
|
if got := ContextOf("claude-gpt-5.6-cyber[1m]"); got != 1_000_000 {
|
|
t.Errorf("ContextOf(claude-gpt-5.6-cyber[1m]) = %d, want 1000000", got)
|
|
}
|
|
// a near miss of the canonical id is still no model
|
|
for _, id := range []string{"claude-gpt-5.6-cyberx", "claude-gpt-5.6", "gpt-5.6-cyber[fast]"} {
|
|
if p, ok := PricedBy([]string{"openai"}, id); ok {
|
|
t.Errorf("%q priced %+v", id, p)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The word an entry says of the model its canonical_model_id names is the
|
|
// model's, though no catalog lists the model by that id: Daybreak Red's
|
|
// entry is gpt-5.6-cyber, so its window, reply limit, thinking, images and
|
|
// name are gpt-5.6-cyber's — asked as given (WorkBuddy's shape, #1520) and
|
|
// behind a relay's prefix (#1383's).
|
|
func TestCanonicalOnlyIDCarriesItsMakerWord(t *testing.T) {
|
|
writeCatalog(t, canonicalRenameCatalog)
|
|
|
|
for _, id := range []string{"gpt-5.6-cyber", "claude-gpt-5.6-cyber"} {
|
|
if got := ContextOf(id); got != 272_000 {
|
|
t.Errorf("ContextOf(%q) = %d, want 272000", id, got)
|
|
}
|
|
if got := OutputOf(id); got != 128_000 {
|
|
t.Errorf("OutputOf(%q) = %d, want 128000", id, got)
|
|
}
|
|
if !Thinks(id) {
|
|
t.Errorf("Thinks(%q) = false, want true", id)
|
|
}
|
|
if !SeesImages(id) {
|
|
t.Errorf("SeesImages(%q) = false, want true", id)
|
|
}
|
|
if got := NameOf(id); got != "Daybreak Red" {
|
|
t.Errorf("NameOf(%q) = %q, want Daybreak Red", id, got)
|
|
}
|
|
}
|
|
// a listed model's answers are as they were: the daybreak entry's own
|
|
// id keeps its own window and name
|
|
if got := ContextOf("gpt-daybreak-red-latest"); got != 272_000 {
|
|
t.Errorf("ContextOf(gpt-daybreak-red-latest) = %d, want 272000", got)
|
|
}
|
|
if got := NameOf("gpt-daybreak-red-latest"); got != "Daybreak Red" {
|
|
t.Errorf("NameOf(gpt-daybreak-red-latest) = %q, want Daybreak Red", got)
|
|
}
|
|
}
|
|
|
|
// canonicalPrefixCatalog is models.dev's api.json as fetched on 2026-10-11
|
|
// for the entries in the shape the guard is about: Cortecs lists Claude's
|
|
// Sonnet 4 as claude-sonnet-4, canonically anthropic/claude-sonnet-4-0 —
|
|
// the canonical id itself starts with the prefix a relay puts in front —
|
|
// and no catalog lists claude-sonnet-4-0 by it (one of the canonical-only
|
|
// ids). A catalog naming a sonnet-4-0 of its own, here Drift's, must not
|
|
// take Claude's model for it.
|
|
const canonicalPrefixCatalog = `{
|
|
"cortecs": {"name":"Cortecs","models": {
|
|
"claude-sonnet-4": {"id":"claude-sonnet-4","name":"Claude Sonnet 4 (latest)",
|
|
"modalities":{"input":["text","image","pdf"],"output":["text"]},
|
|
"cost":{"input":2.989,"output":14.945,"cache_read":0.296,"cache_write":3.707},
|
|
"limit":{"context":200000,"output":65000},
|
|
"canonical_model_id":"anthropic/claude-sonnet-4-0"}}},
|
|
"drift": {"name":"Drift","models": {
|
|
"sonnet-4-0": {"id":"sonnet-4-0","name":"Drift Sonnet",
|
|
"modalities":{"input":["text"],"output":["text"]},
|
|
"cost":{"input":99,"output":99},
|
|
"limit":{"context":32000,"output":4000}}}}
|
|
}`
|
|
|
|
// A canonical id is a model as a listed one is, so it is never taken for
|
|
// another: claude-sonnet-4-0 starts with a relay's prefix, and what is left
|
|
// names a version, but the id is its own model, not Drift's sonnet-4-0.
|
|
func TestCanonicalIDIsNeverTakenForAnother(t *testing.T) {
|
|
writeCatalog(t, canonicalPrefixCatalog)
|
|
|
|
if p, ok := PricedBy([]string{"drift"}, "claude-sonnet-4-0"); ok {
|
|
t.Errorf("PricedBy(drift, claude-sonnet-4-0) = %+v, want none", p)
|
|
}
|
|
// what it carries is Claude's, as Cortecs's entry says of it, never
|
|
// Drift's
|
|
if got := ContextOf("claude-sonnet-4-0"); got != 200_000 {
|
|
t.Errorf("ContextOf(claude-sonnet-4-0) = %d, want 200000", got)
|
|
}
|
|
if got := NameOf("claude-sonnet-4-0"); got != "Claude Sonnet 4 (latest)" {
|
|
t.Errorf("NameOf(claude-sonnet-4-0) = %q, want Claude Sonnet 4 (latest)", got)
|
|
}
|
|
// the model the id is Drift's for keeps its own price, and a listed id
|
|
// in front of the prefix is priced by its own entry
|
|
if p, ok := PricedBy([]string{"drift"}, "sonnet-4-0"); !ok || p.Input != 99 {
|
|
t.Errorf("PricedBy(drift, sonnet-4-0) = %+v, %v, want 99", p, ok)
|
|
}
|
|
if p, ok := PricedBy([]string{"cortecs"}, "claude-sonnet-4"); !ok || p.Input != 2.989 {
|
|
t.Errorf("PricedBy(cortecs, claude-sonnet-4) = %+v, %v, want 2.989", p, ok)
|
|
}
|
|
}
|
|
|
|
// A listed id is always its own model, and a near miss is no model.
|
|
func TestRenameNeverTakesAModelForAnother(t *testing.T) {
|
|
writeCatalog(t, renamedCatalog)
|
|
|
|
// claude-glm-5 is listed: no levels, no images, its own window, though
|
|
// glm-5 has them
|
|
if got := EffortsOf("claude-glm-5"); got != nil {
|
|
t.Errorf("EffortsOf(claude-glm-5) = %v", got)
|
|
}
|
|
if SeesImages("claude-glm-5") || Thinks("claude-glm-5") {
|
|
t.Error("claude-glm-5 took glm-5's images or reasoning")
|
|
}
|
|
if got := ContextOf("claude-glm-5"); got != 64000 {
|
|
t.Errorf("ContextOf(claude-glm-5) = %d", got)
|
|
}
|
|
if got := NameOf("claude-glm-5"); got != "Claude GLM 5" {
|
|
t.Errorf("NameOf(claude-glm-5) = %q", got)
|
|
}
|
|
// the relay's own router is not models.dev's "auto" (the reporter's
|
|
// counter-example), and ids that only look like a known one match none
|
|
for _, id := range []string{
|
|
"claude-auto[1M]", "claude-auto",
|
|
"claude-deepseek-v4.1-flashy[1M]", "claude-deepseek-v4.1",
|
|
"deepseek-v4.1-flash[fast]", "deepseek-v4.1-flash[1M]x", "deepseek-v4.1-flash[infm]",
|
|
"anthropic-deepseek-v4.1-flash", "claude-claude-opus-5x",
|
|
"[1m]", "claude-[1m]",
|
|
} {
|
|
if e, c, i, n := EffortsOf(id), ContextOf(id), SeesImages(id), NameOf(id); e != nil || c != 0 || i || n != "" || Knows(id) {
|
|
t.Errorf("%q matched: efforts %v, context %d, images %v, name %q", id, e, c, i, n)
|
|
}
|
|
if p, ok := PricedBy([]string{"deepseek", "anthropic", "model-oracle-ai"}, id); ok {
|
|
t.Errorf("%q priced %+v", id, p)
|
|
}
|
|
}
|
|
// other vendors' known models are as they were
|
|
if got := strings.Join(EffortsOf("gpt-5.5"), ","); got != "low,medium,high,xhigh" {
|
|
t.Errorf("EffortsOf(gpt-5.5) = %q", got)
|
|
}
|
|
if ContextOf("openai/gpt-5.5") != 400000 || OutputOf("gpt-5.5") != 128000 || !SeesImages("gpt-5.5") {
|
|
t.Error("gpt-5.5 changed")
|
|
}
|
|
if got := EffortsOf("auto"); !slices.Contains(got, "xhigh") {
|
|
t.Errorf("EffortsOf(auto) = %v", got)
|
|
}
|
|
if got := strings.Join(EffortsOf("opus-5"), ","); got != "minimal" {
|
|
t.Errorf("EffortsOf(opus-5) = %q", got)
|
|
}
|
|
if got := ContextOf("glm-5"); got != 200000 {
|
|
t.Errorf("ContextOf(glm-5) = %d", got)
|
|
}
|
|
}
|