routing: a model offered at a window (claude-haiku-5-5@1m) joins its model's found group (Will on Discord)

Will (0.1.4356, macOS, Cursor plugin) ticked claude-haiku-5-5@1m and
claude-fable-5-2@1m in Cursor: served, but never in auto/claude-haiku-5-5.
Cause: found groups merge by catalog.SameModel, which keeps everything
after an "@" except a snapshot date, so every sized id the Cursor plugin
lists (it lists Claude only as <model>@<size>) and grok's grok-4.7@500k
formed a key of its own and never met the unsized model at another
provider.

mergeKey now goes through mergeName = sameModel(windowless(id)):
windowless drops a window after "@" by the same patterns pricing already
reads as "the same model at that window" (modelWindow @<n>k|m, and Grok's
@<n>). It is the same model at the same price per token, and a group's
members already differ in window by provider, so it joins rather than
needing Same as. One member per provider still: its unsized model when it
lists one (grok-4.7 over grok-4.7@500k), else the first size it lists.
spelledIn lists the group by the windowless id; MergeName (the editor's
Same as placeholder) shows it. A Vertex @20260801 stays a snapshot date,
any other "@" (model@cf) stays as it is. catalog.SameModel is unchanged,
so models.dev lookups by spelling don't lend a 1M id the base's specs.

Run (mote, mote-run): go test -timeout 45m -count=1 ./internal/provider/...
./internal/catalog/... ./internal/gui/ ./internal/agent/...
./internal/gateway/... at 9d8d9c544 (same tree): all ok (gateway 1179s).
After rebase on a75a1fffc: ./internal/provider/... ./internal/catalog/...
ok at 174152481. gofmt -l clean.

Broken by hand: mergeName back to sameModel(id) ->
TestAutoGroupsJoinAModelAtItsWindow red (haiku/fable groups missing,
xai grok-4.7@131072 not a member); restored, green.

Not tried: a real Cursor account in the GUI (Routing page showing the
member), the GUI suite (no GUI file changed), Linux/Windows runs (pure
string logic). Note: routing a group request to Cursor's @1m member runs
Cursor in Max Mode for that size, as picking the model directly does.
This commit is contained in:
yetone
2026-11-17 19:20:18 +08:00
parent a75a1fffcb
commit f9492fd8ed
4 changed files with 118 additions and 12 deletions
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -224,13 +224,13 @@ func spelledIn(g Group, same map[string]string) string {
continue
}
if v := same[pid+"/"+m]; v != "" {
if "auto-"+Slug(sameModel(v)) == g.ID {
alike = append(alike, lastPart(v))
if "auto-"+Slug(mergeName(v)) == g.ID {
alike = append(alike, lastPart(windowless(v)))
}
continue
}
if "auto-"+Slug(sameModel(m)) == g.ID {
own = append(own, lastPart(m))
if "auto-"+Slug(mergeName(m)) == g.ID {
own = append(own, lastPart(windowless(m)))
}
}
// an id a relay lists as its display name ("GPT-6 Sol") is no id to
+45 -7
View File
@@ -853,20 +853,53 @@ func AutoGroupOf(pid, model string) string {
}
// MergeName is the name the groups magpie finds merge a model by, when
// the user said nothing of it: its id as vendors agree on it (sameModel).
func MergeName(model string) string { return sameModel(model) }
// the user said nothing of it: its id as vendors agree on it (sameModel),
// without a context window it is offered at (mergeName).
func MergeName(model string) string { return mergeName(model) }
// mergeKey is what the groups magpie finds merge pid's model by: the
// model the user said it is the same as (same, by "<provider>/<model>"),
// spelt as vendors agree on it, else its own id so spelt.
// spelt as vendors agree on it, else its own id so spelt (mergeName).
func mergeKey(pid, model string, same map[string]string) string {
if v := same[pid+"/"+model]; v != "" {
return sameModel(v)
return mergeName(v)
}
if v := editionTwins[pid+"/"+model]; v != "" {
return sameModel(v)
return mergeName(v)
}
return sameModel(model)
return mergeName(model)
}
// mergeName is id as vendors agree on it (sameModel), without the context
// window a plugin offers the model at (windowless): the Cursor plugin's
// claude-haiku-5-5@1m and claude-opus-5-5@300k, the grok plugin's
// grok-4.7@500k are each the same model, at the same price per token,
// asked for at a window of its own (modelWindow), so they join the group
// of claude-haiku-5-5 another provider serves (Will on Discord: ticking
// claude-haiku-5-5@1m in Cursor left auto/claude-haiku-5-5 without it).
// A group's members already differ in window by provider.
func mergeName(id string) string { return sameModel(windowless(id)) }
// windowless is id without the context window it names after an "@"
// (modelWindow, and a Grok one without its k: grokWindow); any other id,
// a Vertex snapshot's @20260801 included, as it is.
func windowless(id string) string {
if !strings.Contains(id, "@") {
return id
}
t := strings.TrimSpace(id)
l := strings.ToLower(t)
m := modelWindow.FindStringSubmatch(l)
if m == nil {
m = grokWindow.FindStringSubmatch(l)
}
if m == nil {
return id
}
if len(l) == len(t) {
return t[:len(m[1])] // as the vendor spells it
}
return m[1]
}
// editionTwins are the models a vendor's international edition lists
@@ -1016,11 +1049,16 @@ func autoGroups(entries []Entry, same map[string]string) []Group {
by := map[string][]Entry{}
for _, e := range entries {
k := mergeKey(e.Provider.ID, e.Model, same)
if !slices.ContainsFunc(by[k], func(o Entry) bool { return o.Provider.ID == e.Provider.ID }) {
i := slices.IndexFunc(by[k], func(o Entry) bool { return o.Provider.ID == e.Provider.ID })
if i < 0 {
if by[k] == nil {
order = append(order, k)
}
by[k] = append(by[k], e)
} else if o := by[k][i]; windowless(o.Model) != o.Model && windowless(e.Model) == e.Model {
// a provider that serves the model unsized and at a window
// (grok-4.7 and grok-4.7@500k) is in the group by the model
by[k][i] = e
}
}
var out []Group
+68
View File
@@ -0,0 +1,68 @@
package provider
import (
"slices"
"testing"
)
// A model a plugin offers at a context window of its own (Cursor's
// claude-haiku-5-5@1m, grok's grok-4.7@500k) is the same model: it joins
// the group magpie finds for it, listed by the model's own id (Will on
// Discord: ticking claude-haiku-5-5@1m in Cursor left it out of
// auto/claude-haiku-5-5).
func TestAutoGroupsJoinAModelAtItsWindow(t *testing.T) {
e := func(p, m string) Entry {
return Entry{ID: p + "/" + m, Model: m, Name: m, Provider: &Provider{ID: p}}
}
gs := autoGroups([]Entry{
e("anthropic", "claude-haiku-5-5"),
e("cursor-plugin", "claude-haiku-5-5@1m"),
e("relay", "claude-fable-5.2"),
e("cursor-plugin", "claude-fable-5-2@1m"),
e("cursor-plugin", "claude-fable-5-2@300k"),
e("grok", "grok-4.7@500k"),
e("grok", "grok-4.7"),
e("relay", "grok-4.7"),
e("xai", "grok-4.7@131072"),
e("vertex", "claude-opus-5-5@20260801"),
e("relay", "claude-opus-5-5"),
e("relay", "model@cf"),
e("other", "model"),
}, nil)
got := map[string][]string{}
spelled := map[string]string{}
for _, g := range gs {
got[g.ID] = g.Members
spelled[g.ID] = g.Spelled
}
want := map[string][]string{
"auto-claude-haiku-5-5": {"anthropic/claude-haiku-5-5", "cursor-plugin/claude-haiku-5-5@1m"},
// one member a provider: the first size it lists
"auto-claude-fable-5-2": {"relay/claude-fable-5.2", "cursor-plugin/claude-fable-5-2@1m"},
// a provider's unsized model over its sized one
"auto-grok-4-7": {"grok/grok-4.7", "relay/grok-4.7", "xai/grok-4.7@131072"},
"auto-claude-opus-5-5": {"vertex/claude-opus-5-5@20260801", "relay/claude-opus-5-5"},
}
if len(got) != len(want) {
t.Fatalf("groups %v, want %v", got, want)
}
for id, ms := range want {
if !slices.Equal(got[id], ms) {
t.Errorf("%s: members %v, want %v", id, got[id], ms)
}
}
// listed by the model, never by a window
if s := spelled["auto-claude-haiku-5-5"]; s != "claude-haiku-5-5" {
t.Errorf("auto-claude-haiku-5-5 spelled %q", s)
}
only := autoGroups([]Entry{e("cursor-plugin", "claude-opus-5-5@1m"), e("cursor-b", "claude-opus-5-5@300k")}, nil)
if len(only) != 1 || only[0].Spelled != "claude-opus-5-5" {
t.Errorf("a group of sized members only: %+v", only)
}
// what the Same as box shows a sized model merging by
for in, want := range map[string]string{"claude-haiku-5-5@1m": "claude-haiku-5-5", "Grok-4.7@500K": "grok-4-7", "claude-opus-5-5@20260801": "claude-opus-5-5", "model@cf": "model@cf"} {
if got := MergeName(in); got != want {
t.Errorf("MergeName(%q) = %q, want %q", in, got, want)
}
}
}