Commit Graph
1 Commits
Author SHA1 Message Date
yetone b942a872ba caps: a lone capped Codex account says its turns go to the fallbacks (not_4O4 on X)
not_4O4 asked for a way to switch to non-official models once a set share
of the ChatGPT quota is used. magpie already does this: a usage cap on the
Codex account (or a cap on the 5-hour / weekly window alone) plus the
provider's Fallback. When Codex is connected to magpie beside its ChatGPT
sign-in, or fails over through it, codexAccounts sends a capped lone
account's own-model turn through serve, so the fallbacks answer it.

The GUI said otherwise. The account row of a lone Codex account said
"Codex still uses it" past the cap even when Codex was connected, and the
cap note said requests are refused when the provider has fallbacks. Now:
- the direct-use note shows for Codex only when it isn't connected or
  failing over (an agent row with wired or failover);
- the held note says the requests go to this provider's fallbacks when it
  has some and Stop at the caps is off, in en, zh, zh-TW, ja, de.
- TestCoreScriptBudget: +236 bytes for this, packed to its shortest form
  with no page to move it to (the account rows are core).
The 11-04 grey Send default and the takeover are untouched: a cap never
takes Codex off ChatGPT.

New tests:
- internal/gateway TestCappedLoneCodexAccountGoesToItsFallback: a lone
  account capped at 80% with usage at 85 is not tried and the fallback
  answers (stream and not); at 50 the account is tried.
- account-cap.test.cjs: Codex connected, the lone capped row's note ends
  with the fallback line and has no direct note; not connected, the
  direct note stays. Chromium and WebKit, every language.

Run (mica, mote was over its load), at the rebased head
(origin/main c2a1d80fc):
- GUI before the rebase: account-cap, i18n-keys, i18n-en-no-cjk,
  window-cap, window-cap-pool, key-usage-cap, account-row-line,
  codex-app-menu-cap, routing-steps-cap: 235 of 236 ok. At the rebased
  head: account-cap, i18n-keys, i18n-en-no-cjk, window-cap,
  account-row-line again: 165 of 166 ok, the same #6422 red; go test -run Budget ./internal/gui ok. The red is i18n-keys "a plugin's
  words are its own" ("No folder" in memory_mcp.go, from 72facf72e),
  filed as #6422; this change touches neither file.
- go test -run 'Cap|Codex.*Fallback|Fallback' ./internal/gateway: ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway and internal/gui: clean.

Broken by hand:
- `if false &&` before the HoldCaps check in codexAccounts: the Go test
  went red (acct-1 tried, fallback 0).
- the old `direct` and the fallback flag forced false: the 10 connected GUI
  cases went red in both engines; the not-connected ones stayed green.

Not tried: a real ChatGPT account reaching its cap with the real Codex
CLI or app; the full suite runs after the tag.
2026-11-13 13:02:05 +08:00