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.
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package gateway
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// ccdcn on X: Codex now offers low, medium and high for a model magpie
|
|
// has no word on (provider.CodexEfforts, XJAI's model-test). Each reaches
|
|
// the vendor as Codex picked it, on its Responses: the levels offered are
|
|
// ones the gateway sends, not a picker that changes nothing.
|
|
func TestCodexPickedEffortReachesUnknownModel(t *testing.T) {
|
|
f := &fake{t: t, reply: sse(
|
|
`data: {"id":"c1","model":"model-test","choices":[{"delta":{"role":"assistant","content":"hi"}}]}`,
|
|
`data: {"id":"c1","choices":[{"delta":{},"finish_reason":"stop"}]}`,
|
|
`data: [DONE]`)}
|
|
up := setup(t, provider.Chat, f)
|
|
if err := provider.Save(provider.Provider{ID: "xjai", Name: "XJAI", Key: "k", Chat: up.URL + "/v1", Models: []string{"model-test"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
e, ok := provider.EntryOf("xjai/model-test")
|
|
if !ok {
|
|
t.Fatal("xjai/model-test not listed")
|
|
}
|
|
levels := provider.CodexEfforts(e)
|
|
if len(levels) != 3 {
|
|
t.Fatalf("Codex is offered %v for xjai/model-test", levels)
|
|
}
|
|
for _, effort := range levels {
|
|
code, body := post(t, "/v1/responses", `{"model":"xjai/model-test","stream":true,"input":"hi","reasoning":{"effort":"`+effort+`","summary":"auto"}}`)
|
|
if code != 200 {
|
|
t.Fatalf("%s: status %d: %s", effort, code, body)
|
|
}
|
|
var got struct {
|
|
Effort string `json:"reasoning_effort"`
|
|
}
|
|
json.Unmarshal(f.got, &got)
|
|
if got.Effort != effort {
|
|
t.Errorf("Codex picked %s; the vendor was sent %s", effort, f.got)
|
|
}
|
|
}
|
|
}
|