magpie icon indicating copy to clipboard operation
magpie copied to clipboard

[Bug] Claude Desktop Credentials Test 被误判为标题请求,命中已关闭 provider

Open EchoTint opened this issue 1 month ago • 6 comments

问题描述

Claude Desktop 已接入 Magpie 本地网关。GET /v1/models 可以成功返回当前启用供应商的模型,但 Gateway credentials → Test connection 会失败,并错误提示另一个已经关闭的供应商不可用。

当前现场:

  • Claude Desktop gateway:http://127.0.0.1:3425
  • 当前启用供应商:My Claude
  • 之前使用、现已关闭的供应商:Any
  • ~/.config/magpie/claude-desktop.model 仍保存:any/claude-fable-5-1-reversed
  • 复现基线:main@674b6ca2881f1289c4ccdec158762978a463320c

复现步骤

  1. 让 Claude Desktop 通过 Magpie 使用供应商 A 的模型,并运行一次会话。
  2. 在 Magpie 中关闭供应商 A。
  3. 保持供应商 B 开启,并让 Claude Desktop 能看到其模型。
  4. 打开 Developer → Configure Third-Party Inference。
  5. Models 连接测试成功,可以列出供应商 B 的模型。
  6. 执行 Gateway credentials → Test connection。

实际结果:

HTTP 404
Any is switched off in Magpie, so "my-claude/claude-sonnet-5-5" is not served; switch it on again in Magpie's Providers to use it

预期结果:Credentials Test 应测试当前配置发现或指定的模型,不应被旧会话中已关闭供应商的模型替换。

现场证据

当前 Claude Desktop 的 gateway health probe 是一个无 tools 的 1-token Anthropic Messages 请求:

{
  "model": "<discovered model>",
  "max_tokens": 1,
  "messages": [
    {"role": "user", "content": "."}
  ]
}

本机验证结果:

  • 使用当前 credential 请求 /v1/models 返回 HTTP 200,并列出 My Claude 模型。
  • 按 Claude Desktop 的 1-token probe 请求 /v1/messages,返回 HTTP 404,并错误指向已关闭的 Any。
  • 直接使用 canonical ID my-claude/claude-sonnet-5-5 进行同样 probe,仍得到相同 Any 错误。
  • 持久化文件 claude-desktop.model 中正是旧 Any 模型。

根因

当前 internal/gateway/desktop.go 中,desktopTurn 会把 Electron 发来的“无 tools、小输出、Claude-looking model”请求当成 Desktop 标题请求:

aside := small(body)
if byClaudeCode {
    aside = desktopTitle(body)
}
title := !tools && aside && desktopAccepts(asked)

small(body) 接受所有 max_tokens <= 4096 的请求。Credentials Test 恰好是 max_tokens: 1、无 tools、模型名看起来像 Claude,因此被误判成标题请求。随后 desktopTurn 使用 claude-desktop.model 中的旧会话模型替换当前 probe model,最终在 provider.SwitchedOff 处得到 Any 404。

这也解释了为什么 Models 测试成功,而 Credentials Test 失败:模型发现不经过 desktopTurn,推理 probe 会经过。

建议修复

使用已有的 desktopTitle(body) 对标题请求做正向识别,不再根据 max_tokens 猜测:

title := !tools && desktopTitle(body) && desktopAccepts(asked)

desktopTitle 已支持 Desktop 的字符串 system prompt 和 Claude Code 的 system text blocks。真实标题请求仍会跟随会话模型;Credentials Test、分类器和其他小请求继续使用它们明确指定的模型。

此后 desktopTurn 的 byClaudeCode 参数也不再需要,可以移除。本改动不增加网络、credential 或 provider 行为。

回归测试

已编写一个不访问网络的回归测试:

  • old/claude-fable-5-1:已关闭,并保存在 claude-desktop.model
  • current/claude-sonnet-5-5:已启用,由 1-token credential probe 指定

修复前:

--- FAIL: TestClaudeDesktopCredentialProbeKeepsItsModel
credential probe sent "old/claude-fable-5-1", want "current/claude-sonnet-5-5"
FAIL github.com/yetone/magpie/internal/gateway

修复后目标测试通过;以下相邻测试也通过:

TestClaudeDesktopAuxiliaryModel
TestClaudeDesktopDefault
TestClaudeDesktopClassifierKeepsItsModel
TestClaudeDesktopCredentialProbeKeepsItsModel
TestDesktopTitle

EchoTint avatar Oct 16 '26 03:10 EchoTint

接这单(hunt30 审计车道)。已在 main@7597c132 上核实根因:desktopTurn 的 small(body) 只看 max_tokens <= 4096,Desktop 的健康探测(max_tokens 1、无 tools、claude 形模型名)被当标题请求,带去 claude-desktop.model 里的旧会话模型,404。修法照报告里说的正向识别 desktopTitle(body),byClaudeCode 参数随之冗余移除。补丁稍后贴在本 issue,分支:hunt30-desktop-title(fork ggbdpq/magpie)。

Generated-by: GLM-5.3-Flash (ZCode)

ggbdpq avatar Oct 16 '26 03:10 ggbdpq

照报告的根因修了,红绿与消融都在 main@7597c132 上做过:

  • desktopTurn 不再拿 max_tokens <= 4096 当标题(small),改用 desktopTitle(body) 的正向识别:标题 prompt 的两种形状(Desktop 自有客户端的字符串 system、Claude Code --system-prompt 的 text block)都已在 desktopTitle 里。其余无 tools 的请求一律保留自己点名的模型——Claude Code 的分类器本来就是这个行为(#1539),Desktop 的探测现在也是。byClaudeCode 参数因此冗余,随补丁移除;small() 保留(observe.go 还在用)。
  • 回归 TestDesktopProbeKeepsItsModel:探测打在被服务的模型上、claude-desktop.model 里留着已关供应商的 pick——修前 404("Any is switched off in Magpie, so "fake/claude-sonnet-5" is not served; switch it on again…",与报告同形),修后探测用自己的模型、不写 pick;标题仍跟随会话 pick。
检查 结果
修前红(7597c132) 404 "Any is switched off in Magpie, so "fake/claude-sonnet-5" is not served…"
修后同测试 绿
消融(checkout 910522a7~1 的 desktop.go / gateway.go / desktop_turn_test.go,仅追加新测试) 回红,同上形状
TestDesktop* / TestClaudeDesktop* / TestHasTools(-tags nogui -p 2) ok
go test ./internal/gateway 全量(-tags nogui -p 2 -timeout 45m) ok,303.5s
gofmt -l internal/ 干净
go vet ./...(darwin / GOOS=linux -tags nogui / GOOS=windows) 干净(trayimage_darwin 的 cgo -Wenum-conversion 警告为本机已知环境噪音)
go build(darwin / linux nogui / windows) ok

补丁与分支:ggbdpq/magpie 分支 hunt30-desktop-title(基于 7597c132,提交 910522a7)。

没跑的:GUI 套件(改动不触 GUI);真实 Claude Desktop 的 Credentials Test(探测体按报告的 JSON 在 httptest 全链路复现);Desktop 的分支名请求(注释说与标题同一 prompt,desktopTitle 一并覆盖,无独立 fixture);gateway 之外的包测试(三平台 vet/build 全仓过)。

合入请保留原作者或加 Co-authored-by: ggbdpq <[email protected]>。

Generated-by: GLM-5.3-Flash (ZCode)

patch(910522a7)
From 910522a70b1633412cc8daf5edf3aebfb967b65e Mon Sep 17 00:00:00 2001
From: ggbdpq <[email protected]>
Date: Fri, 16 Oct 2026 11:58:31 +0800
Subject: [PATCH] gateway: Desktop's one-token probe keeps the model it names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Claude Desktop probes the gateway it is given before saving its
credentials: a one-token request, no tools, a model from /v1/models.
desktopTurn judged a tool-less request a session title by max_tokens
alone (small: at most 4096), so the probe went to the session's pick —
one a previous session left on a provider since switched off, and the
test came back "… is switched off in Magpie, so … is not served" naming
that provider, however healthy the model the probe asked for (#2473,
EchoTint). Models discovery answered fine, which made it look like the
credentials were at fault.

What changed:
- desktop.go: a title is the request whose system prompt is Desktop's
  title prompt (desktopTitle), whoever sent it — Desktop's own client,
  or Claude Code's `claude -p --system-prompt …` for it. Every other
  tool-less request keeps the model it names: Claude Code's classifiers
  did already (#1539), and now Desktop's probe does too. The
  byClaudeCode parameter said which of the two shapes to check and is
  gone; small stays for observe.go's kind.
- desktop_turn_test.go: TestDesktopProbeKeepsItsModel — the probe on a
  served model keeps it while a switched-off provider's pick stands
  (red on 7597c132e: 404 "Any is switched off in Magpie, so …"), the
  pick file survives it, and a title still follows the pick.

Run: GOTOOLCHAIN=auto go test -tags nogui -p 2 -count=1 over the
desktop family (TestDesktop*, TestClaudeDesktop*, TestHasTools): ok.
gofmt -l: clean. Three-platform vet and build below, with the issue.

Generated-by: GLM-5.3-Flash (ZCode)
---
 internal/gateway/desktop.go           | 39 ++++++-------
 internal/gateway/desktop_turn_test.go | 80 +++++++++++++++++++++++++--
 internal/gateway/gateway.go           |  2 +-
 3 files changed, 93 insertions(+), 28 deletions(-)

diff --git a/internal/gateway/desktop.go b/internal/gateway/desktop.go
index 5bd7d5c8..7f5b3a12 100644
--- a/internal/gateway/desktop.go
+++ b/internal/gateway/desktop.go
@@ -437,24 +437,23 @@ var desktopPicked struct {
 func desktopPickedPath() string { return filepath.Join(settings.Dir(), "claude-desktop.model") }
 
 // desktopTurn is the model a Claude Desktop request for asked is served by.
-// byClaudeCode is a request Claude Code sent (its claude-cli/ User-Agent)
-// rather than Desktop's own client. bySubagent is a subagent's request
-// (x-claude-code-agent-id): its turns carry tools too, but its model is
-// the one its tier or definition asked for, not the user's pick, so it is
-// never kept as the session's model. Before, a subagent on the opus tier's
-// model took the session's place until the lead's next turn, and the
-// titles asked for meanwhile went to it.
+// bySubagent is a subagent's request (x-claude-code-agent-id): its turns
+// carry tools too, but its model is the one its tier or definition asked
+// for, not the user's pick, so it is never kept as the session's model.
+// Before, a subagent on the opus tier's model took the session's place
+// until the lead's next turn, and the titles asked for meanwhile went to it.
 //
-// Claude Code names the model of each of its own background requests on
-// purpose: its auto mode's safety classifier asks for its sonnet with no
-// tools and a max_tokens of 64 or 256, its notification classifier with
-// 1024 (#1539, tete1030). So a tool-less request from it goes to the
-// session's model only when it is Desktop's title, which Desktop asks
-// Claude Code for when its own request fails (`claude -p --model <its
-// pick> --system-prompt "You write short session titles…" --tools ""`,
-// sent with max_tokens 64000); one for a model magpie doesn't serve still
-// goes there whoever sent it.
-func desktopTurn(asked string, body []byte, byClaudeCode, bySubagent bool) string {
+// A title goes to the session's model, and is known by its prompt
+// ("You write short session titles…"), whoever sent it: Desktop's own
+// client, or Claude Code, which Desktop asks it for when its own request
+// fails (`claude -p --model <its pick> --system-prompt "You write short
+// session titles…" --tools ""`, sent with max_tokens 64000). Every other
+// tool-less request keeps the model it names — Claude Code's background
+// classifiers ask for their own sonnet with a max_tokens of 64, 256 or
+// 1024 (#1539, tete1030), and Desktop's own client probes the gateway
+// with one token and a model from /v1/models (#2473, EchoTint). A request
+// for a model magpie doesn't serve still goes to the session's model.
+func desktopTurn(asked string, body []byte, bySubagent bool) string {
 	if asked == "" {
 		return asked
 	}
@@ -472,11 +471,7 @@ func desktopTurn(asked string, body []byte, byClaudeCode, bySubagent bool) strin
 	if asked == picked {
 		return asked
 	}
-	aside := small(body)
-	if byClaudeCode {
-		aside = desktopTitle(body)
-	}
-	title := !tools && aside && desktopAccepts(asked)
+	title := !tools && desktopTitle(body) && desktopAccepts(asked)
 	gone := unserved(asked)
 	if gone && !title {
 		if m := servedBeside(asked, picked); m != "" {
diff --git a/internal/gateway/desktop_turn_test.go b/internal/gateway/desktop_turn_test.go
index 4399f35e..d6327d97 100644
--- a/internal/gateway/desktop_turn_test.go
+++ b/internal/gateway/desktop_turn_test.go
@@ -7,6 +7,7 @@ import (
 	"testing"
 
 	"github.com/yetone/magpie/internal/provider"
+	"github.com/yetone/magpie/internal/settings"
 )
 
 // Claude Desktop's session titles (and Claude Code's small tasks in its
@@ -134,7 +135,7 @@ func TestClaudeDesktopDefault(t *testing.T) {
 	if got := desktopDefault("fake/m1"); got != "" {
 		t.Fatalf("default for the first model itself = %q", got)
 	}
-	if got := desktopTurn("claude-haiku-4-5", title, false, false); got != "fake/m1" {
+	if got := desktopTurn("claude-haiku-4-5", title, false); got != "fake/m1" {
 		t.Fatalf("title = %q", got)
 	}
 	StandIn = func(agent, model string) string {
@@ -144,11 +145,11 @@ func TestClaudeDesktopDefault(t *testing.T) {
 		return ""
 	}
 	t.Cleanup(func() { StandIn = nil })
-	if got := desktopTurn("claude-haiku-4-5", title, false, false); got != "fake/claude-opus-4-8" {
+	if got := desktopTurn("claude-haiku-4-5", title, false); got != "fake/claude-opus-4-8" {
 		t.Fatalf("title with a stand-in = %q", got)
 	}
 	// a session on a real Claude model magpie serves keeps it
-	if got := desktopTurn("fake/claude-opus-4-8", turn, false, false); got != "fake/claude-opus-4-8" {
+	if got := desktopTurn("fake/claude-opus-4-8", turn, false); got != "fake/claude-opus-4-8" {
 		t.Fatalf("turn = %q", got)
 	}
 }
@@ -249,14 +250,14 @@ func TestDesktopSubagentTurnKeepsSessionPick(t *testing.T) {
 		{"fake/m2", true, "fake/m1"},
 		{"fake/m2", false, "fake/m2"},
 	} {
-		if got := desktopTurn(turn.model, body, true, turn.sub); got != turn.model {
+		if got := desktopTurn(turn.model, body, turn.sub); got != turn.model {
 			t.Fatalf("turn sent %q, want %q", got, turn.model)
 		}
 		if b, err := os.ReadFile(desktopPickedPath()); err != nil || strings.TrimSpace(string(b)) != turn.picked {
 			t.Fatalf("subagent %v: picked %q, want %q (%v)", turn.sub, b, turn.picked, err)
 		}
 	}
-	if got := desktopTurn("claude-haiku-unserved", body, true, true); got != "fake/m2" {
+	if got := desktopTurn("claude-haiku-unserved", body, true); got != "fake/m2" {
 		t.Fatalf("unserved subagent sent %q, want the session's model", got)
 	}
 }
@@ -303,3 +304,72 @@ func TestDesktopSubagentTurnLeavesTitleOnLead(t *testing.T) {
 		t.Fatalf("title after a subagent's turn: sent %q, want the lead's m1", got)
 	}
 }
+
+// Desktop's own client probes the gateway it is given with a one-token
+// request with no tools and a model from /v1/models (its Credentials
+// test). That probe is not a session title and keeps the model it names:
+// max_tokens alone said "title", so it went to the session's pick, and a
+// pick left by an earlier session's provider — since switched off — came
+// back as a 404 naming that provider (#2473, EchoTint).
+func TestDesktopProbeKeepsItsModel(t *testing.T) {
+	f := &fake{reply: sse(
+		`event: message_start`+"\n"+`data: {"type":"message_start","message":{"id":"m","type":"message","role":"assistant","model":"claude-sonnet-5","content":[],"usage":{"input_tokens":1,"output_tokens":0}}}`,
+		`event: message_stop`+"\n"+`data: {"type":"message_stop"}`)}
+	up := setup(t, provider.Anthropic, f)
+	if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Key: "k", Anthropic: up.URL,
+		Models: []string{"claude-sonnet-5"}}); err != nil {
+		t.Fatal(err)
+	}
+	desktopPicked.Lock()
+	desktopPicked.model, desktopPicked.from = "", ""
+	desktopPicked.Unlock()
+	// a session that ran on the provider "any" left its model there; the
+	// provider has since been switched off
+	if err := provider.Save(provider.Provider{ID: "any", Name: "Any", Key: "k", Anthropic: "http://127.0.0.1:1",
+		Models: []string{"claude-fable-5-1-reversed"}, Off: true}); err != nil {
+		t.Fatal(err)
+	}
+	if err := os.MkdirAll(settings.Dir(), 0o755); err != nil {
+		t.Fatal(err)
+	}
+	if err := os.WriteFile(desktopPickedPath(), []byte("any/claude-fable-5-1-reversed\n"), 0o600); err != nil {
+		t.Fatal(err)
+	}
+	const electron = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Claude/1.6608.0 Chrome/142.0.7444.235 Electron/39.2.7 Safari/537.36"
+	f.got = nil
+	req := httptest.NewRequest("POST", "/v1/messages", strings.NewReader(`{"model":"fake/claude-sonnet-5","max_tokens":1,"stream":true,"messages":[{"role":"user","content":"."}]}`))
+	req.Header.Set("x-api-key", Token+"-claude-desktop")
+	req.Header.Set("User-Agent", electron)
+	rec := httptest.NewRecorder()
+	New().Handler().ServeHTTP(rec, req)
+	if rec.Code != 200 {
+		t.Fatalf("probe: %d %.200s", rec.Code, rec.Body)
+	}
+	if got := modelOf(f.got); got != "claude-sonnet-5" {
+		t.Fatalf("probe sent %q, want claude-sonnet-5", got)
+	}
+	// a probe is no session: the pick stands
+	if b, err := os.ReadFile(desktopPickedPath()); err != nil || strings.TrimSpace(string(b)) != "any/claude-fable-5-1-reversed" {
+		t.Fatalf("pick %q, want the stale one kept (%v)", b, err)
+	}
+	// and a title, known by its prompt, still follows the session's pick:
+	// here a session the fake serves
+	if err := os.WriteFile(desktopPickedPath(), []byte("fake/claude-sonnet-5\n"), 0o600); err != nil {
+		t.Fatal(err)
+	}
+	desktopPicked.Lock()
+	desktopPicked.model, desktopPicked.from = "", ""
+	desktopPicked.Unlock()
+	f.got = nil
+	title := httptest.NewRequest("POST", "/v1/messages", strings.NewReader(`{"model":"claude-sonnet-5","max_tokens":200,"stream":true,"system":"You write short session titles. Reply with only the tagged fields the prompt asks for.","messages":[{"role":"user","content":"hi"}]}`))
+	title.Header.Set("x-api-key", Token+"-claude-desktop")
+	title.Header.Set("User-Agent", electron)
+	rec = httptest.NewRecorder()
+	New().Handler().ServeHTTP(rec, title)
+	if rec.Code != 200 {
+		t.Fatalf("title: %d %.200s", rec.Code, rec.Body)
+	}
+	if got := modelOf(f.got); got != "claude-sonnet-5" {
+		t.Fatalf("title sent %q, want the session's pick", got)
+	}
+}
diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go
index 7a309f9a..bcf4e948 100644
--- a/internal/gateway/gateway.go
+++ b/internal/gateway/gateway.go
@@ -1598,7 +1598,7 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro
 	asked = call.Model
 	if agent == "claude-desktop" {
 		sub, _ := subagentOf(r.Header)
-		asked = desktopTurn(asked, body, fromClaudeCode(r.Header), sub != "")
+		asked = desktopTurn(asked, body, sub != "")
 	} else if agent == ScienceID {
 		asked = scienceTurn(asked, body)
 	}
-- 
2.50.1 (Apple Git-155)

ggbdpq avatar Oct 16 '26 04:10 ggbdpq

Reproduced the stale-provider part of this issue on macOS with packaged Magpie 0.1.1296 and Claude Desktop 2.42304.2.

In this case provider A was still enabled globally, but Claude Desktop had been restricted to provider B. GET /v1/models correctly listed only B. claude-desktop.model still contained an A model, and the Desktop startup probe for B's Haiku alias was sent to A's Opus model. The returned 502 named A. The gateway usage record confirmed req=B/claude-haiku-5-5, provider=A, model=claude-opus-5-5.

The caller was Claude Desktop and the probe body was:

{"model":"<B's Haiku alias>","max_tokens":1,"messages":[{"role":"user","content":"."}]}

So validation against the globally enabled providers alone is not sufficient: a cached pick can also be outside the current Desktop-visible catalog. An explicit connection probe should retain its selected provider/model and should not mutate the session's pick. This supports the positive title-prompt identification fix proposed above.

Separately, this environment also has a credential-specific upstream refusal of raw HTTP probes. Replaying that same minimal request directly to the configured upstream, bypassing Magpie, returns 429, while a genuine Claude Code invocation through the identical proxy and credential succeeds. That is a separate compatibility problem, not evidence that the stale-provider routing fix failed. No credentials, prompts from real work, proxy authentication details, or account identifiers are included here.

SivanCola avatar Oct 20 '26 10:10 SivanCola

Gentle nudge on this one — no rush. The fix (branch hunt30-desktop-title, head 910522a7) still applies cleanly to current main. Since it was posted, SivanCola reproduced the stale-provider half of the report on macOS with packaged Magpie 0.1.1296 and Claude Desktop 2.42304.2, which lands right on the behavior this addresses: the title probe went to a provider a previous session had left behind instead of the model it was asked about, so desktopTurn now recognizes the title prompt by its shape instead of trusting max_tokens. Happy to adjust if anything is missing.

Nudged with AI assistance (GLM-5.3-Flash via ZCode).

ggbdpq avatar Oct 22 '26 15:10 ggbdpq

Published a fix in my fork: https://github.com/skygunner/magpie/commit/9fd7a9d4c087d3c0f4caac1ff3d27a8350577744

Thanks to @ggbdpq for the diagnosis and posted fix above, credited as co-author. Desktop titles now use the existing positive system-prompt check (desktopTitle) for both Electron and Claude Code. A small max_tokens alone no longer reroutes a credential probe to the saved session model. The unused client-kind argument is removed from desktopTurn and all callers, and the routing reference documents the contract.

The HTTP regression is adapted from the posted fixture and covers the old provider both on and off, with streaming and non-streaming probes. It checks the requested model reaches the local backend and that the saved pick remains unchanged; a title control still follows the session pick. On the old product code the streaming cases fail with the same stale-provider 404 (off) and an attempted connection to that provider (on, 502). Fixed Desktop/ClaudeDesktop/HasTools tests pass under -race -count=5.

At this exact head, all seven acceptance commands passed with Go1.26.8, isolated HOME and pinned caches: native Linux vet/build, Linux nogui vet/build, Windows vet/build, and go test -tags nogui ./... -count=1 -timeout=45m (69 packages). Gofmt and whitespace checks are clean.

Combined branch: https://github.com/skygunner/magpie/tree/fix/issue-batch-20261023-t

Not checked: real Claude Desktop's credential dialog, a live provider, macOS/Windows runtime, or the Desktop-visible-catalog restriction itself. The fixture uses the reported probe shape and existing test backend; it does not simulate the separate upstream raw-probe refusal. No live gateway/config changed and no upstream PR opened.

skygunner avatar Oct 23 '26 00:10 skygunner

Verified — 9fd7a9d4 applies clean (git apply --3way --check) to current main (e00fbdbb, checked 2026-10-23; its merge-base 63be4771 took a 444-commit wave in between without touching the site), with the exact trailer Co-authored-by: ggbdpq <[email protected]> in the commit message. The product change is my 910522a7's: the title line title := !tools && desktopTitle(body) && desktopAccepts(asked) and the byClaudeCode removal (signature and call site) are byte-identical to mine, with the comments shortened but the same facts; small is rightly kept for observe.go, and fromClaudeCode's three other callers are untouched. The regression adapts my fixture and extends it from one case to four — old provider off/on, streaming and non-streaming — keeping the pick-file-stays assertions and the real-title control, plus a docs bullet and a fixture touch-up that keeps an existing title case on the title path.

With desktop.go and gateway.go reverted to tip and the new test kept, all four cases fail with the report's shapes, and pass with the fix back:

probe: 404 {"error":{"message":"Any is switched off in Magpie, so \"fake/claude-sonnet-5\" is not served; switch it on again in Magpie's Providers to use it",...}}
probe: 502 {"error":{"message":"Any: Post \"http://127.0.0.1:1/v1/messages\": dial tcp 127.0.0.1:1: connectex: No connection could be made because the target machine actively refused it.",...}}

— the 404 is the report's own error; the 502 is the stale-provider connection attempt SivanCola reproduced on macOS. The Desktop family around it (TestDesktop*, TestClaudeDesktop*, TestHasTools): ok. gofmt -l clean, go vet -tags nogui ./internal/gateway clean. I could not run -race here (no C toolchain on this Windows box), so that stays on your recorded run.

One cross-check on my #3264 patch (b55cf300, tier picks): the two fixes edit the same line, and neither eats the other. #2473 changes what identifies a title (prompt shape instead of max_tokens); #3264 exempts tier picks from titlehood (&& !desktopTierAsked(asked)). Applying b55cf300 on top of this commit conflicts only on that expected shared line; resolved they read title := !tools && desktopTitle(body) && desktopAccepts(asked) && !desktopTierAsked(asked) — a tier pick goes as asked, a real title still follows the session. Either variant of #2473 can land and #3264 stays needed and independent on top.

Thanks for the credit, and for covering the on/off and streaming halves my fixture didn't.

Verified with AI assistance (GLM-5.3-Flash via ZCode); I've read the diff and re-ran the checks above.

Edit — the -race note above was wrong about the reason (though this round indeed didn't run it): this machine does have a C toolchain (a local mingw64, just not on the default PATH). The targeted families above re-ran under -race -count=1 (CGO enabled): go test -race -run TestDesktopProbeKeepsItsModel ./internal/gateway — ok, 4.9s.

ggbdpq avatar Oct 23 '26 04:10 ggbdpq