Skip to content

fix(plugins): follow active chat model for Codex image host (#105398) - #106362

Closed
Finn763 wants to merge 1 commit into
NousResearch:mainfrom
Finn763:fix/105398-image-gen-model
Closed

Finn763 wants to merge 1 commit into
NousResearch:mainfrom
Finn763:fix/105398-image-gen-model

Conversation

@Finn763

@Finn763 Finn763 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

plugins/image_gen/openai-codex/__init__.py pinned the Codex Responses host model to _CODEX_CHAT_MODEL = "gpt-5.5", and every image_generate request rode that id. After OpenAI removed gpt-5.5 from a cohort of ChatGPT accounts (2026-09-07, rolling per-account), all image generation on affected accounts 404s permanently — while chat recovers the moment the user switches agent model (e.g. to gpt-5.6-luna), because the image lane never followed. The host model was neither configurable nor tracking the active chat model.

Changes

  • _resolve_host_model() (new): precedence explicit → OPENAI_CODEX_CHAT_MODEL env → image_gen.openai-codex.host_model (scoped, profile-resolved via the existing load_image_gen_config loader) → active chat model when Codex-served → gpt-5.5 fallback. The id is intentionally unconstrained (no catalog): host availability is per-account.
  • _active_codex_chat_model() (new): follows model.default only when Codex-served — explicitly Codex-routed providers (codex/openai-codex/chatgpt) trusted verbatim, explicitly non-Codex providers never followed (a Claude id would 404 on the Codex backend), auto/unset routes follow on a gpt-/o1/o3/o4/codex id prefix.
  • _build_responses_payload() now sends the resolved host model (plus an optional host_model= override); single call site, no other callers.
  • Key choice deliberate: reuses feat(image-gen): configure Codex host model #97902's image_gen.openai-codex.host_model (closed, unmerged) and folds in the OPENAI_CODEX_CHAT_MODEL env delta its closer asked to carry over — no third competing key scheme. Neither closed PR followed the active chat model (the issue's preference Terminal tool #1); this adds that.
  • Docs: one paragraph in the existing Codex note in image-generation.md.

Evidence

  • TDD red: 5 of 7 new TestHostModel tests failed pre-fix (assert 'gpt-5.5' == 'gpt-5.6-luna'), 2 fallback-pinning tests passed throughout.
  • Green: D:/code/hermes-agent/.venv/Scripts/python.exe -m pytest tests/plugins/image_gen/test_openai_codex_provider.py -q → 35 passed (28 existing + 7 new), no live key (MockTransport asserts the wire body model; real config.yaml files under HERMES_HOME, no internal monkeypatching of the resolver).
  • Sabotage: stashed only the plugin fix → same 5 failures return; restored → 35 passed.
  • ruff check on both touched Python files: all checks passed.
  • Pre-PR re-check: no open PR competes on this call site (feat(image-gen): configure Codex host model #97902/fix(image_gen): make Codex Responses host model retargetable (gpt-5.5 EOL) #105536 both CLOSED unmerged); origin/main still 9e0dc4319a, no rebase needed.

Closes #105398

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation provider/openai OpenAI / Codex Responses API sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Sep 9, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

PR #106362 — fix(plugins): follow active chat model for Codex image host

Summary: The Codex Responses host model is no longer pinned to gpt-5.5; _resolve_host_model (plugins/image_gen/openai-codex/__init__.py:90) resolves explicit arg → env OPENAI_CODEX_CHAT_MODEL → scoped config host_model → active Codex-served chat model → gpt-5.5 fallback.

Findings (all Non-blocking):

  • Guard logic in _active_codex_chat_model is sound: explicit Codex-routed providers trusted verbatim, explicit non-Codex routes (e.g. Claude id) never followed — the test test_non_codex_chat_model_falls_back pins this, since sending a Claude id to the Codex backend would 404.
  • The _CODEX_MODEL_PREFIXES heuristic for auto-routed chat is acknowledged in-code as a prefix list to extend; a future Codex-served non-gpt/o family would silently fall back to gpt-5.5 rather than break — fail-safe direction.
  • Nit: _resolve_host_model calls load_config() (via _active_codex_chat_model) on every payload build. Fine for image-gen frequency, but worth knowing it is per-call, not cached.
  • The unconstrained host id (no catalog validation) is intentional per the docstring (per-account availability) — operators can retarget without a release. Reasonable.

Verdict: Looks correct with good test matrix (precedence, blank-env fallthrough, wire-body assertion). Safe to merge.

@gaoanze888

Copy link
Copy Markdown
Contributor

Red-team comparison against #106758 and the original #105398 constraints: this is the better integration path. It reuses the established image_gen.openai-codex.host_model key from #97902, follows the active Codex-served model, documents the operator surface, and tests the real config loader plus the wire payload. I’m closing #106758 rather than split review attention.

One residual edge worth considering before merge: the final fallback is still _CODEX_CHAT_MODEL = "gpt-5.5". That preserves compatibility for accounts where 5.5 still works, but it reproduces #105398 on an affected account whenever no explicit/env/scoped override exists and the active model is absent, auto-routed to an unrecognized family, or explicitly non-Codex. The original issue’s third preference was to fall through the account’s available models rather than hard-fail on one id. If catalog-based fallback is intentionally out of scope, it may be worth stating that this PR fixes the normal active-model path while those no-live-model cases still require host_model/OPENAI_CODEX_CHAT_MODEL.

No request to expand scope if that tradeoff is deliberate; the current patch is materially stronger than my later competing one.

@teknium1

Copy link
Copy Markdown
Collaborator

Landed in #111000 (3275ca8). The openai-codex image provider no longer sends a Responses call hosted on a pinned chat model; it POSTs directly to the Codex backend's native images/generations / images/edits endpoints (the route the official Codex client uses). This supersedes the host-model retargeting: rather than following the active chat model, there is no host model at all. Thanks @Finn763 for the cohort analysis in #105398 that drove the fix.

@teknium1 teknium1 closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

image_gen/openai-codex: hardcoded gpt-5.5 host model permanently breaks image generation on accounts that lost gpt-5.5

5 participants