catalog: a router's id (auto, free, default) is no one model

models.dev lists several vendors' routers under one bare id: openrouter/auto,
model-oracle-ai's auto, trustedrouter/auto, kilo-auto/free, openrouter/free…
bareID merged them into one "auto" and voted their levels, images and
window onto it, so every provider's own "auto" borrowed them. The 豆包工作
plugin's auto (Doubao picks the model) got reasoning_levels
none/low/medium/high, and pi's models.json a thinkingLevelMap for it.

vote now skips auto, default and free. A provider's own list (ListedBy)
still says what its router does. fast and balanced are routers too
(trustedrouter, Kilo) but stay voted: a vendor may name a real model so,
and TestNamedAvoidsCollisions / TestPickedNamesAvoidCollisions hold such
a "fast".

Run (mote, at 4f3ec591a + this):
- go test ./internal/catalog/ ./internal/provider/: ok (final set).
- go test ./internal/agent/ ./internal/gateway/ -timeout 45m: ok, with
  fast and balanced still in the set; not run again after narrowing it.
- GOOS=linux / GOOS=windows go vet ./internal/catalog/: ok. gofmt clean.
- Broken by hand (`if false && routerIDs[who]`):
  TestRenameNeverTakesAModelForAnother red, "auto took a router's:
  efforts [none minimal low medium high xhigh max], context 2000000,
  images true".
- Sandbox HOME with doubao-work 0.1.1 signed in: /v1/models has
  doubao-work/auto with reasoning_levels [], and `magpie pi
  doubao-work/auto` writes it to pi's models.json with no thinkingLevelMap.
Not tried: the full ./... suite, the GUI suite.
This commit is contained in:
yetone
2026-11-09 07:32:58 +08:00
parent 082ca55a32
commit bca122bf90
2 changed files with 21 additions and 2 deletions
+14
View File
@@ -655,6 +655,9 @@ func loadGen() (map[string]mdProvider, int) {
// deepinfra/…, xiaomi/…) votes its levels once, not
// once a host.
vote := func(who, own, by string, x mdModel) {
if routerIDs[who] {
return
}
spelt[who]++
if x.Name != "" && x.Name != own && x.Name != who {
if named[who] == nil {
@@ -1922,6 +1925,17 @@ func mostGiven(by map[int]int) int {
return best
}
// routerIDs are ids that name a vendor's router, not a model: OpenRouter's
// openrouter/auto, model-oracle-ai's auto, Kilo's kilo-auto/free and the
// rest are each their own, and a plugin's "auto" (豆包工作 picks Doubao's
// model) is none of them. Without a path they were taken for one model,
// and every provider's "auto" was given that model's levels, images and
// window: pi offered thinking levels and image input for 豆包工作's auto.
// What a provider's own list says of its router (ListedBy) still holds.
// Only ids no vendor gives a model are here: "fast" and "balanced" are
// trustedrouter's and Kilo's routers, but a vendor may name a model so.
var routerIDs = map[string]bool{"auto": true, "default": true, "free": true}
// bareID is a model's id without the vendor's prefix, lowercase.
func bareID(id string) string {
id = strings.ToLower(id)
+7 -2
View File
@@ -304,8 +304,13 @@ func TestRenameNeverTakesAModelForAnother(t *testing.T) {
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)
// a router's id is no one model: another vendor's "auto" takes none of
// model-oracle-ai's, whose own list still has its levels
if e, c, i := EffortsOf("auto"), ContextOf("auto"), SeesImages("auto"); e != nil || c != 0 || i || Thinks("auto") {
t.Errorf("auto took a router's: efforts %v, context %d, images %v", e, c, i)
}
if got, _ := ListedBy([]string{"model-oracle-ai"}, "auto"); !slices.Contains(got, "xhigh") {
t.Errorf("ListedBy(model-oracle-ai, auto) = %v", got)
}
if got := strings.Join(EffortsOf("opus-5"), ","); got != "minimal" {
t.Errorf("EffortsOf(opus-5) = %q", got)