You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Model fallback fails when session has modelOverride: LiveSessionModelSwitchError not recognized as failover error #58392
The model fallback mechanism fails entirely when a session has a set (e.g., from a previous model selection). All 6 fallback candidates fail with errors like:
All models failed (6):
github/gpt-4.1: HTTP 404: 404 page not found (model_not_found)
minimax-portal/MiniMax-M2.7: Live session model switch requested: github/gpt-4.1 (unknown)
qiniu/qwen3.5-397b-a17b: Live session model switch requested: github/gpt-4.1 (unknown)
modelscope/deepseek-ai/DeepSeek-R1-0528: Live session model switch requested: github/gpt-4.1 (unknown)
...
Root Cause Analysis
Two related issues:
1. LiveSessionModelSwitchError not classified as failover error
In resolveFailoverReasonFromError(), LiveSessionModelSwitchError is not recognized as a failover-triggering error. The function checks for HTTP status codes and symbolic error codes, but LiveSessionModelSwitchError is neither — it is thrown from the embedded run loop when it detects a session model override that conflicts with the requested fallback model.
When coerceToFailoverError() returns null for this error, isKnownFailover = false, causing the fallback chain to throw immediately instead of continuing to the next candidate.
2. Session modelOverride not cleared on fallback
Even if LiveSessionModelSwitchError were properly classified, the session's modelOverride = github/gpt-4.1 persists across fallback attempts. Each fallback attempt re-reads the session store, sees the stale modelOverride, and throws the same error again. The fallback chain cannot make progress because the lock is never cleared.
Expected Behavior
When a fallback candidate fails with LiveSessionModelSwitchError, it should be treated as a retryable failover error and the chain should continue to the next candidate.
Alternatively, the session's modelOverride should be cleared when a fallback is triggered, so subsequent candidates use the default model.
+1
info agent/embedded {"subsystem":"agent/embedded"} live session model switch detected before attempt for fc95b21e-7946-42e9-bb44-a73f4734fae7: openai-codex/gpt-5.4 -> anthropic/claude-sonnet-4-6
Current main already addresses both parts of the report: fallback now treats LiveSessionModelSwitchError as a failover condition and continues the model chain, and session-scoped auto failover overrides are cleared so stale modelOverride values do not pin subsequent attempts to the wrong model.
What I checked:
Fallback now normalizes live model switch errors:runWithModelFallback explicitly catches LiveSessionModelSwitchError, wraps it as a FailoverError, records the failed candidate, and continues to the next fallback candidate instead of rethrowing. (src/agents/model-fallback.ts:921)
Regression tests cover the reported fallback failure mode: There are dedicated tests asserting that LiveSessionModelSwitchError is treated as failover on the last candidate and that the fallback chain continues to the next candidate. (src/agents/model-fallback.test.ts:644)
Auto failover session override is now self-healed:createModelSelectionState detects direct session entries with modelOverrideSource === "auto", clears the stored override back to the configured default, and resets in-memory provider/model to the primary before allowlist validation or retry selection. (src/auto-reply/reply/model-selection.ts:173)
Regression tests cover stale auto override clearing: Tests assert that an auto failover override is cleared from session state, that the configured primary is retried, and that a preloaded fallback selection is reset in memory for the current turn. (src/auto-reply/reply/model-selection.test.ts:635)
Docs and release tag show the fix shipped: The docs now state that LiveSessionModelSwitchError is normalized into the failover path, and git grep against tag v2026.4.23 found the same model-fallback and model-selection fix blocks plus their regression tests in that release. Public docs: docs/concepts/model-failover.md. (docs/concepts/model-failover.md:258, a9797214338b)
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Activity
jsompis commentedon Mar 31, 2026
+1
info agent/embedded {"subsystem":"agent/embedded"} live session model switch detected before attempt for fc95b21e-7946-42e9-bb44-a73f4734fae7: openai-codex/gpt-5.4 -> anthropic/claude-sonnet-4-6
steipete commentedon Apr 25, 2026
Closing this as implemented after Codex review.
Current
mainalready addresses both parts of the report: fallback now treatsLiveSessionModelSwitchErroras a failover condition and continues the model chain, and session-scoped auto failover overrides are cleared so stalemodelOverridevalues do not pin subsequent attempts to the wrong model.What I checked:
runWithModelFallbackexplicitly catchesLiveSessionModelSwitchError, wraps it as aFailoverError, records the failed candidate, andcontinues to the next fallback candidate instead of rethrowing. (src/agents/model-fallback.ts:921)LiveSessionModelSwitchErroris treated as failover on the last candidate and that the fallback chain continues to the next candidate. (src/agents/model-fallback.test.ts:644)createModelSelectionStatedetects direct session entries withmodelOverrideSource === "auto", clears the stored override back to the configured default, and resets in-memoryprovider/modelto the primary before allowlist validation or retry selection. (src/auto-reply/reply/model-selection.ts:173)src/auto-reply/reply/model-selection.test.ts:635)LiveSessionModelSwitchErroris normalized into the failover path, andgit grepagainst tagv2026.4.23found the same model-fallback and model-selection fix blocks plus their regression tests in that release. Public docs:docs/concepts/model-failover.md. (docs/concepts/model-failover.md:258, a9797214338b)So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review notes: reviewed against 11ad1919edc7; fix evidence: release v2026.4.23.