gateway: Claude Desktop's connection check is tagged as one on the Routing page (cybercaius on Discord)

Also: the check follows a Desktop model switch made after the last turn.

cybercaius (#help): with gpt-6.1-sol on AnyRouter chosen in the
conversation, the Routing page showed "Claude Desktop requested
deepseek/deepseek-flash" while the answer came from gpt-6.1-sol. The route
was right; the row was not explained.

Those rows are Desktop's own connection check ({"max_tokens":1, content
"."}, app.asar 2.7032 lWt/YT). Desktop names its model itself: the
shortest listed id with haiku, else sonnet, else opus, else the FIRST
listed model. magpie lists no Claude-named ids to it, so the check names
the first one (deepseek-flash), whatever the conversation is on, and
magpie sends it to the model chosen in Desktop's menu (desktopChosen).

- The check is recorded with kind connection_check (KindDesktopCheck,
  usage purposeKinds "Connection check", purposes.js regenerated). The
  Routing page tags the row "Connection check" next to the requested id
  and its story says the id is the one Desktop named from its list, not
  the conversation's model, and where magpie sent it. zh/zh-TW/ja/de.
  The requested id itself stays what Desktop sent.
- desktopChosen: a turn sent after cowork_account_settings.json was last
  written wins over the menus (newer of the two). Before, the last
  session's model came first whenever any menu still held it, so the Code
  tab switched off DeepSeek with Cowork left on it kept the check on
  DeepSeek. desktopPicked now carries when that turn was sent (the
  file's mtime once read).

The two 400s were AnyRouter's own (the reporter says so); not changed.

Run (at 0013f990c, this tree before its rebase on e0ad48641 and the
version stamp v0.1.2208 -> v0.1.2212 in comments/doc):
- mote: go test -tags nogui -timeout 45m -count=1 ./... : 81 ok, exit 0.
- mote: go vet ./internal/gateway ./internal/usage for darwin, linux
  (nogui) and windows: ok. gofmt clean. go generate ./internal/usage
  gives the same purposes.js as committed.
- GUI: routing-desktop-check (new; en, zh, zh-TW, ja, de), routing-kind,
  i18n-keys: chromium on mote ok; WebKit could not launch on mote (90+
  hung pw_run.sh launches from other sessions), so both engines ran on
  the Linux box (wsl-run): 14/14 ok.
- Whole GUI suite (wsl-run, concurrency 4) still running at push; reds
  so far are in account-arrange, account-models and agent-expand-steady,
  files this change does not reach. Checked against main after.
Broken by hand:
- call.Kind = KindDesktopCheck turned off: TestClaudeDesktopProbeAsksNoClassifier
  red ('recorded as kind "" (unmarked)').
- the connection_check story removed from client.js: routing-desktop-check red.
- old desktop.go: the new "Code tab switched off the last session's
  model" case red; the at.After check turned off: red too.
Not tried: a real Claude Desktop. Whether Desktop sends a check on each
model switch, and whether its composer switch writes the menu file, are
read from its bundle, not seen live. AnyRouter's 400s not looked into.
This commit is contained in:
yetone
2026-10-30 20:32:25 +08:00
parent e0ad48641e
commit da3c5e0c0f
10 changed files with 206 additions and 26 deletions
+1 -1
View File
@@ -284,7 +284,7 @@ recorded as a prediction failure (`noPrediction`).
- Locally, Claude Code's classifier is a request of its own on the session's model: no tools, a system prompt asking for `<block>yes</block>` or `<block>no</block>`, the transcript in `<transcript>`, a small `max_tokens`, and no stream; Claude Code 2.1.310 waits 60 seconds an attempt for it. To a model that isn't Claude it goes with `classifierRoom` (2048) added to a limit below it and asked to reason least (`fitAutoModeClassifier`): none, or the lowest of the model's known levels. A model whose levels magpie doesn't know (a relay's own name, gpt6.1-sol) is asked for none too, as magpie's own ask (`Request.OwnEffort`): left to the vendor, a reasoning model reasoned at its default past the 60 seconds and every classifier request ended 499 (CyberCaius on Discord). Its 400 to that effort (`ownEffortRefused`) is asked again at low when it named the level, and without the effort when it named the field ("Unrecognized request argument supplied: reasoning_effort"), remembered in `unfit` until magpie restarts (`TestAutoModeClassifierReasonsLeastOnAnUnknownModel`, `TestAutoModeClassifierEffortRefusedGoesWithout`).
- Claude Code's billing line (`x-anthropic-billing-header: cc_version=…; cc_entrypoint=…; cch=…;`, its own first system block, `cch` changing every turn) goes on only to a Claude model asked on Anthropic's Messages API (`keepsBillingLine` in [`billing_line.go`](../../internal/gateway/billing_line.go): Anthropic's, a relay's, Bedrock's), as Claude Code sent it. Anywhere else it is left out, the rest of the system as sent (`withoutBillingLine`): a vendor's model relayed on Messages (`passthrough`), every translation to Chat, Responses or Gemini (`forwardTranslated`, Claude models too). Kept, a vendor read it as the prompt's first words and its prefix cache missed from byte 0 every turn (#1600, justrun1983: 4% read from DeepSeek's cache behind Command Code's plan). The Claude subscription's run sends its own (`withoutBillingHeader`), another magpie decides for the provider it picks, and Code Assist (Antigravity, Gemini CLI) is sent it as before, which `antigravityTurnsAway` reads (#666). Once Antigravity has turned such a request away, for `agForeseeing` (6 hours) after, a candidate loop with someone left after an Antigravity account skips it for a request that carries the line, without asking it (`antigravityForeseen`, #2156: each Claude Desktop turn waited about a second on the same refusal before the next member). The skip goes in `Fallback` with the hint, nothing rests, and the agent is told the refusal if nobody after it answers but with a quota. The last one left is still asked, and an old refusal foresees nothing, so a block Google lifts is noticed (`TestAntigravityTurnedAwayIsForeseen`). Codex's own identity line for its GPT-5 models ("You are Codex, an agent based on GPT-5", "…a coding agent based on GPT-5", any case) is turned away the same way (`antigravityTurnsCodexAway`): Codex sends its model's prompt as the thread's first developer message, which goes in as the system instruction, and a thread begun on a GPT model keeps it after `/model`, `resume -m` or a fork as an agent's thread, so such a thread on an Antigravity model 429'd until Codex's retry limit while dsh on the same account answered (Jodiezzzzzz on X, 10-27). It gets its own hint (`antigravityCodexHint`: start a new chat on the model, which is sent magpie's own Codex prompt "You are Codex, based on GPT-5.", which Antigravity answers), chosen by `antigravityHint`. Codex sends its `web_search` tool every turn, so an Antigravity model's Codex turn goes through magpie's own search (`searchReply`); its rounds are wrapped in `antigravityRound`, which tells the 429 (or the reply's error event) the same way and marks the attempt, where before the search path returned the bare 429 that Codex retried to its limit.
- A request translated to a Chat or Responses upstream that carries no `prompt_cache_key` of the client's (every Anthropic client's) gets one for its conversation when the provider is OpenAI's API with a key or one the user added by its address (`ownCacheKey`, `cacheKeyOf` in [`gateway.go`](../../internal/gateway/gateway.go)): a hash, in a UUID's shape, of the session the client names, else of its first user message, so every turn of it has the same key and nothing in it names the client or magpie. A relay can turn a request away without one ("prompt_cache_key is required", CyberCaius's AnyRouter). A vendor's preset, a signed-in account, a plugin, Bedrock and Vertex get none, nor does a provider whose extraBody names `prompt_cache_key` (the user's value is sent). An upstream whose 400 names the field is asked again without it and not sent it again; another 400 is not asked again for it, so an unrelated refusal is tried as often as before.
- Claude Desktop's check that a gateway model answers (`{"max_tokens":1,"messages":[{"role":"user","content":"."}]}`, sent as it starts and by its settings' Test connection on the shortest id it is listed with haiku in it, else sonnet, else opus; `desktopProbe` in [`desktop.go`](../../internal/gateway/desktop.go)) goes to the model the user chose in one of Desktop's own model menus that magpie still serves (`desktopChosen`: `__model_selector_state` in Claude-3p's `local-agent-mode-sessions/<account>/<org>/cowork_account_settings.json`, the one the last session ran on first, then Code, Cowork, Chat; cybercaius's DeepSeek in the Code tab, v0.1.2033), else to Desktop's default model, the first one listed to it (`desktopDefault`; Desktop's own settings call the first listed model the default), never to the haiku it names, which is another provider's quota, nor to the model the last session ran on (`desktopPicked`), which can be days old: v0.1.1821 sent it there, a relay's GPT model CyberCaius had left for his routing group, and the relay turned it away (Discord, v0.1.1838). It is asked for 16 tokens upstream (`desktopProbeTokens`): OpenAI's models refuse fewer, and a relay in front of one (AnyRouter's "bad response status code 400") passes on no floor for `tokenFloor` to ask again at. A relay that needs `prompt_cache_key` gets one (above). `TestClaudeDesktopProbeToDefaultModel`, `TestClaudeDesktopProbeToChosenModel`.
- Claude Desktop's check that a gateway model answers (`{"max_tokens":1,"messages":[{"role":"user","content":"."}]}`, sent as it starts and by its settings' Test connection on the shortest id it is listed with haiku in it, else sonnet, else opus, else the first model listed; `desktopProbe` in [`desktop.go`](../../internal/gateway/desktop.go)) goes to the model the user chose in one of Desktop's own model menus that magpie still serves (`desktopChosen`: `__model_selector_state` in Claude-3p's `local-agent-mode-sessions/<account>/<org>/cowork_account_settings.json`, in the order Code, Cowork, Chat; cybercaius's DeepSeek in the Code tab, v0.1.2033), unless a session's turn was sent after that file was last written: then the model that turn was for (`desktopPicked`), while magpie serves it, the newer of the two being what the user is on now (before, the last session's model came first whenever any menu still held it, so the Code tab switched off DeepSeek with Cowork left on it kept the check on DeepSeek, cybercaius on Discord, v0.1.2212), else to Desktop's default model, the first one listed to it (`desktopDefault`; Desktop's own settings call the first listed model the default), never to the haiku it names, which is another provider's quota, nor, with no menu chosen, to the model the last session ran on (`desktopPicked`), which can be days old: v0.1.1821 sent it there, a relay's GPT model CyberCaius had left for his routing group, and the relay turned it away (Discord, v0.1.1838). It is asked for 16 tokens upstream (`desktopProbeTokens`): OpenAI's models refuse fewer, and a relay in front of one (AnyRouter's "bad response status code 400") passes on no floor for `tokenFloor` to ask again at. A relay that needs `prompt_cache_key` gets one (above). It is recorded with kind `connection_check` (`KindDesktopCheck`), which the Routing page tags "Connection check" with why its model is the id Desktop named and not the one chosen in the conversation: a list with no Claude-named id made the row read "requested deepseek-flash" while the menu's gpt-6.1-sol answered (cybercaius on Discord, v0.1.2212). `TestClaudeDesktopProbeToDefaultModel`, `TestClaudeDesktopProbeToChosenModel`. `TestClaudeDesktopProbeAsksNoClassifier` checks the kind.
- Claude Desktop's `/v1/models` tags a model with `anthropic_family_tier` only when the user picked it for that tier (`DesktopTiers`, the Agents page's opus, sonnet, haiku and fable). Before, a Claude model magpie served was tagged with its own tier unpicked, so Desktop's Code tab told Claude Code to run its haiku calls (its small, fast model) on whichever provider served a `claude-haiku-…`: a chat on AgentRouter's gpt-6.1-sol sent them to Leee's `claude-haiku-5-5` (cybercaius on Discord). Untagged, Claude Code asks for its own id of the tier. A background call (no tools) or a subagent's turn asking for a Claude model by Claude's own id that is no catalog id (`claudeOwnID`) stays on the chat's provider (`desktopPicked`), even when another provider serves a model of that name: `servedBeside` gives that provider's model of that name, else its newest model of the tier, beside the chat's model first, else the call goes to the chat's model. The provider's Claude models stand in only when the chat itself is on one of them: a chat on Leee's DeepSeek had Claude Code's sonnet calls sent to Leee's `claude-sonnet-5-5`, which its key may not use (403, CyberCaius on Discord), so Claude Code's own calls in a chat on another vendor's model go to the chat's model, and a tier the user picked takes Claude Code's own id of it even where a provider lists a model by that name (`TestClaudeDesktopNonClaudeChatKeepsTierCalls`). A lead's turn and an id the user picked for a tier (a catalog id) go as asked. `TestClaudeDesktopBackgroundStaysOnChatProvider`.
- Antigravity answers a system instruction holding one of a few lines with a 429 "Resource has been exhausted" whatever quota is left, on every model (`agTurnedAway` in [`codeassist.go`](../../internal/gateway/codeassist.go)): Claude Code's billing line, the Claude Agent SDK's identity line, Codex's identity lines for its GPT-5 models (which a Codex thread begun on a GPT model keeps after a switch), and Hermes Agent's earlier default persona. An Antigravity account's system instruction goes with a zero-width space after each such line's first letter (`antigravityCloak`, in `codeAssistBody`), which Google lets through and the model reads the same; every other provider, Gemini CLI's sign-in on the same envelope included, is sent the prompt as written. `magpie provider set antigravity prompt=as-written` (`Provider.PromptAsWritten`) turns it off. The refusal is still told against the system prompt as the agent wrote it (`antigravityTurnedAway`): a 400 with the hint for that prompt, the account not rested, and a group skipping Antigravity for that prompt for 6 hours after a refusal (`antigravityForeseen`).
- Claude Code's advisor (`/advisor`, `--advisor`) is Anthropic's server tool `advisor_20260301`, its `model` named as Claude Code names its own: on magpie, by magpie's id (the tier an alias like `opus` is on), which no vendor knows, so the request was turned away whole (JackChou on Discord). Relayed on Messages (`passthrough`), the advisor's model goes as the upstream's own name for it when it is the same provider's Claude model, or a Claude id naming no provider (`advisorTools` in [`advisor.go`](../../internal/gateway/advisor.go)); one it can't run there (another provider's, a group, not Claude's) is left out, as is every advisor when the request's own model isn't a Claude model (a vendor's Messages API knows no such tool), and the turn is answered without one. A translation drops it with every other server tool. Claude Code (2.1.300) also puts the advisor in the conversation: a `{role: "system"}` message whose text ends in its instructions ("# Advisor Tool … call advisor BEFORE substantive work") and a `tool_addition` naming it. Where the advisor is left out, that `tool_addition` goes too (and a message it leaves empty), and the instructions become Claude Code's own "The advisor tool is no longer available; disregard the earlier advisor instructions." (`withoutAdvisor` on Messages, `advisorGoneIn` in `parseAnthropic` for a translation): left there, the model called `advisor()` as one of the agent's tools and Claude Code answered "No such tool available: advisor" (JackChou on Discord). The Claude subscription's run declares only magpie's tools, so it never has one. `TestAdvisorModelAsTheUpstreamNamesIt`, `TestAdvisorLeftOutOnTranslation`.
+44 -17
View File
@@ -464,11 +464,26 @@ func isClaudeDesktop(r *http.Request) bool {
var desktopPicked struct {
sync.Mutex
model string
from string // the file it was read from
from string // the file it was read from
at time.Time // when that turn was sent (the file's time once read)
}
func desktopPickedPath() string { return filepath.Join(settings.Dir(), "claude-desktop.model") }
// loadPicked reads desktopPicked from its file when it was read from
// another (a new settings.Dir) or not yet. The caller holds its lock.
func loadPicked() {
path := desktopPickedPath()
if desktopPicked.from == path {
return
}
b, _ := os.ReadFile(path)
desktopPicked.model, desktopPicked.from, desktopPicked.at = strings.TrimSpace(string(b)), path, time.Time{}
if fi, err := os.Stat(path); err == nil {
desktopPicked.at = fi.ModTime()
}
}
// 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
@@ -514,12 +529,13 @@ func desktopTurn(asked string, body []byte, byClaudeCode, bySubagent bool) strin
tools := hasTools(body)
desktopPicked.Lock()
defer desktopPicked.Unlock()
if path := desktopPickedPath(); desktopPicked.from != path {
b, _ := os.ReadFile(path)
desktopPicked.model, desktopPicked.from = strings.TrimSpace(string(b)), path
}
loadPicked()
picked := desktopPicked.model
if asked == picked {
if tools && !bySubagent {
// the session goes on on it: newer than a menu changed meanwhile
desktopPicked.at = time.Now()
}
return asked
}
aside := small(body)
@@ -563,7 +579,7 @@ func desktopTurn(asked string, body []byte, byClaudeCode, bySubagent bool) strin
return asked
}
if tools && !bySubagent {
desktopPicked.model = asked
desktopPicked.model, desktopPicked.at = asked, time.Now()
if os.MkdirAll(settings.Dir(), 0o755) == nil {
os.WriteFile(desktopPickedPath(), []byte(asked+"\n"), 0o600)
}
@@ -737,10 +753,17 @@ var desktopSurfaces = []string{"code", "cowork", "chat"}
// changes; the newest such file is read). Desktop's check names a model
// by its name (desktopProbe), so a chat on DeepSeek in the Code tab had
// its check go to the first model listed, another provider's
// (cybercaius on Discord, v0.1.2033). Of the menus' choices, the one the
// last session ran on (desktopPicked) comes first, then desktopSurfaces'
// order. Read only for the check, as Desktop starts and from Test
// connection; a file not read or not parsed is no choice (desktopDefault).
// (cybercaius on Discord, v0.1.2033). The newer of the two the user did
// last wins: a turn sent after the file was last written goes first
// (desktopPicked, the model that turn was for, while magpie serves it),
// else the menus' choices in desktopSurfaces' order. Before, the last
// session's model came first whenever any menu still held it, so a Code
// tab switched off DeepSeek, its Cowork or Chat menu left on it, had the
// check go on to DeepSeek while the chat went to the new model
// (cybercaius on Discord, v0.1.2212). Read only for the check, as
// Desktop starts and from Test connection; a file not read or not parsed
// is no choice (desktopDefault), and a turn alone is not one either,
// since it can be days old.
func desktopChosen() string {
var path string
var newest time.Time
@@ -779,14 +802,14 @@ func desktopChosen() string {
return ""
}
desktopPicked.Lock()
if p := desktopPickedPath(); desktopPicked.from != p {
b, _ := os.ReadFile(p)
desktopPicked.model, desktopPicked.from = strings.TrimSpace(string(b)), p
}
picked := desktopPicked.model
loadPicked()
picked, at := desktopPicked.model, desktopPicked.at
desktopPicked.Unlock()
for _, m := range chosen {
if picked != "" && strings.TrimSuffix(m, "[1m]") == strings.TrimSuffix(unprefixed(picked), "[1m]") {
// a turn sent after the menus last changed is the model the user is
// on now: a session switched to another model, or a menu still on the
// one it left
if picked != "" && at.After(newest) {
if m := unprefixed(picked); !unserved(m) {
return m
}
}
@@ -831,6 +854,10 @@ func desktopProbe(body []byte) bool {
// to ask again at (tokenFloor). Desktop reads only whether it is answered.
const desktopProbeTokens = 16
// KindDesktopCheck is the kind a Claude Desktop check (desktopProbe) is
// recorded with, so the Routing page and the ledger tell it from a turn.
const KindDesktopCheck = "connection_check"
// desktopTitlePrompt is how the system prompt Claude Desktop asks a
// session's title and branch name with starts (dcr in its app.asar), sent
// by its own client or, when that fails, as Claude Code's --system-prompt.
+37 -3
View File
@@ -9,9 +9,11 @@ import (
"path/filepath"
"strings"
"testing"
"time"
"github.com/tidwall/gjson"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/usage"
)
// relayNeedsCacheKey answers as CyberCaius's AnyRouter did a request
@@ -227,6 +229,13 @@ func TestClaudeDesktopProbeAsksNoClassifier(t *testing.T) {
if a.last == "" || r.Rule == nil || r.Rule.Classified == nil || !strings.Contains(r.Rule.Classified.Error, "Claude Desktop's connection check") {
t.Fatalf("not answered by the group's first member, or the trace doesn't say why: %q %+v", a.last, r.Rule)
}
// The Routing page shows the id Desktop named (its first listed model
// when none is Claude-named), not the model chosen in the
// conversation, so the row says it is the check (cybercaius on
// Discord: "requested deepseek-flash" while gpt-6.1-sol answered).
if r.Kind != KindDesktopCheck || usage.PurposeOf(r.Kind) != "kind:connection_check" {
t.Fatalf("the check is recorded as kind %q (%s), not %q", r.Kind, usage.PurposeOf(r.Kind), KindDesktopCheck)
}
// a user's turn through the same group is still classified
if code, body := send(`{"model":"group/r","max_tokens":32000,"stream":true,"messages":[{"role":"user","content":"add a unit test for the parser"}]}`); code != 200 {
t.Fatalf("turn: %d %s", code, body)
@@ -234,6 +243,9 @@ func TestClaudeDesktopProbeAsksNoClassifier(t *testing.T) {
if c.n() != 1 {
t.Fatalf("a user's turn asked the classifier %d times", c.n())
}
if k := lastRoute(s).Kind; k != "" {
t.Fatalf("a user's turn is recorded as kind %q", k)
}
}
// ctyunRefusal is the body Desktop showed (cybercaius, v0.1.1862) as
@@ -430,17 +442,25 @@ func TestClaudeDesktopProbeToChosenModel(t *testing.T) {
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
// the menus are written at the hour, a turn sent at a minute past or
// before it: no two of them in one tick of the file system's clock
hour := time.Now().Add(-time.Hour).Truncate(time.Second)
file := filepath.Join(dir, "cowork_account_settings.json")
choose := func(state string) {
t.Helper()
if err := os.WriteFile(filepath.Join(dir, "cowork_account_settings.json"), []byte(`{"__created_at":1,"__model_selector_state":`+state+`}`), 0o600); err != nil {
if err := os.WriteFile(file, []byte(`{"__created_at":1,"__model_selector_state":`+state+`}`), 0o600); err != nil {
t.Fatal(err)
}
if err := os.Chtimes(file, hour, hour); err != nil {
t.Fatal(err)
}
}
pick := func(m string) {
pickAt := func(m string, at time.Time) {
desktopPicked.Lock()
desktopPicked.model, desktopPicked.from = m, desktopPickedPath()
desktopPicked.model, desktopPicked.from, desktopPicked.at = m, desktopPickedPath(), at
desktopPicked.Unlock()
}
pick := func(m string) { pickAt(m, hour.Add(time.Minute)) }
pick("")
srv := New()
probe := `{"model":"` + haiku + `","max_tokens":1,"messages":[{"role":"user","content":"."}]}`
@@ -484,6 +504,20 @@ func TestClaudeDesktopProbeToChosenModel(t *testing.T) {
check(ds, "deepseek-v4-flash", "Code before Cowork")
pick(kimiID)
check(kimi, "kimi-k3", "the last session's menu first")
// the reporter's (v0.1.2212): a chat on DeepSeek, then the Code tab
// switched to Kimi while Cowork stays on DeepSeek; the check follows
// the switch, not the turn sent before it
pickAt(dsID, hour.Add(-time.Minute))
choose(`{"code":{"model":"` + kimiID + `"},"cowork":{"model":"` + dsID + `"}}`)
check(kimi, "kimi-k3", "Code tab switched off the last session's model")
// a session switched to Kimi after the menu was set to DeepSeek: the
// model the user is on now
choose(`{"code":{"model":"` + dsID + `"}}`)
pick(kimiID)
check(kimi, "kimi-k3", "a turn after the menu was set")
// such a turn on a model magpie no longer serves leaves it to the menu
pick("anthropic/magpie-0000000001")
check(ds, "deepseek-v4-flash", "a newer turn on an unserved model")
pick("")
// a choice magpie no longer serves leaves it to the first listed
choose(`{"code":{"model":"anthropic/magpie-0000000001"}}`)
+8
View File
@@ -1919,6 +1919,14 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro
desktopCheck = probe
asked = desktopTurn(asked, body, fromClaudeCode(r.Header), sub != "")
if probe {
// tagged on the Routing page and in the ledger as the check it
// is: Desktop names its model itself, the first listed when no
// Claude-named model is, so the row read as Desktop asking for
// a model the user had left while the answer came from the
// one chosen in its menu (cybercaius on Discord, v0.1.2212)
if call.Kind == "" {
call.Kind = KindDesktopCheck
}
// its check, asked for room every model answers in
if b, ok := withTokenFloor(body, desktopProbeTokens); ok {
body = b
+4
View File
@@ -3503,6 +3503,7 @@ const I18N = {
"Image description": "图片描述",
"MCP tool": "MCP 工具",
"Routing classifier": "路由分类器",
"Connection check": "连接检查",
"magpie's own": "magpie 自身",
"{n} request in this period was magpie's own": "此期间有 {n} 个请求是 magpie 自身发出的",
"{n} requests in this period were magpie's own": "此期间有 {n} 个请求是 magpie 自身发出的",
@@ -7666,6 +7667,7 @@ const I18N = {
"Image description": "圖片描述",
"MCP tool": "MCP 工具",
"Routing classifier": "路由分類器",
"Connection check": "連線檢查",
"magpie's own": "magpie 自身",
"{n} request in this period was magpie's own": "此期間有 {n} 個請求是 magpie 自身發出的",
"{n} requests in this period were magpie's own": "此期間有 {n} 個請求是 magpie 自身發出的",
@@ -11847,6 +11849,7 @@ const I18N = {
"Image description": "画像の説明",
"MCP tool": "MCP ツール",
"Routing classifier": "ルーティング分類器",
"Connection check": "接続チェック",
"magpie's own": "magpie 自身",
"{n} request in this period was magpie's own": "この期間のリクエストのうち {n} 件は magpie 自身のものです",
"{n} requests in this period were magpie's own": "この期間のリクエストのうち {n} 件は magpie 自身のものです",
@@ -16036,6 +16039,7 @@ const I18N = {
"Image description": "Bildbeschreibung",
"MCP tool": "MCP-Tool",
"Routing classifier": "Routing-Klassifikator",
"Connection check": "Verbindungstest",
"magpie's own": "von magpie selbst",
"{n} request in this period was magpie's own": "{n} Anfrage in diesem Zeitraum kam von magpie selbst",
"{n} requests in this period were magpie's own": "{n} Anfragen in diesem Zeitraum kamen von magpie selbst",
@@ -3108,6 +3108,10 @@ function routingPage(part) {
: t("{agent} requested a subagent on {model}.", { agent, model: r.model });
if (purposeOf(r.kind) === "kind:ambient_suggestions") return t("{agent} drafted the suggested prompts on its home page by itself, in the background, searching the project's files and connected apps, and checked them for safety. Not a turn of the conversation; Codex's Settings › Configuration › Suggested prompts turns it off.", { agent });
if (purposeOf(r.kind) === "kind:composer_predictions") return t("{agent} guessed your next message for its composer by itself, reading the whole conversation again. Not a turn of the conversation; Codex composer predictions, under Settings in Codex's row on the Agents page, picks its model, and Codex's Settings › General › Show predictions turns it off.", { agent });
// Claude Desktop's check that magpie answers names its model itself
// (cybercaius on Discord: "Desktop requested deepseek-flash" while
// the chat was on another model)
if (r.kind === "connection_check") return t("{agent} checked that magpie answers, as it does when it starts and from its Test connection. It names this check's model itself, from the names in its model list ({model}), not the model chosen in the conversation, and only reads whether an answer comes back; magpie sends it to the model chosen in {agent}'s model menu, or to its first listed model when none is. Not a turn of the conversation.", { agent, model: r.model });
if (r.kind === "luna_reserve") return t("{agent} sent this turn on Luna Reserve, which it turns to once the plan's own allowance is used up; it picks the model itself.", { agent });
// the searcher asked first failed or found nothing, and this one
// searched in its place: say which and why, not just who searched
@@ -501,6 +501,7 @@ magpie.strings({
"{agent} drafted the suggested prompts on its home page by itself, in the background, searching the project's files and connected apps, and checked them for safety. Not a turn of the conversation; Codex's Settings › Configuration › Suggested prompts turns it off.": "{agent} 在后台自行生成首页的提示词建议(会搜索项目文件和已连接的应用)并做安全检查,不属于对话轮次。可在 Codex 的 设置 › 配置 › 提示词建议 中关闭。",
"{agent} sent this turn on Luna Reserve, which it turns to once the plan's own allowance is used up; it picks the model itself.": "{agent} 用 Luna 储备发出了本轮(套餐额度用完后改用),模型由它自行选择。",
"{agent} made this call itself ({kind}), not as a turn of the conversation, and picks its model itself.": "{agent} 自行发起的调用({kind}),不属于对话轮次,模型由它自行选择。",
"{agent} checked that magpie answers, as it does when it starts and from its Test connection. It names this check's model itself, from the names in its model list ({model}), not the model chosen in the conversation, and only reads whether an answer comes back; magpie sends it to the model chosen in {agent}'s model menu, or to its first listed model when none is. Not a turn of the conversation.": "{agent} 在检查 magpie 能否应答(启动时和在 Test connection 里都会发)。这次检查的模型由它自己按模型列表里的名字选出({model}),不是对话里选的模型,它也只看有没有回应;magpie 会把它发给 {agent} 模型菜单里选的模型,没选时发给列表里的第一个模型。不属于对话轮次。",
"Nothing was tried: {error}": "没有尝试任何账号:{error}",
"{agent} asked for {model}: {name} serves it, and the vendor is asked for {sent}": "{agent} 请求 {model}:由 {name} 提供,向厂商请求的模型是 {sent}",
"the last {n} the gateway keeps": "网关保留的最近 {n} 个",
@@ -1094,6 +1095,7 @@ magpie.strings({
"{agent} drafted the suggested prompts on its home page by itself, in the background, searching the project's files and connected apps, and checked them for safety. Not a turn of the conversation; Codex's Settings › Configuration › Suggested prompts turns it off.": "{agent} 在後臺自行生成首頁的提示詞建議(會搜尋專案檔案和已連線的應用)並做安全檢查,不屬於對話輪次。可在 Codex 的 設定 › 設定 › 提示詞建議 中關閉。",
"{agent} sent this turn on Luna Reserve, which it turns to once the plan's own allowance is used up; it picks the model itself.": "{agent} 用 Luna 儲備發出了本輪(套餐額度用完後改用),模型由它自行選擇。",
"{agent} made this call itself ({kind}), not as a turn of the conversation, and picks its model itself.": "{agent} 自行發起的呼叫({kind}),不屬於對話輪次,模型由它自行選擇。",
"{agent} checked that magpie answers, as it does when it starts and from its Test connection. It names this check's model itself, from the names in its model list ({model}), not the model chosen in the conversation, and only reads whether an answer comes back; magpie sends it to the model chosen in {agent}'s model menu, or to its first listed model when none is. Not a turn of the conversation.": "{agent} 在檢查 magpie 能否回應(啟動時和在 Test connection 裡都會發)。這次檢查的模型由它自己依模型清單裡的名稱選出({model}),不是對話裡選的模型,它也只看有沒有回應;magpie 會把它送給 {agent} 模型選單裡選的模型,沒選時送給清單裡的第一個模型。不屬於對話輪次。",
"Nothing was tried: {error}": "沒有嘗試任何帳號:{error}",
"{agent} asked for {model}: {name} serves it, and the vendor is asked for {sent}": "{agent} 請求 {model}:由 {name} 提供,向廠商請求的模型是 {sent}",
"the last {n} the gateway keeps": "閘道保留的最近 {n} 個",
@@ -1685,6 +1687,7 @@ magpie.strings({
"{agent} drafted the suggested prompts on its home page by itself, in the background, searching the project's files and connected apps, and checked them for safety. Not a turn of the conversation; Codex's Settings › Configuration › Suggested prompts turns it off.": "{agent} がホーム画面のプロンプト候補をバックグラウンドで自ら作成し(プロジェクトのファイルや接続済みアプリを検索)、安全性をチェックしました。会話のターンではありません。Codex の 設定 › 構成 › Suggested prompts でオフにできます。",
"{agent} sent this turn on Luna Reserve, which it turns to once the plan's own allowance is used up; it picks the model itself.": "{agent} はこのターンを Luna Reserve で送信しました。プラン本来の利用枠を使い切ると Luna Reserve に切り替わり、モデルは自ら選びます。",
"{agent} made this call itself ({kind}), not as a turn of the conversation, and picks its model itself.": "これは {agent} 自身による呼び出し({kind})で、会話のターンではなく、モデルも自ら選びます。",
"{agent} checked that magpie answers, as it does when it starts and from its Test connection. It names this check's model itself, from the names in its model list ({model}), not the model chosen in the conversation, and only reads whether an answer comes back; magpie sends it to the model chosen in {agent}'s model menu, or to its first listed model when none is. Not a turn of the conversation.": "{agent} が magpie の応答を確かめるチェックです(起動時と Test connection で送られます)。このチェックのモデルは {agent} がモデル一覧の名前から自分で選んだもの({model})で、会話で選んだモデルではなく、応答があるかだけを見ます。magpie はこれを {agent} のモデルメニューで選ばれたモデルへ、未選択なら一覧の先頭のモデルへ送ります。会話のターンではありません。",
"Nothing was tried: {error}": "何も試行されませんでした:{error}",
"{agent} asked for {model}: {name} serves it, and the vendor is asked for {sent}": "{agent} が {model} をリクエスト:{name} が提供し、ベンダーには {sent} をリクエスト",
"the last {n} the gateway keeps": "ゲートウェイが保持する直近 {n} 件",
@@ -2278,6 +2281,7 @@ magpie.strings({
"{agent} drafted the suggested prompts on its home page by itself, in the background, searching the project's files and connected apps, and checked them for safety. Not a turn of the conversation; Codex's Settings › Configuration › Suggested prompts turns it off.": "{agent} hat die vorgeschlagenen Prompts auf seiner Startseite selbst im Hintergrund entworfen, dabei die Projektdateien und verbundene Apps durchsucht und sie auf Sicherheit geprüft. Keine Runde der Unterhaltung; abschalten lässt es sich in Codex unter Einstellungen › Konfiguration › Prompt-Vorschläge.",
"{agent} sent this turn on Luna Reserve, which it turns to once the plan's own allowance is used up; it picks the model itself.": "{agent} hat diese Runde über Luna Reserve gesendet, worauf es zurückgreift, sobald das eigene Kontingent des Plans aufgebraucht ist; das Modell wählt es selbst.",
"{agent} made this call itself ({kind}), not as a turn of the conversation, and picks its model itself.": "{agent} hat diesen Aufruf selbst ausgeführt ({kind}), nicht als Runde der Unterhaltung, und wählt sein Modell selbst.",
"{agent} checked that magpie answers, as it does when it starts and from its Test connection. It names this check's model itself, from the names in its model list ({model}), not the model chosen in the conversation, and only reads whether an answer comes back; magpie sends it to the model chosen in {agent}'s model menu, or to its first listed model when none is. Not a turn of the conversation.": "{agent} prüft, ob magpie antwortet, beim Start und über „Test connection“. Das Modell dieser Prüfung wählt {agent} selbst nach den Namen in seiner Modellliste ({model}), nicht das im Gespräch gewählte, und liest nur, ob eine Antwort kommt; magpie schickt sie an das in {agent}s Modellmenü gewählte Modell oder, wenn keins gewählt ist, an das erste der Liste. Kein Zug des Gesprächs.",
"Nothing was tried: {error}": "Nichts wurde versucht: {error}",
"{agent} asked for {model}: {name} serves it, and the vendor is asked for {sent}": "{agent} verlangte {model}: {name} stellt es bereit, beim Anbieter wird {sent} angefragt",
"the last {n} the gateway keeps": "die letzten {n}, die der Zugangspunkt aufbewahrt",
+1 -1
View File
@@ -1,2 +1,2 @@
// Code generated by go generate ./internal/usage; DO NOT EDIT.
const REQUEST_KINDS = {"agent_job":{"purpose":"kind:collab_spawn","name":"Subagent"},"ambient_suggestion_safety":{"purpose":"kind:ambient_suggestions","name":"Suggestions"},"ambient_suggestions":{"purpose":"kind:ambient_suggestions","name":"Suggestions"},"api_detect":{"purpose":"kind:api_detect","name":"Detect APIs"},"auto_review":{"purpose":"kind:guardian","name":"Approval check"},"collab_spawn":{"purpose":"kind:collab_spawn","name":"Subagent"},"compact":{"purpose":"kind:compact","name":"Compaction"},"composer_predictions":{"purpose":"kind:composer_predictions","name":"Prediction"},"guardian":{"purpose":"kind:guardian","name":"Approval check"},"guardian_review":{"purpose":"kind:guardian","name":"Approval check"},"luna_reserve":{"purpose":"kind:luna_reserve","name":"Luna Reserve"},"mcp":{"purpose":"kind:mcp","name":"MCP tool"},"memgen":{"purpose":"kind:memory_consolidation","name":"Memory"},"memory":{"purpose":"kind:memory_consolidation","name":"Memory"},"memory_consolidation":{"purpose":"kind:memory_consolidation","name":"Memory"},"model_list":{"purpose":"kind:model_list","name":"Model list"},"provider_test":{"purpose":"kind:provider_test","name":"Test"},"review":{"purpose":"kind:review","name":"Review"},"routing":{"purpose":"kind:routing","name":"Routing classifier"},"thread_description":{"purpose":"kind:thread_description","name":"Description"},"thread_spawn":{"purpose":"kind:collab_spawn","name":"Subagent"},"thread_title":{"purpose":"kind:thread_title","name":"Title"},"thread_title_reconsideration":{"purpose":"kind:thread_title","name":"Title"},"title":{"purpose":"kind:thread_title","name":"Title"},"title_generation":{"purpose":"kind:thread_title","name":"Title"},"vision":{"purpose":"kind:vision","name":"Image description"},"web_search":{"purpose":"kind:web_search","name":"Web search"}};
const REQUEST_KINDS = {"agent_job":{"purpose":"kind:collab_spawn","name":"Subagent"},"ambient_suggestion_safety":{"purpose":"kind:ambient_suggestions","name":"Suggestions"},"ambient_suggestions":{"purpose":"kind:ambient_suggestions","name":"Suggestions"},"api_detect":{"purpose":"kind:api_detect","name":"Detect APIs"},"auto_review":{"purpose":"kind:guardian","name":"Approval check"},"collab_spawn":{"purpose":"kind:collab_spawn","name":"Subagent"},"compact":{"purpose":"kind:compact","name":"Compaction"},"composer_predictions":{"purpose":"kind:composer_predictions","name":"Prediction"},"connection_check":{"purpose":"kind:connection_check","name":"Connection check"},"guardian":{"purpose":"kind:guardian","name":"Approval check"},"guardian_review":{"purpose":"kind:guardian","name":"Approval check"},"luna_reserve":{"purpose":"kind:luna_reserve","name":"Luna Reserve"},"mcp":{"purpose":"kind:mcp","name":"MCP tool"},"memgen":{"purpose":"kind:memory_consolidation","name":"Memory"},"memory":{"purpose":"kind:memory_consolidation","name":"Memory"},"memory_consolidation":{"purpose":"kind:memory_consolidation","name":"Memory"},"model_list":{"purpose":"kind:model_list","name":"Model list"},"provider_test":{"purpose":"kind:provider_test","name":"Test"},"review":{"purpose":"kind:review","name":"Review"},"routing":{"purpose":"kind:routing","name":"Routing classifier"},"thread_description":{"purpose":"kind:thread_description","name":"Description"},"thread_spawn":{"purpose":"kind:collab_spawn","name":"Subagent"},"thread_title":{"purpose":"kind:thread_title","name":"Title"},"thread_title_reconsideration":{"purpose":"kind:thread_title","name":"Title"},"title":{"purpose":"kind:thread_title","name":"Title"},"title_generation":{"purpose":"kind:thread_title","name":"Title"},"vision":{"purpose":"kind:vision","name":"Image description"},"web_search":{"purpose":"kind:web_search","name":"Web search"}};
@@ -0,0 +1,98 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Claude Desktop's connection check names its model itself, the first
// model listed to it when none is Claude-named, while magpie sends it to
// the model chosen in Desktop's menu. Its row in the Routing page's
// Requests list says it is the check, so "requested deepseek-flash" with
// gpt-6.1-sol answering reads as it is (cybercaius on Discord: 对话里选的
// 是 Anyrouter 的 gpt-6.1-sol,路由页显示 Claude Desktop 请求的是
// DeepSeek 的 deepseek-flash).
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const now = new Date();
const day = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map((n) => String(n).padStart(2, "0")).join("-");
const at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();
const seat = { id: "anyrouter", provider: "anyrouter", name: "AnyRouter", who: "API key", kind: "key", model: "gpt-6.1-sol" };
const rows = [
{ kind: "connection_check", max: 1, status: 400 },
{ kind: "", max: 32000, status: 200 },
];
const routes = rows.map((x, i) => ({
id: 100 - i, seq: 100 - i, time: at(i), agent: "claude-desktop", model: "deepseek/deepseek-flash", provider: "anyrouter", ...(x.kind ? { kind: x.kind } : {}),
order: [seat], tries: [{ id: seat.id, model: "gpt-6.1-sol", start: at(i), done: true, status: x.status, ms: 900 }],
done: true, status: x.status, ms: 900, tokens: 12,
}));
function serve(lang) {
const state = { agents: [{ id: "claude-desktop", name: "Claude Desktop", path: "/test/claude_desktop_config.json", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state);
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3));
return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
}
if (url.pathname === "/api/gateway/history") {
const d = url.searchParams.get("day");
return json({ cut: false, days: [{ day, requests: routes.length }], routes: d ? routes : [] });
}
if (url.pathname === "/api/groups") return json({ groups: [] });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
await route.fulfill({ body: await fs.readFile(file), contentType });
};
}
const want = {
en: { tag: "Connection check", story: /names this check's model itself.*\(deepseek\/deepseek-flash\), not the model chosen in the conversation/ },
zh: { tag: "连接检查", story: /按模型列表里的名字选出(deepseek\/deepseek-flash),不是对话里选的模型/ },
"zh-TW": { tag: "連線檢查", story: /不是對話裡選的模型/ },
ja: { tag: "接続チェック", story: /会話で選んだモデルではなく/ },
de: { tag: "Verbindungstest", story: /nicht das im Gespräch gewählte/ },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(want)) {
test(`${engine} ${lang}: Claude Desktop's connection check is tagged and says whose model it names`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const context = await browser.newContext({ viewport: { width: 1100, height: 860 }, reducedMotion: "reduce" });
const page = await context.newPage();
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
t.after(async () => {
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-desktop-check.png`), fullPage: true });
}
await browser.close();
});
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-days .rt-day").nth(1).click();
await page.locator(".rt-req").nth(rows.length - 1).waitFor();
const tags = await page.locator(".rt-req").evaluateAll((rs) => rs.map((r) => r.querySelector(".asked .kind")?.textContent || ""));
assert.deepEqual(tags, [want[lang].tag, ""]);
await page.locator(".rt-req").nth(0).click();
const story = page.locator(".rt-steps li.kind");
await story.waitFor();
assert.equal(await story.locator(".kind").textContent(), want[lang].tag);
assert.match(await story.textContent(), want[lang].story);
// a turn of the conversation has no tag in its story
await page.locator(".rt-req").nth(1).click();
await page.waitForTimeout(300);
assert.equal(await page.locator(".rt-steps li.kind").count(), 0);
assert.deepEqual(errors, []);
});
}
}
+5 -4
View File
@@ -30,10 +30,11 @@ var purposeKinds = func() map[string]PurposeKind {
add("Web search", "web_search")
add("Image description", "vision")
add("Routing classifier", "routing")
add("Test", "provider_test") // magpie's own (probelog.KindTest)
add("Detect APIs", "api_detect") // probelog.KindDetect
add("Model list", "model_list") // probelog.KindList
add("MCP tool", KindMCP) // an MCP tool call (SourceMCP)
add("Connection check", "connection_check") // Claude Desktop's (gateway.KindDesktopCheck)
add("Test", "provider_test") // magpie's own (probelog.KindTest)
add("Detect APIs", "api_detect") // probelog.KindDetect
add("Model list", "model_list") // probelog.KindList
add("MCP tool", KindMCP) // an MCP tool call (SourceMCP)
return out
}()