From ec403fa3cf4118d2ca71e89a87bb83ff78db3387 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Wed, 6 May 2026 15:18:34 +0000 Subject: [PATCH] fix(routes): persist openai-codex provider unconditionally on stale-session repair (Opus stage-303 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Opus advisor on stage-303 (#1738 verification Q4) flagged that the catalog-coverage branch produces a redundant repair-write per chat-start when the active Codex default is itself slash-prefixed: the repair sets `provider_context = None`, the next chat-start hits the same branch because `requested_provider is None` again, and the repair fires repeatedly. In practice Codex `default_model` is always a bare `gpt-...` ID from the Codex catalog, so this is theoretical. But once we've decided this session belongs to Codex, we should persist that decision. Drop the conditional catalog-coverage check and unconditionally attach `raw_active_provider` ("openai-codex") on this repair path. The shape is now stable across resolutions. Absorb-in-release per Opus stage-303 verdict — small, defensive, ≤10 LOC. --- api/routes.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/api/routes.py b/api/routes.py index 4fe14df2..20bca779 100644 --- a/api/routes.py +++ b/api/routes.py @@ -948,12 +948,13 @@ def _resolve_compatible_session_model_state( and requested_provider is None and default_model ): - provider_context = ( - raw_active_provider - if _should_attach_codex_provider_context(default_model, raw_active_provider, catalog) - else None - ) - return default_model, provider_context, True + # Persist provider_context = "openai-codex" unconditionally on this + # repair path so the resolved shape is stable across resolutions + # (Opus stage-303 SHOULD-FIX: avoid redundant repair-writes per + # chat-start when the catalog-coverage check fails — e.g. if a + # future Codex default is itself slash-prefixed). Once we've + # decided the session belongs to Codex, persist that decision. + return default_model, raw_active_provider, True # Also normalize when the model is from a known provider but the active provider # is an unlisted one (e.g. ollama-cloud) — active_provider is "" in that case