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.
This commit is contained in:
yetone
2026-11-04 14:38:48 +08:00
parent f177c36a9b
commit f0b99745ed
3 changed files with 41 additions and 37 deletions
File diff suppressed because one or more lines are too long
+21 -7
View File
@@ -75,12 +75,11 @@ func TestCodexUsedUpIsWhatTheAppHolds(t *testing.T) {
{"Pro with credits, at a spend cap", with(read("codex_usage_pro_credits.json"), func(m map[string]any) {
m["spend_control"].(map[string]any)["reached"] = true
}), false},
// allowed false holds it. With allowed not said, so does a limit
// reached or a window at 100%; with allowed true, only every
// window at 100% (the 26.1029 app blocked such an account, with
// 用量 showing it used up). A 5h window at 100% with the week open
// is not held: the app still sends, and holding takes it out of
// ChatGPT (#996).
// allowed false holds it, and nothing else does: the app's composer
// gate (26.1029, as 26.930 and 26.1021) greys Send on allowed false
// alone, and holding an account it still sends for takes it out of
// ChatGPT (#996). Not said, or allowed with every window at 100%,
// the app still sends.
{"limit reached but allowed, no credits", with(read("codex_usage_pro_credits.json"), func(m map[string]any) {
delete(m, "credits")
rateLimit(m)["limit_reached"], rateLimit(m)["allowed"] = true, true
@@ -90,11 +89,26 @@ func TestCodexUsedUpIsWhatTheAppHolds(t *testing.T) {
delete(m, "credits")
rateLimit(m)["limit_reached"] = true
delete(rateLimit(m), "allowed")
}), true},
}), false},
{"window at 100%, allowed not said, no credits", with(read("codex_usage_pro_credits.json"), func(m map[string]any) {
delete(m, "credits")
rateLimit(m)["limit_reached"] = false
delete(rateLimit(m), "allowed")
}), false},
{"every window at 100% but allowed, no credits", with(read("codex_usage_pro_credits.json"), func(m map[string]any) {
delete(m, "credits")
rateLimit(m)["limit_reached"], rateLimit(m)["allowed"] = false, true
rateLimit(m)["primary_window"].(map[string]any)["used_percent"] = 100
}), false},
// xiaoq6285's case: a Plus account, its 5h window used up, the
// week open. The backend says not allowed there (the real Team
// reply: 5h at 100%, week at 63%, allowed false), so it is held.
{"Plus, 5h window at 100%, week open, not allowed, no credits", with(read("codex_usage_team_spend_cap.json"), func(m map[string]any) {
m["plan_type"] = "plus"
delete(m, "credits")
delete(m, "spend_control")
delete(m, "rate_limit_upsell")
m["rate_limit_reached_type"] = map[string]any{"type": "rate_limit_reached", "details": "default"}
}), true},
{"5h window at 100%, week open, allowed, no credits", with(read("codex_usage_pro_credits.json"), func(m map[string]any) {
delete(m, "credits")
+19 -29
View File
@@ -1182,36 +1182,26 @@ func codexHeld(u codexUsage) bool {
return true
}
// codexAtLimit is whether the reading says the allowance is used up:
// rate_limit.allowed false, which is what ChatGPT.app 26.1021 gates on, or
// else one the backend does not call open (allowed not said) with
// limit_reached or a window at 100%, or one it calls allowed with every
// window it reports at 100%. The 26.1029 app blocked an account magpie's
// 用量 showed used up, with no credits (xiaoq6285 on Discord), and a
// reading that did not say allowed false is the only way codexHeld could
// have missed it. Held wrongly takes the app out of ChatGPT (durable
// threads, remote control) while it would still send (#996 undid that for
// limit_reached alone), so allowed true stands unless nothing is left in
// any window: a 5h window at 100% with the week open is not held.
// codexAtLimit is whether the reading says the allowance is used up as
// the Codex app's composer reads it: rate_limit.allowed false, and that
// alone. Not said is not at the limit, and neither is allowed true with a
// window at 100%: the app's gate returns open on anything but allowed
// false (ChatGPT.app 26.1029.61003, the macOS build of the version
// xiaoq6285 runs on Windows, async chunk "a6kU": search
// "n.rate_limit?.allowed!==!1||"; the same in OpenAI.Codex 26.1027 on the
// Windows box and in 26.1021), and its remaining-percent reading keeps a
// window of an allowed account at 1% or more (search
// "Math.max(100-e,+(!0===t))"), so to the app such an account still has
// room. Holding it would take the app out of ChatGPT (durable threads,
// remote control, its usage meter, #996) for no Send it would grey.
//
// A used-up 5h window with the week open is held through allowed: the
// backend says allowed false and limit_reached true there (the real Team
// reply in testdata, 5h at 100% and the week at 63%), which is what
// greys the app's Send.
func codexAtLimit(u codexUsage) bool {
r := u.RateLimit
if r.Allowed != nil && !*r.Allowed {
return true
}
spent, any := true, false
for _, w := range []*codexWindow{r.Primary, r.Secondary} {
if w == nil {
continue
}
any = true
if w.UsedPercent < 100 {
spent = false
}
}
if r.Allowed != nil { // allowed true: held only with every window gone
return any && spent
}
return r.LimitReached != nil && *r.LimitReached || any && spent
a := u.RateLimit.Allowed
return a != nil && !*a
}
type codexWindow struct {