Commit Graph
4 Commits
Author SHA1 Message Date
yetone f0b99745ed provider: a Codex account is held on allowed false alone, as the 26.1029 app's Send gate reads it (xiaoq6285)
xiaoq6285 (Discord, Codex App 26.1029 on Windows, Plus, model_provider =
"magpie", requires_openai_auth = true) answered 40cfd32b0: "但是5小时也得算的
我就是5小时用完了 周额度还有" - their 5h window was used up with the week
open, and Send was grey.

What the app greys Send on, read from the bundles:
- ChatGPT.app 26.1029.61003 (the macOS build of the reporter's version,
  from persistent.oaistatic.com/codex-app-prod/appcast.xml), async chunk
  "a6kU": the composer gate returns open unless
  "n.rate_limit?.allowed!==!1" fails, i.e. it greys only on allowed
  false (then lets credits and a workspace within its overage through, and
  a window redeemed with a reset). The composer's sendBlocked is that gate
  or a model-scoped additional_rate_limits entry for the selected model.
- OpenAI.Codex 26.1027.3384 on the Windows box (app-primary lV,
  composer-content TN) and ChatGPT.app 26.1021: the same.
- The app keeps a window of an allowed account at 1% or more left
  ("Math.max(100-e,+(!0===t))"), so allowed true with 100% reads as room.

What the backend says at a used-up 5h window: the real Team reply in
testdata (codex_usage_team_spend_cap.json) has 5h at 100%, the week at
63%, and allowed false, limit_reached true.

So the reporter's case is allowed false, which codexHeld held before
40cfd32b0 and still does; no 5h rule is needed. 40cfd32b0's two new
held cases (allowed not said with limit_reached or a window at 100%;
allowed true with every window at 100%) are readings the app still sends
for, so holding them only took the app out of ChatGPT (#996) for nothing.
codexAtLimit is allowed false again. A new subcase pins the reporter's
shape (Plus, 5h at 100%, week open, allowed false, no credits: held).

Why Send stayed grey with requires_openai_auth still written is not
explained by the rule: with allowed false and no credits magpie holds
it. Left open: their reading, their magpie log, and whether a
model-scoped limit (additional_rate_limits, which magpie doesn't read)
was what greyed it.

Run on mote: go test -count=1 -timeout 45m ./internal/provider
./internal/agent ok (172s, 334s); go vet ./internal/provider native, GOOS=windows
and GOOS=linux ok; gofmt -l clean. Broken by hand: with origin/main's
subscription_usage.go and these tests, TestCodexUsedUpIsWhatTheAppHolds
fails on "limit reached, allowed not said", "window at 100%, allowed not
said" and "every window at 100% but allowed" (CodexUsedUp = true, want
false).
Not tried: the real 26.1029 app with a used-up account, a real Plus
/wham/usage reading at a used-up 5h window (the Team one is the only real
one), a Windows run.
2026-11-04 14:38:48 +08:00
yetone 40cfd32b0b provider: a Codex account with no credits and every window at 100% counts held though allowed isn't false (xiaoq6285)
xiaoq6285 (Discord, magpie 0.1.2891, Codex App 26.1029, Windows): a used-up
Plus account, no credits, 用量 showing it used up, config.toml with
model_provider = "magpie" and requires_openai_auth = true, Send grey until
Codex was switched off in magpie. Banked resets and paid credits were ruled
out (codexHeld reads neither resets nor, here, any credits). What is left is
a reading that doesn't say allowed false: codexHeld needed exactly that, so
CodexUsedUp stayed false and Sync kept requires_openai_auth, which makes the
app read the account's rate limit and grey Send.

codexAtLimit now holds: allowed false (as before); allowed not said with
limit_reached or a window at 100%; allowed true with every reported window
at 100%. Credits and the workspace-overage exemptions are unchanged and
still run after it.

Why the two cases that were false stay narrow: a7c4e5ddd (#996) pinned
"limit_reached but allowed, no credits" to not held, because the composer
gate (hP / hardBlocked in 26.930) reads allowed alone and the app still
sent; holding such an account only takes the app out of ChatGPT (durable
threads, remote control, cloud tasks, its usage meter) for nothing. That
cost is real, so allowed true still stands unless no window has room: a 5h
window at 100% with the week open is not held (new case). The case
"limit_reached, allowed not said" does flip to held.

Not known: the reporter's actual reading (allowed true or missing, never
seen) or the 26.1029 gate (its bundle isn't on any test box; 26.1021 is).
If their reading says allowed false with no credits this changes nothing
for them.

Run on mote: go test -timeout 45m ./internal/provider ./internal/agent ok
(194s, 346s); GOOS=linux, GOOS=windows and native go vet on both ok; gofmt -l
clean. Broken by hand: with the old subscription_usage.go and the new tests,
TestCodexUsedUpIsWhatTheAppHolds fails on "limit_reached, allowed not said,
no credits" and "every window at 100% but allowed, no credits".
Not tried: the real 26.1029 app, a real used-up reading, Windows run.
2026-11-04 12:41:11 +08:00
forever a7c4e5ddde provider: a Codex account the Codex app still sends for keeps Codex signed in — spend cap or overage with credits, limit_reached alone; a hold survives a failed read (#996)
* provider: a Codex account at a spend cap or past its overage with credits left keeps Codex signed in, as the Codex app's composer still sends for it

#966 held such an account (and one whose limit_reached alone was true),
following the readiness check Tht in ChatGPT.app 26.930. Tht has one
caller, the work-credit-restriction-recovery poller; it isn't the
composer's gate. The composer's submit is disabled only by hP (search
"n.rate_limit?.allowed!==!1||Jpe(n)||SIe(") and hardBlocked (search
"hardBlocked:r.rate_limit?.allowed===!1"): both read rate_limit.allowed
alone and let credits (has_credits or unlimited) through before any spend
cap or overage. So the app sends for that account, and holding it gains
nothing: CodexUsedUp only moves Codex to magpie as provider while Codex is
on a magpie model, whose turns already reach magpie through
openai_base_url. It only takes the app out of ChatGPT (durable threads,
remote control), the loss #966 set out to stop.

codexHeld is back to that gate: held when allowed is false, no credits,
and not a workspace within its overage (no spend cap, an ordinary
reason). Its comment names the build, both gates and why Tht isn't one,
each with a string to search for. The spend-cap and overage subcases now
expect not held; new subcases pin allowed as the only trigger. Five
subcases fail on the merged codexHeld. agent-wiring.md and reference.md
say the same.

Follow-up to #966.

* provider: a Sci, Law, FinServ or Enterprise trial/view-only workspace within its overage keeps Codex signed in

codexHeld lets a workspace with no credits through while it is within
its overage, as the Codex app's composer does, but the workspace list
came from codex-rs's PlanType alone. The app's own plan_type switch for
its usage banner (ChatGPT.app 26.930.61225, app-initial) also names sci,
law, finserv, enterprise_cbp_trial and enterprise_cbp_view_only, so such
an account read held and magpie took Codex off its ChatGPT sign-in while
the app still sent. They are added; the comment cites that switch. guest
there is a personal plan and stays out, and a plan not listed still
counts as no workspace (held).

Verification: "Law without credits, within its overage" in
TestCodexUsedUpIsWhatTheAppHolds fails without the list change
(CodexUsedUp = true, want false) and passes with it.

* provider: a held Codex reading with no window at 100% stays held through a failed read

A reading kept for when /wham/usage fails dropped Held whenever none of
its windows read 100%. That is right for a hold that came with a used-up
window which has since started again, but a hold with no window used up
(the backend says not allowed, no credits, every window under 100%) has
no reset to wait for: the first 503 after it read not held and put Codex
back on its ChatGPT sign-in for an account its app sends nothing for.
Held is now cleared only when the saved reading had a window used up and
none is after the passed resets are applied; any other hold stands till
a fresh read.

Verification: TestCodexHeldWithNoWindowUpKeptTillAFreshRead (the real Pro
reply, credits spent, its window at 40%: a good read, then a 503) fails
without the change ("CodexUsedUp = false on the kept held reading, no
window used up") and passes with it. TestCodexHeldKeptOnlyTillTheReset
still passes; both share their setup now. -race -count=10 passes.

* agent, gui, docs: Codex's sign-in notes say magpie steps in while the Codex app blocks the account, not whenever it is used up

#981's sign-in notes said magpie becomes Codex's provider "while its
account is used up". Since codexHeld, a ChatGPT account at 100% with
credits left keeps Codex signed in; magpie steps in only while the Codex
app blocks the account (out of allowance, no credits left), and the notes
now say that, Always ChatGPT's to match, in English, Chinese, Japanese
and German. agent-wiring.md's sign-in line and reference.md's Codex
paragraph say when the app holds an account as codexHeld reads it: OpenAI
no longer allows it and it has no credits left, a workspace still within
its overage excepted; at 100% with credits Codex stays signed in.

Verification: codex-signin-always (Chromium and WebKit, en/zh/ja/de, 1100
and 440px) 8/8, i18n-keys 1/1, gui-ja 3/3, gui-de 3/3. git grep finds the
old English notes nowhere under internal/gui/tests or internal/gui/assets.
2026-10-06 15:28:41 +08:00
forever 8005f17551 provider, codex: a ChatGPT account at 100% with credits left keeps Codex signed in (#966)
* provider, codex: a ChatGPT account at 100% with credits left keeps Codex signed in — magpie becomes its provider only while the Codex app itself holds the account

magpie made itself Codex's provider (model_provider = "magpie", #540)
whenever any of the active ChatGPT account's windows read 100%. A Pro
account at 100% on its week with credits left keeps working in the Codex
app: the backend answers every turn (about 490 200s in one day's usage log
at 100%), yet magpie moved Codex off it, and as a provider without
requires_openai_auth the app lost its ChatGPT state ("Sign in to ChatGPT
to start a durable thread", no remote control).

CodexUsedUp now reads codexHeld, which mirrors the Codex app's own
composer block (ChatGPT.app webview bundle, hP and its helpers): the
backend says the account isn't allowed (rate_limit.allowed = false), it
has no credits (has_credits / unlimited), and it isn't a workspace still
within its overage (overage_limit_reached = false, no spend cap, an
ordinary rate_limit_reached). Window percent never decides it. Where the
app goes by what /wham/usage can't show (a statsig gate, the gpt-reserve
fallback, Team's reserve experiment that ignores overage), it counts as
held: a wrong move costs ChatGPT extras, a missed one every turn. A
reading kept through a failed read (keepLast) stops saying held once its
used-up window has started again, as its usage does. NextLogin's account
rotation and its thresholds are unchanged.

A user stuck on the old move (codex.out = 1) is put back beside the
sign-in by the next Sync, as #540 already does once the account has room.

Verification:
- TestCodexUsedUpIsWhatTheAppHolds (real /wham/usage replies, ids
  replaced) fails on the old trigger: 7 subcases, "CodexUsedUp = true,
  want false". Each workspace guard (spend cap, reason, overage, plan
  list, Team reserve) was mutated and fails its own subcase.
- TestCodexHeldKeptOnlyTillTheReset fails without the quota_last change.
- The real Pro account (7-day window 100%, ~28k credits, allowed false):
  CodexUsedUp true before, false after.
- go vet ./...; go build (darwin), GOOS=linux -tags nogui, GOOS=windows;
  go test -tags nogui ./... under a sandbox HOME; -race -count=20 on the
  new and related Codex tests.
- Not run: a live Codex app turn on an account truly held (none at hand),
  Windows/WSL runtime, GUI suites (no GUI change).

* provider: a Codex account at a spend cap or past its overage is held, credits or not; limit_reached counts as not allowed

codexHeld let credits through before the spend cap, so a Team seat at its
cap (spend_control.reached, allowed false) with has_credits read not held
and magpie left Codex on an account the backend refuses. The app's
readiness check (26.930.61225, app-primary) returns limited on
spend_control.reached or credits.overage_limit_reached before it looks at
credits, and treats rate_limit.limit_reached like allowed false; held now
reads the same. A spend cap with the rate limit still allowed (a
workspace's included usage) stays not held.
2026-10-06 14:50:39 +08:00