Merge pull request #1227 from NousResearch/hermes/hermes-07d947aa

fix: surface gpt-5.4 in codex setup
This commit is contained in:
Teknium 2026-03-13 21:55:51 -07:00 committed by GitHub
commit 7c3cb9bb31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 145 additions and 4 deletions

View file

@ -18,6 +18,36 @@ DEFAULT_CODEX_MODELS: List[str] = [
"gpt-5.1-codex-mini",
]
_FORWARD_COMPAT_TEMPLATE_MODELS: List[tuple[str, tuple[str, ...]]] = [
("gpt-5.3-codex", ("gpt-5.2-codex",)),
("gpt-5.4", ("gpt-5.3-codex", "gpt-5.2-codex")),
("gpt-5.3-codex-spark", ("gpt-5.3-codex", "gpt-5.2-codex")),
]
def _add_forward_compat_models(model_ids: List[str]) -> List[str]:
"""Add Clawdbot-style synthetic forward-compat Codex models.
If a newer Codex slug isn't returned by live discovery, surface it when an
older compatible template model is present. This mirrors Clawdbot's
synthetic catalog / forward-compat behavior for GPT-5 Codex variants.
"""
ordered: List[str] = []
seen: set[str] = set()
for model_id in model_ids:
if model_id not in seen:
ordered.append(model_id)
seen.add(model_id)
for synthetic_model, template_models in _FORWARD_COMPAT_TEMPLATE_MODELS:
if synthetic_model in seen:
continue
if any(template in seen for template in template_models):
ordered.append(synthetic_model)
seen.add(synthetic_model)
return ordered
def _fetch_models_from_api(access_token: str) -> List[str]:
"""Fetch available models from the Codex API. Returns visible models sorted by priority."""
@ -54,7 +84,7 @@ def _fetch_models_from_api(access_token: str) -> List[str]:
sortable.append((rank, slug))
sortable.sort(key=lambda x: (x[0], x[1]))
return [slug for _, slug in sortable]
return _add_forward_compat_models([slug for _, slug in sortable])
def _read_default_model(codex_home: Path) -> Optional[str]:
@ -125,7 +155,7 @@ def get_codex_model_ids(access_token: Optional[str] = None) -> List[str]:
if access_token:
api_models = _fetch_models_from_api(access_token)
if api_models:
return api_models
return _add_forward_compat_models(api_models)
# Fall back to local sources
default_model = _read_default_model(codex_home)
@ -140,4 +170,4 @@ def get_codex_model_ids(access_token: Optional[str] = None) -> List[str]:
if model_id not in ordered:
ordered.append(model_id)
return ordered
return _add_forward_compat_models(ordered)

View file

@ -1057,6 +1057,7 @@ def _model_flow_openai_codex(config, current_model=""):
_codex_token = _codex_creds.get("api_key")
except Exception:
pass
codex_models = get_codex_model_ids(access_token=_codex_token)
selected = _prompt_model_selection(codex_models, current_model=current_model)
@ -1072,6 +1073,7 @@ def _model_flow_openai_codex(config, current_model=""):
print("No change.")
def _model_flow_custom(config):
"""Custom endpoint: collect URL, API key, and model name.

View file

@ -40,6 +40,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"deepseek-v3.2",
],
"openai-codex": [
"gpt-5.3-codex",
"gpt-5.2-codex",
"gpt-5.1-codex-mini",
"gpt-5.1-codex-max",

View file

@ -654,6 +654,7 @@ def setup_model_provider(config: dict):
_update_config_for_provider,
_login_openai_codex,
get_codex_auth_status,
resolve_codex_runtime_credentials,
DEFAULT_CODEX_BASE_URL,
detect_external_credentials,
)
@ -1266,7 +1267,15 @@ def setup_model_provider(config: dict):
elif selected_provider == "openai-codex":
from hermes_cli.codex_models import get_codex_model_ids
codex_models = get_codex_model_ids()
codex_token = None
try:
codex_creds = resolve_codex_runtime_credentials()
codex_token = codex_creds.get("api_key")
except Exception as exc:
logger.debug("Could not resolve Codex runtime credentials for model list: %s", exc)
codex_models = get_codex_model_ids(access_token=codex_token)
model_choices = codex_models + [f"Keep current ({current_model})"]
default_codex = 0
if current_model in codex_models: