ccdcn on X: in the Codex app, the models of a provider they added
(XJAI's model-code, model-work, model-test) had no reasoning effort to
pick, though the chip said 中. Nothing magpie reads knows those ids, so
their entries in magpie-models.json (and /v1/codex/models) had
supported_reasoning_levels [] and default_reasoning_level null. Codex
then hides the choice but still sends an effort (medium, or
model_reasoning_effort), and the gateway's fitEffort passes an effort on
as asked when a model's levels are unknown, so the effort went out and
couldn't be changed.
provider.CodexEfforts offers low, medium and high for a model whose
levels are wholly unknown. It is used by codexListed (GET
/v1/codex/models, the backend list, spawn models) and by
agent.magpieModels("codex") (the file Codex reads, and magpie's own
Codex effort control). A model known to have no levels keeps none: one
the vendor's catalog or models.dev lists (any provider, any spelling),
one the user marked as taking no reasoning ask, a vendor entry in
Codex's shape, and a routing group.
TestCodexDesktopEfforts' "user's own" now expects medium added to the
user's enabled-reasoning-efforts: its fixture's fake/m1 is such a model.
Run (on mote):
- go test -timeout 45m -count=1 ./internal/provider ./internal/agent
./internal/codexcat: ok
- go test -timeout 45m -count=1 ./internal/gateway ./internal/gui:
gateway ok (615s); gui red only in 10 real-window AppKit tests
(dock, panel, tray, main window), each killed at its deadline. Four of
them run alone on origin/main 024393fbb fail the same way on mote:
#4125 (mote's AppKit/launchd hang). Not run on another Mac.
- GOOS=linux / GOOS=windows go vet ./internal/provider ./internal/agent
./internal/gateway: ok; gofmt -l clean
The runs above were at base d99e213f5. Rebased on 024393fbb, which
changed internal/gateway only; at this head the new tests and every
TestCodex.*Effort test in provider, agent and gateway pass again.
Broken by hand: with codex_models.go and route.go stashed, the new
TestCodexOffersLevelsForUnknownModels and
TestCodexCatalogOffersUnknownModelsLevels fail (offered []).
TestCodexPickedEffortReachesUnknownModel checks each offered level
reaches the vendor as reasoning_effort.
Real Codex: codex-cli 0.165.0 app-server (sandbox CODEX_HOME), model/list
on the catalog codexcat writes for xjai/model-test: before,
supportedReasoningEfforts [] / default none; after, low, medium, high /
default medium.
Not tried: the Codex desktop app with a real XJAI vendor. Not changed:
other agents (OpenCode variants etc.), which send no effort for such a
model today, and groups whose members are all unknown.
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package agent
|
|
|
|
import (
|
|
"encoding/json"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// ccdcn on X: in the Codex app, the models of a provider the user added
|
|
// (XJAI's model-code, model-work, model-test), which nothing magpie reads
|
|
// knows, had no reasoning effort to pick. magpie-models.json, which Codex
|
|
// reads them from, now offers them low, medium and high, as GET
|
|
// /v1/codex/models does (provider.CodexEfforts).
|
|
func TestCodexCatalogOffersUnknownModelsLevels(t *testing.T) {
|
|
home := syncHome(t)
|
|
if err := provider.Save(provider.Provider{ID: "xjai", Name: "XJAI", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"model-code", "model-work", "model-test"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cx := codex(home)
|
|
if err := cx.Fields[0].Set("xjai/model-test"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got struct {
|
|
Models []struct {
|
|
Slug string `json:"slug"`
|
|
Default *string `json:"default_reasoning_level"`
|
|
Levels []struct {
|
|
Effort string `json:"effort"`
|
|
} `json:"supported_reasoning_levels"`
|
|
} `json:"models"`
|
|
}
|
|
raw := readFile(filepath.Join(home, ".codex", "magpie-models.json"))
|
|
if err := json.Unmarshal([]byte(raw), &got); err != nil {
|
|
t.Fatalf("%v: %s", err, raw)
|
|
}
|
|
seen := 0
|
|
for _, m := range got.Models {
|
|
if m.Slug != "xjai/model-code" && m.Slug != "xjai/model-work" && m.Slug != "xjai/model-test" {
|
|
continue
|
|
}
|
|
seen++
|
|
var ls []string
|
|
for _, l := range m.Levels {
|
|
ls = append(ls, l.Effort)
|
|
}
|
|
if len(ls) != 3 || ls[0] != "low" || ls[1] != "medium" || ls[2] != "high" || m.Default == nil {
|
|
t.Errorf("%s offers %v (default %v), want low, medium, high", m.Slug, ls, m.Default)
|
|
}
|
|
}
|
|
if seen != 3 {
|
|
t.Errorf("%d of XJAI's models in magpie-models.json: %s", seen, raw)
|
|
}
|
|
// and magpie's own effort control for Codex offers the same
|
|
if opts := codexEfforts(magpieModels("codex"), "xjai/model-test"); len(opts) != 4 || opts[0].Value != "" {
|
|
t.Errorf("effort control: %+v", opts)
|
|
}
|
|
}
|