Skip to content

fix(runtime-fallback): make fallback provider selection provider-agnostic (fixes #2303)#2695

Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/provider-agnostic-fallback
Mar 25, 2026
Merged

fix(runtime-fallback): make fallback provider selection provider-agnostic (fixes #2303)#2695
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/provider-agnostic-fallback

Conversation

@MoerAI
Copy link
Copy Markdown
Contributor

@MoerAI MoerAI commented Mar 19, 2026

Summary

  • Preserve fallback entry progression when listed providers are disconnected but the current provider is still connected.
  • Apply provider matching case-insensitively in model/runtime fallback reachability checks.

Problem

Runtime/model fallback provider selection was nominally provider-agnostic in selectFallbackProvider, but upstream reachability gating could skip fallback entries before selection happened. If an entry's provider list was disconnected while the current provider remained connected, fallback progression stopped early instead of reusing the connected provider.

Fix

Updated reachability checks in both model fallback hook and background fallback retry path to treat a fallback entry as reachable when either (a) any entry provider is connected or (b) the current/preferred provider is connected. Also normalized connectivity checks to lowercase to avoid case-sensitive mismatches.

Changes

File Change
src/hooks/model-fallback/hook.ts Include connected preferred provider in reachability gating; normalize connected provider matching to lowercase.
src/hooks/model-fallback/hook.test.ts Add regression test for disconnected entry providers with connected preferred provider.
src/features/background-agent/fallback-retry-handler.ts Include connected preferred provider in reachability gating before selecting fallback provider.
src/features/background-agent/fallback-retry-handler.test.ts Add regression test covering preferred-provider fallback path in background retry flow.

Fixes #2303


Summary by cubic

Make fallback selection provider-agnostic and case-insensitive, continuing via the connected preferred provider when listed fallback providers are disconnected. Fixes #2303.

  • Bug Fixes
    • Treat a fallback entry as reachable if any listed provider is connected or the current/preferred provider is connected.
    • Normalize provider IDs and connectivity checks to lowercase.
    • Update background retry and model fallback paths; add regression tests for both.

Written for commit 0e610a7. Summary will update on new commits.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 19, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92c59ea55f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +146 to +147
const preferredProvider = state.providerID.toLowerCase()
return connectedSet.has(preferredProvider)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip provider-specific entries when only the preferred provider is connected

This makes getNextFallback treat an entry as reachable whenever the current provider is still connected, even if the entry only names a provider-specific model. I checked src/shared/model-requirements.ts and several built-in chains contain single-provider models such as kimi-for-coding/k2p5, zai-coding-plan/glm-4.6v, and github-copilot/grok-code-fast-1, while src/shared/provider-model-id-transform.ts only rewrites Google/Copilot aliases. In the common case where anthropic is still connected but kimi-for-coding is not, this path now selects anthropic/k2p5, which will fail with a model-not-found error instead of skipping to the next valid fallback.

Useful? React with 👍 / 👎.

Comment on lines +42 to +45
if (entry.providers.some((provider) => connectedSet.has(provider.toLowerCase()))) {
return true
}
return preferredProvider ? connectedSet.has(preferredProvider) : false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid queueing background retries on unsupported provider/model pairs

The same reachability relaxation in tryFallbackRetry now keeps entries whose listed providers are disconnected as long as the task's current provider is connected. That is unsafe for provider-specific fallbacks in src/shared/model-requirements.ts like kimi-for-coding/k2p5 or zai-coding-plan/glm-4.6v: selectFallbackProvider will reuse the current provider, and src/shared/provider-model-id-transform.ts has no mapping for those aliases, so the background retry gets queued with an impossible model such as anthropic/k2p5 and burns an attempt before any real fallback can run.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Fixes fallback reachability logic by allowing the current connected provider to be used even if entry providers are listed as disconnected. Includes regression tests.

@MoerAI MoerAI force-pushed the fix/provider-agnostic-fallback branch from 92c59ea to 0e610a7 Compare March 20, 2026 01:00
@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 20, 2026

I have read the CLA Document and I hereby sign the CLA

@code-yeongyu code-yeongyu added the triage:bug-fix PR: Bug fix label Mar 24, 2026
@code-yeongyu code-yeongyu merged commit bff74f4 into code-yeongyu:dev Mar 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug-fix PR: Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime/model fallback provider selection should be provider-agnostic

2 participants