buildAnthropic asked every Claude that thinks only adaptively for max when the client asked xhigh, on the grounds that 4.6 has no xhigh. Only Opus and Sonnet 4.6 lack it: Anthropic's effort docs list xhigh on Fable 5 and 5.1, Mythos 5 and 5.1, Opus 5.5, 5, 4.8 and 4.7, Sonnet 5.5 and 5, and Haiku 5.5, and describe max as no constraint on token spending. So Codex, Cursor or any Chat client picking xhigh on claude-opus-5-5 was billed for max. Claude Code's own levels in magpie (claudeEffortsFor) already say only Opus and Sonnet 4.6 skip xhigh. Now xhigh becomes max only on 4.6 (noXhigh, which reads the version through claudeVersionOf, shared with adaptiveOnly). A relayed thinking budget is unchanged: budgetOf gives xhigh and max the same budget, and 31999 is Claude Code's old ultrathink, so a budget above high still goes as max. docs/subsystems/gateway-routing.md now says which models are asked adaptively (#1470) and where xhigh stays xhigh. What was run: TestXhighStaysXhighWhereClaudeTakesIt (Chat and Responses through the server stack to a fake Anthropic upstream) fails on the old main with output_config = map[effort:max], want "xhigh" for Opus 5.5 (Chat and Responses), Opus 4.7, Sonnet 5 and Haiku 5.5, and passes with the change; Opus and Sonnet 4.6 get max before and after, and a Fable 5.1 row asserts xhigh. TestAdaptiveThinking's Opus 5.5 xhigh case now asserts xhigh, beside a 4.6 case asserting max. Broken by hand (noXhigh always false) the 4.6 cases fail. gofmt -l prints nothing; go vet -tags nogui ./... passes for darwin, linux and windows; go test -tags nogui -count=1 ./... under a temp HOME passes. Through the aihubmix relay, claude-opus-5-5 with adaptive thinking and effort xhigh answers 200. Not tried against Anthropic directly (no credential outside the keychain); a relay that checks effort against an older list could still refuse xhigh. Reported and fixed by ggbdpq (#1471). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
49 lines
2.1 KiB
Go
49 lines
2.1 KiB
Go
package gateway
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A client that asks xhigh of a Claude that takes it (Opus 4.7 on, Sonnet
|
|
// 5 on, Haiku 5.5, Fable: platform.claude.com/docs/en/build-with-claude/effort)
|
|
// gets xhigh, not max, which spends without limit; Opus and Sonnet 4.6,
|
|
// which have no xhigh, are asked max.
|
|
func TestXhighStaysXhighWhereClaudeTakesIt(t *testing.T) {
|
|
fresh(t)
|
|
up := &adaptiveVendor{}
|
|
srv := httptest.NewServer(up)
|
|
t.Cleanup(srv.Close)
|
|
if err := provider.Save(provider.Provider{ID: "anth", Name: "Anth", Key: "k", Anthropic: srv.URL,
|
|
Models: []string{"claude-opus-5-5", "claude-opus-4-7", "claude-sonnet-5", "claude-haiku-5-5", "claude-fable-5-1", "claude-opus-4-6", "claude-sonnet-4-6"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, c := range []struct{ model, path, body, want string }{
|
|
{"claude-opus-5-5", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "xhigh"},
|
|
{"claude-opus-5-5", "/v1/responses", `"reasoning":{"effort":"xhigh"}`, "xhigh"},
|
|
{"claude-opus-4-7", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "xhigh"},
|
|
{"claude-sonnet-5", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "xhigh"},
|
|
{"claude-haiku-5-5", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "xhigh"},
|
|
{"claude-fable-5-1", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "xhigh"},
|
|
{"claude-opus-4-6", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "max"},
|
|
{"claude-sonnet-4-6", "/v1/chat/completions", `"reasoning_effort":"xhigh"`, "max"},
|
|
} {
|
|
t.Run(c.model+c.path, func(t *testing.T) {
|
|
body := `{"model":"anth/` + c.model + `",` + c.body + `,"messages":[{"role":"user","content":"hi"}]}`
|
|
if c.path == "/v1/responses" {
|
|
body = `{"model":"anth/` + c.model + `",` + c.body + `,"input":"hi"}`
|
|
}
|
|
code, out := post(t, c.path, body)
|
|
if code != 200 {
|
|
t.Fatalf("status %d: %s", code, out)
|
|
}
|
|
oc, _ := up.last()["output_config"].(map[string]any)
|
|
if e, _ := oc["effort"].(string); e != c.want {
|
|
t.Errorf("output_config = %v, want effort %q", up.last()["output_config"], c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|