Files
magpie/internal/catalog/effort_alias_test.go
T
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00

33 lines
1.0 KiB
Go

package catalog
import "testing"
// TestNearestEffortTakesVendorWords: a model listing Trae's light, high and
// extra_high (Our Free Model's plugin, nianshou5) is asked low as light and
// xhigh as extra_high, in its own words, and its light as it is; a model in
// EffortRank's words is fitted as before.
func TestNearestEffortTakesVendorWords(t *testing.T) {
trae := []string{"light", "high", "extra_high"}
for _, tc := range []struct {
want string
levels []string
got string
}{
{"low", trae, "light"},
{"light", trae, "light"},
{"minimal", trae, "light"},
{"medium", trae, "high"},
{"xhigh", trae, "extra_high"},
{"extra_high", trae, "extra_high"},
{"max", trae, "extra_high"},
{"light", []string{"low", "high"}, "low"},
{"extra_high", []string{"low", "high", "max"}, "max"},
{"low", []string{"low", "high"}, "low"},
{"medium", []string{"low", "high", "max"}, "high"},
} {
if got := NearestEffort(tc.want, tc.levels); got != tc.got {
t.Errorf("NearestEffort(%q, %v) = %q, want %q", tc.want, tc.levels, got, tc.got)
}
}
}