ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d3898ca8d3 |
provider: ChatGPT account calls go with Codex's headers, and saved accounts are listed once a day
Two follow-ups of 6e55914b6's audit of what magpie sends OpenAI for
idle saved Codex accounts (owl, Discord #general: three ChatGPT accounts
deactivated). Product call made by the session the owner delegated
product calls to; mimicking the official client is allowed for every
vendor but Claude Code. Identity, base_instructions and prompts are not
touched.
- Headers. GET /backend-api/wham/usage, /wham/rate-limit-reset-credits,
POST .../consume and POST auth.openai.com/oauth/token (live and saved
sign-ins, and the sign-in's code exchange) went with Go's
"Go-http-client/1.1" and no originator. They now carry Codex's
originator and User-Agent through codexClientHeaders, the part of
codexSign that /codex/models and /responses already used. No version
header on them: codex-rs sends it with model requests only
(login/src/auth/default_client.rs default_headers is originator +
User-Agent; backend-client/src/client.rs adds auth headers).
- Refresh body. codex-rs (main f32b6cfd and rust-v0.165.0,
login/src/oauth/client.rs refresh, auth/manager.rs
request_chatgpt_token_refresh) sends JSON client_id, grant_type,
refresh_token and refresh_reason, and no scope. magpie sent
scope "openid profile email" and no reason. It now sends codex-rs's
fields: proactive_expiry near expiry, unauthorized_recovery after a
401 (stale token), scheduled from the 8-day keep-alive, forced for an
import or a revoked-sign-in check. The code exchange's form already
matched exchange_code; only its headers changed.
- Model lists. The active Codex account's /codex/models fetch (hourly
KeepAccountsListed, FetchNew, Refresh) also fetched every switched-on
saved account's list each time. codexFetchSaved now asks one with no
list at once, and the others once a day, one per call, oldest asked
first; a failed ask is remembered so a deactivated account doesn't go
first every hour. The active account's list is unchanged.
Docs: providers-accounts.md says both.
Tests (codex_quiet_test.go), each red on the old behaviour (broken by
hand: wham/refresh/exchange headers removed, scope back, the age check
and the one-a-look cap removed, the keep-alive's reason dropped, and
separately the failed-ask memory skipped):
- TestCodexAccountCallsGoAsCodex counts the requests to a fake (usage 1,
credits 1, consume 1, token 2) and checks User-Agent/originator on
each and the refresh body's keys. Old: Go-http-client/1.1, "" and
scope in the body.
- TestCodexRefreshSaysWhy: scheduled, forced, unauthorized_recovery.
Old: no reason.
- TestSavedCodexListsOnceADay: 2 asks on the first look, 0 an hour on,
1 then 1 a day on, 0 again, and 0 within the day while failing. Old:
2 on every look; without the memory, a failing one asked again.
Run (mote-run, at origin/main
|
||
|
|
6e55914b6d |
provider: Codex accounts are read one at a time and renewed every 8 days, not all at once
owl (Discord #general) holds several ChatGPT accounts in magpie with
no agent wired and had three deactivated. Auditing what magpie sends
to OpenAI for such accounts found two bursts from one address that
the official Codex client never makes:
- KeepOnAnAccountWithRoom read /wham/usage for every saved Codex
account, concurrently, every 5 minutes (every minute near the cap),
though only the account Codex is on matters until it is spent.
NextLogin now reads the account it is on and the one it goes back
to, and the spares only once the one it is on is spent; CodexUsedUp
reads the active account alone (codexReadingHeld only looks at it).
The Claude side of the same loop gets the same rule.
- KeepLoginsAlive force-refreshed every idle saved ChatGPT sign-in
once a day, all in the same hourly look, so after day one they were
refreshed side by side for good. It now renews after 8 days (codex-rs
TOKEN_REFRESH_INTERVAL in login/src/auth/manager.rs) and one account
per hourly look, so they drift apart.
Not changed: headers, identity, originator, prompts. The refresh and
usage requests still go with Go's User-Agent and no originator, while
Codex sends codex_cli_rs and an originator; that is left for the
owner. The hourly /models list per saved account and the Usage page
reading every account when it is open are unchanged too.
Run (mote-run, at origin/main
|