From 6fa3109ea738f078d19601117671eff6345dccc8 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 13 Oct 2026 13:08:15 +0800 Subject: [PATCH] qwen: /model names magpie's models as Names in agents' lists says (love1sbug on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The same report as the Claude Code fix before this one: Names in agents' lists changed nothing in Qwen Code. magpie wrote each catalog model's modelProviders.openai[].name as "magpie/", and Qwen's /model shows name as the row's label (the id beside it: @qwen-code/qwen-code's dialog, `label: model.name`), so the setting had nothing to change. qwenEntriesAt now writes the model's name as magpieModels gives it, provider.Labels: "pro · DeepSeek" with the setting On, "pro" Off, a name the user gave without its provider under Not on names I set. An entry is found by its id, never by name, so the user's own entries ("[IdeaLab] glm-5") and magpie's pick are unchanged. TestQwenNamesFollowSuffixMode walks On, Not on names I set, Off and On again through provider.SetSuffixMode with SyncCatalog and reads the names back; it fails on the old qwen.go. TestQwen finds its entry by id. Run: go test -tags nogui ./internal/agent ./internal/gui ./internal/provider; gofmt -l; go vet on darwin, GOOS=linux, GOOS=windows. Not tried: a real qwen in a sandbox HOME showing the new names. --- internal/agent/qwen.go | 6 ++++- internal/agent/qwen_test.go | 45 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/internal/agent/qwen.go b/internal/agent/qwen.go index c87bbdce1..616362eee 100644 --- a/internal/agent/qwen.go +++ b/internal/agent/qwen.go @@ -68,7 +68,11 @@ type qwenGen struct { func qwenEntriesAt(v1 string) []qwenEntry { var out []qwenEntry for _, m := range magpieModels("qwen") { - e := qwenEntry{ID: m.ID, Name: magpieID + "/" + m.ID, BaseURL: v1, EnvKey: qwenEnvKey} + // name is what /model shows, the id beside it when they differ: + // the model's name as every agent's list calls it, by the Provider + // in model names setting (magpie/ before, which none of the + // setting's ways changed) + e := qwenEntry{ID: m.ID, Name: m.Name, BaseURL: v1, EnvKey: qwenEnvKey} if m.Context > 0 { e.Generation = &qwenGen{ContextWindowSize: m.Context} } diff --git a/internal/agent/qwen_test.go b/internal/agent/qwen_test.go index 810fcc256..7dff5c3cd 100644 --- a/internal/agent/qwen_test.go +++ b/internal/agent/qwen_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "github.com/yetone/magpie/internal/catalog" "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/provider" ) @@ -130,7 +131,7 @@ func TestQwen(t *testing.T) { t.Errorf("%s missing: %v", id, order) continue } - if e["name"] != "magpie/"+id || e["baseUrl"] != gatewayV1() || e["envKey"] != "MAGPIE_QWEN_API_KEY" { + if e["name"] != listLabels("qwen")[id] || e["baseUrl"] != gatewayV1() || e["envKey"] != "MAGPIE_QWEN_API_KEY" { t.Errorf("%s: %v", id, e) } } @@ -153,9 +154,9 @@ func TestQwen(t *testing.T) { t.Fatalf("sync: %v", ms) } // something else rewrote magpie's entry: its baseUrl is the one - // before its name, as the fields are ordered + // before its id, as the fields are ordered cur := readFile(path) - at := strings.Index(cur, `"magpie/anth/claude-sonnet-5"`) + at := strings.Index(cur, `"id": "anth/claude-sonnet-5"`) base := strings.LastIndex(cur[:at], gatewayV1()) if base < 0 { t.Fatal("no baseUrl before the entry's name:\n" + cur) @@ -345,3 +346,41 @@ func TestQwenHomeOverride(t *testing.T) { t.Fatalf("override: %s %s", a.Dir, a.Path) } } + +// love1sbug on X: Names in agents' lists changed nothing in Qwen Code's +// /model, which shows an entry's name (the id beside it), as magpie named +// every entry magpie/. The name follows the setting now, written again +// as it changes. +func TestQwenNamesFollowSuffixMode(t *testing.T) { + _, path := qwenHome(t) + writeFile(t, path, qwenUser) + if err := provider.SetModelName("deepseek/flash", "Quick"); err != nil { + t.Fatal(err) + } + a, err := Find("qwen") + if err != nil { + t.Fatal(err) + } + if err := a.Apply("model", "magpie/deepseek/pro"); err != nil { + t.Fatal(err) + } + catalog.Changed = SyncCatalog + t.Cleanup(func() { catalog.Changed = nil }) + for _, c := range []struct{ mode, pro, flash string }{ + {provider.SuffixOn, "pro · DeepSeek", "Quick · DeepSeek"}, + {provider.SuffixOwn, "pro · DeepSeek", "Quick"}, + {provider.SuffixOff, "pro", "Quick"}, + {provider.SuffixOn, "pro · DeepSeek", "Quick · DeepSeek"}, + } { + if err := provider.SetSuffixMode(c.mode); err != nil { + t.Fatal(err) + } + ms, _, _ := qwenFile(t, path) + if ms["deepseek/pro"]["name"] != c.pro || ms["deepseek/flash"]["name"] != c.flash { + t.Fatalf("%s: %v / %v", c.mode, ms["deepseek/pro"], ms["deepseek/flash"]) + } + if ms["glm-5"]["name"] != "[IdeaLab] glm-5" { + t.Fatalf("%s: the user's entry renamed: %v", c.mode, ms["glm-5"]) + } + } +}