Files
magpie/internal
yetone b72e7d4a74 gateway: Claude Code's auto-mode classifier in Claude Desktop goes to the model it asks for, not the session's (#1539, tete1030)
17a3e0b sent a small tool-less Claude Desktop request (max_tokens at most
4096) for a Claude-looking model to the model the session is on. Its target
was Desktop's session title. Desktop's own client sends that title
(wcr/Ecr in its app.asar, model = its "small_fast" pick) as
{"model":…,"max_tokens":200,"system":"You write short session titles. …"}
with its Electron User-Agent. The rule also caught Claude Code's own
background calls on the same magpie-claude-desktop key. Claude Code picks
those models on purpose. Its auto-mode safety classifier asks for its sonnet
with no tools and max_tokens 64/256 (+2048 thinking), and its notification
classifier asks with 1024. So tete1030's 26 classifier calls in one session
went to claude-opus-5-5 instead of claude-sonnet-5, in one try with no
fallback.

Where the line goes: the User-Agent. Every Claude Code request carries
claude-cli/<ver> (external, claude-desktop). Desktop's own client sends
"Mozilla/… Claude/…". A request from Claude Code now goes to the session's
model only when it is Desktop's title. When its direct request fails,
Desktop asks Claude Code for the title:
`claude -p --model <pick> --system-prompt "You write short session titles…"
--tools ""`. Claude Code 2.1.296 sends that as tools [] with max_tokens
64000, and the prompt sits in a system text block (desktopTitle).
17a3e0b's 4096 bound never matched that request, so it went to Desktop's
pick before. Now it goes to the session's model, which is what 17a3e0b
wanted. Desktop's own client keeps 17a3e0b's rule unchanged. A model magpie
doesn't serve (Claude Code's claude-haiku-… by name) still goes to the
session's model whoever asks, and the tier stand-in is unchanged.

I didn't match on prompt text or max_tokens to recognise the classifier. Its
prompt and sizes change between Claude Code releases. The User-Agent tells
"Claude Code chose this model" from "Desktop chose its small_fast pick".
That split is the one 17a3e0b's goal needs.

Tested:
- TestClaudeDesktopClassifierKeepsItsModel covers several requests on the
  claude-desktop key after an opus turn. The classifier's 64 and
  256+thinking stages and the 1024 notification classifier stay on
  claude-sonnet-5. Desktop's title from its Electron UA and from Claude
  Code (real 2.1.296 bytes) goes to claude-opus-5-5. An unserved
  claude-haiku goes to claude-opus-5-5.
- TestDesktopTitle.
- I broke the fix by hand twice. With the old condition the classifier
  goes to opus and the test fails. Without the title exception, Claude
  Code's title stays on sonnet and the test fails.
- Real use: I ran real Claude Code 2.1.296 (sandbox HOME, key
  magpie-claude-desktop) through a sandboxed magpie built from this tree,
  with a capture server as the provider. The turn on claude-opus-5-5 went
  to opus. `claude -p --system-prompt "You write short session titles…"
  --tools "" --model claude-sonnet-5` reached the provider as
  claude-opus-5-5. Its notification classifier (sonnet, 1024, no tools)
  reached it as claude-sonnet-5. A title with Desktop's Electron UA reached
  it as claude-opus-5-5.
- go test -tags nogui ./... passes (rebased on origin/main, run under the shared lock), gofmt -l clean,
  GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway/.
2026-10-11 04:36:11 +08:00
..
settings: keep awake can keep the display on too (#975, Hu9956: magpie's keep-awake held the system up, but the screen still went black and locked, and their agents record the screen to check their work, which a locked screen stops) — Settings › General's "Keep awake while agents work" row now has three segments, Off / On / Screen on too, saved as keepAwake and the new keepAwakeDisplay (default off, so On and every existing settings.json behave as before). awake.Keep takes a Level (Off, System, Display) in place of a bool; a level changed while held releases and takes the hold anew. On a Mac the display level runs caffeinate -i -d -w <pid> (pmset -g assertions on a caffeinate of the same flags shows PreventUserIdleDisplaySleep beside PreventUserIdleSystemSleep); on Windows SetThreadExecutionState gets ES_DISPLAY_REQUIRED too; on Linux logind's idle inhibitor (systemd-inhibit --what=idle:sleep, unchanged) is all there is, and whether the screen stays on is up to the desktop. keepAwakeDisplay is this computer's own (KeepOwn) and goes in prefsKeep, so another setting's save keeps it. The row's line says the display stays on when it's chosen; it keeps its English in data-en, so a language change re-translates it. zh/ja/de strings added. No TUI or CLI has keep-awake, so none changed. TestKeepDisplay (taken once, taken anew with the display, not again at the same level, back to System, released at Off), TestCaffeinateArgs, TestExecutionState (GOOS=windows test build) and TestKeepAwakeKeptAndOwn cover it; go test ./internal/awake ./internal/settings ./internal/gui ./internal/gateway pass, -race -count=5 on awake. keep-awake.test.cjs now runs en/zh/ja/de at 900px and 440px in Chromium and WebKit (display posts keepAwake+keepAwakeDisplay true, the line changes, another setting's save keeps it, segments fit the row, On and Off clear it, no click moves the page): 32/32 twice; gui-ja, gui-de, i18n-keys and click-scroll pass. go vet (darwin, windows, linux), darwin, linux (nogui) and windows builds pass. Not tried with an agent recording the screen; the reporter is asked to confirm.
2026-10-06 15:33:28 +08:00
windows: an account list read while another magpie writes it is waited for, not taken for no accounts (Packing1 on Discord, Windows 11: 早上更新重启后之前登录的Antigravity订阅供应商和账号都没了 … 整行都没了,供应商里面antigravity直接消失了) — on Windows a file being renamed over (every write magpie makes: a temp file renamed onto it) is, for a moment of up to ~2ms, "The system cannot find the file specified" to anyone else looking at it, with MoveFileEx and with POSIX-semantics renames alike. filememo.Read gave that back as an error, readLogins as no accounts, and whatever change came next (any account's read-modify-write) wrote the empty list back: every built-in account gone, its subscription with it. Measured on Windows 11 (10.0.0.132): one process replacing a 200 KB file, another stat-ing and reading it, saw the file "not there" in a few windows each 20 s. Now steady.Stat and steady.ReadThere wait out a moment of a file not there (15 tries a millisecond apart, Windows only), and filememo looks through them, remembering a file found not there so one that really isn't costs the wait once. A magpie started by an update now waits for the one it replaces before its start-up moves write any file (AwaitPredecessor at the top of run, not only in the GUI). TestLoginsKeptWhileAnotherMagpieWrites (Windows: two writers replacing logins.json, readLogins never without the Antigravity account) failed 1 in 3 and 2 in 8 runs on the old code ("read as no accounts 8 times"), passed 11 of 11 on this; filememo's TestReadWhileReplaced the same (1180 misses on the old code); TestStatWaitsOutAReplace everywhere. A real update in a sandbox home on the Windows box, magpie-cli 0.1.880 → 0.1.942 from the release, kept the account and logins.json byte for byte. go vet (darwin, and windows nogui), builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
2026-10-05 10:57:45 +08:00
…
upstream: the vendors' own status pages say when their API is down (#971, emo172: an Anthropic or OpenAI outage looked like a sign-in or quota problem) — a provider that calls Anthropic's, OpenAI's or Moonshot's API (by its base URL's host: api.anthropic.com, which the Claude subscription calls too; api.openai.com and chatgpt.com, Codex's; api.moonshot.cn/.ai) carries "API outage" (red), "API degraded" or "API maintenance" beside its name on its Providers row and its Usage card while the vendor's page says so; its title names the parts and the open incidents, and a click opens the incident (or the page), not the row. internal/upstream reads each page's Statuspage-style summary.json (status.claude.com; status.openai.com, incident.io's; status.moonshot.cn), checked by hand on 2026-10-06, and only the API's own parts (Claude API and Claude Code, not claude.ai; Chat Completions, Responses, Codex, Codex CLI, not "Codex in ChatGPT Desktop", which was degraded that day); an incident naming no parts (OpenAI's) counts only while those parts are affected. Pages are read only when the Providers or Usage page asks (GET /api/upstream), at most once in five minutes, never on a request's way; a page that fails, isn't JSON or no longer lists the API's parts is unknown and marks nothing. A relay serving the same models is never marked. DeepSeek's page (Flashduty) has nothing readable and is only known for its link; OpenRouter, xAI, Mistral and z.ai have no page read. The gateway's failure messages, TUI, CLI and tray aren't changed. zh/ja/de added. upstream_test (fake pages from the real summaries: API down, claude.ai down isn't the API, Claude Code degraded, OpenAI's app isn't the API, 503/HTML/changed page unknown, read once in Fresh and Of never waits, hosts; -race -count=5) and gui's TestUpstreamRoute pass; upstream-status (Anthropic down: its provider and the Claude subscription marked, relay/OpenAI/unread Moonshot not, click opens the incident not the row, all well marks nothing; 900 and 440px, the badge whole, the name giving way) passes in Chromium and WebKit, en and zh, and fails 8/8 without the app.js change. i18n-keys, gui-ja, gui-de, click-scroll, account-return, account-models, usage-keys-fold, deprecated-subscriptions and add-sheet pass; go vet, go test ./internal/gui/, linux/windows/nogui builds pass.
2026-10-06 12:36:05 +08:00
…