codex: a service tier set in Codex's settings goes on every request of Codex's (JackyFill on X)
JackyFill asked for a choice in Codex's agent settings that rewrites
service_tier: follow the request, force Fast, force Ultra Fast. Codex's
settings on the Agents page now have "Codex service tier", picked from
the app menu: As Codex asks (the default, nothing changes), Standard,
Fast or Ultrafast.
The values are Codex's own request values (codex-rs protocol
config_types.rs ServiceTier, tui service_tier_resolution.rs): Fast is
"priority", Ultra Fast is "ultrafast", and Standard sends no
service_tier. Flex isn't offered: the ChatGPT backend's requests drop
it (codex_request.go).
settings.CodexServiceTier ("", "default", "priority", "ultrafast";
anything else refused) is set through POST
/api/settings/codex-service-tier. codexTiered rewrites the body where
Codex's requests come in, on both ways: codexBackend (Codex signed in,
/backend-api/codex) and the main handler's Codex-on-Responses block,
which a websocket turn goes through too. It applies only when the
request is Codex's (fromCodex or agentOf == codex). Everything after
treats it as Codex's own ask: an account whose list lacks Ultrafast is
put after a mate that has it or sent priority. A bare model (Codex's own
sign-in, whose plan magpie doesn't know) gets ultrafast only where one
of magpie's Codex accounts lists it on the model (UltraModels), else
priority. The body is edited with topMember/withoutTopMember, no full
decode. Fast picks still apply after, unchanged.
Run (mote):
- TestCodexServiceTierSet, TestWithServiceTier: ok. The test signs in a
Plus and a Pro ChatGPT account against a fake backend whose lists offer
gpt-6-luna's Ultrafast to Pro only, and checks the tier sent for each
setting x what Codex asked, through /v1/responses (account:tier tried)
and on /backend-api/codex for a model with Ultrafast and one without;
OpenCode's own priority is left alone; "flex" is refused.
- go test -count=1 -timeout 45m ./internal/settings ./internal/provider
./internal/gui ./internal/gateway: ok but internal/gui, which was red
twice: TestCoreScriptBudget (1,535,075 > 1,533,802) and
TestSettingsSaveKeepsWhatItDoesNotSend (a save of the Settings page
dropped the tier). Paid for by eight Codex-row comments cut in app.js
(now 1,533,416), no raise; settingsapi.Apply keeps CodexServiceTier
as it keeps the other Codex rows. At the pushed head: go test
./internal/settingsapi ./internal/settings ./internal/gui ok, the two
gateway tier tests ok.
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (gateway,
provider, settings, gui): clean. gofmt -l: clean.
- GUI, chromium + webkit: codex-service-tier (new, en/zh/zh-TW/ja/de at
900 and 400px: 20/20), agent-prefs (56/56, Codex's row list updated),
i18n-keys, i18n-en-no-cjk, settings-search, codex-titles,
codex-subagent-model, settings-general, codex-sheet-providers,
click-scroll: all pass; at the pushed head codex-service-tier,
agent-prefs, i18n-keys, settings-search, codex-titles,
codex-subagent-model, settings-general, click-scroll: 166/166.
Broken by hand:
- codexTiered returning the body as it came: TestCodexServiceTierSet red
(17 lines).
- the Ultrafast-to-Fast downgrade for a bare model removed: red on
gpt-6-sol (sent ultrafast, want priority).
- the GUI posting to the wrong path, and the row left out of Codex's
AGENT_PREFS: codex-service-tier red in chromium and webkit.
- settingsapi without the CodexServiceTier keep:
TestSettingsSaveKeepsWhatItDoesNotSend red.
Not tried: a real ChatGPT account's Ultrafast or Fast request with the
setting on (only the fake backend), a real Codex websocket session, and
Windows/Linux runs of the GUI.
This commit is contained in:
@@ -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 "<provider> 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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+35
-25
@@ -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");
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -526,6 +526,10 @@
|
||||
<div class="who"><div class="name" data-t>Codex background compaction</div><div class="sub" data-t>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</div></div>
|
||||
<div id="codexAsyncSegs"></div>
|
||||
</div>
|
||||
<div class="row pref" id="codexServiceTierRow">
|
||||
<div class="who"><div class="name" data-t>Codex service tier</div></div>
|
||||
<div class="val" id="codexServiceTierPick"></div>
|
||||
</div>
|
||||
<div class="row pref" id="codexTitlesRow">
|
||||
<div class="who"><div class="name" data-t>Codex thread titles</div></div>
|
||||
<div class="val" id="codexTitlesPick"></div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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,
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -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, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user