feat(codex): pre-flight model availability check with fallback#889
Conversation
Before starting a Codex session, check the OpenAI models API to verify the configured model is accessible. If it returns 404, automatically swap to the fallback model (gpt-5.2-codex by default). This avoids wasting 5 internal SDK retries when gpt-5.3-codex isn't available via OPENAI_API_KEY auth. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a1ef098b1
ℹ️ 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".
| this.startTimestampMs = Date.now(); | ||
| this.emittedToolUseIds.clear(); | ||
|
|
||
| await this.resolveModelWithFallback(); |
There was a problem hiding this comment.
Make stop requests cancel model preflight
Placing await this.resolveModelWithFallback() before creating this.abortController introduces a new async window where stop() cannot abort anything. If a stop signal arrives while the model check is waiting on network/timeout, stop() sets wasStopped but this.abortController is still null, so execution continues into runTurn and can still emit tool/assistant activity despite the session being stopped. This regresses stop behavior specifically when the preflight request is slow or unreachable; the preflight should be tied to a cancellable signal created before the await.
Useful? React with 👍 / 👎.
Summary
GET /v1/models/{model}to verify the configured model is accessible via the OpenAI APIgpt-5.3-codexnot available viaOPENAI_API_KEYauth), automatically swaps to the fallback model before creating the sessionRunnerSelectionServiceto usegpt-5.2-codexas the default Codex fallback model (instead of stripping-codexsuffix or falling through togpt-5)Test plan
gpt-5.3-codexreturns 404,gpt-5.2-codexreturns 200 on OpenAI models API🤖 Generated with Claude Code