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.
100 lines
4.0 KiB
Go
100 lines
4.0 KiB
Go
package provider
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
)
|
|
|
|
// A built-in moved onto its plugin offers the reasoning levels it did for
|
|
// a model its vendor lists none for (Command Code's, Grok's, WorkBuddy's):
|
|
// its maker's, as the built-in borrowed them; a plugin of its own gives
|
|
// what it says: the variants it lists, and nothing for a model it doesn't
|
|
// say thinks (one it says thinks with no variants borrows,
|
|
// TestPluginThinkingModelBorrowsEfforts).
|
|
func TestMovedKeepsEfforts(t *testing.T) {
|
|
movedPlugin(t, "grok", map[string]map[string]any{})
|
|
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
|
os.WriteFile(catalog.CachePath(), []byte(`{"xai":{"id":"xai","models":{"grok-4.7":{"id":"grok-4.7",
|
|
"reasoning_options":[{"type":"effort","values":["low","medium","high","xhigh"]}]}}}}`), 0o644)
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
id := "grok-4.7"
|
|
if len(borrowedEfforts(id)) == 0 {
|
|
t.Fatal("the catalog written gives grok-4.7 no efforts")
|
|
}
|
|
pp := plugin.Provider{ID: "grok", Spec: "opencode-grok-auth", Models: []plugin.Model{{ID: id, Reasoning: true}}}
|
|
if got := pluginCatalog(pp)[0].Efforts; !slices.Equal(got, borrowedEfforts(id)) {
|
|
t.Fatalf("moved: %s's efforts %v, want %v", id, got, borrowedEfforts(id))
|
|
}
|
|
pp.ID = "someplugin"
|
|
pp.Models[0].Variants = []string{"high"}
|
|
if got := pluginCatalog(pp)[0].Efforts; !slices.Equal(got, []string{"high"}) {
|
|
t.Fatalf("a plugin's own provider's variants: %v", got)
|
|
}
|
|
pp.Models[0].Variants, pp.Models[0].Reasoning = nil, false
|
|
if got := pluginCatalog(pp)[0].Efforts; len(got) != 0 {
|
|
t.Fatalf("a plugin's own provider borrowed %v", got)
|
|
}
|
|
}
|
|
|
|
// Cline's plugin borrows its models' makers' levels, as ClinePass by API
|
|
// key does: signed in through the plugin, ClinePass showed none.
|
|
func TestClinePluginBorrowsEfforts(t *testing.T) {
|
|
claudeHome(t)
|
|
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
|
os.WriteFile(catalog.CachePath(), []byte(`{"xai":{"id":"xai","models":{"grok-4.7":{"id":"grok-4.7",
|
|
"reasoning_options":[{"type":"effort","values":["low","medium","high","xhigh"]}]}}}}`), 0o644)
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
id := "cline-pass/grok-4.7"
|
|
want := effortsOf(catalog.Model{ID: id})
|
|
if len(want) == 0 {
|
|
t.Fatal("the catalog written gives grok-4.7 no efforts")
|
|
}
|
|
pp := plugin.Provider{ID: "cline", Spec: "@magpie-community/opencode-cline-auth", Models: []plugin.Model{{ID: id}}}
|
|
if got := pluginCatalog(pp)[0].Efforts; !slices.Equal(got, want) {
|
|
t.Fatalf("cline plugin: %s's efforts %v, want the API key's %v", id, got, want)
|
|
}
|
|
}
|
|
|
|
// Moved, the agent's own sign-in is the plugin's: the agent signing in to
|
|
// another account meanwhile writes no row of the built-in's, which came
|
|
// back beside the one set aside as a second own account.
|
|
func TestMovedOwnRowNotWritten(t *testing.T) {
|
|
movedPlugin(t, "grok", map[string]map[string]any{})
|
|
sideLogins("grok", "new@x", func(savedLogin) bool { return true })
|
|
for _, l := range readLogins() {
|
|
if l.Agent == "grok" {
|
|
t.Fatalf("a grok row written while moved: %+v", l)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Devin's own account moves with the plan the Devin CLI says, as the
|
|
// built-in showed it, though its saved row has none.
|
|
func TestDevinOwnMovesWithPlan(t *testing.T) {
|
|
home := claudeHome(t)
|
|
data := filepath.Join(home, "data")
|
|
t.Setenv("XDG_DATA_HOME", data)
|
|
t.Setenv("APPDATA", data) // where Windows' Devin CLI keeps it
|
|
os.MkdirAll(filepath.Join(data, "devin"), 0o700)
|
|
if err := os.WriteFile(filepath.Join(data, "devin", "credentials.toml"), devinCredentials("cog_own_key_1234", "", "", ""), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
devinStatus.Lock()
|
|
devinStatus.user, devinStatus.plan, devinStatus.ok, devinStatus.at = "dev@example.com", "Devin Pro", true, time.Now()
|
|
devinStatus.Unlock()
|
|
t.Cleanup(devinStatus.forget)
|
|
own := movingOf(t, "devin")["dev@example.com"]
|
|
md, _ := own.Auth["metadata"].(map[string]any)
|
|
if !own.Own || own.Plan != "Devin Pro" || md["plan"] != "Devin Pro" {
|
|
t.Fatalf("Devin's own: %+v", own)
|
|
}
|
|
}
|