From 6db5e9d593de6c0adedd2be4ec13478d64ba4ecc Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 24 Oct 2026 16:19:30 +0800 Subject: [PATCH] usage: ClinePass's vmc/ name for the model asked is not a swap (zRain on Discord) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zRain (Discord, 10-24) sent Snow CLI through magpie to cline/cline-pass/deepseek-v4.1-flash-1017 and read the Routing row's "vmc/deepseek-v4p1-flash-101…" as the upstream, so the DeepSeek pin (cline plugin 0.1.11) looked ignored. That text is magpie's swap tag ("实际 vmc/…", "likely another model"): ClinePass answers a cline-pass/ model under its virtual model config's name, the version's dot written "p", and Swapped read deepseek-v4p1-flash as another model than deepseek-v4.1-flash. hy125245's pinned requests (finalProvider deepseek, X 10-23) carried the same vmc/ name, so the name says nothing about the upstream; the upstream is the "上游:…" tag after it, which the swap tag pushed out of a narrow row. Changed: usage.ServingName now includes ClineServing: served "vmc/" for a sent model with a cline-pass/ path, equal once "p" reads as ".". Scoped to ClinePass: the same vmc/ name for deepseek/… (not cline-pass/), another model (v4-pro answered as v4p1-flash, v4p1 vs v4p2, glm-5.3 vs glm-5p3-flash) and another prefix stay swaps. ServingName is what routedAgain and the ledger's kept rows already re-read, so routes and Requests rows kept marked swapped read as not swapped too. Facts checked, not changed: - The pin reaches ClinePass on every path. The real opencode-cline-auth 0.1.11 index.mjs, loaded in magpie's plugin host against a fake api.cline.bot (scratch wrapper over fetch, not committed), got providerOptions {gateway:{only:["deepseek"],has:["vision", "implicit-caching"]}} for a Snow-shaped streamed /v1/responses, a non-streamed one, /v1/chat/completions and /v1/messages, and the route's Upstream was the reply's finalProvider. - With the fake refusing the pin ("no matching upstream"), the plugin's one unpinned retry went out and the route showed the fallback's finalProvider as Upstream: a fallback would show as another "上游". - Vercel's AI Gateway lists deepseek for deepseek-v4.1-flash-1017 with vision and implicit-caching, so the has filter doesn't rule it out; "vmc" is not one of its providers. - @magpie-community plugins update by themselves hourly; npm has 0.1.11 since 10-23 14:18 UTC. Run at this commit, rebased on origin/main 3e9efe1d5: - gofmt -l, go vet (darwin), GOOS=linux and GOOS=windows go vet of ./internal/usage ./internal/gateway: clean. - go test -count=1 -timeout 45m ./...: ok, 70 packages, no FAIL (internal/gateway 544.996s) Broken by hand (ClineServing returning false), each red: TestSwappedClineServingName, TestKeptRowClineServingNameNotSwapped, TestRouteKeptClineServingNameNotSwapped; and the scratch real-plugin run marked all four routes Swapped. Not tried: a real ClinePass request (no Cline sign-in on this machine), so whether zRain's four rows had "上游:deepseek" after the vmc/ name is the reporter's to say; the GUI suite (no GUI file changed). --- internal/gateway/history_gemini_test.go | 18 +++++++++ internal/usage/served.go | 28 +++++++++++++- internal/usage/served_cline_test.go | 49 +++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 internal/usage/served_cline_test.go diff --git a/internal/gateway/history_gemini_test.go b/internal/gateway/history_gemini_test.go index 66ce06934..591fcb01c 100644 --- a/internal/gateway/history_gemini_test.go +++ b/internal/gateway/history_gemini_test.go @@ -34,3 +34,21 @@ func TestRouteKeptGrokServingNameNotSwapped(t *testing.T) { t.Fatalf("a real swap was cleared: %+v", r) } } + +// A route kept with a try marked swapped for ClinePass's +// cline-pass/deepseek-v4.1-flash-1017 answered as +// vmc/deepseek-v4p1-flash-1017 (its virtual model config's name, zRain on +// Discord) is read as not swapped; deepseek-v4-pro answered by +// vmc/deepseek-v4p1-flash stays swapped. +func TestRouteKeptClineServingNameNotSwapped(t *testing.T) { + r := &Route{Swapped: true, Served: "vmc/deepseek-v4p1-flash-1017", Tries: []Try{{Model: "cline-pass/deepseek-v4.1-flash-1017", Served: "vmc/deepseek-v4p1-flash-1017", Swapped: true, Upstream: "deepseek"}}} + r.routedAgain() + if r.Swapped || r.Tries[0].Swapped { + t.Fatalf("still swapped: %+v", r) + } + r = &Route{Swapped: true, Served: "vmc/deepseek-v4p1-flash", Tries: []Try{{Model: "cline-pass/deepseek-v4-pro", Served: "vmc/deepseek-v4p1-flash", Swapped: true}}} + r.routedAgain() + if !r.Swapped || !r.Tries[0].Swapped { + t.Fatalf("a real swap was cleared: %+v", r) + } +} diff --git a/internal/usage/served.go b/internal/usage/served.go index 39bfbc611..3130b530e 100644 --- a/internal/usage/served.go +++ b/internal/usage/served.go @@ -86,11 +86,35 @@ func RelayRenamed(sent, served string) bool { // ServingName reports whether served is the vendor's own name for the // deployment serving the model sent, which no request asks for by: Google's -// for a Gemini model (GeminiServing), xAI's for a Grok one (GrokServing). +// for a Gemini model (GeminiServing), xAI's for a Grok one (GrokServing), +// ClinePass's for one of its models (ClineServing). func ServingName(sent, served string) bool { - return GeminiServing(sent, served) || GrokServing(sent, served) + return GeminiServing(sent, served) || GrokServing(sent, served) || ClineServing(sent, served) } +// ClineServing reports whether served is ClinePass's name for the virtual +// model config ("vmc/") serving the cline-pass/ model sent: the model's +// own name, its version's dot written as "p". ClinePass answers +// cline-pass/deepseek-v4.1-flash-1017 as vmc/deepseek-v4p1-flash-1017 +// whichever upstream served it, DeepSeek's own API included +// (finalProvider "deepseek": hy125245 on X, 10-23), and the swap it was +// marked read as the request going to another provider (zRain on +// Discord, 10-24). It holds for ClinePass's models only, and for the same +// model: vmc/deepseek-v4p1-flash for cline-pass/deepseek-v4-pro is still +// a swap, as is a vmc/ name for a model not asked of ClinePass. +func ClineServing(sent, served string) bool { + s := strings.ToLower(strings.TrimSpace(served)) + if !strings.HasPrefix(s, "vmc/") || !strings.Contains(strings.ToLower(sent), "cline-pass/") { + return false + } + a := squash(bareModel(sent)) + return a != "" && squash(bareModel(vmcPoint.ReplaceAllString(s, "$1.$2"))) == a +} + +// vmcPoint is a version's dot as ClinePass's vmc/ names write it (v4p1 +// for v4.1), the part ClineServing reads past +var vmcPoint = regexp.MustCompile(`(\d)p(\d)`) + // GrokServing reports whether served is xAI's name for the build serving // the Grok model sent: the model's own name with "-build" after its // version. xAI answers grok-4.7 as grok-4.7-build, and grok-4.6 as diff --git a/internal/usage/served_cline_test.go b/internal/usage/served_cline_test.go new file mode 100644 index 000000000..0b24816d2 --- /dev/null +++ b/internal/usage/served_cline_test.go @@ -0,0 +1,49 @@ +package usage + +import "testing" + +// ClinePass answers a cline-pass/ model under its virtual model config's +// name, the version's dot written "p" (cline-pass/deepseek-v4.1-flash-1017 +// as vmc/deepseek-v4p1-flash-1017, hy125245 on X and zRain on Discord): +// the model asked for, whichever upstream served it. Another model under +// a vmc/ name, and a vmc/ name for a model not asked of ClinePass, are +// still swaps. +func TestSwappedClineServingName(t *testing.T) { + for _, c := range [][2]string{ + {"cline-pass/deepseek-v4.1-flash-1017", "vmc/deepseek-v4p1-flash-1017"}, + {"cline/cline-pass/deepseek-v4.1-flash-1017", "vmc/deepseek-v4p1-flash-1017"}, + {"cline-pass/deepseek-v4.1-flash", "vmc/deepseek-v4p1-flash"}, + {"cline-pass/deepseek-v4.1-flash", "VMC/DeepSeek-V4p1-Flash"}, + {"cline-pass/glm-5.3", "vmc/glm-5p3"}, + {"cline-pass/deepseek-v4-pro", "vmc/deepseek-v4-pro"}, + } { + if Swapped(c[0], c[1]) { + t.Errorf("%s answered as %s is the model asked for", c[0], c[1]) + } + } + for _, c := range [][2]string{ + {"cline-pass/deepseek-v4-pro", "vmc/deepseek-v4p1-flash"}, + {"cline-pass/deepseek-v4.1-flash", "vmc/deepseek-v4p1-pro"}, + {"cline-pass/deepseek-v4.1-flash", "vmc/deepseek-v4p2-flash"}, + {"cline-pass/glm-5.3", "vmc/glm-5p3-flash"}, + {"deepseek/deepseek-v4.1-flash", "vmc/deepseek-v4p1-flash"}, + {"cline-pass/deepseek-v4.1-flash", "other/deepseek-v4p1-flash"}, + } { + if !Swapped(c[0], c[1]) { + t.Errorf("%s answered as %s is another model", c[0], c[1]) + } + } +} + +// A row kept marked swapped before is read back as not swapped when +// ClinePass named its vmc/ config for the model; a real swap stays one. +func TestKeptRowClineServingNameNotSwapped(t *testing.T) { + c := &rowChunk{} + c.add(Row{Record: Record{Model: "cline-pass/deepseek-v4.1-flash-1017", Served: "vmc/deepseek-v4p1-flash-1017"}, Swapped: true}, "", 0, false) + c.add(Row{Record: Record{Model: "cline-pass/deepseek-v4-pro", Served: "vmc/deepseek-v4p1-flash"}, Swapped: true}, "", 1, false) + for _, chunk := range []*rowChunk{c, c.pack().unpack()} { + if chunk.row(0).Swapped || !chunk.row(1).Swapped { + t.Fatalf("serving name %v, another model %v", chunk.row(0).Swapped, chunk.row(1).Swapped) + } + } +}