claude-desktop: a model picked for two tiers is listed for the second too, so that tier isn't left empty (#5534)
Claude Desktop keys a profile's inferenceModels by name and reads one tier
off an entry: for each tier, the entry tagged with it (isFamilyDefault
first) names ANTHROPIC_DEFAULT_<TIER>_MODEL for the Code tab's Claude
Code (JNn/WNn in 4.16336's app.asar, FPn in 4.23118's). desktopTierOf
tags a model picked for two tiers with the first only, so the second had
no model. dawei picked copilot/claude-sonnet-5.5 for sonnet and haiku
(Copilot has no Haiku 5.5); Desktop spawned Claude Code with
ANTHROPIC_DEFAULT_HAIKU_MODEL empty, and its small tasks (WebFetch page
summaries) ran on the session's copilot/claude-opus-5.5 at 94-244 s each.
Now:
- desktopSharedTiers: each tier whose pick an earlier tier already has.
- DesktopInferenceModels lists such a model once more per later tier,
after the rows (the first row, which a new session starts on, stays
first), tagged with the tier and isFamilyDefault, with the row's 1M
fields and its label plus " · <tier>".
- desktopTierAlias names it in the form claudeLooking gives the model
under a number made of its id and the tier (magpie-<n>.anthropic.<model>,
mythos-magpie-<n>, or anthropic/magpie-<n> for a model listed by its own
id). aliased reads that number back to the model, so the gateway serves
it as the pick (desktopTierAsked), and a session saved on it is still
served after the picks change.
- desktopRunsAs (previous commit) gives it behavesAs where Claude Code
doesn't know the id.
- agent: CLAUDE_CODE_MODEL_CAPABILITIES and the modelSettings budgets
carry the extra ids too (gateway.DesktopTierAliases).
- docs/subsystems/gateway-routing.md and agent-wiring.md say so.
Not changed: /v1/models still tags one row per model (Desktop reads no
/v1/models while the list is written); the Providers page's Desktop
number is the first id's. Desktop's menu shows the extra entry
("Claude Sonnet 5.5 · Copilot · haiku"); the list has no hidden entries.
Ported from mdwsk88's desktop-tier-shared-pick (817edde09), reviewed line
by line. Added here: TestDesktopTierSharedPick's "every tier" (one model
for opus, sonnet, haiku and fable: three extra entries, every name
distinct, each tier tagged once, each id read back and its tool-less
small task served on the pick while the session is on another model)
and "own id" (a Claude model with no reasoning levels, listed by its own
id: the later tier is anthropic/magpie-<n> with behavesAs that model).
Run on mote (go1.26.8):
- TestDesktopTierSharedPick (4 subtests), TestDesktopGroupPickRunsAsItsModel,
TestClaudeDesktopModelsSharedTier, TestClaudeCapabilitiesDesktopSharedTier:
ok. Broken by hand, each red:
- desktopSharedTiers looping over no tier (the old behaviour): all four
subtests ("haiku has no entry"), and both agent tests;
- aliased not reading a tier's number back: all four subtests
("magpie-2213721611.anthropic.claude-sonnet-5-5 read back as ...").
- go test -run 'Desktop|Claude|Alias|Tier' ./internal/gateway
./internal/agent: ok. go vet darwin, linux (-tags nogui), windows,
go build ./...: ok. gofmt -l: nothing.
- Desktop's own code: the list this commit gives for opus m1, sonnet and
haiku claude-sonnet-5-5, fable m1, run through JNn/WNn taken verbatim
from Desktop 4.16336's app.asar in node: HAIKU =
magpie-2213721611.anthropic.claude-sonnet-5-5, FABLE =
mythos-magpie-7663130977, OPUS and SONNET as before. The same list
without the extra entries (the old one): HAIKU and FABLE "".
Not tried: a real Claude Desktop reading the list and starting Claude
Code; the Playwright suites (no GUI file changed). The full suite runs
after the push.
Reported-by: dawei (Discord)
Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
This commit is contained in:
@@ -132,7 +132,7 @@ something else shows up as drift.
|
||||
- Claude Code's "subagents" field is `env.CLAUDE_CODE_SUBAGENT_MODEL`. Unset, magpie writes nothing there (`writeTiers`, `setSubagent`), and Claude Code picks: the Agent tool call's model, then the subagent's own frontmatter model, then the variable, then the lead's model (Claude Code 2.1.306; the built-in Explore inherits, capped at opus). So the GUI calls unset "Claude Code's own pick" (`claudePicks` in app.js), not "same as model" (KorenKrita on Discord). Its effort is written only with a model: unset, a saved subagent effort is kept (`claude.subagent_effort` in the stash) and not applied, since writing the main model at that effort into the variable would pin every subagent to the main model (KorenKrita on Discord). A model picked later takes it. A value an older magpie wrote that way (the main model at an effort, not own) is moved into the stash and taken out of the env by `writeTiers` and Sync (`subagentFollowing`, `TestClaudeSubagentEffortNeedsAModel`). The window draws that effort at the right of the Subagents row like a tier's, disabled at Default while the model is unset (`effortBtn` in `connectPanel`, `claude-subagent-effort-row.test.cjs`); the tray panel keeps its own square.
|
||||
- Codex's "subagent model" field writes nothing to Codex's config: its lead names each subagent's model in `spawn_agent`, which `[agents]` can't overrule. It is magpie's setting (`settings.CodexSubagentModel`, [`codex_subagent.go`](../../internal/provider/codex_subagent.go)), and the gateway moves the subagent's request onto it (see [gateway routing](gateway-routing.md)). Its options are every model and routing group Codex's own lists show (`CatalogFor("codex")`, so a model taken out of them or not picked is left out here too), ChatGPT accounts' first (#1633: a lead on a chat provider wants its subagents there too). A task a ChatGPT-backed lead sealed opens only on a ChatGPT account, so the gateway keeps such a subagent on its own model when the one set is another provider's. Its setter takes any `provider/model` or `group/<id>`, also one magpie doesn't serve now, so a profile or backup put back on another computer still applies (`ApplyFields` stops at the first failed Set), and refuses one of Codex's own bare names. Unset, the GUI says "Lead's pick": the lead may name one of Codex's own models, which goes through Codex's ChatGPT sign-in. "Same as the lead" is the value `lead` (`provider.CodexSubagentLead`): every subagent on the model the lead's own turns go on, whatever it names (cleverpigo on X: a lead on WorkBuddy's DeepSeek named `gpt-5.6-sol`, the first of Codex's own models `spawn_agent` lists, under what then read "Same as the lead").
|
||||
- Claude Desktop's "subagent model" field (`subagent_model`, `desktopSubagentField` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)) writes nothing to Desktop's config: Desktop runs its Code tab's Claude Code with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1`, under which Claude Code ignores `CLAUDE_CODE_SUBAGENT_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` and the tier variables in its settings files' `env` ("Ignoring … this session's provider routing is managed by the host", Claude Code 2.1.295), and the env Desktop builds for the Code tab has no key for it (Desktop 2.31226). It is magpie's setting (`settings.DesktopSubagentModel`, [`desktop_subagent.go`](../../internal/provider/desktop_subagent.go)), and the gateway moves each subagent's turn onto it (see [gateway routing](gateway-routing.md)). It is labelled as Codex's, so the Agents page gives it the same square. Its options are magpie's models and groups as Desktop's list shows them (`viaMagpie("claude-desktop")`), while Desktop is on magpie, as for the tiers. A Desktop alias picked is kept by its catalog id (`DesktopCatalogID`). Like Codex's, its setter takes any `provider/model` or `group/<id>`, also one magpie doesn't serve now, so a profile or backup still applies, and refuses a bare name. It is `Live`: the gateway reads it on each request.
|
||||
- Claude Desktop's tiers also write magpie's profile's `inferenceModels` (`desktopSyncModels` in [`claudedesktop_models.go`](../../internal/agent/claudedesktop_models.go)), the list `gateway.DesktopInferenceModels` gives (see [gateway routing](gateway-routing.md)): on a tier's `Set`, as Desktop comes on magpie, and on the agent's `Sync`, so a provider saved or removed reaches it through `SyncCatalog`. Desktop 4.4212 reads no `/v1/models` while such a list has no bare tier word as a name (`adminListObviatesDiscovery` in its app.asar) and names an entry by its `labelOverride`, else its catalog's name, else the id, so every entry carries the `display_name` `/v1/models` gives its row as `labelOverride`; without it every `mythos-magpie-<number>` read as that id once a tier was picked (chengming0v0 on Discord, `TestDesktopInferenceModelsNamed`), and a catalog-named Claude model reads as that name too ("Opus 5.5 · <provider>") while the list is written. It is written through temp-and-rename and only when it changed, and taken away when no tier is picked. The list is magpie's only while its hash is one magpie recorded (`desktopModelsMark` in the stash, the next hash recorded before each write); any other list, the user's own or one carried from their own gateway profile, is never written over or taken away. A pick that runs as a Claude model (`behavesAs`) is told its own window in Claude Code's `modelSettings` (`claudeBudget.behaves`), since Claude Code would otherwise run it at that Claude model's. Desktop reads the list as it starts. Not tried against a real Desktop 4.29 or later; a Desktop below 2 (no mythos word) is given the mythos ids `/v1/models` gives 2 and up. `TestClaudeDesktopModelsList`.
|
||||
- Claude Desktop's tiers also write magpie's profile's `inferenceModels` (`desktopSyncModels` in [`claudedesktop_models.go`](../../internal/agent/claudedesktop_models.go)), the list `gateway.DesktopInferenceModels` gives (see [gateway routing](gateway-routing.md)): on a tier's `Set`, as Desktop comes on magpie, and on the agent's `Sync`, so a provider saved or removed reaches it through `SyncCatalog`. Desktop 4.4212 reads no `/v1/models` while such a list has no bare tier word as a name (`adminListObviatesDiscovery` in its app.asar) and names an entry by its `labelOverride`, else its catalog's name, else the id, so every entry carries the `display_name` `/v1/models` gives its row as `labelOverride`; without it every `mythos-magpie-<number>` read as that id once a tier was picked (chengming0v0 on Discord, `TestDesktopInferenceModelsNamed`), and a catalog-named Claude model reads as that name too ("Opus 5.5 · <provider>") while the list is written. It is written through temp-and-rename and only when it changed, and taken away when no tier is picked. The list is magpie's only while its hash is one magpie recorded (`desktopModelsMark` in the stash, the next hash recorded before each write); any other list, the user's own or one carried from their own gateway profile, is never written over or taken away. A pick that runs as a Claude model (`behavesAs`) is told its own window in Claude Code's `modelSettings` (`claudeBudget.behaves`), since Claude Code would otherwise run it at that Claude model's. A model picked for two tiers is listed for the second by an id of its own (`gateway.DesktopTierAliases`), and Claude Code's settings carry that id's window and reasoning levels as they carry the first's (`claudeCapabilities`, the `modelSettings` budgets; `TestClaudeDesktopModelsSharedTier`, `TestClaudeCapabilitiesDesktopSharedTier`). Desktop reads the list as it starts. Not tried against a real Desktop 4.29 or later; a Desktop below 2 (no mythos word) is given the mythos ids `/v1/models` gives 2 and up. `TestClaudeDesktopModelsList`.
|
||||
- Claude Desktop's "subagent effort" (`desktopSubagentEffortField`, `settings.DesktopSubagentEffort`) is also Quiet and Live. Default keeps the effort the request asks for, including disabled thinking; it never selects a new default. A picked level works independently of the subagent model: no model pick, the same model and an unavailable model pick all still take the effort. While wired, the field offers the selected model's levels, or the standard levels when its model is inherited or unavailable; a model marked reasonless offers none. The stored pick survives model changes. A disconnected preference can be saved or cleared without connecting Desktop or showing restart advice, so profile restoration and Disconnect can restore a value saved before connecting; reconnect returns to the last live pick. `subEffortTitle` gives Desktop the Claude Code default explanation; Codex's default meaning is unchanged. The gateway fits each attempt to its actual model and preserves fixed group-member efforts (see [gateway routing](gateway-routing.md)).
|
||||
- Claude Desktop picks its userData in its main process before any window opens: while a 3p configuration is applied and `deploymentMode` isn't `"1p"`, it is `Claude-3p` (Desktop 2.7032's `index.pre.js`, `app.setPath("userData", …-3p)`). So turning Desktop onto magpie shows none of the chats, projects and Code sessions of the Anthropic sign-in, which stay in `Claude` (xgddm88 on X: 之前的工程和会话记录全没了). magpie writes nothing in `Claude` but `deploymentMode` in its `claude_desktop_config.json`, and reads its `config.json` for the language; Off brings that history back. A row not yet connected says so before it is turned on (`CONNECT_BEFORE` in `app.js`), the opened row once it is on (`CONNECT_COST`), and the notice after each change (`noticeClaudedesktop3`, `noticeClaudedesktop4`; `TestClaudeDesktopKeepsTheSignedInHistory`, `desktop-history.test.cjs`). Opus beside the gateway's other models in that mode comes from a Claude subscription added in magpie. With `disableDeploymentModeChooser` unset Desktop's login screen would offer Claude.ai sign-in too; magpie still seeds it (as CC Switch does), so the way back is Off. The drift check asks Desktop's own question (`desktop3p`, `m4` in 4.4212's and 2.7032's `index.pre.js`): Desktop is off magpie only when Claude-3p's `deploymentMode` is `"1p"` and the applied profile leaves the chooser on. The `Claude` folder's `deploymentMode` isn't read, and Desktop 4.4212 deletes Claude-3p's itself (a stored `"1p"` with no claude.ai sign-in is dropped at start, `deploymentMode written { mode: undefined }`), so a missing one is still magpie (dev_quj on X; `TestClaudeDesktopModeAsDesktopReadsIt`).
|
||||
- Claude Desktop's 3p mode runs in a userData of its own (`Claude-3p`), whose `config.json` (Desktop's own settings, not `claude_desktop_config.json`) starts with no `locale`, so Desktop on magpie came up in the system's language rather than the one picked signed in with Anthropic (memory and Osal on Discord). Turning Desktop onto magpie copies that one key, `locale`, from the signed-in userData's `config.json` (`Claude`, `%APPDATA%\Claude` on Windows, the first set's before the others) into `Claude-3p/config.json` when that file is missing or a JSON object without one (`desktopCarryLocale` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)); only a name Desktop takes for a catalog is carried. A `locale` already in `Claude-3p`, Desktop's or set by hand, is never written over, and no other key of that file is ever written. Off removes the file only when magpie made it and it still holds nothing but the language carried (`TestClaudeDesktopCarriesTheLanguage`, `TestClaudeDesktopKeepsThe3pLanguage`, `TestClaudeDesktopUserEditsThenReapply`). Desktop shows the language only where its 3p window has that catalog: the window is Desktop's bundled UI (`Resources/ion-dist`, 11 catalogs and no Chinese in 2.7032, 2.9939, 3.6556.2, 4.4212.0 and 4.23118.0 (11-05; packed as `Resources/ion-dist.asar` from 4.4212.0; 4.23118.0's `frame-shell` catalogs in `app.asar` are the same 11), while 3.6556.2's main process has `zh-Hans` and `zh-Hant` for the signed-in window). On every start that window asks the main process for its own pick (`requestLocaleChange`: its localStorage, else `navigator.languages` mapped onto its 11, else `en-US`), and the main process writes it into `Claude-3p/config.json`. So a Chinese `locale` there, carried or set by hand, is `en-US` again after each start, written by Desktop and not by magpie (Dx25 on Discord, Windows); nothing magpie writes can keep it. So the GUI says it to a Chinese reader: Claude Desktop's opened row on Agents has a line that Desktop on magpie is Anthropic's gateway window, with no Chinese, and that its Chinese comes back once disconnected, and the switch-on notice says the same in Chinese (GZXYMH on X, `desktop-lang.test.cjs`).
|
||||
|
||||
@@ -320,7 +320,7 @@ recorded as a prediction failure (`noPrediction`).
|
||||
- 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, 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`.
|
||||
- While a model is picked for one of Claude Desktop's tiers, magpie's Desktop profile also lists Desktop's models in `inferenceModels` (`DesktopInferenceModels` in [`desktop_list.go`](../../internal/gateway/desktop_list.go)), so a pick that isn't a Claude model runs in the Code tab with the prompt of its tier's newest Claude model (`behavesAs`: `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-haiku-5-5`, `claude-fable-5-1`, Desktop's catalog v3739), not Claude Code's generic one (moer2831 on Discord). Desktop 4.29 and later hand Claude Code `behavesAs` only from that list (z3t in its app.asar, 4.4212: `modelPicker.options` with each entry's `behavesAs`); the gateway's `behaves_as` row field feeds Desktop's own effort profile only. A non-empty list replaces `/v1/models` in Desktop's menus (pzn: a discovered row gives only its name and description, by id), so the list is every row `/v1/models` gives Desktop, by its id and in its order, each with what Desktop would have read off the row: `supports1m` for a window of 1M and up, `prefer1m` (and the row's `display_name` as `labelOverride`, where Desktop names the row by display_name) for a model listed by its `[1m]` id, and a pick's `anthropicFamilyTier` with `isFamilyDefault`. A Claude model picked runs as itself where Claude Code knows it by the id it is listed by; a routing group led by one is listed by its mythos-magpie-<number> and runs as the group's model, as one listed by anthropic/magpie-<number> does (`desktopRunsAs`, `TestDesktopGroupPickRunsAsItsModel`). Nothing picked (or a pick of a model no longer listed): no list, and Desktop finds the models as before. Picks that can't be read are unknown, and what is written stays. Older builds take the entries' names and drop the rest (2.7032's entry is a zod object, which strips unknown keys). Desktop reads its profile only as it starts, so the tiers' menu says to restart it, and the Agents row's Restart shows (`AppBehind` reads the profile). `TestDesktopInferenceModels`.
|
||||
- While a model is picked for one of Claude Desktop's tiers, magpie's Desktop profile also lists Desktop's models in `inferenceModels` (`DesktopInferenceModels` in [`desktop_list.go`](../../internal/gateway/desktop_list.go)), so a pick that isn't a Claude model runs in the Code tab with the prompt of its tier's newest Claude model (`behavesAs`: `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-haiku-5-5`, `claude-fable-5-1`, Desktop's catalog v3739), not Claude Code's generic one (moer2831 on Discord). Desktop 4.29 and later hand Claude Code `behavesAs` only from that list (z3t in its app.asar, 4.4212: `modelPicker.options` with each entry's `behavesAs`); the gateway's `behaves_as` row field feeds Desktop's own effort profile only. A non-empty list replaces `/v1/models` in Desktop's menus (pzn: a discovered row gives only its name and description, by id), so the list is every row `/v1/models` gives Desktop, by its id and in its order, each with what Desktop would have read off the row: `supports1m` for a window of 1M and up, `prefer1m` (and the row's `display_name` as `labelOverride`, where Desktop names the row by display_name) for a model listed by its `[1m]` id, and a pick's `anthropicFamilyTier` with `isFamilyDefault`. Desktop keys the list by name and reads one tier off an entry (FPn in its app.asar, 4.23118: the entry tagged with a tier names its `ANTHROPIC_DEFAULT_<TIER>_MODEL`), so a model picked for two tiers is tagged with the first (`desktopTierOf`) and listed once more, after the rows, for each later tier (`desktopSharedTiers`), by its id's form under a number of its own (`desktopTierAlias`: magpie-<number>.anthropic.<model>, mythos-magpie-<number> or anthropic/magpie-<number>), which `aliased` reads back to the model, so the gateway serves it as the pick (`desktopTierAsked`). Before, the later tier had no model: copilot/claude-sonnet-5.5 picked for sonnet and haiku gave Claude Code an empty `ANTHROPIC_DEFAULT_HAIKU_MODEL`, and its small tasks, WebFetch's page summaries among them, ran on the session's model. The rows stay first, so a new session still starts on the first row. A Claude model picked runs as itself where Claude Code knows it by the id it is listed by; a routing group led by one is listed by its mythos-magpie-<number> and runs as the group's model, as one listed by anthropic/magpie-<number> does (`desktopRunsAs`; `TestDesktopTierSharedPick`, `TestDesktopGroupPickRunsAsItsModel`). Nothing picked (or a pick of a model no longer listed): no list, and Desktop finds the models as before. Picks that can't be read are unknown, and what is written stays. Older builds take the entries' names and drop the rest (2.7032's entry is a zod object, which strips unknown keys). Desktop reads its profile only as it starts, so the tiers' menu says to restart it, and the Agents row's Restart shows (`AppBehind` reads the profile). `TestDesktopInferenceModels`.
|
||||
- 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`.
|
||||
- Kiro is told where to cache the prompt (plugins#110: a Kiro subscription read 0 from its cache). Its API takes Bedrock's `cachePoint: {"type":"default"}` on a `userInputMessage`, an `assistantResponseMessage` or as a tool entry. The built-in (`buildKiro` in [`kiro.go`](../../internal/gateway/kiro.go)) marks the first message when there is a system prompt, which it folds into that message, and the current message, as `buildAnthropic` marks Anthropic's. A moved Kiro's plugin (opencode-kiro-auth 0.1.10, the mover's `min`) turns each `cache_control` in the Anthropic body it is handed into one, at most 4, the last kept.
|
||||
|
||||
@@ -429,10 +429,14 @@ func claudeCapabilities(first []string, own, desktop bool) string {
|
||||
}
|
||||
if desktop {
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
again := gateway.DesktopTierAliases()
|
||||
for _, e := range shown {
|
||||
// one named as a Claude model Claude Code knows on its own
|
||||
if id := gateway.DesktopID(e); claudeName(id) == "" {
|
||||
add(id, e.Efforts)
|
||||
// one named as a Claude model Claude Code knows on its own;
|
||||
// a model picked for two tiers is listed for the second too
|
||||
for _, id := range append([]string{gateway.DesktopID(e)}, again[e.ID]...) {
|
||||
if claudeName(id) == "" {
|
||||
add(id, e.Efforts)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1251,9 +1255,12 @@ func claudeIn(at place) *Agent {
|
||||
if desktopOn() {
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
behaves, _ := gateway.DesktopBehavesAs()
|
||||
again := gateway.DesktopTierAliases()
|
||||
for _, e := range shown {
|
||||
if id := gateway.DesktopID(e); claudeName(id) == "" {
|
||||
models = append(models, claudeBudget{id: id, window: e.Context, long: gateway.DesktopListed1M(e), compact: work(e.ID), behaves: behaves[id] != ""})
|
||||
for _, id := range append([]string{gateway.DesktopID(e)}, again[e.ID]...) {
|
||||
if claudeName(id) == "" {
|
||||
models = append(models, claudeBudget{id: id, window: e.Context, long: gateway.DesktopListed1M(e), compact: work(e.ID), behaves: behaves[id] != ""})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,3 +186,50 @@ func TestClaudeCapabilitiesSync(t *testing.T) {
|
||||
t.Fatalf("after w/b was added: %q", caps())
|
||||
}
|
||||
}
|
||||
|
||||
// A model picked for two of Claude Desktop's tiers is listed for the
|
||||
// second by an id of its own (gateway.DesktopTierAliases); Claude Code is
|
||||
// told that id's reasoning levels too, as it is the first's.
|
||||
func TestClaudeCapabilitiesDesktopSharedTier(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("APPDATA", filepath.Join(home, "AppData", "Roaming"))
|
||||
t.Setenv("LOCALAPPDATA", filepath.Join(home, "AppData", "Local"))
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
if err := provider.Save(provider.Provider{ID: "v", Name: "V", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"Deep", "mid"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := provider.SetModelEfforts("v/Deep", []string{"low", "medium", "high", "xhigh", "max"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path := filepath.Join(home, ".claude", "settings.json")
|
||||
writeFile(t, path, `{"theme":"dark"}`)
|
||||
if err := claude(home).Field("model").Set("v/mid"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d := claudeDesktop(home)
|
||||
for _, kv := range [][2]string{{"provider", "magpie"}, {"sonnet", "v/Deep"}, {"haiku", "v/Deep"}} {
|
||||
if err := d.Field(kv[0]).Set(kv[1]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := claude(home).Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
caps, _ := edit.GetJSON(path, "env."+claudeCapsEnv)
|
||||
segs := map[string]string{}
|
||||
for _, s := range strings.Split(caps, ";") {
|
||||
if k, v, ok := strings.Cut(s, "="); ok {
|
||||
segs[k] = v
|
||||
}
|
||||
}
|
||||
again := gateway.DesktopTierAliases()["v/Deep"]
|
||||
if len(again) != 1 || !strings.HasPrefix(again[0], "mythos-magpie-") {
|
||||
t.Fatalf("haiku's id for Deep: %v", again)
|
||||
}
|
||||
if segs[again[0]] != "effort,xhigh_effort,max_effort" {
|
||||
t.Fatalf("haiku's %s: %q (%s)", again[0], segs[again[0]], caps)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,3 +157,46 @@ func TestClaudeDesktopModelsList(t *testing.T) {
|
||||
t.Fatalf("the user's list: %s, was %s", now, mine)
|
||||
}
|
||||
}
|
||||
|
||||
// A model picked for two of Desktop's tiers is listed once more for the
|
||||
// second (gateway.DesktopTierAliases), by an id of its own: Desktop keys
|
||||
// the list by name and reads one tier off an entry, so before, the second
|
||||
// tier had no model and Claude Code ran it on the session's model. Claude
|
||||
// Code is told the pick's window under that id too, since it would take
|
||||
// the behavesAs model's.
|
||||
func TestClaudeDesktopModelsSharedTier(t *testing.T) {
|
||||
home, p := desktopSandbox(t)
|
||||
if err := provider.Save(provider.Provider{ID: "v", Name: "V", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"a", "b"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := catalog.SaveLive("v", "http://127.0.0.1:1/v1", []catalog.Model{{ID: "a", Context: 272000}, {ID: "b", Context: 128000}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cc := filepath.Join(home, ".claude", "settings.json")
|
||||
writeFile(t, cc, `{"theme":"dark"}`)
|
||||
d := claudeDesktop(home)
|
||||
for _, kv := range [][2]string{{"provider", "magpie"}, {"sonnet", "v/a"}, {"haiku", "v/a"}} {
|
||||
if err := d.Field(kv[0]).Set(kv[1]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
raw, ok := edit.GetJSONRaw(p.prof, "inferenceModels")
|
||||
if !ok {
|
||||
t.Fatal("no list")
|
||||
}
|
||||
var list []map[string]any
|
||||
if err := json.Unmarshal([]byte(raw), &list); err != nil {
|
||||
t.Fatalf("%v: %s", err, raw)
|
||||
}
|
||||
again := gateway.DesktopTierAliases()["v/a"]
|
||||
if len(list) != 3 || len(again) != 1 {
|
||||
t.Fatalf("a for sonnet and haiku: %v, aliases %v", list, again)
|
||||
}
|
||||
haiku := list[2]
|
||||
if haiku["name"] != again[0] || haiku["anthropicFamilyTier"] != "haiku" || haiku["behavesAs"] != "claude-haiku-5-5" {
|
||||
t.Fatalf("haiku's entry: %v (alias %s)", haiku, again[0])
|
||||
}
|
||||
if v, _ := edit.GetJSON(cc, budgetPath(again[0])); v != "272000" {
|
||||
t.Fatalf("a's window under haiku's id in Claude Code's settings: %q\n%s", v, readFile(cc))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,6 +461,16 @@ func aliased(id string) (string, bool) {
|
||||
return e.ID, true
|
||||
}
|
||||
}
|
||||
// a model listed once more for a tier after the first it is picked
|
||||
// for (desktopTierAlias), by whichever tier, so a session saved on it
|
||||
// is served after the picks change too
|
||||
for _, e := range provider.CatalogOf("claude-desktop") {
|
||||
for _, t := range DesktopTierNames {
|
||||
if aliasNumber(desktopTierKey(e.ID, t)) == number {
|
||||
return e.ID, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package gateway
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -38,15 +39,16 @@ var desktopBehavesAs = map[string]string{
|
||||
}
|
||||
|
||||
// DesktopBehavesAs is the Claude model each picked tier's model runs as in
|
||||
// Desktop's Code tab, by the id Desktop hands Claude Code (DesktopID); one
|
||||
// Claude Code knows as a Claude model by that id has its own already
|
||||
// (desktopRunsAs). ok is false when the picks can't be read.
|
||||
// Desktop's Code tab, by the id Desktop hands Claude Code (DesktopID, and
|
||||
// for a tier after the first its desktopTierAlias); one Claude Code knows
|
||||
// as a Claude model by that id has its own already (desktopRunsAs). ok is
|
||||
// false when the picks can't be read.
|
||||
func DesktopBehavesAs() (as map[string]string, ok bool) {
|
||||
picked, ok := desktopTiersKnown()
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
tierOf := desktopTierOf(picked)
|
||||
tierOf, more := desktopTierOf(picked), desktopSharedTiers(picked)
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
as = map[string]string{}
|
||||
for _, e := range shown {
|
||||
@@ -55,23 +57,56 @@ func DesktopBehavesAs() (as map[string]string, ok bool) {
|
||||
as[DesktopID(e)] = b
|
||||
}
|
||||
}
|
||||
for _, t := range more[e.ID] {
|
||||
id := desktopTierAlias(e, t)
|
||||
if b := desktopRunsAs(e, id, t); b != "" {
|
||||
as[id] = b
|
||||
}
|
||||
}
|
||||
}
|
||||
return as, true
|
||||
}
|
||||
|
||||
// DesktopTierAliases are, by a picked model's catalog id, the ids Claude
|
||||
// Desktop is shown it by for the tiers it is picked for after the first
|
||||
// (desktopTierAlias): nil when no model is picked for two, or the picks
|
||||
// can't be read.
|
||||
func DesktopTierAliases() map[string][]string {
|
||||
picked, ok := desktopTiersKnown()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
more := desktopSharedTiers(picked)
|
||||
if len(more) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := map[string][]string{}
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
for _, e := range shown {
|
||||
for _, t := range more[e.ID] {
|
||||
out[e.ID] = append(out[e.ID], desktopTierAlias(e, t))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// DesktopInferenceModels is the inferenceModels list magpie gives Claude
|
||||
// Desktop's profile: nil while no model it lists is picked for a tier,
|
||||
// when Desktop finds magpie's models on its own (/v1/models). ok is false
|
||||
// when the picks can't be read: whatever is written stays.
|
||||
// when the picks can't be read: whatever is written stays. A model picked
|
||||
// for a tier after the first it is picked for is listed once more after
|
||||
// the rows, for that tier (desktopSharedTiers), so the first row, which a
|
||||
// new session starts on, stays the first.
|
||||
func DesktopInferenceModels() (list []map[string]any, ok bool) {
|
||||
picked, ok := desktopTiersKnown()
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
tierOf := desktopTierOf(picked)
|
||||
tierOf, more := desktopTierOf(picked), desktopSharedTiers(picked)
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
rows := desktopModels(shown, true)
|
||||
tagged := false
|
||||
var again []map[string]any
|
||||
for i, m := range rows {
|
||||
e := shown[i]
|
||||
id, _ := m["id"].(string)
|
||||
@@ -99,15 +134,30 @@ func DesktopInferenceModels() (list []map[string]any, ok bool) {
|
||||
}
|
||||
}
|
||||
list = append(list, entry)
|
||||
for _, t := range more[e.ID] {
|
||||
alias := desktopTierAlias(e, t)
|
||||
x := map[string]any{"name": alias, "labelOverride": fmt.Sprint(m["display_name"]) + " · " + t,
|
||||
"anthropicFamilyTier": t, "isFamilyDefault": true}
|
||||
for _, k := range []string{"supports1m", "prefer1m"} {
|
||||
if v, has := entry[k]; has {
|
||||
x[k] = v
|
||||
}
|
||||
}
|
||||
if b := desktopRunsAs(e, alias, t); b != "" {
|
||||
x["behavesAs"] = b
|
||||
}
|
||||
again = append(again, x)
|
||||
}
|
||||
}
|
||||
if !tagged {
|
||||
return nil, true
|
||||
}
|
||||
return list, true
|
||||
return append(list, again...), true
|
||||
}
|
||||
|
||||
// desktopTierOf is the tier each picked model is tagged with: a model
|
||||
// picked for two, the first (desktopModels).
|
||||
// picked for two, the first (desktopModels); desktopSharedTiers has the
|
||||
// rest.
|
||||
func desktopTierOf(picked map[string]string) map[string]string {
|
||||
tierOf := map[string]string{}
|
||||
for _, t := range DesktopTierNames {
|
||||
@@ -118,6 +168,52 @@ func desktopTierOf(picked map[string]string) map[string]string {
|
||||
return tierOf
|
||||
}
|
||||
|
||||
// desktopSharedTiers are, by a picked model's catalog id, the tiers it is
|
||||
// picked for after the first (desktopTierOf). Desktop keys inferenceModels
|
||||
// by name and reads one tier off an entry (FPn in its app.asar, 4.23118:
|
||||
// the entry of a tier's anthropicFamilyTier names its
|
||||
// ANTHROPIC_DEFAULT_<TIER>_MODEL), so a model picked for sonnet and haiku
|
||||
// left haiku with no model at all: Claude Code in the Code tab got an
|
||||
// empty ANTHROPIC_DEFAULT_HAIKU_MODEL and ran its small tasks, WebFetch's
|
||||
// page summaries among them, on the session's model (copilot's
|
||||
// claude-opus-5.5, 94–244 s each, where the haiku pick answers in seconds).
|
||||
// Each such tier gets an entry of its own (desktopTierAlias).
|
||||
func desktopSharedTiers(picked map[string]string) map[string][]string {
|
||||
tierOf := desktopTierOf(picked)
|
||||
more := map[string][]string{}
|
||||
for _, t := range DesktopTierNames {
|
||||
if id := picked[t]; id != "" && tierOf[id] != t {
|
||||
more[id] = append(more[id], t)
|
||||
}
|
||||
}
|
||||
return more
|
||||
}
|
||||
|
||||
// desktopTierKey is what the number of e's id for tier t is made of
|
||||
// (desktopTierAlias), which aliased reads back.
|
||||
func desktopTierKey(id, t string) string { return id + "\x00" + t }
|
||||
|
||||
// desktopTierAlias is the id Claude Desktop is shown e by for a tier it is
|
||||
// picked for after the first (desktopSharedTiers): its own id's form
|
||||
// (claudeLooking) under a number of its own, so Desktop keeps the two
|
||||
// entries apart and Claude Code knows a Claude model by either, which
|
||||
// aliased reads back to e and the gateway serves as the pick. A model
|
||||
// listed by its own id has no number to change, and is listed for the
|
||||
// tier as anthropic/magpie-<number>, which runs as e (desktopRunsAs).
|
||||
func desktopTierAlias(e provider.Entry, t string) string {
|
||||
n := aliasNumber(desktopTierKey(e.ID, t))
|
||||
id := claudeLooking(e)
|
||||
if rest, ok := strings.CutPrefix(id, "magpie-"); ok {
|
||||
if i := strings.Index(rest, desktopClaudeInfix); i > 0 {
|
||||
return "magpie-" + n + rest[i:]
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(id, desktopEffortAlias) {
|
||||
return desktopEffortAlias + n
|
||||
}
|
||||
return desktopAlias + n
|
||||
}
|
||||
|
||||
// desktopTiersKnown is DesktopTiers, ok false when the file is there and
|
||||
// can't be read or parsed: no picks is something else than unknown picks.
|
||||
func desktopTiersKnown() (map[string]string, bool) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -72,6 +73,197 @@ func tierEntries(t *testing.T, list []map[string]any) map[string]map[string]any
|
||||
return out
|
||||
}
|
||||
|
||||
// A model picked for two of Claude Desktop's tiers (a user's
|
||||
// copilot/claude-sonnet-5.5 for sonnet and haiku) was tagged with the
|
||||
// first only: Desktop keys inferenceModels by name and reads one tier off
|
||||
// an entry, so haiku had no model, Claude Code in the Code tab got an empty
|
||||
// ANTHROPIC_DEFAULT_HAIKU_MODEL, and its small tasks (WebFetch's page
|
||||
// summaries) ran on the session's model. The second tier is listed once
|
||||
// more, after the rows, by the model's id form under a number of its own,
|
||||
// which the gateway reads back to the model and serves as the pick.
|
||||
func TestDesktopTierSharedPick(t *testing.T) {
|
||||
t.Run("claude model", func(t *testing.T) {
|
||||
u := desktopPickSetup(t)
|
||||
sonnet := shownEntry(t, func(e provider.Entry) bool { return e.ID == "fake/claude-sonnet-5-5" })
|
||||
for _, tier := range []string{"sonnet", "haiku"} {
|
||||
if err := SetDesktopTier(tier, sonnet.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
list, ok := DesktopInferenceModels()
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
rows := desktopModels(shown, true)
|
||||
if !ok || len(list) != len(rows)+1 {
|
||||
t.Fatalf("%d entries for %d rows and one more tier: %v", len(list), len(rows), list)
|
||||
}
|
||||
for i, r := range rows {
|
||||
if want := strings.TrimSuffix(r["id"].(string), "[1m]"); list[i]["name"] != want {
|
||||
t.Fatalf("entry %d is %v, /v1/models has %s there", i, list[i]["name"], want)
|
||||
}
|
||||
}
|
||||
tiers := tierEntries(t, list)
|
||||
if e := tiers["sonnet"]; e == nil || e["name"] != DesktopID(sonnet) {
|
||||
t.Fatalf("sonnet: %v", list)
|
||||
}
|
||||
haiku := tiers["haiku"]
|
||||
if haiku == nil {
|
||||
t.Fatalf("haiku has no entry, so Claude Code's ANTHROPIC_DEFAULT_HAIKU_MODEL is empty: %v", list)
|
||||
}
|
||||
alias, _ := haiku["name"].(string)
|
||||
if !regexp.MustCompile(`^magpie-\d{10}\.anthropic\.claude-sonnet-5-5$`).MatchString(alias) || alias == DesktopID(sonnet) ||
|
||||
haiku["isFamilyDefault"] != true || list[len(list)-1]["name"] != alias {
|
||||
t.Fatalf("haiku's entry: %v (sonnet's name %s)", haiku, DesktopID(sonnet))
|
||||
}
|
||||
if _, has := haiku["behavesAs"]; has {
|
||||
t.Fatalf("Claude Code knows %s as Claude Sonnet 5.5: %v", alias, haiku)
|
||||
}
|
||||
if l, _ := haiku["labelOverride"].(string); !strings.HasSuffix(l, " · haiku") {
|
||||
t.Fatalf("haiku's label: %v", haiku)
|
||||
}
|
||||
for _, id := range []string{alias, alias + "[1m]"} {
|
||||
if got := DesktopCatalogID(id); got != sonnet.ID {
|
||||
t.Fatalf("%s read back as %q", id, got)
|
||||
}
|
||||
}
|
||||
if a := DesktopTierAliases(); len(a) != 1 || len(a[sonnet.ID]) != 1 || a[sonnet.ID][0] != alias {
|
||||
t.Fatalf("tier aliases: %v", a)
|
||||
}
|
||||
|
||||
// the session on m1; Claude Code's small task for the haiku tier,
|
||||
// by that entry's name, goes to the pick, not the session's model
|
||||
s := New()
|
||||
m1 := shownEntry(t, func(e provider.Entry) bool { return e.ID == "fake/m1" })
|
||||
desktopSubagentAsk(t, s, Token+"-claude-desktop", DesktopID(m1), "", "/v1/messages", true)
|
||||
if m, _ := u.seen(); m != "m1" {
|
||||
t.Fatalf("the session's turn went to %q", m)
|
||||
}
|
||||
desktopSubagentAsk(t, s, Token+"-claude-desktop", alias, "", "/v1/messages", false)
|
||||
if m, _ := u.seen(); m != "claude-sonnet-5-5" {
|
||||
t.Fatalf("haiku's small task went to %q, want the haiku pick claude-sonnet-5-5", m)
|
||||
}
|
||||
|
||||
// the picks apart again: one entry a tier, none more
|
||||
if err := SetDesktopTier("haiku", "fake/m1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if list, _ := DesktopInferenceModels(); len(list) != len(rows) {
|
||||
t.Fatalf("picks apart: %v", list)
|
||||
}
|
||||
if a := DesktopTierAliases(); a != nil {
|
||||
t.Fatalf("picks apart, tier aliases: %v", a)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("other model", func(t *testing.T) {
|
||||
desktopPickSetup(t)
|
||||
m1 := shownEntry(t, func(e provider.Entry) bool { return e.ID == "fake/m1" })
|
||||
for _, tier := range []string{"opus", "haiku"} {
|
||||
if err := SetDesktopTier(tier, m1.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
list, _ := DesktopInferenceModels()
|
||||
tiers := tierEntries(t, list)
|
||||
opus, haiku := tiers["opus"], tiers["haiku"]
|
||||
if opus == nil || opus["name"] != DesktopID(m1) || opus["behavesAs"] != "claude-opus-5-5" {
|
||||
t.Fatalf("opus: %v", list)
|
||||
}
|
||||
if haiku == nil {
|
||||
t.Fatalf("haiku has no entry: %v", list)
|
||||
}
|
||||
alias, _ := haiku["name"].(string)
|
||||
if !regexp.MustCompile(`^mythos-magpie-\d{10}$`).MatchString(alias) || alias == DesktopID(m1) || haiku["behavesAs"] != "claude-haiku-5-5" {
|
||||
t.Fatalf("haiku's entry: %v", haiku)
|
||||
}
|
||||
as, ok := DesktopBehavesAs()
|
||||
if !ok || as[DesktopID(m1)] != "claude-opus-5-5" || as[alias] != "claude-haiku-5-5" || len(as) != 2 {
|
||||
t.Fatalf("behaves as: %v %v", as, ok)
|
||||
}
|
||||
if got := DesktopCatalogID(alias); got != m1.ID {
|
||||
t.Fatalf("%s read back as %q", alias, got)
|
||||
}
|
||||
})
|
||||
|
||||
// one model for every tier: each tier after the first gets an entry
|
||||
// of its own, by an id of its own, each served as the pick
|
||||
t.Run("every tier", func(t *testing.T) {
|
||||
u := desktopPickSetup(t)
|
||||
m1 := shownEntry(t, func(e provider.Entry) bool { return e.ID == "fake/m1" })
|
||||
sonnet := shownEntry(t, func(e provider.Entry) bool { return e.ID == "fake/claude-sonnet-5-5" })
|
||||
for _, tier := range DesktopTierNames {
|
||||
if err := SetDesktopTier(tier, m1.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
list, _ := DesktopInferenceModels()
|
||||
shown, _ := provider.CatalogFor("claude-desktop")
|
||||
if len(list) != len(shown)+len(DesktopTierNames)-1 {
|
||||
t.Fatalf("%d entries for %d rows and %d more tiers: %v", len(list), len(shown), len(DesktopTierNames)-1, list)
|
||||
}
|
||||
tiers := tierEntries(t, list)
|
||||
names := map[string]bool{}
|
||||
for _, e := range list {
|
||||
n, _ := e["name"].(string)
|
||||
if names[n] {
|
||||
t.Fatalf("%s listed twice: %v", n, list)
|
||||
}
|
||||
names[n] = true
|
||||
}
|
||||
if tiers["opus"] == nil || tiers["opus"]["name"] != DesktopID(m1) {
|
||||
t.Fatalf("opus, the first tier, on the row: %v", list)
|
||||
}
|
||||
s := New()
|
||||
desktopSubagentAsk(t, s, Token+"-claude-desktop", DesktopID(sonnet), "", "/v1/messages", true)
|
||||
for _, tier := range DesktopTierNames {
|
||||
e := tiers[tier]
|
||||
if e == nil || e["behavesAs"] != desktopBehavesAs[tier] || e["isFamilyDefault"] != true {
|
||||
t.Fatalf("%s: %v", tier, list)
|
||||
}
|
||||
id, _ := e["name"].(string)
|
||||
if got := DesktopCatalogID(id); got != m1.ID {
|
||||
t.Fatalf("%s's %s read back as %q", tier, id, got)
|
||||
}
|
||||
desktopSubagentAsk(t, s, Token+"-claude-desktop", id, "", "/v1/messages", false)
|
||||
if m, _ := u.seen(); m != "m1" {
|
||||
t.Fatalf("%s's small task went to %q, want the pick m1", tier, m)
|
||||
}
|
||||
}
|
||||
if a := DesktopTierAliases(); len(a[m1.ID]) != len(DesktopTierNames)-1 {
|
||||
t.Fatalf("tier aliases: %v", a)
|
||||
}
|
||||
})
|
||||
|
||||
// a Claude model with no reasoning levels is listed by its own id,
|
||||
// which has no number to change: the later tier's entry is
|
||||
// anthropic/magpie-<n>, which Claude Code doesn't know, so it runs as
|
||||
// that model
|
||||
t.Run("own id", func(t *testing.T) {
|
||||
desktopPickSetup(t)
|
||||
if err := provider.Save(provider.Provider{ID: "own", Name: "Own", Key: "k", Anthropic: "http://127.0.0.1:1", Models: []string{"claude-haiku-4-5"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h := shownEntry(t, func(e provider.Entry) bool { return e.ID == "own/claude-haiku-4-5" })
|
||||
for _, tier := range []string{"sonnet", "haiku"} {
|
||||
if err := SetDesktopTier(tier, h.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
list, _ := DesktopInferenceModels()
|
||||
tiers := tierEntries(t, list)
|
||||
if e := tiers["sonnet"]; e == nil || e["name"] != DesktopID(h) {
|
||||
t.Fatalf("sonnet: %v", list)
|
||||
}
|
||||
haiku := tiers["haiku"]
|
||||
alias, _ := haiku["name"].(string)
|
||||
if !regexp.MustCompile(`^anthropic/magpie-\d{10}$`).MatchString(alias) || haiku["behavesAs"] != "claude-haiku-4-5" {
|
||||
t.Fatalf("haiku's entry: %v", haiku)
|
||||
}
|
||||
if got := DesktopCatalogID(alias); got != h.ID {
|
||||
t.Fatalf("%s read back as %q", alias, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A routing group led by a Claude model, picked for a tier, is shown to
|
||||
// Desktop by its mythos-magpie-<n> (claudeLooking: never as the model
|
||||
// itself), which Claude Code doesn't know; its entry had no behavesAs, as
|
||||
|
||||
Reference in New Issue
Block a user