fix(cli): auto-select Codex model when provider resolves to openai-codex - #696
Closed
teyrebaz33 wants to merge 2 commits into
Closed
fix(cli): auto-select Codex model when provider resolves to openai-codex#696teyrebaz33 wants to merge 2 commits into
teyrebaz33 wants to merge 2 commits into
Conversation
When the runtime provider resolves to openai-codex, the active model is now validated against the Codex API regardless of how it was set (CLI arg, LLM_MODEL env-var, or config default). If the model is not Codex-compatible, it is replaced with the first available Codex model returned by get_codex_model_ids(). Root cause of NousResearch#651: LLM_MODEL=claude-opus-4-6 was set in the user's .env, which caused a 400 BadRequestError on every Codex request. Fixes NousResearch#651
The Codex Responses API rejects model IDs with a provider prefix (e.g. openai/gpt-5.3-codex) — only the bare slug is accepted. Reported by @yosun in NousResearch#651 after the initial fix.
teknium1
added a commit
that referenced
this pull request
Mar 8, 2026
When _ensure_runtime_credentials() resolves the provider to openai-codex, check if the active model is Codex-compatible. If not (e.g. the default anthropic/claude-opus-4.6), swap it for the best available Codex model. Also strips provider prefixes the Codex API rejects (openai/gpt-5.3-codex → gpt-5.3-codex). Adds _model_is_default flag so warnings are only shown when the user explicitly chose an incompatible model (not when it's the config default). Fixes #651. Co-inspired-by: stablegenius49 (PR #661) Co-inspired-by: teyrebaz33 (PR #696)
Contributor
|
Thanks for the thorough fix @teyrebaz33! The Unfortunately this PR couldn't be merged directly because the branch is 12 commits behind main and the diff includes unrelated regressions — it removes the We implemented the fix in commit 95b1130, combining the best of both this PR and #661:
Credit noted in the commit message. Closing this PR — thanks for the contribution! |
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
When _ensure_runtime_credentials() resolves the provider to openai-codex, check if the active model is Codex-compatible. If not (e.g. the default anthropic/claude-opus-4.6), swap it for the best available Codex model. Also strips provider prefixes the Codex API rejects (openai/gpt-5.3-codex → gpt-5.3-codex). Adds _model_is_default flag so warnings are only shown when the user explicitly chose an incompatible model (not when it's the config default). Fixes NousResearch#651. Co-inspired-by: stablegenius49 (PR NousResearch#661) Co-inspired-by: teyrebaz33 (PR NousResearch#696)
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
When _ensure_runtime_credentials() resolves the provider to openai-codex, check if the active model is Codex-compatible. If not (e.g. the default anthropic/claude-opus-4.6), swap it for the best available Codex model. Also strips provider prefixes the Codex API rejects (openai/gpt-5.3-codex → gpt-5.3-codex). Adds _model_is_default flag so warnings are only shown when the user explicitly chose an incompatible model (not when it's the config default). Fixes NousResearch#651. Co-inspired-by: stablegenius49 (PR NousResearch#661) Co-inspired-by: teyrebaz33 (PR NousResearch#696)
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
When _ensure_runtime_credentials() resolves the provider to openai-codex, check if the active model is Codex-compatible. If not (e.g. the default anthropic/claude-opus-4.6), swap it for the best available Codex model. Also strips provider prefixes the Codex API rejects (openai/gpt-5.3-codex → gpt-5.3-codex). Adds _model_is_default flag so warnings are only shown when the user explicitly chose an incompatible model (not when it's the config default). Fixes NousResearch#651. Co-inspired-by: stablegenius49 (PR NousResearch#661) Co-inspired-by: teyrebaz33 (PR NousResearch#696)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Fixes #651
When a user sets up Hermes with OpenAI Codex, any non-Codex model in
LLM_MODEL,OPENAI_MODEL, or the config default (e.g.anthropic/claude-opus-4.6) causes an immediate 400 BadRequestError on every request:Root Cause
HermesCLI.__init__setsself.modelfromLLM_MODEL/OPENAI_MODELenv-vars or the config default before the provider is resolved. When_ensure_runtime_credentials()later resolves the provider toopenai-codex, the incompatible model was never corrected.PR #661 addressed only the config-default path and used a hardcoded fallback model (
gpt-5.3-codex). This PR fixes the root cause for all model sources including env-vars, which is the exact scenario reported in #651.Fix
In
_ensure_runtime_credentials(), after the provider resolves toopenai-codex, check whether the active model is Codex-compatible. If not, replace it with the first model returned byget_codex_model_ids()and warn the user if they had explicitly set the model.Changes
_model_is_defaultflag to track explicit vs default model selection_ensure_runtime_credentials(), normalise incompatible models when provider isopenai-codex— covers CLI arg, env-var, and config default pathsTesting
Full suite: 2063 passed, 0 failed.