gateway: Claude Desktop's Code tab and a build with no version keep the mythos alias (#2426)

67293346e gave Desktop the plain anthropic/magpie-<n> alias whenever its
User-Agent had no " Claude/<ver>". The Code tab's Claude Code calls with
"claude-cli/2.1.x (external, claude-desktop)" and current builds, so its
reasoning-level models lost their effort picker. desktopKnowsMythos is
now false only for a build whose version it reads and that is older
than 2; no version reads as a current build.

Run:
- On 67293346e's desktop.go the Code-tab UA listed
  anthropic/magpie-5487751739; with this it lists mythos-magpie-<n>.
- desktop_models_test: the old build gets the plain alias; the 2.7032
  UA, the claude-cli UA and "" get mythos-magpie-<n>.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider ok.
- gofmt clean; go vet -tags nogui darwin, linux, windows ok on gateway.
Full suite: gateway and provider only here; the release head runs ./... before its tag.
This commit is contained in:
yetone
2026-10-16 00:46:27 +08:00
parent 43fef06978
commit 39bebbbdf3
2 changed files with 23 additions and 14 deletions
+9 -6
View File
@@ -59,19 +59,22 @@ func desktopAccepts(id string) bool {
// it (its app.asar has neither mythos nor fable), so every reasoning-level
// model listed by mythos-magpie-<n> vanished from its menu
// (sublatesublate-design). The version a User-Agent names ("Mozilla/5.0 …
// Claude/2.7032.0 Chrome/…") is the only word magpie gets of the build: 2
// and up take mythos, anything older — or a version magpie cannot read —
// does not, and falls back to the plain alias every build keeps (no effort
// picker there, and those builds have no mythos effort table either).
// Claude/2.7032.0 Chrome/…") is the only word magpie gets of the build: one
// that says a version below 2 falls back to the plain alias every build
// keeps (no effort picker there, and those builds have no mythos effort
// table either). Anything else keeps the picker alias: 2 and up, and a
// request that names no build at all, as the Code tab's Claude Code
// ("claude-cli/… (external, claude-desktop)", known by its key) whose
// ids are mythos-magpie-<n> already.
var desktopUAVersion = regexp.MustCompile(` Claude/(\d+)`)
func desktopKnowsMythos(ua string) bool {
m := desktopUAVersion.FindStringSubmatch(ua)
if m == nil {
return false
return true
}
n, err := strconv.Atoi(m[1])
return err == nil && n >= 2
return err != nil || n >= 2
}
// desktopAlias is the prefix of the id a model is listed by to Claude
+14 -8
View File
@@ -241,7 +241,7 @@ func TestClaudeDesktopOldBuildModels(t *testing.T) {
const oldUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Claude/1.6608.2 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36"
// the old build keeps every model it is shown
for _, ua := range []string{oldUA, ""} {
for _, ua := range []string{oldUA} {
for catalog, id := range list(ua) {
if !oldBuildKeeps(id) {
t.Errorf("User-Agent %q: %s is listed as %s, which the build drops", ua, catalog, id)
@@ -249,15 +249,18 @@ func TestClaudeDesktopOldBuildModels(t *testing.T) {
}
}
// a 2.x build is still offered the effort picker
ids := list("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Claude/2.7032.0 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36")
if id := ids["opencode-go/deepseek-v4.1-flash"]; !regexp.MustCompile(`^mythos-magpie-\d{10}$`).MatchString(id) {
t.Errorf("2.7032.0: deepseek-v4.1-flash is listed as %q, want the mythos picker alias", id)
// a 2.x build is still offered the effort picker, and so is a request
// that names no build (the Code tab's Claude Code, known by its key)
for _, ua := range []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Claude/2.7032.0 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36", "claude-cli/2.1.295 (external, claude-desktop)", ""} {
if id := list(ua)["opencode-go/deepseek-v4.1-flash"]; !regexp.MustCompile(`^mythos-magpie-\d{10}$`).MatchString(id) {
t.Errorf("User-Agent %q: deepseek-v4.1-flash is listed as %q, want the mythos picker alias", ua, id)
}
}
}
// desktopKnowsMythos, by the version a User-Agent names: 2.x takes the
// mythos effort alias, anything older or unreadable does not.
// mythos effort alias, an older one does not, and a request naming no
// build is listed as before.
func TestDesktopKnowsMythos(t *testing.T) {
for _, c := range []struct {
ua string
@@ -267,8 +270,11 @@ func TestDesktopKnowsMythos(t *testing.T) {
{"Mozilla/5.0 … Claude/2 Chrome/…", true},
{"Mozilla/5.0 … Claude/1.6608.2 Chrome/… Safari/537.36", false},
{"Mozilla/5.0 … Claude/3.0.0 Chrome/… Safari/537.36", true},
{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", false},
{"", false},
// no build named (the Code tab's Claude Code, known by its key):
// listed as before, by the picker alias
{"claude-cli/2.1.295 (external, claude-desktop)", true},
{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", true},
{"", true},
} {
if got := desktopKnowsMythos(c.ua); got != c.want {
t.Errorf("desktopKnowsMythos(%q) = %v, want %v", c.ua, got, c.want)