Files
magpie/internal/codexcat/description_test.go
T
yetone f1ac93aa54 codex: Ultra on every other vendor's model that reasons (pingqipai3 on X)
pingqipai3 asked for Codex's Ultra effort on every model, so Codex uses
subagents more. Codex offers a level only where the model's catalog entry
lists it, and magpie listed Ultra only on OpenAI's own models.

What Codex does with it (openai/codex 553c764): Ultra is never sent.
ModelInfo::resolve_reasoning_effort sends the entry's
multi_agent_reasoning_effort, else max, else its highest other level; and
under MultiAgent V2, Ultra is what makes subagents proactive
(effective_multi_agent_mode). So Ultra on another vendor's model asks it
its own top level, which is honest, and turns on V2's proactive subagents.

codexcat.entriesAt now ends the levels of a model that lists some, from a
vendor other than OpenAI, with "ultra" and says multi_agent_version v2
(ultraHere). Left alone: GPT, o-series and Codex models (their Ultra is
provider.OffersUltra's), a model with no levels, Fast and Seals entries
(V1 stays theirs), a vendor's own Codex entry (listedEntry). The default
level is never Ultra. catalogFormat goes to v3, so Codex fetches the list
again. Only Codex's catalog changes; other agents' level lists don't.
docs/subsystems/agent-wiring.md has a row for it.

Run: at origin/main 54b6d4d39 + these three commits (c63a6d674, mica):
gofmt -l clean; go vet ./internal/{codexcat,gui,agent,gateway,provider,
catalog,usage} on darwin, GOOS=linux -tags nogui and GOOS=windows ok;
go test -count=1 of those seven packages: all ok.
Rebased onto origin/main 21ed46106 after that run (main's gateway,
provider and i18n.js changes): provider, gui, codexcat and
gateway-model-info, i18n-keys, gui-zh-tw run again there (mica): Go all ok, GUI 8 of 9; i18n-keys is red on
"No folder" from 72facf72e on main (#6423), not this change.
The full suite runs after the tag.
The provider tests that read Codex's list (TestCPAVariantModelsBorrowLevels,
TestGroupQuietMemberKeepsCodexEffortControl,
TestCodexOffersLevelsForUnknownModels) now expect ultra at the end.
Broken by hand: ultraHere returning false turns TestUltraOnOtherVendorsModels
red (claude-opus-4-8, glm-5.3, deepseek-v4-pro, group/mixed: no ultra, no v2).
Not tried: a real Codex session picking Ultra on a non-GPT model and
watching it spawn subagents; magpie's own Codex effort control
(codexEfforts) still doesn't list Ultra for these models; a Codex app
[desktop] enabled-reasoning-efforts the user set without "ultra" is left
as they set it.
2026-11-13 12:53:04 +08:00

67 lines
3.0 KiB
Go

package codexcat
import (
"encoding/json"
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// #5024: Codex 0.166 fails the whole model catalog on a
// supported_reasoning_levels entry without a description ("missing field
// `description`"), so every level of an entry magpie writes from a vendor's
// carries one: the vendor's own where it gave it, else the effort's display
// name. That is whether the user's efforts are the vendor's own, whose
// levels magpie keeps as it wrote them, or differ from them, whose missing
// ones magpie makes. A level of an entry magpie makes alone has said a
// description (an empty one) all along.
func TestCodexListedLevelsSayDescription(t *testing.T) {
v1Home(t, `{"etag":"W/\"a\"","models":[]}`)
same := json.RawMessage(`{"slug":"glm-5.3","display_name":"GLM-5.3","description":"x","base_instructions":"y",` +
`"supported_reasoning_levels":[{"effort":"low","description":"Fastest"},{"effort":"medium"},{"effort":"high"}],` +
`"shell_type":"shell_command","visibility":"list"}`)
// a vendor entry with no levels at all, for a model with no efforts
bare := json.RawMessage(`{"slug":"plain","display_name":"Plain","description":"x","base_instructions":"y",` +
`"shell_type":"shell_command","visibility":"list"}`)
short := json.RawMessage(`{"slug":"kimi","display_name":"Kimi","description":"x","base_instructions":"y",` +
`"supported_reasoning_levels":[{"effort":"low"}],` +
`"shell_type":"shell_command","visibility":"list"}`)
var got struct {
Models []struct {
Slug string `json:"slug"`
Levels []map[string]any `json:"supported_reasoning_levels"`
} `json:"models"`
}
if err := json.Unmarshal(Catalog([]catalog.Model{
{ID: "relay/glm-5.3", Name: "GLM-5.3", Efforts: []string{"low", "medium", "high"}, Codex: same},
{ID: "relay/kimi", Name: "Kimi", Efforts: []string{"low", "xhigh"}, Codex: short},
{ID: "or/deepseek-v4", Name: "DeepSeek V4", Efforts: []string{"low", "max"}},
{ID: "relay/plain", Name: "Plain", Codex: bare},
}), &got); err != nil || len(got.Models) != 4 {
t.Fatalf("%v %v", err, got)
}
want := map[string]map[string]string{
// the vendor's own kept where it gave one, the name where it didn't
"relay/glm-5.3": {"low": "Fastest", "medium": "Medium", "high": "High"},
// one the vendor doesn't list, made for an effort of the user's
"relay/kimi": {"low": "Low", "xhigh": "Extra High"},
// magpie's own entry: a description said all along, Codex's
// Ultra after its levels (TestUltraOnOtherVendorsModels)
"or/deepseek-v4": {"low": "", "max": "", "ultra": ""},
// none listed and none asked for: nothing to describe, no panic
"relay/plain": {},
}
for _, m := range got.Models {
if len(m.Levels) != len(want[m.Slug]) {
t.Fatalf("%s: levels %v", m.Slug, m.Levels)
}
for _, l := range m.Levels {
ef, _ := l["effort"].(string)
d, _ := l["description"].(string)
if d != want[m.Slug][ef] {
t.Errorf("%s: level %s says description %q, want %q", m.Slug, ef, d, want[m.Slug][ef])
}
}
}
}