Skip to content

fix: fall back to target provider's default model on provider switch#1152

Closed
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
cursor/model-fallback-on-provider-switch-976a
Closed

fix: fall back to target provider's default model on provider switch#1152
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
cursor/model-fallback-on-provider-switch-976a

Conversation

@cursor
Copy link
Contributor

@cursor cursor bot commented Mar 16, 2026

What Changed

When switching providers (e.g., Codex to Claude) without explicitly specifying a model, the ensureSessionForThread function now falls back to DEFAULT_MODEL_BY_PROVIDER[targetProvider] instead of carrying over the thread's existing model slug.

The unit test expectation is updated accordingly to assert "claude-sonnet-4-6" instead of "gpt-5-codex" when provider: "claudeAgent" is requested.

Why

desiredModel was computed as options?.model ?? thread.model. When a user switches from Codex to Claude without providing a model override, the thread's stored model (a Codex-specific slug like "gpt-5-codex") was forwarded to the Claude adapter unchanged. The Claude SDK doesn't understand Codex model names and will fail or behave unpredictably.

The fix detects when options.provider is explicitly set and differs from the current provider (including when there is no current session), and uses the target provider's default model from the existing DEFAULT_MODEL_BY_PROVIDER map.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes — N/A, no UI changes
  • I included a video for animation/interaction changes — N/A
Open in Web Open in Cursor 

Note

Fix ProviderCommandReactor to use target provider's default model on provider switch

When switching providers without specifying an explicit model, the reactor previously kept the thread's existing model (from the old provider). It now selects the default model for the incoming provider via DEFAULT_MODEL_BY_PROVIDER.

The fix adds a providerIsChanging check in ProviderCommandReactor.ts to distinguish between a same-provider resume and a cross-provider switch when resolving desiredModel.

Macroscope summarized 5b9f3fb.

When switching providers (e.g., Codex -> Claude) without explicitly
specifying a model, the thread's existing model slug (a Codex slug like
'gpt-5-codex') was passed to the new provider's adapter. The Claude SDK
does not understand Codex model names, causing failures.

Now, when a provider is explicitly requested and differs from the current
provider, the code falls back to DEFAULT_MODEL_BY_PROVIDER for the
target provider instead of carrying over the thread's existing model.

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions bot added size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants