Skip to content

feat(codex): pre-flight model availability check with fallback#889

Merged
cyrusagent merged 1 commit into
mainfrom
feat/codex-model-fallback
Feb 21, 2026
Merged

feat(codex): pre-flight model availability check with fallback#889
cyrusagent merged 1 commit into
mainfrom
feat/codex-model-fallback

Conversation

@Connoropolous
Copy link
Copy Markdown
Contributor

Summary

  • Before starting a Codex session, CodexRunner now hits GET /v1/models/{model} to verify the configured model is accessible via the OpenAI API
  • If the model returns 404 (e.g. gpt-5.3-codex not available via OPENAI_API_KEY auth), automatically swaps to the fallback model before creating the session
  • Updated RunnerSelectionService to use gpt-5.2-codex as the default Codex fallback model (instead of stripping -codex suffix or falling through to gpt-5)

Test plan

  • All codex-runner tests pass (15/15)
  • All edge-worker tests pass (524/524)
  • Verified via curl: gpt-5.3-codex returns 404, gpt-5.2-codex returns 200 on OpenAI models API

🤖 Generated with Claude Code

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>
@cyrusagent cyrusagent merged commit 977c619 into main Feb 21, 2026
3 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants