diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index 9a5ec5136..16b3c6bfc 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -211,6 +211,7 @@ recorded as a prediction failure (`noPrediction`). - A failed call is in `app.log` too, not only the Routing page and the usage ledger (wjh66 on Discord: Codex's "error decoding response body" after "reconnecting 5/5", and the log had nothing of the turn). `record` writes each call whose status is 400 or more, or that carries an error, as one line (`failedCallLine`: agent, model, provider, status, time, the error to 300 characters); the same failure again within a minute is counted into the next line, not written (`failedLogEvery`), so a client asking in a loop can't fill the log. A Codex reply relayed from the ChatGPT backend that ends before its last event also says which side ended it (`codexEndedEarly` in [`codex_backend.go`](../../internal/gateway/codex_backend.go)): the read of OpenAI's stream that failed, with its error, or a clean end; and the client gone, a write to it that failed, or the failure passed on as `response.failed`, with the bytes passed on. reqwest, Codex's HTTP client, says "error decoding response body" for any read of a body whose connection broke, so only this line tells the legs apart. A gateway that ends with requests still in flight logs that they were cut (`srv.Shutdown`'s error; on Windows there is no handover, so an update or quit cuts a stream after `shortDrain`) (`TestCodexReplyBrokenOffLogged`, `TestCodexClientGoneLogged`, `TestFailedCallLineOncePerMinute`). - Each record keeps the service tier three ways (#1784): `tier_asked` is what the client's body asked (`bodyTier`; Claude's speed fast reads `fast`), `tier_sent` is what that try's last request went out with, noted in `forwardOnce` after every rewrite (fast picks, Ultrafast to priority on a plan without it) onto the per-attempt `wireAt`, and `tier_served` is only what the reply said it ran at (`upstreamTier`, read by the sniffer and the translated readers), empty when it says nothing; from the ChatGPT backend (CodexBase's host) its `auto` and `default` are empty too, since it says them whether priority ran or not (`servedTierAt`, applied in `attempt` and `codexUpstreamOn`). The route's tries carry `tier` and `tier_served` the same way. A bridge that doesn't go through `forwardOnce` (the Claude subscription, Cursor's built-in) leaves `tier_sent` empty. Code: [`tier_record.go`](../../internal/gateway/tier_record.go). - An agent's fast pick (`settings.FastPicks`, the bolt in its picker, #954) may also be in `settings.UltraPicks` (#1954), offered by the GUI only where one of Codex's accounts lists Ultrafast on the model (`provider.CanUltra`, `UltraModels`). `fastPick` marks its candidates `ultra`; a try of one goes with `service_tier: "ultrafast"` on Chat and Responses, and an agent on Messages carries it in the context (`withUltra`) to `forwardTranslated`, which sets `Request.Ultrafast` for the ChatGPT backend. Either way the same check as a client's own Ultrafast ask applies, now on Chat as well as Responses: an account whose list doesn't offer it is put after a mate that does (`tierMate`), or, with none left, sent `priority`. A Chat body's own `service_tier: "ultrafast"` is parsed as Ultrafast too (`chat.go`). `TestUltraPickSentUltrafast`. +- Codex's service tier (`settings.CodexServiceTier`, a row in Codex's settings, JackyFill on X) sets the `service_tier` of every request of Codex's, whatever Codex's own `/fast` asked: empty is as Codex asks (the default, nothing changed), `default` sends none (standard), `priority` is Codex's Fast and `ultrafast` its Ultra Fast (the request values in Codex's `ServiceTier`; Flex is not offered, since the ChatGPT backend's requests drop it in `codex_request.go`). `codexTiered` ([`codex_tier.go`](../../internal/gateway/codex_tier.go)) rewrites the body as it comes in, on both of Codex's ways in: `codexBackend` (Codex signed in, `/backend-api/codex`) and the main handler's Codex-on-Responses block, which a websocket turn reaches too. Everything after treats it as Codex's own ask: an account whose list lacks Ultrafast is put after a mate that offers it (`tierMate`) or sent `priority`, and a provider that refuses a tier drops it. A model with no provider (`gpt-…`, Codex's own sign-in, whose plan magpie doesn't know) is sent `ultrafast` only where one of magpie's Codex accounts lists it on the model (`UltraModels`), else `priority`. Another agent's request is never touched, and fast picks still apply after. `TestCodexServiceTierSet`, `codex-service-tier.test.cjs`. - A usage record carries its prompt's cache beside `in` and `out` (#1839): `cache_read` (tokens read from the vendor's cache) and `cache_write` (cache creation, Anthropic's `cache_creation_input_tokens`; `cache_write_1h` the part written for an hour). `in` holds neither. Both are written on every record, 0 too, so a prompt that missed the cache reads as that. A record from before then has neither and reads as 0. Every route fills them: Anthropic's messages, Chat (OpenAI's `prompt_tokens_details.cached_tokens`, DeepSeek's `prompt_cache_hit_tokens`), Responses (`input_tokens_details.cached_tokens`) and Gemini (`cachedContentTokenCount`), passed through or translated, whole or streamed, a plugin's fetch, and the Claude subscription bridge. System One's decision calls report no cache. `TestUsageRecordsCacheTokensOnEveryRoute`, `TestPluginUsageRecordsCacheTokens`, `TestClaudeSubscriptionUsageKeepsCacheTokens`, `TestRecordAlwaysCarriesCacheTokens`. - What the vendor read from its cache reaches the agent in the names its SDK reads, not only the record. A relayed Chat reply whose usage tells the cache in another vendor's names (a relay's Anthropic `cache_read_input_tokens` and `cache_creation_input_tokens`, DeepSeek's `prompt_cache_hit_tokens` or Moonshot's top-level `cached_tokens` beside a 0 in `prompt_tokens_details`) is told in OpenAI's too, streamed (`chatTidy`) and whole (`chatWhole`), by `openAIUsage` in [`chattidy.go`](../../internal/gateway/chattidy.go): `prompt_tokens_details.cached_tokens` (and `cache_write_tokens`), with `prompt_tokens` and `total_tokens` made to hold the cached part where the vendor left it out. Every other field stays, and a usage already in OpenAI's names, or with no cache, goes byte for byte; one in OpenAI's names alone isn't even decoded (`mayMendUsage`). pi-ai, which DeepSeek Harness and Pi use, reads `prompt_tokens_details.cached_tokens` first, a 0 there too, and maps no Anthropic names at all, so such a relay showed DSH 缓存命中 0% while magpie had counted the hit (B3TT3R on Discord asked; DeepSeek's own API sends both names and was already read right). Relayed Responses and Messages replies, translated replies and a plugin's need nothing: their usage is written in the agent's own names. `TestAgentReadsCacheTokensOnEveryRoute`, `TestPluginAgentReadsCacheTokens`, `TestOpenAIUsageLeavesOpenAIsAlone`, `TestMayMendUsageOnlyOtherNames` in [`usage_cache_agent_test.go`](../../internal/gateway/usage_cache_agent_test.go). - A request whose key is a Claude sign-in (`claudeSignIn`: `Authorization: Bearer sk-ant-oat…`, Claude Code signed in to claude.ai with magpie as its base URL) is never told a 401, nor a 403 saying "OAuth token has been revoked". magpie never passes that sign-in on, so such an answer is a provider refusing magpie's credential, or one of magpie's own Claude accounts lapsing; told it, Claude Code renews its own sign-in before each of its retries (ten for one request) and then asks to `/login`. Any error whose message mentions x-api-key, whatever its status, Claude Code tells as "Not logged in · Please run /login" too. It is told as a 502 in magpie's words, an `api_error` saying " refused magpie's credential (HTTP 401): …" with x-api-key said as "API key", and any other error such a request is told keeps its status with x-api-key said as "API key", as does a stream's error after its 200 (`keepsSignIn`, `claude_signin.go`). Recent calls and the usage log keep the provider's status and message. Any other 403, and a request with magpie's key or an API key, is answered as before. The sign-in's beta (`oauth-…` in `anthropic-beta`) isn't passed on either (`askedBetas`), so a provider gets the request as Claude Code with magpie's key sends it; a provider's own `header.anthropic-beta` still goes. diff --git a/internal/gateway/codex_backend.go b/internal/gateway/codex_backend.go index bcdd5edd9..7fbdb1e60 100644 --- a/internal/gateway/codex_backend.go +++ b/internal/gateway/codex_backend.go @@ -118,6 +118,8 @@ func (s *Server) codexBackend(w http.ResponseWriter, r *http.Request) { // it, as handle's and gemini's do (Jason on Discord: a held Codex // turn showed as no model, "magpie · 0 on") noteAsked(r.Context(), model) + // the service tier set for Codex, in place of the one it asked + body = codexTiered(r, body, model) // a turn of the conversation's own: the model its side calls may // follow (codexFollowTo) meta := requestSessionMetadata(r.Header, body) diff --git a/internal/gateway/codex_tier.go b/internal/gateway/codex_tier.go new file mode 100644 index 000000000..0f14bbcce --- /dev/null +++ b/internal/gateway/codex_tier.go @@ -0,0 +1,62 @@ +package gateway + +import ( + "bytes" + "net/http" + "strings" + + "github.com/yetone/magpie/internal/provider" + "github.com/yetone/magpie/internal/settings" +) + +// codexTiered is the body of a request of Codex's with the service tier +// the user set for Codex (provider.CodexServiceTier, JackyFill on X) in +// place of the one Codex asked: none for the standard tier, "priority" +// (Codex's Fast) or "ultrafast" (its Ultra Fast). Unset, or another +// agent's request, goes as it came. The tier is then served as Codex's own +// ask would be: an account whose plan has no Ultrafast is put after one +// that has, or asked for priority (serve), a provider added by its address +// that turns a tier away is not sent it again (fits). One of Codex's own +// models no account in magpie lists Ultrafast on is asked for priority +// instead, as it may go on to Codex's own sign-in, whose plan magpie +// doesn't know. +func codexTiered(r *http.Request, body []byte, model string) []byte { + set := provider.CodexServiceTier() + if set == "" || !fromCodex(r.Header) && agentOf(r) != "codex" { + return body + } + if set == "ultrafast" && !strings.Contains(model, "/") && !provider.UltraModels()[model] { + set = "priority" + } + if set == settings.CodexTierStandard { + set = "" + } + return withServiceTier(body, set) +} + +// withServiceTier is body with its top-level service_tier set to tier, or +// without one for "", every other byte as it came. A body that isn't a +// JSON object goes as it came. +func withServiceTier(body []byte, tier string) []byte { + cur, found, ok := topMember(body, tierField) + if !ok || !found && tier == "" { + return body + } + want := []byte(`"` + tier + `"`) + if found && bytes.Equal(bytes.TrimSpace(cur), want) { + return body + } + b := withoutTopMember(body, tierField) + if tier == "" { + return b + } + i := bytes.IndexByte(b, '{') + if i < 0 { + return body + } + sep := "," + if j := skipJSONSpace(b, i+1); j < len(b) && b[j] == '}' { + sep = "" + } + return insertAt(b, i+1, `"`+tierField+`":`+string(want)+sep) +} diff --git a/internal/gateway/codex_tier_test.go b/internal/gateway/codex_tier_test.go new file mode 100644 index 000000000..c88589c9d --- /dev/null +++ b/internal/gateway/codex_tier_test.go @@ -0,0 +1,114 @@ +package gateway + +import ( + "net/http/httptest" + "strings" + "testing" + + "github.com/yetone/magpie/internal/provider" + "github.com/yetone/magpie/internal/settings" +) + +// JackyFill on X: Codex's settings in magpie set the service tier every +// request of Codex's goes at, whatever Codex asked: as Codex asks it +// (unset), none (standard), priority (Fast) or ultrafast (Ultrafast). +// Another agent's request goes as it asked, and Ultrafast on a model no +// account lists it on goes as priority. Both of Codex's ways in: with +// magpie as its provider (/v1/responses) and signed in, on the ChatGPT +// backend's route. +func TestCodexServiceTierSet(t *testing.T) { + tried := tierAccounts(t, nil, nil) + s := New() + last := func() string { + t.Helper() + got := tried() + if len(got) == 0 { + t.Fatal("the ChatGPT backend was asked nothing") + } + return got[len(got)-1] + } + body := func(model, tier string) string { + b := `{"model":"` + model + `","stream":true,"input":"ping"` + if tier != "" { + b += `,"service_tier":"` + tier + `"` + } + return b + "}" + } + // through magpie's Codex provider, whose accounts' lists magpie knows + viaProvider := func(agent, tier string) string { + t.Helper() + postFrom(t, s, agent, "/v1/responses", body("codex/gpt-6-luna", tier)) + return last() + } + // on the backend's route, as Codex signed in to ChatGPT sends + viaBackend := func(model, tier string) string { + t.Helper() + rec := httptest.NewRecorder() + req := httptest.NewRequest("POST", CodexPath+"/responses", strings.NewReader(body(model, tier))) + req.Header.Set("Authorization", "Bearer chatgpt-token") + req.Header.Set("chatgpt-account-id", "acct-plus") + req.Header.Set("User-Agent", "codex_cli_rs/0.170.0 (Mac OS 26.6.0; arm64) kitty") + req.Header.Set("originator", "codex_cli_rs") + s.Handler().ServeHTTP(rec, req) + if rec.Code != 200 { + t.Fatalf("backend route: %d %s", rec.Code, rec.Body) + } + return strings.SplitN(last(), ":", 2)[1] + } + for _, c := range []struct { + set, asked string + provider string // account:tier tried last + luna, sol string // the tier sent for a model a plan offers Ultrafast on, and one none does + }{ + {"", "priority", "acct-plus:priority", "priority", "priority"}, + {"", "", "acct-plus:", "", ""}, + {settings.CodexTierStandard, "priority", "acct-plus:", "", ""}, + {settings.CodexTierStandard, "ultrafast", "acct-plus:", "", ""}, + {"priority", "", "acct-plus:priority", "priority", "priority"}, + {"priority", "ultrafast", "acct-plus:priority", "priority", "priority"}, + {"ultrafast", "", "acct-pro:ultrafast", "ultrafast", "priority"}, + {"ultrafast", "priority", "acct-pro:ultrafast", "ultrafast", "priority"}, + } { + if err := provider.SetCodexServiceTier(c.set); err != nil { + t.Fatal(err) + } + if got := viaProvider("codex", c.asked); got != c.provider { + t.Errorf("set %q, Codex asked %q through /v1/responses: tried %s, want %s", c.set, c.asked, got, c.provider) + } + if got := viaBackend("gpt-6-luna", c.asked); got != c.luna { + t.Errorf("set %q, Codex asked %q for gpt-6-luna on the backend's route: sent %q, want %q", c.set, c.asked, got, c.luna) + } + if got := viaBackend("gpt-6-sol", c.asked); got != c.sol { + t.Errorf("set %q, Codex asked %q for gpt-6-sol on the backend's route: sent %q, want %q", c.set, c.asked, got, c.sol) + } + } + // the rule is Codex's alone + provider.SetCodexServiceTier(settings.CodexTierStandard) + if got := viaProvider("opencode", "priority"); got != "acct-plus:priority" { + t.Errorf("OpenCode's priority tried %s", got) + } + // a value magpie doesn't know is refused + if err := provider.SetCodexServiceTier("flex"); err == nil { + t.Error("flex was taken") + } +} + +// withServiceTier sets, replaces or takes out the top-level tier alone, +// every other byte as it came; a nested service_tier is not the request's. +func TestWithServiceTier(t *testing.T) { + for _, c := range []struct{ in, tier, want string }{ + {`{"model":"m"}`, "priority", `{"service_tier":"priority","model":"m"}`}, + {`{}`, "priority", `{"service_tier":"priority"}`}, + {` { } `, "priority", ` {"service_tier":"priority" } `}, + {`{"model":"m","service_tier":"ultrafast"}`, "priority", `{"service_tier":"priority","model":"m"}`}, + {`{"model":"m","service_tier":"priority"}`, "priority", `{"model":"m","service_tier":"priority"}`}, + {`{"model":"m","service_tier":"priority"}`, "", `{"model":"m"}`}, + {`{"model":"m"}`, "", `{"model":"m"}`}, + {`{"model":"m","metadata":{"service_tier":"flex"}}`, "", `{"model":"m","metadata":{"service_tier":"flex"}}`}, + {`not json`, "priority", `not json`}, + } { + if got := string(withServiceTier([]byte(c.in), c.tier)); got != c.want { + t.Errorf("withServiceTier(%s, %q) = %s, want %s", c.in, c.tier, got, c.want) + } + } +} diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 99bd23c55..53e4e28f4 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -2117,6 +2117,9 @@ func (s *Server) handle(from provider.Protocol) http.HandlerFunc { // (Gearclickist on Discord) if from == provider.Responses && (fromCodex(r.Header) || agentOf(r) == "codex") { body = spawnAgentModels(r, body, model, false) + // the service tier set for Codex, in place of the one it + // asked (codexTiered) + body = codexTiered(r, body, model) } if from == provider.Chat { body = thinkingEffort(body) diff --git a/internal/gui/api.go b/internal/gui/api.go index a8b8f23b2..1de0cfd2f 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -2007,6 +2007,20 @@ func Handler(w Windows, gw *gateway.Server) http.Handler { } writeJSON(rw, settingsState()) }) + // the service tier every request of Codex's goes at (JackyFill on X): + // "" as Codex asks it, "default" with none, "priority" or "ultrafast" + mux.HandleFunc("POST /api/settings/codex-service-tier", func(rw http.ResponseWriter, r *http.Request) { + var in struct{ Tier string } + if err := json.NewDecoder(r.Body).Decode(&in); err != nil { + fail(rw, err) + return + } + if err := provider.SetCodexServiceTier(in.Tier); err != nil { + fail(rw, err) + return + } + writeJSON(rw, settingsState()) + }) // Warm up now: one Codex or Claude account's warm-up sent at once, and // why it failed mux.HandleFunc("POST /api/warm-now", func(rw http.ResponseWriter, r *http.Request) { diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index b4368ac52..98228a4da 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -21159,7 +21159,7 @@ function renderAlerts(s, keep) { // in Settings, apart from the agents they set (the owner, 10-20); Long // conversations is Codex's, Claude Code's and Grok Build's (uk.jent), in each one's sheet. const AGENT_PREFS = { - codex: ["codexAgentsV1Row", "codexSubagentModelRow", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"], + codex: ["codexAgentsV1Row", "codexSubagentModelRow", "codexServiceTierRow", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"], claude: ["fullContextRow"], grok: ["fullContextRow"], }; @@ -21214,16 +21214,14 @@ function renderAgentPrefs() { homeAgentPrefRows(); // what each row does, in its tooltip (#2120) for (const [row, en] of [ + ["#codexServiceTierRow", "Every request Codex sends goes at this tier, whatever /fast is set to in Codex; Ultrafast goes as Fast where the plan has none"], ["#codexTitlesRow", "Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"], ["#codexDescriptionsRow", "Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"], ["#codexPredictionsRow", "Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model"], ["#codexAutoReviewRow", "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session"], ["#codexMemoriesRow", "Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on Codex’s own memory models when that is one of Codex’s own"], ]) $(row + " .who").title = t(en); - // Codex's own models in multi-agent V1 (their subagents' tasks go as text), - // so a GPT lead can run a subagent on magpie's other models (#141). Where - // Codex's own multi_agent_v2 is on in the config magpie routes it wins, and - // magpie writes nothing: the row says so and the user turns it off. + // multi-agent V1 (#141); Codex's own multi_agent_v2 wins, said in the row const v1Warn = $("#codexAgentsV1Warn"); v1Warn.hidden = !s.notice; v1Warn.textContent = s.notice ? tNotice(s.notice) : ""; @@ -21272,6 +21270,7 @@ function renderAgentPrefs() { box.append(asyncRow); if (held.length) box.append(el("div", "hint codex-async-held", codexHeld(held))); $("#codexAsyncSegs").replaceChildren(box); + renderCodexServiceTier(s); renderCodexTitles(s); renderCodexDescriptions(s); renderCodexPredictions(s); @@ -21354,27 +21353,42 @@ function codexSidePick(s, key, aria, none, path) { $("#" + key + "Pick").replaceChildren(b); } -// renderCodexDescriptions picks the model for descriptions independently -// of titles; an empty setting preserves Codex's requested model, off -// answers with no description. +// Codex's service tiers, its own names (JackyFill on X) +const CODEX_TIERS = [ + { v: "", name: "As Codex asks", note: "/fast in Codex" }, + { v: "default", name: "Standard", note: "" }, + { v: "priority", name: "Fast", note: "priority" }, + { v: "ultrafast", name: "Ultrafast", note: "ultrafast" }, +]; +function renderCodexServiceTier(s) { + const v = s.codexServiceTier || ""; + const cur = CODEX_TIERS.find((o) => o.v === v) || CODEX_TIERS[0]; + const b = el("button", "rt-cond on"); + b.type = "button"; + b.setAttribute("aria-label", t("Codex service tier")); + b.setAttribute("aria-haspopup", "menu"); + b.append(el("span", "", t(cur.name))); + b.onclick = (e) => { + e.stopPropagation(); + if (b.classList.contains("open")) return closeProtoMenu(); + openProtoMenu(b, CODEX_TIERS, cur.v, (tier) => { + if (tier === cur.v) return; + prefWrite(api("settings/codex-service-tier", { tier })); + }, "Codex service tier", "sess-menu"); + }; + $("#codexServiceTierPick").replaceChildren(b); +} + +// Codex's descriptions: as sent, off, or a model function renderCodexDescriptions(s) { codexSidePick(s, "codexDescriptions", "Codex thread descriptions", "no description, nothing sent", "codex-descriptions"); } -// renderCodexPredictions: where the Codex app's guess at the user's next -// message goes (#1970) — as Codex sends it, on the thread's own model; off, -// answered by magpie with no prediction; or to a model of magpie's. +// Codex's next-message guesses (#1970) function renderCodexPredictions(s) { codexSidePick(s, "codexPredictions", "Codex composer predictions", "no prediction, nothing sent", "codex-predictions"); } -// renderCodexTitles: where Codex's requests for a thread's title go (#705) -// — as Codex sends them, to its own model through its ChatGPT sign-in; off, -// answered by magpie with no title; or to a model of magpie's — set on its -// own, as Codex's subagents are. +// Codex's thread titles (#705) function renderCodexTitles(s) { codexSidePick(s, "codexTitles", "Codex thread titles", "no title, nothing sent", "codex-titles"); } -// renderCodexAutoReview: the model Codex's auto-review — the reviewer that -// decides an approval in the user's place — runs on (#938): Codex's own pick -// (its codex-auto-review, else the conversation's model), or a model of -// magpie's named in every entry of the list magpie hands Codex, or the -// session's own ("session": each of magpie's entries names itself). +// Codex's auto-review model (#938) function renderCodexAutoReview(s) { const models = s.titleModels || []; const v = s.codexAutoReview || ""; @@ -21415,11 +21429,7 @@ function renderCodexMemories() { $("#codexMemoriesPick").replaceChildren(b); } -// renderCodexSubagentModel: Codex's subagent model in its sheet, a row with -// a name, as the memories one is: the card's square alone is easy to miss. -// The same field and picker, so the row and the square are one setting. -// It says its name alone, its button the choice, Same as the lead or the -// model; what that does is the row's title. +// Codex's subagent model: the card's field, as a row function renderCodexSubagentModel() { homeAgentPrefRows(); const row = $("#codexSubagentModelRow"); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 7941e2351..f4d45673d 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -4,6 +4,11 @@ // works. {name} slots are filled by t(str, vars). const I18N = { zh: { + "Codex service tier": "Codex 服务层级", + "As Codex asks": "按 Codex 的请求", + "/fast in Codex": "Codex 里的 /fast", + "Standard": "标准", + "Every request Codex sends goes at this tier, whatever /fast is set to in Codex; Ultrafast goes as Fast where the plan has none": "Codex 发出的每个请求都走这个层级,不管 Codex 里的 /fast 怎么设;套餐没有极速时按快速发", "Check-in time": "签到时间", "From {at} each day, for every vendor's check-in": "每天 {at} 起签到,所有服务商的签到都按这个时间", "As soon as each vendor's day starts": "每个服务商的新一天一开始就签到", @@ -4890,6 +4895,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "这份报告已经不在了:magpie 只保留最近 5 份。", }, "zh-TW": { + "Codex service tier": "Codex 服務層級", + "As Codex asks": "依 Codex 的請求", + "/fast in Codex": "Codex 裡的 /fast", + "Standard": "標準", + "Every request Codex sends goes at this tier, whatever /fast is set to in Codex; Ultrafast goes as Fast where the plan has none": "Codex 送出的每個請求都走這個層級,不論 Codex 裡的 /fast 怎麼設;方案沒有極速時按快速送出", "Check-in time": "簽到時間", "From {at} each day, for every vendor's check-in": "每天 {at} 起簽到,所有服務商的簽到都按這個時間", "As soon as each vendor's day starts": "每個服務商的新一天一開始就簽到", @@ -9761,6 +9771,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "這份報告已經不在了:magpie 只保留最近 5 份。", }, ja: { + "Codex service tier": "Codex のサービスティア", + "As Codex asks": "Codex の指定どおり", + "/fast in Codex": "Codex の /fast", + "Standard": "標準", + "Every request Codex sends goes at this tier, whatever /fast is set to in Codex; Ultrafast goes as Fast where the plan has none": "Codex が送るすべてのリクエストをこのティアで送ります。Codex の /fast の設定は問いません。プランに超高速がなければ高速で送ります", "Check-in time": "チェックインの時刻", "From {at} each day, for every vendor's check-in": "毎日 {at} からチェックイン(すべてのサービスのチェックインに共通)", "As soon as each vendor's day starts": "各サービスの日付が変わったらすぐにチェックイン", @@ -14634,6 +14649,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "このレポートはもう残っていません。magpie は最新の 5 件だけを保存します。", }, de: { + "Codex service tier": "Codex-Servicestufe", + "As Codex asks": "Wie Codex es anfragt", + "/fast in Codex": "/fast in Codex", + "Standard": "Standard", + "Every request Codex sends goes at this tier, whatever /fast is set to in Codex; Ultrafast goes as Fast where the plan has none": "Jede Anfrage von Codex geht in dieser Stufe, egal wie /fast in Codex steht; Ultrafast geht als Schnell, wo der Tarif es nicht hat", "Check-in time": "Check-in-Zeit", "From {at} each day, for every vendor's check-in": "Täglich ab {at}, für den Check-in jedes Anbieters", "As soon as each vendor's day starts": "Sobald der Tag des jeweiligen Anbieters beginnt", diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index ff5ceb045..fed49d9ad 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -526,6 +526,10 @@
Codex background compaction
Codex 0.163 and later summarise while a turn goes on, past the share of the window typed (65% when empty); a value set in its own config stays
+
+
Codex service tier
+
+
Codex thread titles
diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 9d709bc43..9e07d96be 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -16,7 +16,7 @@ import ( // raises them and says why in its commit. const ( appScriptBudget = 1_316_874 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30); 1,317,705 with a Claude account added from a setup-token (sfss5362 on X): the sign-in's Use a setup-token instead…, its sheet, and its account row's magpie only, the provider editor's account rows, the core's own editor, its comments cut down, with no room added (10-30); back to 1,315,316 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, loaded when one is asked for (signAsk, 10-30); 1,315,479 with the provider editor lining its Advanced up with its fields (the owner: 高级这个折叠按钮为什么在一个前不着村后不着店的位置?) and a refresh on each of its accounts (在这里也要加上手动刷新用量的按钮), the core's own editor, with no room added (10-31); 1,315,603 with About's Log row, the path of the log the app writes and an Open for its folder (rayem1w on X), in app.js, its comment cut to one line, with no room added (10-31); 1,316,781 with a provider's model listed by an id of the user's (zeewell on X), the provider editor's Names & levels Listed as box beside Same as, the core's own editor, with no room added (10-31); 1,316,874 with a package manager's magpie (the AUR's magpie-bin) naming the command that updates it in Settings' Version row and lighting no Update pill (shuhai on Discord), the core's own update row, which the tray panel reads too, its comments cut to one line, with no room added (10-31); Settings › Sync's Kept on this computer row (hayden4608 on Discord) raised it to 1,317,497, which is no bound; the 1,316,874 it had came back once later trims left app.js at 1,308,363 (10-31) - coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10); the daily check-in's time of day (times_ang on X), its row in checkinnow.js, its one call in app.js, went over it at 1,534,281 on a main that had grown under it, and six check-in comments cut brought it back to 1,533,495, no raise (11-10) + coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10); the daily check-in's time of day (times_ang on X), its row in checkinnow.js, its one call in app.js, went over it at 1,534,281 on a main that had grown under it, and six check-in comments cut brought it back to 1,533,495, no raise (11-10); Codex's service tier row (JackyFill on X), in app.js, paid for by eight Codex-row comments cut, no raise (11-10) ) func TestCoreScriptBudget(t *testing.T) { diff --git a/internal/gui/settings_keep_test.go b/internal/gui/settings_keep_test.go index 1e344b843..629ff1f28 100644 --- a/internal/gui/settings_keep_test.go +++ b/internal/gui/settings_keep_test.go @@ -170,6 +170,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) { CodexPredictions: "off", CodexAutoReview: "fake/m1", CodexSubagentModel: "codex/gpt-6-astra", + CodexServiceTier: "priority", DesktopSubagentModel: "fake/m2", DshCompactModel: "fake/m1", ChinaMirror: true, diff --git a/internal/gui/tests/agent-prefs.test.cjs b/internal/gui/tests/agent-prefs.test.cjs index 9f9f432ee..2ae0c64c3 100644 --- a/internal/gui/tests/agent-prefs.test.cjs +++ b/internal/gui/tests/agent-prefs.test.cjs @@ -1,7 +1,7 @@ // Run with Node's test runner and Playwright on the module path; see README.md. // An agent's own settings are where the agent is (the owner, 10-20: Codex's // and Claude Code's rows sat in Settings › General, apart from the agents -// they set). In the window, Codex's opened row holds its eight and Claude +// they set). In the window, Codex's opened row holds its nine and Claude // Code's and Grok Build's their one, Long conversations (Grok Build's since // uk.jent on Discord: its context_window is where it compacts); Settings has none of them, but its // search still finds them, as a row saying where they are whose Open shows @@ -20,7 +20,7 @@ const { chromium, webkit } = require("playwright"); const { watchSettingsReads, agentRow, openAgentSettings } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); -const CODEX = ["codexAgentsV1Row", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"]; +const CODEX = ["codexAgentsV1Row", "codexServiceTierRow", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"]; function settingsPayload(over) { return { @@ -103,7 +103,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.goto("http://magpie.test/?view=agents"); await openAgentSettings(page, "codex"); const codexBox = '.row.agent[data-id="codex"] .ag-prefs'; - assert.deepEqual(await shownIn(page, codexBox), CODEX, `${lang} ${width}: Codex's eight`); + assert.deepEqual(await shownIn(page, codexBox), CODEX, `${lang} ${width}: Codex's nine`); assert(await page.locator(codexBox).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), `${lang} ${width}: the rows fit the opened row`); await noSideScroll(page, `${lang} ${width} Codex`); await openAgentSettings(page, "claude"); @@ -131,7 +131,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await link.getByRole("button", { name: w.open, exact: true }).click(); await sheet(page).waitFor(); assert.equal(await sheet(page).locator(".ehead").textContent(), w.sheet); - assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), CODEX, `${lang} ${width}: the sheet has Codex's eight`); + assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), CODEX, `${lang} ${width}: the sheet has Codex's nine`); assert(await page.locator("#view-agents").isVisible(), "Open goes to the Agents page"); await page.keyboard.press("Escape"); await page.locator("#modal").waitFor({ state: "hidden" }); diff --git a/internal/gui/tests/codex-service-tier.test.cjs b/internal/gui/tests/codex-service-tier.test.cjs new file mode 100644 index 000000000..3ede8120c --- /dev/null +++ b/internal/gui/tests/codex-service-tier.test.cjs @@ -0,0 +1,129 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Codex's service tier (JackyFill on X): a row in Codex's settings on the +// Agents page sets the tier every request of Codex's goes at. Its button +// says the choice, "As Codex asks" by default; the app's menu (no native +// select) offers As Codex asks, Standard, Fast and Ultrafast, and a pick +// posts settings/codex-service-tier on its own: "", "default", "priority" +// or "ultrafast". No click scrolls the page. Every language, Chromium and +// WebKit, a wide and a narrow window; no backend, the API is faked here. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); +const { watchSettingsReads, agentRow, openAgentSettings } = require("./reader.cjs"); + +const assets = path.resolve(__dirname, "../assets"); + +function server(lang, posted) { + let cur = { theme: "light", lang, version: "0.1.400", titleModels: [], codexServiceTier: "" }; + return async (route) => { + const req = route.request(), url = new URL(req.url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + // agents below Codex, so its opened row is not the list's end: a choice + // that rewraps its row at the very bottom must move the list + if (url.pathname === "/api/state") return json({ agents: [agentRow("codex", "Codex"), agentRow("claude", "Claude Code"), agentRow("pi", "Pi"), agentRow("opencode", "OpenCode"), agentRow("gemini", "Gemini CLI"), agentRow("kimi", "Kimi CLI"), agentRow("droid", "Droid"), agentRow("cline", "Cline"), agentRow("qwen", "Qwen Code"), agentRow("crush", "Crush")], profiles: [], settings: { lang, theme: "light" } }); + if (url.pathname === "/api/settings/codex-service-tier") { + const body = req.postDataJSON(); + posted.push(["codex-service-tier", body]); + cur = { ...cur, codexServiceTier: body.tier }; + return json(cur); + } + if (url.pathname === "/api/settings") { + if (req.method() === "POST") posted.push(["settings", req.postDataJSON()]); + return json(cur); + } + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/usage/quotas") return json([]); + if (url.pathname === "/api/groups") return json({ groups: [], models: [] }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + try { + await route.fulfill({ body: await fs.readFile(file), contentType }); + } catch { + await route.fulfill({ status: 404, body: "" }); + } + }; +} + +// the words as i18n.js has them +const W = { + en: { name: "Codex service tier", asks: "As Codex asks", standard: "Standard", fast: "Fast", ultra: "Ultrafast" }, + zh: { name: "Codex 服务层级", asks: "按 Codex 的请求", standard: "标准", fast: "快速", ultra: "极速" }, + "zh-TW": { name: "Codex 服務層級", asks: "依 Codex 的請求", standard: "標準", fast: "快速", ultra: "極速" }, + ja: { name: "Codex のサービスティア", asks: "Codex の指定どおり", standard: "標準", fast: "高速", ultra: "超高速" }, + de: { name: "Codex-Servicestufe", asks: "Wie Codex es anfragt", standard: "Standard", fast: "Schnell", ultra: "Ultrafast" }, +}; +const engines = process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"]; +const langs = process.env.LANGS ? process.env.LANGS.split(",") : Object.keys(W); + +for (const engine of engines) { + for (const lang of langs) { + for (const width of [900, 400]) { + test(`${engine} ${lang} ${width}px: Codex's service tier is picked from the app menu in its settings`, async (t) => { + const w = W[lang]; + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const page = await (await browser.newContext({ viewport: { width, height: 720 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = [], posted = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang, posted)); + t.after(async () => { + if (process.env.ARTIFACT_DIR) { + await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); + await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-codex-service-tier.png`) }); + } + await browser.close(); + }); + await watchSettingsReads(page); + await page.goto("http://magpie.test/?view=agents"); + await openAgentSettings(page); + const row = page.locator('.row.agent[data-id="codex"] #codexServiceTierRow'); + const pick = page.locator("#codexServiceTierPick button"); + await pick.waitFor(); + assert.equal((await row.locator(".name").textContent()).trim(), w.name); + assert.equal((await pick.textContent()).trim(), w.asks, "as Codex asks by default"); + assert.equal(await page.locator("select").count(), 0, "a native select"); + // only Codex's settings have it + await page.locator('.row.agent[data-id="claude"] .ag-link').click(); + await page.locator('.row.agent[data-id="claude"] .ag-prefs').waitFor(); + assert.equal(await page.locator('.row.agent[data-id="claude"] #codexServiceTierRow').count(), 0, "the row in Claude Code's settings"); + await openAgentSettings(page); + await pick.waitFor(); + await pick.scrollIntoViewIfNeeded(); + const box = await pick.boundingBox(); + assert(box && box.x >= 0 && box.x + box.width <= width, `the button runs off the window: ${JSON.stringify(box)}`); + assert(await page.evaluate(() => document.scrollingElement.scrollWidth <= innerWidth), "the page scrolls sideways"); + + // where the button sits on screen: a pick that moved the page would + // move it. At a narrow width the row rewraps as the choice's words + // change (the button under the name or beside it), which moves the + // button with no scroll at all, so it is held to its place only + // while the row keeps its height. + const top = () => pick.evaluate((b) => Math.round(b.getBoundingClientRect().top)); + const tall = () => row.evaluate((r) => Math.round(r.getBoundingClientRect().height)); + for (const [label, tier] of [[w.ultra, "ultrafast"], [w.standard, "default"], [w.fast, "priority"], [w.asks, ""]]) { + const y = await top(), h = await tall(); + await pick.click(); + const menu = page.locator(".proto-menu"); + await menu.waitFor(); + const items = (await menu.locator(".pm-item .pm-name").allTextContents()).map((s) => s.trim()); + assert.deepEqual(items, [w.asks, w.standard, w.fast, w.ultra]); + const mb = await menu.boundingBox(); + assert(mb.x >= 0 && mb.x + mb.width <= width, `the menu runs off the window: ${JSON.stringify(mb)}`); + await menu.locator(".pm-item").filter({ has: page.locator(".pm-name", { hasText: new RegExp("^" + label + "$") }) }).click(); + await page.locator("#codexServiceTierPick button", { hasText: new RegExp("^\\s*" + label + "\\s*$") }).waitFor(); + assert.deepEqual(posted.at(-1), ["codex-service-tier", { tier }]); + await page.waitForTimeout(200); + if (await tall() === h) assert(Math.abs((await top()) - y) <= 1, `picking ${label} moved the button from ${y} to ${await top()}`); + } + assert.equal(posted.length, 4, JSON.stringify(posted)); + assert.deepEqual(errors, []); + }); + } + } +} diff --git a/internal/provider/codex_tier.go b/internal/provider/codex_tier.go new file mode 100644 index 000000000..7659e16b9 --- /dev/null +++ b/internal/provider/codex_tier.go @@ -0,0 +1,35 @@ +package provider + +import ( + "fmt" + "slices" + "strings" + + "github.com/yetone/magpie/internal/settings" +) + +// CodexServiceTier is the service tier set for every request Codex sends +// (settings.CodexServiceTier): "" as Codex asks it, settings.CodexTierStandard +// for none, "priority" or "ultrafast". A value this magpie doesn't know +// (a newer one's, a file edited by hand) is read as "" and changes nothing. +func CodexServiceTier() string { + v := strings.TrimSpace(heldSettings().CodexServiceTier) + if !slices.Contains(settings.CodexServiceTiers, v) { + return "" + } + return v +} + +// SetCodexServiceTier sets settings.CodexServiceTier. +func SetCodexServiceTier(tier string) error { + tier = strings.TrimSpace(tier) + if !slices.Contains(settings.CodexServiceTiers, tier) { + return fmt.Errorf("Codex's service tier must be one of %q, not %q", settings.CodexServiceTiers[1:], tier) + } + s := settings.Load() + if s.CodexServiceTier == tier { + return nil + } + s.CodexServiceTier = tier + return settings.Save(s) +} diff --git a/internal/settings/settings.go b/internal/settings/settings.go index f6f7c209b..7f45ba2e2 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -45,6 +45,15 @@ const CodexAutoReviewSession = "session" // names for it in spawn_agent. const CodexSubagentLead = "lead" +// CodexTierStandard is the CodexServiceTier that sends Codex's requests +// with no service tier, the standard one, whatever Codex asked; the +// sentinel codex-rs itself uses for that (SERVICE_TIER_DEFAULT_REQUEST_VALUE). +const CodexTierStandard = "default" + +// CodexServiceTiers are the values CodexServiceTier may take, "" (as +// Codex asks) first. +var CodexServiceTiers = []string{"", CodexTierStandard, "priority", "ultrafast"} + // Settings is what the user chose. "" and "system" both mean "follow the OS". type Settings struct { Theme string `json:"theme,omitempty"` // system | light | dark @@ -765,6 +774,13 @@ type Settings struct { // lead asked for; CodexSubagentLead puts each on the model its lead's // own turns go on, even when the lead names another. CodexSubagentModel string `json:"codexSubagentModel,omitempty"` + // CodexServiceTier is the service tier the gateway puts on every + // request Codex sends, whatever Codex asked (JackyFill on X): "" as + // Codex asks it (its /fast, Ultra Fast or neither), CodexTierStandard + // with no tier at all, "priority" (Codex's Fast) or "ultrafast" (its + // Ultra Fast). Codex's words, as codex-rs ServiceTier::request_value + // sends them; its Flex is not offered, the ChatGPT backend takes none. + CodexServiceTier string `json:"codexServiceTier,omitempty"` // DesktopSubagentModel is the model the gateway puts Claude Desktop's // subagent tool turns on. "" leaves them on the model their lead asks // for; tool-less helpers and the lead's own turns are never moved. @@ -2356,6 +2372,10 @@ func saveOwn(s Settings, recording, reads bool) error { if s.CodexSubagentModel != "" && s.CodexSubagentModel != CodexSubagentLead && !strings.Contains(s.CodexSubagentModel, "/") { return fmt.Errorf("the model for Codex's subagents must be a model's id such as codex/gpt-5.5, not %q", s.CodexSubagentModel) } + s.CodexServiceTier = strings.TrimSpace(s.CodexServiceTier) + if !slices.Contains(CodexServiceTiers, s.CodexServiceTier) { + return fmt.Errorf("Codex's service tier must be one of %q, not %q", CodexServiceTiers[1:], s.CodexServiceTier) + } s.RedactRouteTo = strings.TrimSpace(s.RedactRouteTo) if s.RedactRouteTo != "" && !strings.Contains(s.RedactRouteTo, "/") { return fmt.Errorf("the model for requests masking would change must be a model's id such as ollama/qwen3, not %q", s.RedactRouteTo) diff --git a/internal/settingsapi/settingsapi.go b/internal/settingsapi/settingsapi.go index 350308c1a..9f29d63a0 100644 --- a/internal/settingsapi/settingsapi.go +++ b/internal/settingsapi/settingsapi.go @@ -353,6 +353,7 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err // in their Agents rows in.CodexSubagentModel = cur.CodexSubagentModel in.DesktopSubagentModel = cur.DesktopSubagentModel + in.CodexServiceTier = cur.CodexServiceTier // codex-service-tier // and the model DeepSeek Harness compacts on, set in its row in.DshCompactModel = cur.DshCompactModel // and the model for requests masking would change (redact-route)