oxsean asked for one place to turn a model (claude-fable-5) off for good:
not reached by a direct request, an old session, a routing group member,
a fallback, a sub-agent, count_tokens or a decision model.
What changed:
- settings.DisabledModels: patterns, an exact id or a glob (* any run, /
included; ? one), matched ignoring case against provider/model, the
bare id and its last segment (provider/disabled.go). Empty by default,
so nothing changes for anyone who doesn't set it.
- Lists: buildEntries (entriesOff) leaves a disabled model out of the
catalog, so /v1/models, agents' model files and pickers, Codex's list
and every group go without it; membersIn skips it as a member, Deciders
as a decision model; codexModels drops Codex's own disabled slugs and
codexListTag changes so Codex refetches.
- Requests (gateway/disabled.go): 403 "model <id> is disabled in magpie"
in each API's error shape, at #882's choke points: serve (idOff),
perKeyBarred (no candidate: group next member, provider Fallback),
count_tokens and Gemini :countTokens, serveSystemOne,
serveDecisionGroup and postDecide, draw/video/embeddings, and
codexBackend for Codex's own bare models. A group with a member left
goes on without it; one with none left is refused naming them. A bare
id the catalog no longer has is refused as disabled, not 404. A Codex
sub-agent pick onto a disabled model stays on its lead's model.
- An unreadable settings.json is never "none disabled": the list read
last stays; with none read, every request is refused; nothing is
written over the file.
- CLI: magpie model disable <model|glob>..., enable ..., disabled
(list-disabled).
- GUI: Settings > Models > Disabled models: each pattern with the models
it matches now and Enable; Disable... opens the model picker, which
also takes a typed glob. Says only requests through magpie are covered.
POST /api/settings/disabled-models; POST /api/settings keeps the list.
Strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: Disabled models section.
What was run (worktree at origin/main 091593f7d, private GOCACHE, temp HOME):
- gofmt -l clean; go vet on darwin (touched pkgs), GOOS=linux -tags nogui
./..., GOOS=windows ./... clean; go build ./...
- go test -count=1 ./internal/provider ./internal/gateway ./internal/cli
./internal/gui ./internal/settings: all ok (gui after adding the field to
TestSettingsSaveKeepsWhatItDoesNotSend's fixture, which it asked for).
- node --test internal/gui/tests/disabled-models.test.cjs: 16/16 (chromium
+ webkit, en/zh/ja/de, 1100/420); neighbouring Settings > Models tests
and i18n-keys: 131/131.
- Broken by hand, each turned TestDisabled* red: serve's idOff (404
instead of 403), perKeyBarred's filter (fallback reached spare), the
catalog filter (/v1/models and Codex list), countOff (count_tokens 200),
postDecide's check (decision call went out).
- Not tried with a real vendor account or a real agent.
Ref #1867
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// magpie model disable, disabled and enable (#1867): a glob and an id are
|
|
// saved as written, each said with the models it turns off now, listed,
|
|
// and taken off again; one not on the list is said so.
|
|
func TestModelDisableCmd(t *testing.T) {
|
|
groupsHome(t)
|
|
catalog.Changed = nil // no agent's files are rewritten here
|
|
if _, err := refusedArgs(t, "disable"); err == nil {
|
|
t.Fatal("no model named")
|
|
}
|
|
out := saidArgs(t, "disable", "*opus*", "b/gpt-5.5")
|
|
if !strings.Contains(out, "*opus*") || !strings.Contains(out, "a/claude-opus-5-5") || !strings.Contains(out, "b/gpt-5.5") || !strings.Contains(out, "only requests through magpie") {
|
|
t.Fatal(out)
|
|
}
|
|
if got := provider.DisabledModels(); !slices.Equal(got, []string{"*opus*", "b/gpt-5.5"}) {
|
|
t.Fatal(got)
|
|
}
|
|
if out := saidArgs(t, "disabled"); !strings.Contains(out, "*opus*") || !strings.Contains(out, "a/claude-opus-5-5") {
|
|
t.Fatal(out)
|
|
}
|
|
out = saidArgs(t, "enable", "*OPUS*", "nope")
|
|
if !strings.Contains(out, "enabled again") || !strings.Contains(out, "nope was not on the disabled list") {
|
|
t.Fatal(out)
|
|
}
|
|
if got := provider.DisabledModels(); !slices.Equal(got, []string{"b/gpt-5.5"}) {
|
|
t.Fatal(got)
|
|
}
|
|
saidArgs(t, "list-disabled")
|
|
saidArgs(t, "enable", "b/gpt-5.5")
|
|
if out := saidArgs(t, "disabled"); !strings.Contains(out, "no model is disabled") {
|
|
t.Fatal(out)
|
|
}
|
|
}
|