fix(codex): retry caller main after pool rejection (carry of #3135) - #3180
Conversation
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e280397a3b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| requestScopedMainCredential | ||
| && fixedAccountId === undefined | ||
| && options.excludeAccountId !== MAIN_CODEX_ACCOUNT_ID |
There was a problem hiding this comment.
Refuse caller fallback when it is the rejected account
When the inbound chatgpt-account-id identifies the same ChatGPT account as the rejected Pool credential, this condition still treats the caller bearer as an alternate because it compares only the Pool's local id (for example, pool-a) with __main__. A 429/402 therefore triggers a second request against the same exhausted upstream account in both Responses and compact flows, defeating the alternate-account retry bound. Pass the rejected credential identity/account id into this decision and suppress the caller fallback when it matches.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Maintainer rebase carry of #3135 by @luvs01 — all three commits cherry-picked onto current
devwith author credit preserved.This is not superseded by #3166. That question was checked explicitly. #3166 (
75090d4e) fixed initial selection — keeping a healthy request-owned__main__pin so Pool discovery does not persist an exhausted stored account before the first send. This is the post-rejection retry, and the gap was still present in the landed tree:src/codex/auth-context.tsrefused the fallback on anyexcludeAccountId, andsrc/server/responses/compact.tsstill dropped on!authCtx.accountId. #3166's own description called the two complementary.Security review
Credential-selection change, so
MAINTAINERS.mdrequires explicit review. Performed on this exact head by reading the diff:options.excludeAccountId !== MAIN_CODEX_ACCOUNT_ID. The exactly-once boundary is preserved by that condition, not by the absence of exclusions.mainModelGrantUnobservedflag only changes which of two error messages is returned; it does not widen who may serve a request.Conflict resolution
One conflict in
src/server/responses/core.tsand one intests/codex-auth-context.test.ts, both against work that landed this week.The
core.tsconflict is the interesting one: #3176 added a 5xx quota-outcome recorder inside theno-alternatebranch, and this PR widens the condition guarding that same branch to admitmain. Both are kept — the guard now excludespool,main-pool, andmain, and the recorder stays inside it. Taking either side alone would have silently dropped a fix.The test conflict was purely additive: #3166 added request-owned-pin cases, this PR added caller-main fallback cases. Both are retained.
Verification
Exact head
e280397a3:bun test ./tests/codex-auth-context.test.ts— 70 pass, 0 fail, 278 expect() calls. That count includes both authors' cases, which is the proof the merge kept both.Full-suite and typecheck coverage is left to CI on this exact head.
Checklist
dev