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/main54b6d4d39+ 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/main21ed46106after 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" from72facf72eon 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.
116 lines
3.5 KiB
Go
116 lines
3.5 KiB
Go
package agent
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// What the user adds by hand to the model list magpie writes for Codex
|
|
// stays through the next model switch, sync and stepping out (#1450:
|
|
// supports_reasoning_summaries, put in for Codex to show a model's
|
|
// thinking, was gone after the next change). A key magpie writes, or took
|
|
// out on purpose (multi_agent_version with the V1 setting off), is
|
|
// magpie's.
|
|
func TestCodexCatalogKeepsWhatTheUserAdded(t *testing.T) {
|
|
home, _ := codexHome(t, "", "")
|
|
list := filepath.Join(home, ".codex", "magpie-models.json")
|
|
cx := codex(home)
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// the file as magpie wrote it, edited by hand: two keys on fake/m1's
|
|
// entry, and a version magpie no longer writes
|
|
var cat map[string]any
|
|
if err := json.Unmarshal([]byte(readFile(list)), &cat); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
e := cat["models"].([]any)[0].(map[string]any)
|
|
if e["slug"] != "fake/m1" {
|
|
t.Fatalf("first entry: %v", e["slug"])
|
|
}
|
|
e["supports_reasoning_summaries"] = true
|
|
e["default_reasoning_summary"] = "detailed"
|
|
e["multi_agent_version"] = "v1"
|
|
b, _ := json.MarshalIndent(cat, "", " ")
|
|
writeFile(t, list, string(b))
|
|
|
|
has := func(when string) {
|
|
t.Helper()
|
|
var got struct {
|
|
Models []map[string]any `json:"models"`
|
|
}
|
|
if err := json.Unmarshal([]byte(readFile(list)), &got); err != nil {
|
|
t.Fatalf("%s: %v", when, err)
|
|
}
|
|
var m1 map[string]any
|
|
for _, m := range got.Models {
|
|
if m["slug"] == "fake/m1" {
|
|
m1 = m
|
|
}
|
|
}
|
|
if m1 == nil || m1["supports_reasoning_summaries"] != true || m1["default_reasoning_summary"] != "detailed" {
|
|
t.Errorf("%s: the user's keys are gone: %v %v", when, m1["supports_reasoning_summaries"], m1["default_reasoning_summary"])
|
|
}
|
|
// magpie writes v2 for a model it offers Ultra (pingqipai3 on X),
|
|
// never the user's v1 back
|
|
if v, ok := m1["multi_agent_version"]; ok && v != "v2" {
|
|
t.Errorf("%s: a version magpie no longer writes stayed: %v", when, v)
|
|
}
|
|
if m1["base_instructions"] == nil || m1["supports_parallel_tool_calls"] != true {
|
|
t.Errorf("%s: magpie's own keys are gone", when)
|
|
}
|
|
}
|
|
|
|
// a provider added: the sync writes the list again
|
|
if err := provider.Save(provider.Provider{ID: "added", Name: "Added", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m2"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
SyncCatalog()
|
|
if !strings.Contains(readFile(list), `"added/m2"`) {
|
|
t.Fatal("sync didn't write the new model")
|
|
}
|
|
has("after a sync")
|
|
|
|
if err := cx.Fields[0].Set("added/m2"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
has("after a model switch")
|
|
|
|
// Codex's own default: magpie steps out, and the list the user added
|
|
// to stays for when magpie is back
|
|
if err := cx.Fields[0].Set(""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := os.Stat(list); err != nil {
|
|
t.Fatalf("the list the user added to was removed: %v", err)
|
|
}
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
has("after stepping out and back")
|
|
}
|
|
|
|
// A list holding nothing of the user's still goes as magpie steps out.
|
|
func TestCodexCatalogRemovedWhenNothingAdded(t *testing.T) {
|
|
home, _ := codexHome(t, "", "")
|
|
list := filepath.Join(home, ".codex", "magpie-models.json")
|
|
cx := codex(home)
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := os.Stat(list); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := cx.Fields[0].Set(""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := os.Stat(list); err == nil {
|
|
t.Error("magpie's list stayed after it stepped out")
|
|
}
|
|
}
|