Files
magpie/docs
yetone 1534474c8e gateway: a ChatGPT account out of its credits rests until they are back, not 30 minutes
PaulT on Discord: ChatGPT plans now come with monthly API credits. An
account on credits only answers 402 once they run out, and magpie rested
it the flat creditRest (30 minutes, a guess) and asked it again, refused
the same, every half hour.

For a Codex account (UsageAgent "codex"; scoped to that vendor, every
other 402 rests as before) the credit rest now takes, in order: a reset
the refusal's body names (resetsAt), one its headers note (resetsNoted),
the time its full window renews from its usage reading (Allowance.Full),
a Retry-After longer than the default, else chatgptCreditRest (5 hours),
capped at longestMonthly and not marked guessed. renewed() also lifts a
Codex account's credit rest, so a reading that finds its window renewed,
or a reset spent, has it back at once.

Test: TestChatGPTOutOfCreditsRestsLong (internal/gateway/
chatgpt_credit_rest_test.go): unread -> 5h, lifted by renewed; window
read full, back in 3h -> rests 3h by "window", lifted by renewed; a key's
402 and a Claude account's 402 still rest creditRest, and renewed
("claude") doesn't lift theirs.

Broken by hand: the Codex branch off -> red ("rests 30m0s ... want
5h0m0s"); the renewed() change off -> red ("still resting after its
window renewed: 5h0m0s by credit").

Not tried: a real ChatGPT 402 from an account out of credits. No real
body is known (not in magpie's code or tests, the plugins repo, logs or
the codex binary's strings), so the test sends a bare 402 and the rest
keys on the account's vendor and status, not on body words. The 5-hour
default is a judgment: credits renew monthly, but the plan's own window
can serve again sooner, and a reading or reset lifts the rest early.
2026-10-30 11:55:36 +08:00
..