Files
magpie/internal/provider/ultra.go
T
yetone b6467c9551 codex: Ultra on GPT-6.1 Sol wherever it is served, Copilot's too, with Codex's agents taking parts of the task (#656) — Codex offers Ultra on a model whose entry lists "ultra", and on a thread at multi-agent V2 hands parts of the task to agents of its own; its catalog (models-manager/models.json) lists it for gpt-6.1-sol, gpt-6-sol, gpt-6-astra, gpt-5.6-sol and gpt-5.6-terra, not the Lunas, which stop at max. magpie listed Copilot's gpt-6.1-sol only up to max, so Codex had no Ultra for it. Now an entry for one of those models (by the id the vendor serves: openai/…, dated snapshots) that reaches max lists ultra too, in Codex's catalog and /v1/models, and its Codex entry says multi_agent_version v2, as Codex's own does; GPT-6 Luna still stops at max. A ChatGPT account's entry stays as the backend lists it, and a group with a ChatGPT account in it offers ultra but isn't told V2 (its lead's subagent tasks come sealed, #141); the "subagents on any model" setting still stamps v1 on OpenAI's entries. Ultra is no API's level: the gateway now always sends max for it (fitEffort), even to a model whose list says ultra. Subagent tasks with web_search kept (the translated path) were fixed in v0.1.689 (#613); TestCopilotUltraSubagentWithWebSearch now covers it against a stub Copilot: the lead's spawn_agent comes back with plain arguments and encrypted_function_args [], no "encrypted" goes upstream, and the subagent's agent_message reaches Copilot as text. TestCopilotSolOffersUltra (sol has ultra in /v1/models and Codex's catalog with v2, luna not; ultra goes to Copilot as max, with and without web_search) and TestUltraIsSentAsMax fail on the old code; TestUltraOnModelsThatOfferIt and TestUltraEntriesSayV2 cover entries, groups and the catalog. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried in the Codex App with a real Copilot account.
2026-10-03 16:08:26 +08:00

41 lines
1.6 KiB
Go

package provider
import (
"regexp"
"slices"
"strings"
)
// Codex's Ultra is not a level an API takes: Codex sends the model its max
// (or the entry's multi_agent_reasoning_effort) and, on a thread at
// multi-agent V2, hands parts of the task to agents of its own unasked
// (codex-rs core/src/session/multi_agents.rs). Codex offers it on a model
// whose entry lists "ultra"; its own catalog (models-manager/models.json)
// lists it for these alone — GPT-6 Luna and GPT-5.6 Luna stop at max — so
// magpie offers it on them wherever they are served (Copilot's, a key's, a
// relay's: #656), never on every model that reaches max.
var ultraModels = []string{"gpt-6.1-sol", "gpt-6-sol", "gpt-6-astra", "gpt-5.6-sol", "gpt-5.6-terra"}
// datedSuffix is a snapshot's date after a model's id (-2026-09-14, -20260914).
var datedSuffix = regexp.MustCompile(`-(\d{4}-\d{2}-\d{2}|\d{8})$`)
// OffersUltra reports whether Codex offers its Ultra on the model, by the id
// a vendor serves it under: openai/gpt-6.1-sol on a relay, a dated snapshot.
func OffersUltra(model string) bool {
id := strings.ToLower(model)
if i := strings.LastIndex(id, "/"); i >= 0 {
id = id[i+1:]
}
id = datedSuffix.ReplaceAllString(id, "")
return slices.Contains(ultraModels, id)
}
// withUltra adds Codex's ultra to the levels of a model that offers it and
// reaches max; the gateway sends max for it (fitEffort).
func withUltra(model string, efforts []string) []string {
if !OffersUltra(model) || !slices.Contains(efforts, "max") || slices.Contains(efforts, "ultra") {
return efforts
}
return append(slices.Clone(efforts), "ultra")
}