From 869a596f4b941118b56139f09dc2d0e04276739e Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 8 Apr 2026 22:30:55 -0400 Subject: [PATCH] fix: don't fall back when a model is explicitly configured in registry Previously any backend error would silently fall back to Claude. Now if the user has a model configured via the model registry, errors propagate to the UI so the actual problem is visible rather than hidden behind a transparent backend switch. Fallback still applies when using the default/auto backend with no registry config. Co-Authored-By: Claude Sonnet 4.6 --- cortex/llm_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cortex/llm_client.py b/cortex/llm_client.py index a67f9df..b810912 100644 --- a/cortex/llm_client.py +++ b/cortex/llm_client.py @@ -87,9 +87,15 @@ async def complete( return response, primary except Exception as e: err_str = str(e) - logger.warning("%s failed (%s) — falling back to %s", primary, e, fallback) if primary == "claude" and any(k in err_str for k in ("401", "authenticate", "expired", "OAuth")): await event_bus.publish({"type": "claude_auth_expired"}) + # Only fall back when using a default/auto backend. + # If the user has explicitly configured a model via the registry, + # surface the error so they know something is wrong. + if resolved_cfg is not None: + logger.error("%s failed (no fallback — model explicitly configured): %s", primary, e) + raise + logger.warning("%s failed (%s) — falling back to %s", primary, e, fallback) response = await _dispatch(fallback, system_prompt, messages, None) return response, fallback