Files
magpie/internal/agent/claude_haiku_test.go
T
yetone 6fe754cb20 claude: Fable 5.2 on Vertex, Bedrock, Desktop's fable tier and Anthropic's fast mode
Anthropic launched Claude Fable 5.2 (claude-fable-5-2) on 11-09
(thelegendof2414 on X: not in magpie's list). Checked against
Anthropic's "What's new in Fable 5.2" page, AWS's model card, models.dev
and Claude Code 2.1.321's own bundle:

- Claude subscription and Anthropic API: the list follows models.dev,
  which already has claude-fable-5-2 (8/40, cache read 0.2, write 10,
  1M context, 128k out), so it shows once the catalog syncs (at most
  24h). TestClaudeAccountListsFable52 holds that with the literal
  models.dev row: listed first, priced, 1M window, low to max efforts.
- Vertex global and Bedrock presets list it
  (global.anthropic.claude-fable-5-2 is on AWS's card).
- Claude Desktop's fable tier now behaves as claude-fable-5-2 (2.1.321's
  latest_per_family); Desktop's own catalog v4371 still ends at 5.1.
- Fast mode on Anthropic's API key: Fable 5.2 has it ($16/$80; 2.1.321's
  fast-mode opt-in set is fable-5-2 and mythos-5-2). Fable 5.1 never had
  it and stays off. A Claude subscription account still gets no fast
  mode in magpie, as before.
- Claude Code's effort: 2.1.321 reads the top-level effortLevel only for
  models up to Fable 5.1 and Mythos 5.1, so 5.2 goes in modelSettings,
  as Opus 5.5 does (claudeReadsTop unchanged, test added).
- Gateway: adaptive-only thinking, no sampling, thinking off never sent,
  xhigh kept: the version rules already cover 5.2; tests now name it.

Run at this tree (mote): gofmt -l clean; go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -count=1 ./internal/agent ./internal/gateway ./internal/provider
-run 'Fable|Claude|Fast|Vertex|Bedrock|Effort|Thinking|Xhigh|XHigh|Desktop|Sampling|Adaptive'
ok (84s, 178s, 36s).
Not run before the push: the full go test ./... (mote had six suites
queued on suite.lock at load 420); it runs after, and a red is filed.
Not tried: a real Fable 5.2 request through magpie; fast mode on a real
API key.
2026-11-10 04:58:30 +08:00

190 lines
7.5 KiB
Go

package agent
import (
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
)
// On a Claude model, Claude Code's haiku tier — its titles, Explore
// subagents, the small asks it makes on its own — follows on the Haiku the
// same provider serves, as Claude Code runs them by itself, not on the main
// model (X, AncientTwo: a Claude subscription's limits went much faster
// through magpie). A model of the user's own for it stays; on a model that
// isn't Claude's it follows the main model as before.
func TestClaudeHaikuTierOnClaude(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", "claude-haiku-3-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)
env := func(k string) string { v, _ := edit.GetJSON(path, "env."+k); return v }
tiers := func() [3]string {
return [3]string{env("ANTHROPIC_DEFAULT_OPUS_MODEL"), env("ANTHROPIC_DEFAULT_HAIKU_MODEL"), env("ANTHROPIC_SMALL_FAST_MODEL")}
}
if err := a.Field("model").Set("anth/claude-opus-4-7"); err != nil {
t.Fatal(err)
}
if got := tiers(); got != [3]string{"anth/claude-opus-4-7", "anth/claude-haiku-4-5", "anth/claude-haiku-4-5"} {
t.Fatalf("haiku should be the provider's Haiku: %v", got)
}
if a.Field("haiku").Get() != "anth/claude-haiku-4-5" {
t.Fatalf("haiku shown: %q", a.Field("haiku").Get())
}
// another Claude model: haiku stays on Haiku
if err := a.Field("model").Set("anth/claude-sonnet-4-6"); err != nil {
t.Fatal(err)
}
if got := tiers(); got != [3]string{"anth/claude-sonnet-4-6", "anth/claude-haiku-4-5", "anth/claude-haiku-4-5"} {
t.Fatalf("on sonnet: %v", got)
}
// a model that isn't Claude's: haiku follows it
if err := a.Field("model").Set("deepseek/pro"); err != nil {
t.Fatal(err)
}
if got := tiers(); got != [3]string{"deepseek/pro", "deepseek/pro", "deepseek/pro"} {
t.Fatalf("on deepseek: %v", got)
}
if err := a.Field("model").Set("anth/claude-opus-4-7"); err != nil {
t.Fatal(err)
}
if got := tiers(); got[1] != "anth/claude-haiku-4-5" {
t.Fatalf("back on Claude: %v", got)
}
// the user's own pick, even the main model, stays
if err := a.Field("haiku").Set("anth/claude-opus-4-7"); err != nil {
t.Fatal(err)
}
if err := a.Field("model").Set("anth/claude-sonnet-4-6"); err != nil {
t.Fatal(err)
}
if got := tiers(); got[1] != "anth/claude-opus-4-7" {
t.Fatalf("own haiku lost: %v", got)
}
if err := a.Follow(); err != nil {
t.Fatal(err)
}
if got := tiers(); got[1] != "anth/claude-opus-4-7" {
t.Fatalf("own haiku lost on Follow: %v", got)
}
// back to following: the Haiku again
if err := a.Field("haiku").Set(""); err != nil {
t.Fatal(err)
}
if got := tiers(); got[1] != "anth/claude-haiku-4-5" {
t.Fatalf("haiku back to following: %v", got)
}
// an effort for the haiku tier keeps it on the Haiku
if err := a.Field("haiku_effort").Set("low"); err == nil {
if got := tiers(); got[1] != "anth/claude-haiku-4-5:low" {
t.Fatalf("haiku effort: %v", got)
}
if err := a.Field("haiku_effort").Set(""); err != nil {
t.Fatal(err)
}
}
// an older magpie wrote every tier on the main model: Follow moves the
// haiku tier onto the Haiku
if err := edit.SetJSON(path, edit.KV{Path: "env.ANTHROPIC_DEFAULT_HAIKU_MODEL", Value: "anth/claude-sonnet-4-6"}, edit.KV{Path: "env.ANTHROPIC_SMALL_FAST_MODEL", Value: "anth/claude-sonnet-4-6"}); err != nil {
t.Fatal(err)
}
if err := a.Follow(); err != nil {
t.Fatal(err)
}
if got := tiers(); got[1] != "anth/claude-haiku-4-5" || got[2] != "anth/claude-haiku-4-5" {
t.Fatalf("older wiring not moved: %v", got)
}
}
func TestClaudeLight(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: "Claude", Chat: "https://api.anthropic.com/v1", Key: "k", Models: []string{"claude-opus-5-5", "claude-haiku-4-5-20251001", "claude-haiku-4-5", "claude-haiku-3-5"}},
{ID: "or", Name: "Router", Chat: "https://or.test/v1", Key: "k", Models: []string{"anthropic/claude-opus-5.5", "anthropic/claude-haiku-4.5"}},
{ID: "cp", Name: "Copilot", Chat: "https://cp.test/v1", Key: "k", Models: []string{"claude-opus-5.5", "gpt-5"}},
} {
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
}
for main, want := range map[string]string{
"anth/claude-opus-5-5": "anth/claude-haiku-4-5",
"anth/claude-opus-5-5[1m]": "anth/claude-haiku-4-5",
"anth/claude-haiku-4-5": "",
"or/anthropic/claude-opus-5.5": "or/anthropic/claude-haiku-4.5",
"cp/claude-opus-5.5": "",
"cp/gpt-5": "",
} {
if got := claudeLight(main); got != want {
t.Errorf("claudeLight(%q) = %q, want %q", main, got, want)
}
}
}
// Claude Haiku 5.5 (claude-haiku-5-5; anthropic/claude-haiku-5.5 on a
// router, as Vercel's gateway lists it) is the newest Haiku where a provider
// serves it beside Haiku 4.5, dated or not, so Claude Code's haiku tier
// follows it. It is a Claude after Opus 5.5: Claude Code sends it every
// level and reads its effort from modelSettings only.
func TestClaudeLightHaiku55(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: "Claude", Chat: "https://api.anthropic.com/v1", Key: "k", Models: []string{"claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-4-5-20251001", "claude-haiku-5-5", "claude-haiku-4-5"}},
{ID: "or", Name: "Router", Chat: "https://or.test/v1", Key: "k", Models: []string{"anthropic/claude-haiku-5.5", "anthropic/claude-sonnet-5.5", "anthropic/claude-haiku-4.5"}},
} {
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
}
for main, want := range map[string]string{
"anth/claude-opus-5-5": "anth/claude-haiku-5-5",
"anth/claude-sonnet-5-5[1m]": "anth/claude-haiku-5-5",
"anth/claude-haiku-5-5": "",
"or/anthropic/claude-sonnet-5.5": "or/anthropic/claude-haiku-5.5",
} {
if got := claudeLight(main); got != want {
t.Errorf("claudeLight(%q) = %q, want %q", main, got, want)
}
}
if got := claudeEffortsFor("claude-haiku-5-5"); len(got) != len(claudeEfforts) {
t.Errorf("claudeEffortsFor(claude-haiku-5-5) = %v, want %v", got, claudeEfforts)
}
if claudeReadsTop("claude-haiku-5-5[1m]") {
t.Error("claude-haiku-5-5 should read only modelSettings' effort, as every Claude after Opus 5.5")
}
// Claude Code 2.1.321 reads the top effortLevel for Fable 5.1 and
// none after it.
if !claudeReadsTop("claude-fable-5-1") || claudeReadsTop("claude-fable-5-2[1m]") {
t.Error("claude-fable-5-1 reads the top effortLevel, claude-fable-5-2 only modelSettings'")
}
}