Files
magpie/internal/provider/reasonless_test.go
T
yetone f074996d93 provider, gateway, gui: a model with none of its levels ticked is sent no reasoning field, on every route and in a routing group (yuexian7)
yuexian7 on Discord: models.dev lists their model as reasoning, and the
vendor answers any reasoning parameter with 422 while the same request
without it works. In a routing group they couldn't set an effort per
model, and the model editor refused to untick the last level ("Keep at
least one level"). The learned refusals (bed306ae, #1062) don't cover
this: they learn a refusal of reasoning *off* and of Gemini levels, and
optionalFields holds thinking/enable_thinking, not reasoning_effort.

- settings.ModelReasonless, set by provider.SetModelReasonless (the
  provider editor's Names & levels with every level unticked, saved as
  modelPrefs {reasonless: true}; `magpie model efforts <ref> off`).
  Ticking levels again or Restore default clears it (setModelEfforts);
  setting it drops the model's kept levels.
- entryFor and Efforts/Thinks/Levelless: the model offers no levels and
  is Quiet, so agents are given none for it.
- Gateway: the candidate loop strips the body with withoutAnyReasoning
  in the agent's protocol (Chat/Responses reasoning_effort, reasoning,
  thinking, enable_thinking, include's reasoning.encrypted_content;
  Anthropic thinking of any type and output_config.effort; Gemini
  thinkingConfig). The Anthropic relay doesn't add
  thinking:{type:disabled} for it, and forwardTranslated clears Effort,
  ThinkOff and Thinking for its other callers (continuation, search).
- A routing group with it as a member keeps the other members' levels
  (it `continue`s like a member whose levels are unknown, #597), and the
  member that reasons is still sent the effort asked.
- GUI: none ticked shows "No reasoning field sent" beside the levels, in
  zh, zh-TW, ja and de too; a model with one known level now shows its
  picker so it can be unticked. A model whose levels aren't known
  (m.given) keeps none ticked meaning no levels known.

Run (worktree on origin/main 82f3befd2, sandbox HOME, private GOCACHE):
gofmt -l clean; with set -o pipefail go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... all clean; node --check
app.js. go test -count=1 ./internal/provider ./internal/gateway
./internal/settings ./internal/cli: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline under
load (AppKit window measurement, untouched here; #1936, noted there).
The run caught TestSettingsSaveKeepsWhatItDoesNotSend (ModelReasonless
added to it) and the CLI usage alignment tests (fixed).
New tests and what breaking the change does: TestReasonlessModelSentNoReasoning
(Chat, Chat+enable_thinking, Responses with include, Anthropic->Chat
translated; by name and through group/mix) and TestReasonlessAnthropicRelay
fail with gateway.go/quiet.go reverted; TestGroupReasonlessMemberKeepsLevels
fails with group.go's reasonless branch disabled; TestModelReasonless
needs the new API. model-reasonless.test.cjs in chromium and webkit, at
1100 and 420, in en, zh, zh-TW, ja, de: 20/20; on the old assets all
fail. Related GUI tests 418/418 (one model-copy-id failure on a first
run under load, passed alone; #2066).
Not tried against the reporter's real vendor: the 422 is taken from
their report.
2026-10-14 09:38:12 +08:00

68 lines
2.0 KiB
Go

package provider
import (
"slices"
"testing"
)
// Ticking no level of a model whose levels are known says it takes no
// reasoning field at all (yuexian7: a model models.dev lists as reasoning
// that answers any reasoning parameter with 422). Ticking levels again, or
// Restore default, takes that back; the two settings never both hold.
func TestModelReasonless(t *testing.T) {
effortHome(t)
if err := SetModelEfforts("a/m", []string{"high"}); err != nil {
t.Fatal(err)
}
if err := SetModelReasonless("a/m", true); err != nil {
t.Fatal(err)
}
if !Reasonless("a", "m") || Reasonless("a", "n") {
t.Fatal("reasonless not kept for a/m alone")
}
if got := (Provider{ID: "a"}).ModelEfforts()["m"]; got != nil {
t.Fatalf("its kept levels stayed: %v", got)
}
if err := SetModelEfforts("a/m", []string{"low", "high"}); err != nil {
t.Fatal(err)
}
if Reasonless("a", "m") {
t.Fatal("ticking levels left it reasonless")
}
if err := SetModelReasonless("a/m", true); err != nil {
t.Fatal(err)
}
if err := SetModelEfforts("a/m", nil); err != nil { // Restore default
t.Fatal(err)
}
if Reasonless("a", "m") {
t.Fatal("Restore default left it reasonless")
}
}
// A reasonless member is sent no reasoning, so it doesn't take the group's
// levels away (as a member whose levels nothing knows doesn't, #597), and
// the group is quiet to it alone.
func TestGroupReasonlessMemberKeepsLevels(t *testing.T) {
groupReasoningHome(t)
// as entryFor leaves it: no levels, no reasoning, on a provider whose
// list is known (not #597's unknown, which keeps the levels anyway)
off := quietMember()
off.Reasonless = true
if !off.Quiet() {
t.Fatal("a reasonless member isn't quiet")
}
for name, in := range map[string][]Entry{
"off last": {thinksMember(), off},
"off first": {off, thinksMember()},
} {
g := groupEntries(in)
if len(g) != 1 {
t.Fatalf("%s: groups %+v", name, g)
}
if !g[0].Reasoning || !slices.Equal(g[0].Efforts, levels) {
t.Errorf("%s: reasoning %v, levels %v, want %v", name, g[0].Reasoning, g[0].Efforts, levels)
}
}
}