-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(codex): distinguish model availability from auth failure #4480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
aaed68a
fix(bridge): fail an in-flight search at a truncated terminal [skip ci]
lidge-jun b1453a3
fix(images): bound bridge iteration buffering [skip ci]
lidge-jun 2fb74c1
fix(codex): distinguish model availability from auth failure
lidge-jun bd39d3b
test(server): expect 400 for an account-gated model with no grant
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
devlog/_plan/260913_model_availability_errors/000_summary.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Model availability error classification | ||
|
|
||
| Carried from #4460 (AgenticLab-SH) as the tip of lane B in the contributor carry | ||
| train. This unit stays in `_plan` until the carry lands on `dev`; a `_fin` record | ||
| describes work already visible in public git history, which this is not yet. | ||
|
|
||
| ## Problem | ||
|
|
||
| Account-gated native model selection inherited `CodexPoolAuthenticationError`, so every local | ||
| compatibility or capacity failure became HTTP 401 `invalid_api_key`. A healthy pool account that | ||
| did not support the selected model therefore looked like a broken credential. | ||
|
|
||
| ## Change | ||
|
|
||
| - Added typed `unsupported` and `temporarily_unavailable` model-availability reasons. | ||
| - Mapped unsupported selections to 400 `invalid_request_error`. | ||
| - Mapped temporarily unavailable model-capable pools to 429 `rate_limit_error` with code | ||
| `rate_limit_exceeded`. | ||
| - Reused the mapping on Responses, Images, Live, and Search surfaces. | ||
| - Preserved existing 401 behavior for actual pool credential failures. | ||
|
|
||
| ## Verification | ||
|
|
||
| - Focused mapping tests cover 400, 429, and unchanged 401 behavior. | ||
| - The existing auth-context regression suite covers account-gated detours, exact selection, | ||
| cooldowns, affinity, and reauthentication behavior. | ||
|
|
||
| ## Catch-order audit | ||
|
|
||
| `CodexModelAvailabilityError` extends `CodexPoolAuthenticationError`, so any `catch` that | ||
| tests the parent first would fold the new 400 and 429 back into 401. Every such site was | ||
| audited during the carry: | ||
|
|
||
| - `src/server/responses/codex-auth-error.ts`, `images.ts`, `live.ts` and `search.ts` test the | ||
| subclass before the parent. That order is the contract. | ||
| - `src/server/context-history.ts` folds the parent straight to 401 and was left unchanged. It | ||
| resolves with `modelId: "context_history"`, and every `CodexModelAvailabilityError` throw | ||
| site is gated on `ACCOUNT_GATED_NATIVE_OPENAI_MODELS` membership — directly, or through | ||
| `modelEligibleAccountIds`, which is only populated for a gated model. The subclass therefore | ||
| cannot reach that catch. `tests/codex-integration/codex-model-availability-error.test.ts` | ||
| pins the membership that keeps this true. | ||
| - `src/server/responses/encrypted-payload.ts` and `collaboration.ts` import the parent but | ||
| never branch on it. | ||
|
|
||
| Whether the context-history surface should adopt the same mapping outright is a maintainer | ||
| decision recorded on #4460, not a defect in this carry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When every model-roster lookup is unconfirmed—for example, because
/modelstimed out—or credential snapshots returnnull,entitledAccountIdsis empty even though no account has actually denied the model. This condition therefore labels the resultunsupported, causing the new mapper to return a non-retryable 400; in the missing/failed-credential case it also violates the intended unchanged 401 authentication behavior. Classifyunsupportedonly when the relevant account rosters are confirmed denials, and allow unknown or credential-failure states to retain their transient/authentication response.Useful? React with 👍 / 👎.