laomao04_65777 on Discord: in Codex, with SenseTime Raccoon (商汤小浣熊) picked, the reasoning effort couldn't be switched. Cause: Raccoon's plugin lists its models as thinking with no variants. Its sn-* ids (sn-glm-5-3, sn-kimi-k3, sn-glm-5-3-flash, sn-deepseek-v4-1-flash, sn-deepseek-v4-pro) are ones models.dev knows under the maker's spelling (catalog.Knows). So levelsUnknown counted them as known and offered nothing, and pluginCatalog borrowed the maker's levels only for moved built-ins and Cline. Codex's catalog got supported_reasoning_levels [] and hid the picker. A custom provider's same id already borrows them (effortsOf), and an id models.dev doesn't know already got low/medium/high (ddb1701fe). The class: every plugin model that says it thinks and gives no variants now borrows its maker's levels (borrowedEfforts). OpenCode also reads no variants as nothing said and makes its own from the SDK (packages/core/src/variant.ts, low/medium/high for openai-compatible). A model with variants keeps them. A model that doesn't say it thinks gets nothing borrowed. What the vendor takes: xiaohuanxiong.com has no public API docs. The official 1.1.3 desktop app's code only flips enable_deep_thinking on its web API. The gateway already sends Codex's effort (medium) to Raccoon today, because fitEffort passes it through when there are no levels, and no rejection has been reported. The levels borrowed are the maker's (kimi-k3, glm-5.3, deepseek-v4 on models.dev). magpie-community/plugins#598 asks the plugin for real per-model reasoning and variants. Run (mote, at 88183d15d on origin/main 1fac66c06; then rebased onto57246b381, whose 3 commits since touch none of provider, plugin, codexcat or catalog): - go test -tags nogui ./internal/provider ./internal/codexcat ./internal/catalog: all ok (provider 154s) - go test -run 'Effort|Reason|Level|PluginCatalog|Variant' ./internal/gateway ./internal/agent: both ok - gofmt -l clean. GOOS=linux and GOOS=windows go vet ./internal/provider pass. - A repro against a copy of the live models.dev cache, with the Raccoon plugin's 11 models: before, the five sn-* ids got []. After, sn-kimi-k3, sn-glm-5-3, sn-glm-5-3-flash and sn-deepseek-v4-pro get [low high max], and sn-deepseek-v4-1-flash gets [none low high max]. The raccoon-*/sensenova ids are unchanged ([low medium high]). Broken by hand: with plugins.go reverted, TestPluginThinkingModelBorrowsEfforts is red ("raccoon/sn-kimi-k3 offered [] in Codex", and so are the provider's Efforts). TestMovedKeepsEfforts now also checks a plugin's own variants and the non-thinking case. Not tried: a real Raccoon account (none here), so no request with a borrowed level went to xiaohuanxiong.com. Not tried in the real Codex app either. Not a full ./... suite: mote was at load 270 with another session's gateway suite running.
83 lines
3.1 KiB
Go
83 lines
3.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// laomao04_65777 on Discord: in Codex, SenseTime Raccoon's (商汤小浣熊's)
|
|
// models had no reasoning effort to pick. Its plugin lists sn-kimi-k3,
|
|
// sn-glm-5-3 and sn-deepseek-v4-1-flash as thinking with no variants;
|
|
// models.dev knows each under its maker's spelling, so the entry counted
|
|
// as known (levelsUnknown) and was offered none, and nothing borrowed the
|
|
// maker's levels as a custom provider's same id does. A plugin's thinking
|
|
// model with no variants borrows them now; a model the plugin gives
|
|
// variants keeps them, and one it doesn't say thinks gets none borrowed.
|
|
func TestPluginThinkingModelBorrowsEfforts(t *testing.T) {
|
|
claudeHome(t)
|
|
t.Setenv("MAGPIE_BUN", "")
|
|
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
|
os.WriteFile(catalog.CachePath(), []byte(`{
|
|
"moonshotai":{"id":"moonshotai","models":{"kimi-k3":{"id":"kimi-k3","reasoning":true,
|
|
"reasoning_options":[{"type":"effort","values":["low","medium","high","max"]}],"limit":{"context":1000000}}}},
|
|
"zai":{"id":"zai","models":{"glm-5.3":{"id":"glm-5.3","reasoning":true,
|
|
"reasoning_options":[{"type":"effort","values":["low","high","max"]}],"limit":{"context":1000000}}}}}`), 0o644)
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
spec := "@magpie-community/opencode-raccoon-auth"
|
|
write := func(name string, v any) {
|
|
t.Helper()
|
|
b, _ := json.Marshal(v)
|
|
os.MkdirAll(settings.Dir(), 0o700)
|
|
if err := os.WriteFile(filepath.Join(settings.Dir(), name), b, 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
write("plugins.json", map[string]any{"plugins": []map[string]any{{"spec": spec}}})
|
|
write("plugin-auth.json", map[string]map[string]any{"raccoon": {"type": "oauth", "access": "a", "refresh": "r", "expires": 9999999999999}})
|
|
plugin.UseCached([]plugin.Provider{{ID: "raccoon", Spec: spec, Name: "商汤小浣熊",
|
|
Methods: []plugin.Method{{Type: "oauth", Label: "Sign in"}},
|
|
Accounts: []plugin.Account{{Key: "raccoon", Type: "oauth"}},
|
|
Models: []plugin.Model{
|
|
{ID: "sn-kimi-k3", Name: "Kimi-K3", Reasoning: true},
|
|
{ID: "sn-glm-5-3", Name: "GLM-5-3", Reasoning: true, Variants: []string{"high"}},
|
|
{ID: "kimi-k3", Name: "Kimi K3 (no word on thinking)"},
|
|
}}})
|
|
t.Cleanup(func() { plugin.UseCached(nil) })
|
|
|
|
shown, _ := CatalogFor("codex")
|
|
got := map[string][]string{}
|
|
for _, m := range CodexCatalog(shown) {
|
|
got[m.ID] = m.Efforts
|
|
}
|
|
want := map[string][]string{
|
|
"raccoon/sn-kimi-k3": {"low", "medium", "high", "max"},
|
|
"raccoon/sn-glm-5-3": {"high"},
|
|
"raccoon/kimi-k3": nil,
|
|
}
|
|
for id, w := range want {
|
|
g, ok := got[id]
|
|
if !ok {
|
|
t.Fatalf("no %s in Codex's list: %v", id, got)
|
|
}
|
|
if !slices.Equal(g, w) {
|
|
t.Errorf("%s offered %v in Codex, want %v", id, g, w)
|
|
}
|
|
}
|
|
// the gateway fits an effort to the same levels
|
|
p, err := Find("raccoon")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if e := p.Efforts("sn-kimi-k3"); !slices.Equal(e, want["raccoon/sn-kimi-k3"]) {
|
|
t.Errorf("provider's sn-kimi-k3 efforts %v", e)
|
|
}
|
|
}
|