agent: a model at max without xhigh tells Claude Code it has xhigh, so Ultracode shows on GLM, DeepSeek and Kimi in Claude Desktop

leesunrise2364 on Discord: Claude Desktop on magpie has no Ultracode effort,
which cc-switch had, and Ultracode is what turns on dynamic workflows.

Desktop 2.7032.0 shows Ultracode only when the model's effort options
include xhigh and Claude Code takes it. magpie lists a model with known
levels to Desktop as mythos-magpie-<n>, whose options include xhigh, and
tells Claude Code what each model can do in CLAUDE_CODE_MODEL_CAPABILITIES.
That value said only the levels magpie knows the model has. GLM-5.3
(low/high/max), DeepSeek V4 (high/max), Kimi K3 and the like reach max
without xhigh, so they were written as "effort,max_effort", and Claude Code
refuses Ultracode there: "Ultracode isn't available on <model>". cc-switch
names its models as real Claude ids, which Claude Code already knows have
xhigh.

A model Claude Code doesn't know whose levels reach max now also gets
xhigh_effort. The gateway already runs xhigh at max for such a model
(fitEffort: a tie goes up), so no level the model doesn't take is sent.
Claude models Claude Code knows are unchanged: Opus and Sonnet 4.6 still
get no xhigh, as Claude Code's own table has it. Models that top out at
high, or have no known levels, are unchanged too.

Tests: TestClaudeModelCapabilities gets v/glm (low/high/max) and v/top
(high/max), both now "effort,xhigh_effort,max_effort", while
v/claude-opus-4-6 stays "effort,max_effort". TestClaudeCapabilitiesSync's
w/b (low/max) now has xhigh_effort. TestFitEffort covers xhigh to
[high,max] going out as max. With the change turned off by hand, both
agent tests go red on exactly those values.

Run:
- Real Claude Code 2.1.299 in a sandbox HOME, gateway mode
  (CLAUDE_CODE_USE_GATEWAY=1), `-p '/effort ultracode'`, with the value
  magpie's own code wrote for v/glm-5.3 at low/high/max
  ("v/glm-5.3=effort,xhigh_effort,max_effort") printed "Ultracode on (this
  session only): dynamic workflows on every task". The old value
  "effort,max_effort" printed "Ultracode isn't available on v/glm-5.3".
  The same pair was run for Desktop's id mythos-magpie-7, with the same
  two results.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/agent passes when run alone (1110s at load ~250),
  and so do the caps and fitEffort tests.
- The full go test ./... ran twice at load average ~300.
  - The first run hit internal/provider's 10m timeout (#2051).
  - The second run (-timeout 30m) had these reds:
    - internal/agent and internal/gateway passed 30m as whole packages;
    - TestAgentGoneInTheRetryPause/last_one_left (#2175's sibling);
    - TestMainWindowCorners was killed at its deadline (#1936).
  - None of these is in code this commit touches.

Not tried: a live Claude Desktop. The packaged app won't start on a
sandbox user-data dir, and the live Desktop config is not to be touched.
So Desktop's effort menu showing Ultracode was not seen. It rests on
Desktop's renderer code (the Ultracode gate needs xhigh among the options
and the claude_code_workflows capability) and on the Claude Code probe
above.
This commit is contained in:
yetone
2026-10-14 20:51:01 +08:00
parent 22512cde53
commit d1c485f7e9
4 changed files with 21 additions and 4 deletions
+1
View File
@@ -67,6 +67,7 @@ something else shows up as drift.
- Claude Code's sign-in (`login`) is magpie's key (`""`, the default) or claude.ai (`claudeai`). claude.ai writes `ANTHROPIC_AUTH_TOKEN` empty, which Claude Code reads as no key: it keeps its claude.ai login and sends that to magpie, which never passes it on (`claudeSignIn` in the gateway). Every later write keeps the token empty (`wiredKey`), and a key put there by hand is reported by Check, not taken for magpie's. It's offered only where the gateway takes any key (`gwKey() == gateway.Token`: loopback, a WSL distro mirrored), not from a distro under NAT while magpie is shared on the network, where only the sharing key gets in. The choice is stashed, so it survives Disconnect and a port move. An empty token counts as magpie's only beside the address magpie last wrote (`claude.wired_at` in the stash, which Rewire carries to the new port, `keyOurs`): an endpoint of the user's own with an empty token stays theirs when the model goes back to Claude Code's own.
- Claude Code's auto mode review (`CLAUDE_CODE_AUTO_MODE_SERVER`, `claudeReviewEnv` in [`claude.go`](../../internal/agent/claude.go)) is written `"0"` while Claude Code is routed through magpie and none of the models it can reach there is one Anthropic reviews (`claudeReviewed`, by `gateway.AutoModeReviewed`): those it is shown (and Claude Desktop's while Desktop is on magpie), a shown group's members, those providers' fallbacks, and the models it is set to. Off, it classifies locally from the start, as it does anyway behind a gateway that doesn't answer, without the "isn't eligible because your requests go through 127.0.0.1:3425" notice (1EFLOPS on X). Any reviewed model leaves it unset, since `/model` can take the session there; a model hidden from Claude Code doesn't count. It is rewritten on every model set and `Sync`, so adding a Claude provider turns the review back on. magpie's value is kept apart in the stash (`claude.auto_mode_server`), a user's own is left alone, and it goes when Claude Code is taken off magpie (`desktopOnly`, `unroute`). T3 Code's magpie instance, which runs Claude Code on the gateway through its own environment, carries the same `"0"` there by the models it lists (`t3InstanceJSON` in [`t3code.go`](../../internal/agent/t3code.go)); a value in the user's `~/.claude` settings comes after it.
- Claude Code takes one window (`CLAUDE_CODE_MAX_CONTEXT_TOKENS`, `claudeContextEnv` in [`claude.go`](../../internal/agent/claude.go)) for every model it doesn't know. Claude Code alone on magpie is told its main model's (`claudeWindow`). While Claude Desktop is on magpie too, its Code tab runs Claude Code on the same `~/.claude/settings.json` with every model Desktop lists, so magpie tells it the largest window of those and of Claude Code's own models, and holds each model below it to its own with `modelSettings.<id>.autoCompactWindow` (`claudePlan` in [`claude_budget.go`](../../internal/agent/claude_budget.go), #2025: the least held a 1M model to 131K). Claude Code 2.1.296 matches that key by the id it was handed, lowercased and without `[1m]`; it comes before the top-level `autoCompactWindow`, which serves a model without one. `CLAUDE_CODE_AUTO_COMPACT_WINDOW` would take precedence over both, so in this mode magpie's working window goes in the top-level `autoCompactWindow` instead, and an entry is written only where a model's window or its own threshold differs from what it would run at without one. magpie's entries and top-level value are stashed (`claude.model_budgets`, `claude.compact_default`) and go when Desktop leaves magpie; the user's own entries, top-level value and variables stay, a user's entry past its model's window (or `auto`) holds the largest to that window, and with a `CLAUDE_CODE_AUTO_COMPACT_WINDOW` of the user's the least window is told as before.
- Claude Code is told what each of magpie's models can do in `CLAUDE_CODE_MODEL_CAPABILITIES` (`claudeCapsEnv`, `claudeCapabilities` in [`claude.go`](../../internal/agent/claude.go)): `<model>=effort[,xhigh_effort][,max_effort]` for those it is shown, and, while Claude Desktop is on magpie, for Desktop's `mythos-magpie-<number>` ids its Code tab hands it. A Claude model Claude Code knows gets no more than Claude Code gives it (Opus and Sonnet 4.6: no xhigh), and one with no known levels isn't named. A model that reaches max without xhigh (GLM-5.3 at low/high/max, DeepSeek V4 at high/max) is said to have xhigh too: the gateway runs xhigh at max for it (`fitEffort`), and Claude Code 2.1.299 turns Ultracode down without `xhigh_effort` ("Ultracode isn't available on …"), which in Desktop is the Ultracode level and dynamic workflows (leesunrise2364 on Discord; `TestClaudeModelCapabilities`). A value of the user's is left alone.
- MiniMax Code takes a model ref with one slash in the whole (a SubAgent's `model` must match `^[^/\s]+\/[^/\s]+$`, #1387), and magpie's refs there are `custom_provider:magpie/<model>`. So a model under `custom_provider.magpie` is written with `~` for each slash of its catalog id (`bb-codex~gpt-6.1-sol`, `provider.FlatID`), only when that spelling stands for one served id (`provider.Flattened`); the gateway takes it back. A config an older magpie wrote moves over on the next sync: the user's keys on a model go to its new key, `defaultModel`, `defaultLightModel` and `memory.captureModel`/`consolidationModel` follow (`mcodeRefs`), and the slashed key stays, switched off (`enabled: false`), so a session begun on it still resumes. magpie never edits the user's own `agents/<name>/agent.md`. No other agent was found with this limit ([`minimax.go`](../../internal/agent/minimax.go)).
- Claude Code's `/model` list (`modelPicker` in its settings.json) is magpie's while it is marked in the stash (`claude.model_picker`, `claude@wsl:<distro>.model_picker` for a WSL distro) or while every row's description ends "via magpie", as every row magpie writes does (`magpiesPicker` in [`claude.go`](../../internal/agent/claude.go)). magpie keeps its own list up to date on every model set and `Sync`, and removes it when Claude Code is taken off magpie; a list the user wrote is left alone. The fingerprint covers a list whose mark an older magpie's stash lost, which otherwise stayed without every model added since (#2046).
- Claude Code 2.1.296 reads a Claude model whose version has a dot (`relay/claude-opus-4.6-us`) as Claude Opus 4: a retired warning, budget thinking, 32000 output tokens, no effort. With dashes (`relay/claude-opus-4-6-us`) it knows the model (misteer_ti. on Discord). So every model magpie writes into its settings (`model`, the tier envs, `ANTHROPIC_SMALL_FAST_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL`, `modelPicker`), T3 Code's Claude slugs and Claude Desktop's Code-tab ids (`claudeLooking`) spell a dotted Claude version with dashes (`provider.ClaudeSpelled`), only when that spelling stands for one served id. A Claude model listed to Desktop with reasoning levels is given as `magpie-<n>.anthropic.<model>`, its dotted version dashed as well (`claudeModel`: Copilot's `claude-opus-5.5` is `…anthropic.claude-opus-5-5`, which Claude Code knows; it was `mythos-magpie-<n>`, an unknown model, and Haiku 4.5 got an effort Copilot refuses, #1819); a request for it is served by `<n>` alone (`aliased`), so that spelling needn't be unique. Mythos counts as Claude here too: Claude Code matches `claude-mythos-5-1` by substring, so `claude-mythos-5.1` would read as Mythos 5. Every read of those keys takes it back (`provider.ClaudeRead`: `claudeIn`'s `env`, `claudeMain`, `claudeStandInAt`), so magpie's fields, applied state and Drift keep the dotted id. The user's own values are stashed and given back as written. Values an older magpie wrote dotted are rewritten on the next Sync. Other vendors' ids are never respelled ([`claudedash.go`](../../internal/provider/claudedash.go)).
+9 -1
View File
@@ -199,7 +199,9 @@ const claudeUnknownOutput = 32000
// a gateway (CLAUDE_CODE_USE_GATEWAY, as Claude Desktop's Code tab runs it)
// it otherwise takes no model of magpie's for one with effort, xhigh or max,
// so "ultracode": true, which needs xhigh, did nothing (#430). Each magpie
// model is said to have only the levels magpie knows it has.
// model is said to have only the levels magpie knows it has, and xhigh
// with max: the gateway runs xhigh at max for one without it, and without
// xhigh_effort Claude Code turns Ultracode down (leesunrise2364 on Discord).
const claudeCapsEnv = "CLAUDE_CODE_MODEL_CAPABILITIES"
// claudeReviewEnv is whether Claude Code's auto mode asks the API to review
@@ -292,6 +294,12 @@ func claudeCapabilities(first []string, own, desktop bool) string {
return
}
levels = slices.DeleteFunc(slices.Clone(levels), func(l string) bool { return !contains(claudeEffortsFor(id), l) })
// one that reaches max without xhigh runs xhigh at max (the
// gateway's fitEffort), and Claude Code's Ultracode needs
// xhigh_effort (2.1.299: "Ultracode isn't available on …")
if contains(levels, "max") && !contains(levels, "xhigh") && contains(claudeEffortsFor(id), "xhigh") {
levels = append(levels, "xhigh")
}
if c := claudeCaps(levels); c != "" && !slices.ContainsFunc(segs, func(s seg) bool { return s.id == id }) {
segs = append(segs, seg{id, c})
}
+10 -3
View File
@@ -16,7 +16,10 @@ import (
// in CLAUDE_CODE_MODEL_CAPABILITIES what each of its models (and Desktop's
// mythos-magpie-<number> for it) can do, only the levels the model has, the
// model Claude Code is set to first; a value of the user's is left alone,
// and magpie's goes when Claude Code is taken off magpie.
// and magpie's goes when Claude Code is taken off magpie. One that reaches
// max without xhigh (GLM, DeepSeek) is said to have xhigh too: the gateway
// runs it at max, and Claude Code's Ultracode needs xhigh_effort
// (leesunrise2364 on Discord, Ultracode missing on Desktop).
func TestClaudeModelCapabilities(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
@@ -26,12 +29,14 @@ func TestClaudeModelCapabilities(t *testing.T) {
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", "plain", "claude-opus-4-6"}}); err != nil {
Models: []string{"Deep", "mid", "plain", "claude-opus-4-6", "glm", "top"}}); err != nil {
t.Fatal(err)
}
for id, levels := range map[string][]string{
"v/Deep": {"low", "medium", "high", "xhigh", "max"},
"v/mid": {"low", "medium", "high"},
"v/glm": {"low", "high", "max"},
"v/top": {"high", "max"},
// Claude Code sends Opus 4.6 no xhigh, whatever the vendor says
"v/claude-opus-4-6": {"low", "medium", "high", "xhigh", "max"},
} {
@@ -69,6 +74,8 @@ func TestClaudeModelCapabilities(t *testing.T) {
"v/mid": "effort",
"group/both": "effort",
"v/claude-opus-4-6": "effort,max_effort",
"v/glm": "effort,xhigh_effort,max_effort",
"v/top": "effort,xhigh_effort,max_effort",
} {
if got[id] != want {
t.Errorf("%s: %q, want %q (%s)", id, got[id], want, caps())
@@ -175,7 +182,7 @@ func TestClaudeCapabilitiesSync(t *testing.T) {
if err := a.Sync(); err != nil {
t.Fatal(err)
}
if caps() != "v/a=effort,xhigh_effort;w/b=effort,max_effort" {
if caps() != "v/a=effort,xhigh_effort;w/b=effort,xhigh_effort,max_effort" {
t.Fatalf("after w/b was added: %q", caps())
}
}
+1
View File
@@ -24,6 +24,7 @@ func TestFitEffort(t *testing.T) {
{"medium", glm, "high"}, // a tie goes up
{"low", glm, "low"},
{"xhigh", glm, "max"},
{"xhigh", []string{"high", "max"}, "max"}, // DeepSeek V4: Ultracode's xhigh
{"max", []string{"low", "medium", "high"}, "high"},
{"low", []string{"none", "minimal", "medium"}, "medium"},
{"medium", nil, "medium"}, // levels not known: as asked