fix: fall back to target provider's default model on provider switch#1152
Closed
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
Closed
fix: fall back to target provider's default model on provider switch#1152cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
cursor[bot] wants to merge 1 commit intocodething/648ca884-claudefrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
When switching providers (e.g., Codex to Claude) without explicitly specifying a model, the
ensureSessionForThreadfunction now falls back toDEFAULT_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"whenprovider: "claudeAgent"is requested.Why
desiredModelwas computed asoptions?.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.provideris 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 existingDEFAULT_MODEL_BY_PROVIDERmap.Checklist
Note
Fix
ProviderCommandReactorto use target provider's default model on provider switchWhen 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
providerIsChangingcheck in ProviderCommandReactor.ts to distinguish between a same-provider resume and a cross-provider switch when resolvingdesiredModel.Macroscope summarized 5b9f3fb.