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/.