agent: Claude's main model is written as a tier alias, so Claude Desktop on a subscription no longer sends magpie's prefixed id (iryan_sun on X)
Claude Desktop's Code tab sets CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1. Claude
Code then ignores the env block of settings.json (base URL, token, tier model
vars) but still honours the top-level `model`. magpie wrote `model` as the
provider-prefixed id (anth/claude-opus-4-7), so the official API rejected it
and WebFetch failed.
writeTiers now writes `model` as the tier alias (opus/sonnet/haiku/fable, with
[1m]) whose ANTHROPIC_DEFAULT_<TIER>_MODEL already maps to the main model, on
this machine's ~/.claude only. A distro file, the claude-magpie launch file and
a main with no tier keep the id. The model field reads the alias back through
the tier env, also while the gateway is unreachable (drift). Unwire drops
`model` when magpie wrote the alias.
What happens to old values: a settings.json an older magpie wrote with the
prefixed id (model "up/big-x") is rewritten to the alias at the next catalog
sync, for every user, with no step on their side; the tier env already maps it
to the same model. A prefixed id picked from the modelPicker rows is brought to
the alias the same way. A model the user set themselves (claude-haiku-9,
own/xyz, opusplan) is never rewritten.
Ran:
- Real Claude Code CLI (~/.local/bin/claude) in a sandbox HOME and
CLAUDE_CONFIG_DIR, wired by a magpie built from this tree (gateway :38760)
to a scripted upstream that logs each request's model: main -> big-x,
`--model haiku` -> fast-x, a subagent (Agent tool) -> sub-x, WebFetch's
extraction of https://example.com -> fast-x (haiku's). Old prefixed file
migrated to "sonnet" by a catalog sync; the three user models above stayed.
- TestClaudeMainModelIsAnAlias: red on the old code, red again with mainWord
broken by hand, green with the fix; it also covers the user's own models.
- 11 existing tests read the raw `model` as an id; they read it through
writtenModel now. TestWSLClaudePick compares the distro's file with the
native one after normalising `model` (the distro keeps the id by design).
- go test ./internal/agent ok at the pushed head; gofmt; go vet darwin, linux
nogui, windows for internal/agent.
- internal/cli: TestGatewayKeyLimitCLI is red on origin/main b39a793c9 too,
untouched here: #6082.
Not tried: the real Claude Desktop UI (only Claude Code with the
host-managed flag, 2.1.312/.314/.316); a user whose Claude runs in a WSL
distro is not covered; the full suite is run after the tag.
This commit is contained in:
@@ -159,6 +159,7 @@ something else shows up as drift.
|
||||
uninstalled, magpie's models come out when it answers again. Shelley has
|
||||
no Windows build, so there is no Windows or WSL wiring.
|
||||
- T3 Code runs a thread on the harness of the provider instance its model is picked under, so magpie writes two instances (karissasel_ on X: only Claude Code could be picked). `magpie` runs Claude Code, as above. `magpie-codex` ("magpie · Codex", `t3CodexJSON` in [`t3code.go`](../../internal/agent/t3code.go)) runs Codex: its `config.launchArgs`, which T3 hands to `codex app-server` and the `-c` pairs of to `codex exec`, are Codex's own overrides, making `magpie` its `model_provider` (the same table `codex.go` writes) and `magpie-codex-models.json`, written beside settings.json from `codexcat`, its `model_catalog_json`. Each value is quoted for T3's `tokenizeCliArgs` (`t3Arg`; `TestT3CodeCodexInstance` reads them back with a port of it). `~/.codex/config.toml` is not written, and a `binaryPath` or `homePath` the user gave T3's own `codex` instance is carried over. The name, on/off and unknown keys are the user's; the launch args and catalog are magpie's, and Check says when the launch args no longer reach the gateway (`t3CodexOff`). An older Claude-only wiring gets the Codex instance on its next Sync once; one the user removed stays removed (`t3code.codex` in the stash) until magpie is turned on for T3 again (`TestT3CodeCodexInstanceAddedOnce`).
|
||||
- Claude Code's main model in `~/.claude/settings.json` is written as the alias of a tier that carries it (`mainWord` in [`claude.go`](../../internal/agent/claude.go): sonnet, opus, haiku, fable, `[1m]` kept), not as magpie's provider-prefixed id. Claude Desktop's Code tab on the user's own subscription runs Claude Code with its provider routing managed by the host (`CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`): it drops this file's env (the gateway's address, key, tiers; tried on 2.1.312, 2.1.314 and 2.1.316) but still takes the top-level `model`, so the prefixed id went to Anthropic and every request failed, WebFetch included (iryan_sun on X). The alias is magpie's model through the env and Anthropic's own tier anywhere else. A model on no tier, a distro's file and the `claude-magpie` launch file keep the id; Sync brings a file an older magpie wrote to the alias, and Disconnect takes the alias out with the tiers (`wroteAlias`; `TestClaudeMainModelIsAnAlias`). `modelPicker` rows still carry the ids: they only list.
|
||||
- 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`), and a model picked in its `/model` (magpie's `modelPicker`) runs at that one value. Beside a main that is one of Claude's own models (or a group of them), with no tier that isn't, nothing is told, so a model picked there ran at Claude Code's own 200K: a routing group of a 500K GPT and a 1M Claude did (young02036 on Discord). Then (`pickerApart`) the `/model` rows (`pickerRefs`) count as tiers do in the layout below. 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 (its main, tiers and `/model` rows), 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). A model handed by a `[1m]` id (Desktop's under `DesktopLongest`, or Claude Code's own) counts by its 1M too, so it still runs at 1M when Claude Code stops taking the id for 1M (the 1M beta turned away once, `CLAUDE_CODE_DISABLE_1M_CONTEXT`); left out, a 1M model beside a 272K GPT was told 272K (dumplings on Discord). 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. A Code tab session whose environment host is WSL runs on the distro's Claude Code, which reads `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` there (Desktop 4.29.0's remote probe) and not Windows' file, so each `claude@wsl:<distro>` is told the same while Windows' Desktop is on magpie (`desktopOn`), on magpie itself or not; it read 200K for a 500K group before (young02036 on Discord).
|
||||
- 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.
|
||||
- Claude Code's status line (`statusline`, [`claude_statusline.go`](../../internal/agent/claude_statusline.go)) is a switch on its row, beside ultracode (steven_4422 on Discord: the 5h and 7d use in Claude Code). On writes settings.json's `statusLine` to run this magpie by its full path (`update.Program()`, forward slashes and quoted for Git Bash on Windows) with `statusline` (#1997, [`statusline_cli.go`](../../internal/cli/statusline_cli.go)), which reads the gateway's kept windows with a 1s timeout and prints nothing when it can't. A status line runs magpie's when its program's base name is `magpie` (or `magpie-…`) and its first argument `statusline` (`claudeStatusOurs`), so one written by hand from the reference counts too. A status line of the user's own (claude-hud, a script) is never written over: Options is empty while one is there, so the square isn't shown, and on is refused; an unreadable settings.json is refused too. Off and Disconnect take out only magpie's. Claude Code watches settings.json and reruns a changed command in its open sessions, so it is Quiet and needs no restart. Only on this computer: a WSL distro, running or stopped (`wslKinds` asleep options), isn't offered it (`TestClaudeStatusLine*`, `TestWSLClaudeNoStatusLine`, `claude-statusline.test.cjs`). For Claude Code on another computer than magpie (Docker), the gateway serves the same line at `/v1/magpie/statusline` ([`statusline.go`](../../internal/gateway/statusline.go), the renderer shared in [`provider/statusline.go`](../../internal/provider/statusline.go)), and `magpie web` shows the curl to put in settings.json (`TestStatuslineEndpoint`, `TestStatuslineEndpointIsTheCLIsLine`, `statusline-remote.test.cjs`); nothing writes that computer's file.
|
||||
|
||||
@@ -787,9 +787,21 @@ func claudeIn(at place) *Agent {
|
||||
return m == "" || m == was || m == follow(t, was)
|
||||
}
|
||||
|
||||
// wroteAlias says "model" is the alias magpie wrote for the main model
|
||||
// it last wrote (mainWord), still on that model: a tier alias the user
|
||||
// picked since stands for another model, or none of magpie's
|
||||
wroteAlias := func() bool {
|
||||
m, _ := edit.GetJSON(path, "model")
|
||||
if at.id != "" || !contains(claudeTiers, strings.TrimSuffix(m, "[1m]")) {
|
||||
return false
|
||||
}
|
||||
was := strings.TrimSuffix(stashShared()[mainKey], "[1m]")
|
||||
return was != "" && isMagpie(was) && strings.TrimSuffix(mainModel(), "[1m]") == was
|
||||
}
|
||||
|
||||
// the value shown: the catalog ref while routed, else Claude's own model.
|
||||
get := func() string {
|
||||
if routed() {
|
||||
if routed() || wroteAlias() {
|
||||
if m := mainModel(); m != "" {
|
||||
return m
|
||||
}
|
||||
@@ -1607,6 +1619,9 @@ func claudeIn(at place) *Agent {
|
||||
}
|
||||
return "", dropStray()
|
||||
}
|
||||
// the alias magpie wrote for its main model (mainWord) means a tier
|
||||
// of Anthropic's again once the tiers go, so it goes with them
|
||||
aliased := wroteAlias()
|
||||
keys := make([]string, len(claudeEnv))
|
||||
for i, k := range claudeEnv {
|
||||
keys[i] = "env." + k
|
||||
@@ -1614,6 +1629,11 @@ func claudeIn(at place) *Agent {
|
||||
if err := edit.DelJSON(path, keys...); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if aliased {
|
||||
if err := edit.DelJSON(path, "model"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
forget(aboutKey)
|
||||
// the auto mode classifier's model goes only where it is magpie's
|
||||
if autoOurs() {
|
||||
@@ -1764,6 +1784,33 @@ func claudeIn(at place) *Agent {
|
||||
return edit.SetJSON(path, edit.KV{Path: "model", Value: v})
|
||||
}
|
||||
|
||||
// mainWord is the main model as settings.json's "model" says it. A
|
||||
// Claude Code that doesn't go through magpie but reads this file
|
||||
// anyway — Claude Desktop's Code tab on the user's own subscription
|
||||
// drops the env, the gateway's address and the tiers with it, and still
|
||||
// takes "model" — would send a provider-prefixed id to Anthropic, which
|
||||
// refuses it (iryan_sun on X: WebFetch failed everywhere). So on this
|
||||
// computer's own file the model is said as the alias of a tier that
|
||||
// carries it: magpie's env gives the alias magpie's model, and
|
||||
// Anthropic's own tier is what it means anywhere else. A model on no
|
||||
// tier, another machine's Claude Code (a distro's file, which Desktop
|
||||
// doesn't read) and the claude-magpie launch file keep the id.
|
||||
mainWord := func(main string, tiers map[string]string) string {
|
||||
id := spell(main)
|
||||
if at.id != "" {
|
||||
return id
|
||||
}
|
||||
for _, t := range []string{"sonnet", "opus", "haiku", "fable"} {
|
||||
if tiers[t] != "" && spell(tiers[t]) == id {
|
||||
if strings.HasSuffix(id, "[1m]") {
|
||||
return t + "[1m]"
|
||||
}
|
||||
return t
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// writeTiers routes Claude Code through the gateway with main as its
|
||||
// model and each tier on the model given.
|
||||
writeTiers = func(main string, tiers map[string]string) error {
|
||||
@@ -1811,7 +1858,7 @@ func claudeIn(at place) *Agent {
|
||||
{Path: "env.ANTHROPIC_BASE_URL", Value: gw},
|
||||
{Path: "env.ANTHROPIC_AUTH_TOKEN", Value: tok},
|
||||
{Path: "env.ANTHROPIC_SMALL_FAST_MODEL", Value: spell(tiers["haiku"])},
|
||||
{Path: "model", Value: spell(main)},
|
||||
{Path: "model", Value: mainWord(main, tiers)},
|
||||
}
|
||||
// a tier on no model is left out, for Claude Code's own (fable on
|
||||
// a Claude model, follow)
|
||||
@@ -2356,6 +2403,16 @@ func claudeIn(at place) *Agent {
|
||||
}) {
|
||||
return writeTiers(curTiers())
|
||||
}
|
||||
// the model an older magpie wrote as an id of magpie's goes in
|
||||
// as the alias of its tier (mainWord)
|
||||
if m, ts := curTiers(); m != "" {
|
||||
word, cur := mainWord(m, ts), jsonGet(path, "model")()
|
||||
if cur != word && word != spell(m) {
|
||||
if r, _ := tierAt(provider.ClaudeRead(cur)); isMagpie(strings.TrimSuffix(r, "[1m]")) {
|
||||
return writeTiers(m, ts)
|
||||
}
|
||||
}
|
||||
}
|
||||
models := []string{mainModel()}
|
||||
tiers := map[string]string{}
|
||||
for _, t := range claudeTiers {
|
||||
|
||||
@@ -32,7 +32,13 @@ func TestClaude1MMarked(t *testing.T) {
|
||||
path := filepath.Join(home, ".claude", "settings.json")
|
||||
writeFile(t, path, `{}`)
|
||||
a := claude(home)
|
||||
get := func(k string) string { v, _ := edit.GetJSON(path, k); return v }
|
||||
get := func(k string) string {
|
||||
if k == "model" {
|
||||
return writtenModel(path)
|
||||
}
|
||||
v, _ := edit.GetJSON(path, k)
|
||||
return v
|
||||
}
|
||||
set := func(key, v string) {
|
||||
t.Helper()
|
||||
if err := a.Field(key).Set(v); err != nil {
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestClaudeDottedVersionsGoInDashed(t *testing.T) {
|
||||
`{"env": {"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4.5"}}`)
|
||||
a := claude(home)
|
||||
env := func(k string) string { v, _ := edit.GetJSON(path, "env."+k); return v }
|
||||
model := func() string { v, _ := edit.GetJSON(path, "model"); return v }
|
||||
model := func() string { return writtenModel(path) }
|
||||
set := func(key, v string) {
|
||||
t.Helper()
|
||||
if err := a.Field(key).Set(v); err != nil {
|
||||
@@ -169,7 +169,7 @@ func TestClaudeDottedServedDashedToo(t *testing.T) {
|
||||
home, path := claudeDottedHome(t, provider.Provider{ID: "both", Name: "Both", Anthropic: "https://example.test", Key: "k",
|
||||
Models: []string{"claude-opus-4.6", "claude-opus-4-6"}}, `{}`)
|
||||
a := claude(home)
|
||||
model := func() string { v, _ := edit.GetJSON(path, "model"); return v }
|
||||
model := func() string { return writtenModel(path) }
|
||||
for _, m := range []string{"both/claude-opus-4.6", "both/claude-opus-4-6"} {
|
||||
if err := a.Field("model").Set(m); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// TestClaudeMainModelIsAnAlias (iryan_sun on X): Claude Desktop's Code tab
|
||||
// runs Claude Code on the user's own subscription with the provider
|
||||
// routing managed by the host, so it drops the settings.json env (the
|
||||
// gateway's address, the tiers) but still takes the top-level "model".
|
||||
// magpie's provider-prefixed id there went to Anthropic, which doesn't
|
||||
// know it, and every request failed (WebFetch among them). The main model
|
||||
// is written as the alias of the tier that carries it, which the env gives
|
||||
// magpie's model and Anthropic's own gives the real tier.
|
||||
func TestClaudeMainModelIsAnAlias(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("USERPROFILE", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
for _, p := range []provider.Provider{
|
||||
{ID: "anth", Name: "Anthropic", Chat: "https://api.anthropic.com/v1", Key: "k", Models: []string{"claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5"}},
|
||||
{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash"}},
|
||||
} {
|
||||
if err := provider.Save(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
path := filepath.Join(home, ".claude", "settings.json")
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(`{}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a := claude(home)
|
||||
for _, main := range []string{"anth/claude-opus-4-7", "anth/claude-sonnet-4-6", "deepseek/pro"} {
|
||||
if err := a.Field("model").Set(main); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m, _ := edit.GetJSON(path, "model")
|
||||
if strings.Contains(m, "/") || !contains(claudeAliases, strings.TrimSuffix(m, "[1m]")) {
|
||||
t.Fatalf("%s: settings.json model is %q, which Anthropic's API doesn't know", main, m)
|
||||
}
|
||||
if got, _ := edit.GetJSON(path, "env."+tierEnv(strings.TrimSuffix(m, "[1m]"))); strings.TrimSuffix(got, "[1m]") != main {
|
||||
t.Fatalf("%s: the alias %q is on %q", main, m, got)
|
||||
}
|
||||
if got := a.Field("model").Get(); got != main {
|
||||
t.Fatalf("%s: shown as %q", main, got)
|
||||
}
|
||||
if got := claudeMain(path); got != main {
|
||||
t.Fatalf("%s: claudeMain %q", main, got)
|
||||
}
|
||||
}
|
||||
// a Sync leaves it as it is, and a settings.json an older magpie wrote
|
||||
// with the prefixed id is brought to the alias
|
||||
if err := edit.SetJSON(path, edit.KV{Path: "model", Value: "deepseek/pro"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); strings.Contains(m, "/") {
|
||||
t.Fatalf("after Sync: %q", m)
|
||||
}
|
||||
if got := a.Field("model").Get(); got != "deepseek/pro" {
|
||||
t.Fatalf("after Sync shown as %q", got)
|
||||
}
|
||||
// a model the user set themselves is never rewritten
|
||||
for _, own := range []string{"claude-haiku-9", "own/xyz", "opusplan"} {
|
||||
if err := edit.SetJSON(path, edit.KV{Path: "model", Value: own}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != own {
|
||||
t.Fatalf("the user's %q became %q", own, m)
|
||||
}
|
||||
}
|
||||
if err := edit.SetJSON(path, edit.KV{Path: "model", Value: "deepseek/pro"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Disconnect leaves no alias on magpie's tiers behind
|
||||
if err := a.Unwire(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, has := edit.GetJSON(path, "model"); has && m != "" {
|
||||
t.Fatalf("after Unwire: model %q", m)
|
||||
}
|
||||
}
|
||||
|
||||
// writtenModel is settings.json's main model as the id it stands for: an
|
||||
// alias magpie wrote resolved through its tier's env, anything else as is.
|
||||
func writtenModel(path string) string {
|
||||
m, _ := edit.GetJSON(path, "model")
|
||||
if t := strings.TrimSuffix(m, "[1m]"); contains(claudeTiers, t) {
|
||||
v, _ := edit.GetJSON(path, "env."+tierEnv(t))
|
||||
return v
|
||||
}
|
||||
return m
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func TestClaudeModelPickedInClaudeCode(t *testing.T) {
|
||||
|
||||
set("model", "deepseek/pro")
|
||||
set("haiku", "deepseek/lite")
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "deepseek/pro" || env("ANTHROPIC_MODEL") != "" {
|
||||
if m := writtenModel(path); m != "deepseek/pro" || env("ANTHROPIC_MODEL") != "" {
|
||||
t.Fatalf("the main model is settings.json's alone:\n%s", readFile(path))
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestClaudeModelPickedInClaudeCode(t *testing.T) {
|
||||
if err := a.Follow(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "deepseek/flash" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "deepseek/flash" ||
|
||||
if m := writtenModel(path); m != "deepseek/flash" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "deepseek/flash" ||
|
||||
env("ANTHROPIC_DEFAULT_SONNET_MODEL") != "deepseek/flash" || env("ANTHROPIC_DEFAULT_HAIKU_MODEL") != "deepseek/lite" {
|
||||
t.Fatalf("followers go with the pick, haiku keeps its own:\n%s", readFile(path))
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func TestClaudeModelPickedInClaudeCode(t *testing.T) {
|
||||
if err := a.Follow(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "deepseek/pro" || env("ANTHROPIC_MODEL") != "" || env("CLAUDE_CODE_SUBAGENT_MODEL") != "" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "deepseek/pro" {
|
||||
if m := writtenModel(path); m != "deepseek/pro" || env("ANTHROPIC_MODEL") != "" || env("CLAUDE_CODE_SUBAGENT_MODEL") != "" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "deepseek/pro" {
|
||||
t.Fatalf("legacy ANTHROPIC_MODEL:\n%s", readFile(path))
|
||||
}
|
||||
// nothing to follow: settings.json isn't written
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestClaudePickerListsRoutingGroups(t *testing.T) {
|
||||
if err := a.Apply("model", "group/auto-deepseek-v4-1-flash"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main, _ := edit.GetJSON(path, "model")
|
||||
main := writtenModel(path)
|
||||
if !strings.HasPrefix(main, "auto/deepseek-v4.1-flash") {
|
||||
t.Fatalf("model: %q\n%s", main, readFile(path))
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func TestClaudeSubagentModel(t *testing.T) {
|
||||
if err := a.Field("model").Set("deepseek/lite"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); env("CLAUDE_CODE_SUBAGENT_MODEL") != "deepseek/flash" || m != "deepseek/lite" {
|
||||
if m := writtenModel(path); env("CLAUDE_CODE_SUBAGENT_MODEL") != "deepseek/flash" || m != "deepseek/lite" {
|
||||
t.Fatalf("own subagent model lost: %v", a.Values())
|
||||
}
|
||||
if err := sub.Set(""); err != nil {
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestClaudeTierEffort(t *testing.T) {
|
||||
if a.Field("haiku").Get() != "v/flash" || a.Field("haiku_effort").Get() != "low" || a.Field("sonnet_effort").Get() != "" {
|
||||
t.Fatalf("read back: %v", a.Values())
|
||||
}
|
||||
if v, _ := edit.GetJSON(path, "model"); v != "v/glm" || env("ANTHROPIC_MODEL") != "" || a.Field("effort").Get() != "high" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "v/glm" {
|
||||
if v := writtenModel(path); v != "v/glm" || env("ANTHROPIC_MODEL") != "" || a.Field("effort").Get() != "high" || env("ANTHROPIC_DEFAULT_OPUS_MODEL") != "v/glm" {
|
||||
t.Fatalf("the main model's effort changed: %v", a.Values())
|
||||
}
|
||||
// a tier following the main model, at another effort
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
@@ -31,7 +30,7 @@ func TestConnectOnARoutingGroupAlone(t *testing.T) {
|
||||
if err := c.Connect(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "group/folia-1" {
|
||||
if m := writtenModel(path); m != "group/folia-1" {
|
||||
t.Fatalf("connected on %q:\n%s", m, readFile(path))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestConnectKeepsTheModel(t *testing.T) {
|
||||
if err := c.Connect(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "aaa/claude-opus-5-5" {
|
||||
if m := writtenModel(path); m != "aaa/claude-opus-5-5" {
|
||||
t.Fatalf("connected on %q:\n%s", m, readFile(path))
|
||||
}
|
||||
}
|
||||
@@ -428,7 +428,7 @@ func TestConnectSaysHow(t *testing.T) {
|
||||
if how, err := c.ConnectHow(); err != nil || how.How != "again" {
|
||||
t.Fatalf("switched on again: %+v %v", how, err)
|
||||
}
|
||||
if m, _ := edit.GetJSON(path, "model"); m != "aaa/claude-sonnet-5-5" {
|
||||
if m := writtenModel(path); m != "aaa/claude-sonnet-5-5" {
|
||||
t.Fatalf("back on %q", m)
|
||||
}
|
||||
if err := c.Disconnect(); err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -172,7 +173,11 @@ func TestWSLClaudePick(t *testing.T) {
|
||||
n.Field("model").Set("relay/glm-4.6")
|
||||
n.Field("effort").Set("max")
|
||||
want := strings.ReplaceAll(readFile(filepath.Join(nat, ".claude", "settings.json")), `"`+gateway.URL()+`"`, `"`+gw+`"`)
|
||||
if got := readFile(path); got != want {
|
||||
// native Claude Code's main model is a tier alias for the id the
|
||||
// distro's file keeps (writeTiers' mainWord)
|
||||
got := regexp.MustCompile(`"model":\s*"[^"]*"`).ReplaceAllString(readFile(path), `"model": "relay/glm-4.6"`)
|
||||
want = regexp.MustCompile(`"model":\s*"[^"]*"`).ReplaceAllString(want, `"model": "relay/glm-4.6"`)
|
||||
if got != want {
|
||||
t.Fatalf("mirrored %v:\n got %s\nwant %s", mirrored, got, want)
|
||||
}
|
||||
// a tier of its own
|
||||
|
||||
Reference in New Issue
Block a user