[Bug] Claude Code: an effort tier on the advisor model (model:xhigh[1m]) is rejected by the CLI, not offered by the picker, and taken off by "Apply again"
magpie version
v0.1.4685 (the command below was run on it). The code paths quoted here are the same in v0.1.4738 (27c27ef, today's main).
Where
CLI and GUI (Agents page). The gateway side works.
OS
Windows (magpie app) + WSL2 Ubuntu 24.04, where Claude Code runs. The command was run from the WSL shell against the Windows-side claude agent.
Agent, provider and model
Claude Code 2.1.330 → local magpie gateway → a relay provider (claude-2) serving claude-fable-5-2. Advisor: claude-2/claude-fable-5-2.
Steps to reproduce
- Claude Code routed through magpie, its advisor not set yet.
- Give the advisor an effort tier, the form a tier or the subagents' model takes (#536,
tierAtininternal/agent/claude.go):
$ magpie claude advisor 'claude-2/claude-fable-5-2:xhigh[1m]'
magpie: claude-2's model list has no claude-fable-5-2:xhigh[1m]: magpie provider refresh claude-2 fetches the list again (or add the model to it in its editor), and magpie models claude lists what Claude Code is shown
Exit status 1, nothing written. The provider does serve the model; only the :xhigh makes the lookup miss. What the Agents page had written for the advisor before is claude-2/claude-fable-5-2[1m], without a tier.
What happened, and what you expected
Only step 2 was run. Points 2 and 3 below come from reading the code at 27c27ef.
1. The CLI refuses a tier on the advisor. set() spells the value first (internal/cli/main.go:816). Agent.Spell has no split for an effort on Claude Code (a.split returns the whole value, internal/agent/agent.go:752 and 826-831; only omp sets SplitSuffix), so …:xhigh[1m] is looked up as a model id, matches no option, and notOffered reports it as missing from the provider (agent.go:796-821, the text at 818). The field's own Set would take the value: it asks isMagpie and writes it through spell (internal/agent/claude.go:2468-2484), and provider.Resolve accepts any <provider>/<model> of a provider that is on (internal/provider/models.go:4112-4117).
2. No way in magpie to set it. Each tier and the subagents' model have an effort field (effortField(tier+"_effort", …) at claude.go:2402, subagent_effort at 2404). The advisor has none, and its picker lists claudeViaMagpie(false) (claude.go:2486-2491): models without a tier. Picking the advisor there writes an untiered advisorModel, and so replaces a tiered one.
3. A tiered advisor set by hand is taken off by "Apply again". With "advisorModel": "claude-2/claude-fable-5-2:xhigh[1m]" in settings.json, Claude Code passes the value through and the gateway serves it (checked with :low in a real session, and with :xhigh sent straight to the gateway). It reads as one of magpie's values (isMagpie → provider.Resolve), so it isn't drift (internal/agent/applied.go:240-256). But magpie's record still holds the untiered value from before, as only Apply records (applied.go:133-135). When another field of the agent is reported as replaced and "Apply again" is used (the amber pill, internal/gui/assets/app.js:1092-1109, or the row menu at 3929), Reapply sets every recorded field that differs back (applied.go:496-510), the advisor among them. The tier is gone and nothing says so. "Keep current settings" (app.js:3930) avoids it.
Expected: the advisor takes an effort the way the tiers and the subagents do — an effort field for it that writes tierWith(model, effort) to advisorModel, or the CLI and the picker accepting <model>:<level>[1m] — and a tiered value magpie finds in settings.json is kept by "Apply again".
Why it matters here
The advisor turn goes out with max_tokens 4096 (internal/gateway/advisor_serve.go:209). An advisor model that reasons before answering spends about 2600–3300 tokens of that, so on long conversations the advice is cut (stop_reason: max_tokens) or comes back empty ("The advisor failed: unavailable"). With a tier on the model name the requests completed: on one ~189k-token conversation, untiered 4 of 4 cut, :low 5 of 5 and :xhigh 2 of 2 complete (small samples, one provider). So the tier is what makes the advisor usable for me, and today the only way to set it is by editing settings.json by hand.
Related: #6851 is about the tier the gateway is asked for on the advisor; its reproduction also sets the tier through claude --settings, outside magpie.
Error text or logs
The command output above.
take
@yetone Fix for @gitxm's report (#7630): Claude Code's advisor effort tier (<provider>/<model>:<effort>[1m]) was rejected by magpie claude advisor via Agent.Spell and stripped by "Apply again" (Agent.Reapply) whenever another field drifted.
Root cause:
- Claude Code's
AgenthadSplitSuffix == nil(internal/agent/claude.go:2624), soAgent.Spell(internal/agent/agent.go:757-796) looked up the whole string including:xhigh[1m]as a model id and rejected it innotOffered.advisor.Set(claude.go:2541) andUnwire(claude.go:1840) also stripped only[1m]withouttierAt. - On
replaceddrift,Agent.Reapply(internal/agent/applied.go:510-516) re-applied every other recorded field whose current value differed fromrec.Fields[f.Key], even when the field still held a valid magpie value (magpieValueIn/sameGroup), overwriting a hand-tieredadvisorModelback to the untiered record.
The fix:
- Following @gitxm's analysis, added
claudeSplitasSplitSuffixon Claude Code'sAgent(internal/agent/claude.go) soAgent.Spell,magpieValueIn,RenameProvider, andReseatsplit off valid:effort(provider.MemberEfforts) and/or[1m]suffixes while still rejecting unknown models and bogus effort names. - Updated
advisor.SetandUnwireininternal/agent/claude.goto parseadvisorModelthroughtierAtbefore checkingisMagpie. - Updated
Agent.Reapply(internal/agent/applied.go:504-520) to skip overwriting sibling recorded fields that are still valid magpie values (magpieValueIn(a, f, now, vals, opts) || sameGroup(v, now)), matchingDrift's rule (applied.go:259), while still restoring any field that drifted off magpie. - Note on point 2 (a dedicated
advisor_effortpicker in the Agents GUI row): left for you since adding a new field to Claude Code's row requires wiringinternal/gui/assets/app.js(subject toappScriptBudget) and 4-locale i18n/Playwright checks.
patch: fix(agent): accept Claude Code advisor effort tiers in CLI and preserve them on Reapply (#7630) — git am applies it as is; SHA-256 first 16: c8ea0890e688f376
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ggbdpq <[email protected]>
Date: Thu, 26 Nov 2026 21:42:12 +0800
Subject: [PATCH] fix(agent): accept Claude Code advisor effort tiers in CLI
and preserve them on Reapply (#7630)
What changed:
- Add claudeSplit as SplitSuffix on Claude Code's Agent so Agent.Spell (used by the CLI) accepts effort-tiered and [1m]-marked model refs such as <provider>/<model>:xhigh[1m] while still rejecting unknown models and invalid effort names.
- Parse advisorModel through tierAt in Claude Code's advisor.Set and Unwire so tiered advisor values validate and disconnect cleanly.
- In Agent.Reapply for replaced drift, skip overwriting sibling recorded fields whose current value is still a valid magpie value (magpieValueIn or sameGroup), matching Drift's rule so Apply again keeps a tiered advisor instead of stripping its effort suffix.
Run:
- TestClaudeAdvisorEffortTierSpellAndReapply: red before fix (both subtests failed), green after.
- Regression: TestClaudeAdvisor*, TestDrift*, TestReapply*, TestSpell*, TestRename*, TestOmp*, and internal/cli TestClaude|TestSpell|TestAgent all pass.
- gofmt -l clean; go vet ./... (native, GOOS=linux -tags nogui, GOOS=windows) clean; go build (native, GOOS=linux -tags nogui, GOOS=windows) clean.
Generated-by: Gemini 4 Neon (Antigravity)
---
internal/agent/applied.go | 8 ++-
internal/agent/claude.go | 22 ++++++-
internal/agent/claude_advisor_test.go | 89 +++++++++++++++++++++++++++
3 files changed, 116 insertions(+), 3 deletions(-)
diff --git a/internal/agent/applied.go b/internal/agent/applied.go
index 6e084f00f..0dbc84f30 100644
--- a/internal/agent/applied.go
+++ b/internal/agent/applied.go
@@ -507,8 +507,14 @@ func (a *Agent) Reapply() error {
if err := a.Apply(d.Field, d.Want); err != nil {
return err
}
+ vals := a.Values()
+ opts := fieldOptions{}
for _, f := range a.Fields {
- if v, ok := rec.Fields[f.Key]; ok && f.Key != d.Field && f.Get() != v {
+ if v, ok := rec.Fields[f.Key]; ok && f.Key != d.Field {
+ now := vals[f.Key]
+ if now == v || magpieValueIn(a, f, now, vals, opts) || sameGroup(v, now) {
+ continue
+ }
if err := a.Apply(f.Key, v); err != nil {
return err
}
diff --git a/internal/agent/claude.go b/internal/agent/claude.go
index 65d584dd8..34ea02531 100644
--- a/internal/agent/claude.go
+++ b/internal/agent/claude.go
@@ -723,6 +723,23 @@ func tierWith(model, effort string) string {
return v
}
+// claudeSplit is Claude Code's SplitSuffix: a model and its effort tier
+// (":xhigh", provider.MemberEfforts) and/or [1m] context mark.
+func claudeSplit(v string) (model, suffix string, one bool) {
+ m, e := tierAt(v)
+ bare, marked := strings.CutSuffix(m, "[1m]")
+ if e == "" && !marked {
+ return v, "", true
+ }
+ if e != "" {
+ suffix = ":" + e
+ }
+ if marked {
+ suffix += "[1m]"
+ }
+ return bare, suffix, true
+}
+
// tierEfforts are the levels a tier on model can be fixed at: the ones
// magpie knows the model has, else those Claude Code sends it.
func tierEfforts(model string) []string {
@@ -1837,7 +1854,7 @@ func claudeIn(at place) *Agent {
forget(autoKey)
// the advisor goes where it is on magpie's model, and its switch
// where magpie wrote it
- if isMagpie(strings.TrimSuffix(claudeReadOwn(jsonGet(path, "advisorModel")()), "[1m]")) {
+ if m, _ := tierAt(claudeReadOwn(jsonGet(path, "advisorModel")())); isMagpie(strings.TrimSuffix(m, "[1m]")) {
if err := edit.DelJSON(path, "advisorModel"); err != nil {
return "", err
}
@@ -2538,7 +2555,7 @@ func claudeIn(at place) *Agent {
}
return fmt.Errorf("pick a model through magpie for Claude Code first; its advisor can then have a model")
}
- if v != "" && !isMagpie(strings.TrimSuffix(v, "[1m]")) {
+ if m, _ := tierAt(v); v != "" && !isMagpie(strings.TrimSuffix(m, "[1m]")) {
return fmt.Errorf("advisor: %q is not a model magpie serves", v)
}
if v == "" {
@@ -2622,6 +2639,7 @@ func claudeIn(at place) *Agent {
Bin: "claude", Dir: filepath.Dir(path), Path: path, signIn: ".credentials.json",
claudeSettings: &ClaudeSettings{path: path, distro: at.wsl},
Fields: fields,
+ SplitSuffix: claudeSplit,
ModelAliases: claudeAliases,
Telemetry: claudeTelemetry(at, path),
// Claude Code as it was before magpie: its default puts it back as
diff --git a/internal/agent/claude_advisor_test.go b/internal/agent/claude_advisor_test.go
index a6400826e..f9b25cc03 100644
--- a/internal/agent/claude_advisor_test.go
+++ b/internal/agent/claude_advisor_test.go
@@ -96,3 +96,92 @@ func TestClaudeAdvisorUserSwitch(t *testing.T) {
t.Fatalf("disconnect took the user's own switch: %s", b)
}
}
+
+// #7630: an effort tier on Claude Code's advisor model (model:xhigh[1m]) must
+// pass Agent.Spell (used by the CLI), apply and disconnect cleanly, and survive
+// Reapply ("Apply again") when another field drifted.
+func TestClaudeAdvisorEffortTierSpellAndReapply(t *testing.T) {
+ t.Run("spell-and-apply", func(t *testing.T) {
+ a, path, _ := claudeAutoModeHome(t, `{}`)
+ if err := a.Apply("model", "relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ get := func() string { v, _ := edit.GetJSON(path, "advisorModel"); return v }
+
+ spelled, err := a.Spell("advisor", "relay/claude-opus-5-5:xhigh[1m]")
+ if err != nil || spelled != "relay/claude-opus-5-5:xhigh[1m]" {
+ t.Fatalf("Spell tiered advisor = %q, err=%v", spelled, err)
+ }
+ spelledPrefixed, err := a.Spell("advisor", "magpie/relay/claude-opus-5-5:xhigh[1m]")
+ if err != nil || spelledPrefixed != "relay/claude-opus-5-5:xhigh[1m]" {
+ t.Fatalf("Spell prefixed tiered advisor = %q, err=%v", spelledPrefixed, err)
+ }
+ if _, err := a.Spell("advisor", "relay/no-such-model:xhigh[1m]"); err == nil {
+ t.Fatal("Spell accepted unknown model with effort suffix")
+ }
+ if _, err := a.Spell("advisor", "relay/claude-opus-5-5:bogus[1m]"); err == nil {
+ t.Fatal("Spell accepted invalid effort suffix")
+ }
+
+ if err := a.Apply("advisor", spelled); err != nil {
+ t.Fatalf("Apply tiered advisor: %v", err)
+ }
+ if got := get(); got != "relay/claude-opus-5-5:xhigh[1m]" {
+ t.Fatalf("advisorModel = %q, want relay/claude-opus-5-5:xhigh[1m]", got)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if got := get(); got != "" {
+ t.Fatalf("Disconnect left tiered advisorModel = %q", got)
+ }
+ })
+
+ t.Run("reapply-keeps-tiered-advisor", func(t *testing.T) {
+ a, path, _ := claudeAutoModeHome(t, `{}`)
+ get := func() string { v, _ := edit.GetJSON(path, "advisorModel"); return v }
+
+ if err := a.Apply("model", "relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Apply("advisor", "relay/claude-opus-5-5"); err != nil {
+ t.Fatal(err)
+ }
+ if err := edit.SetJSON(path,
+ edit.KV{Path: "advisorModel", Value: "relay/claude-opus-5-5:xhigh[1m]"},
+ edit.KV{Path: "model", Value: "sonnet"},
+ ); err != nil {
+ t.Fatal(err)
+ }
+ if err := edit.DelJSON(path, "env.ANTHROPIC_DEFAULT_SONNET_MODEL"); err != nil {
+ t.Fatal(err)
+ }
+ d := a.Drift()
+ if d == nil || d.Kind != "replaced" || d.Field != "model" {
+ t.Fatalf("Drift = %+v, want replaced on model", d)
+ }
+ if err := a.Reapply(); err != nil {
+ t.Fatalf("Reapply: %v", err)
+ }
+ if got := get(); got != "relay/claude-opus-5-5:xhigh[1m]" {
+ t.Fatalf("Reapply stripped advisor effort tier: got %q, want relay/claude-opus-5-5:xhigh[1m]", got)
+ }
+
+ // If advisor itself is replaced with an off-magpie value, Reapply restores it.
+ if err := edit.SetJSON(path,
+ edit.KV{Path: "advisorModel", Value: "opus"},
+ edit.KV{Path: "model", Value: "sonnet"},
+ ); err != nil {
+ t.Fatal(err)
+ }
+ if err := edit.DelJSON(path, "env.ANTHROPIC_DEFAULT_SONNET_MODEL"); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Reapply(); err != nil {
+ t.Fatalf("Reapply after off-magpie advisor: %v", err)
+ }
+ if got := get(); got != "relay/claude-opus-5-5" {
+ t.Fatalf("Reapply did not restore off-magpie advisor: got %q, want relay/claude-opus-5-5", got)
+ }
+ })
+}
--
2.56.0.windows.4
Branch with the commit: fix/7630-claude-advisor-effort (head db6f360b5ab506a3a4949f3594447cfc4e1e731a), rebased onto current upstream/main (f85c2f748); on a fresh checkout git am applies clean.
| Check | Result |
|---|---|
TestClaudeAdvisorEffortTierSpellAndReapply (new, 2 subtests) |
red before the fix, pass after |
TestClaudeAdvisor*, TestDrift*, TestReapply*, TestSpell*, TestRename*, TestOmp*, internal/cli `TestClaude |
TestSpell |
go test ./internal/agent -tags nogui -timeout 25m -count=1 |
not re-run in full after targeted/regression suites passed; TestAppliedOfParsesAnUnchangedFileOnce fails on Windows host (6 allocs) |
go test -tags nogui ./... |
not run (per parallel lane constraint) |
targeted -race |
not run (no C toolchain on Windows host) |
gofmt -l internal/agent/claude.go internal/agent/applied.go internal/agent/claude_advisor_test.go |
prints nothing |
go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./... |
clean |
go build; GOOS=linux go build -tags nogui; GOOS=windows go build |
clean |
| Ablation | reverting internal/agent/claude.go and internal/agent/applied.go turns both subtests of TestClaudeAdvisorEffortTierSpellAndReapply red; restored, green |
Clean git am on f85c2f748 |
applies clean, tree 9be8a840ffa021a442ef9b116ad22bf86d10aba5 matches branch HEAD |
Source: internal/agent/claude.go (claudeSplit, advisor.Set, Unwire, Agent.SplitSuffix), internal/agent/applied.go (Agent.Reapply).
Red without the fix: Both subtests of TestClaudeAdvisorEffortTierSpellAndReapply failed: spell-and-apply failed with relay's model list has no claude-opus-5-5:xhigh[1m] (exact CLI error from report); reapply-keeps-tiered-advisor failed with Reapply stripped advisor effort tier: got "relay/claude-opus-5-5", want relay/claude-opus-5-5:xhigh[1m].
Siblings:
omp(internal/agent/omp.go:73,489): Already guarded viaompSplitasSplitSuffix.Agent.Spell,magpieValueIn,RenameProvider,Reseat,inuse.go,autoref.go,cli/main.go: All calla.split/a.SplitSuffix, soclaudeSplitflows cleanly through every sibling caller.Claude Codetiers & subagents (claude.go:2321,2381,2705,2715): Already usetierAt/tierWith.internal/gateway/advisor.go(advisorID): Already strips[1m]and delegates toClaudeUndashed/CanonicalRef, which preserve:effortviaprovider.claudeSplit.
Not verified: Real Claude Code 2.1.330 + WSL2 session with live relay provider; GUI advisor_effort picker (deferred to maintainer due to appScriptBudget); -race (no C toolchain on Windows host); full repo go test ./....
Attribution: AI-written; I've read the whole diff and the tests pass. Please keep the author (ggbdpq) or add Co-authored-by: ggbdpq <[email protected]>.