fix(agents): keep the provider you picked across an auth-method change - #715
Open
Adam-Dalloul wants to merge 1 commit into
Open
fix(agents): keep the provider you picked across an auth-method change#715Adam-Dalloul wants to merge 1 commit into
Adam-Dalloul wants to merge 1 commit into
Conversation
Leaving "model_provider" auth mode drops `draft.modelProviderId`, so a save in another mode cannot persist a binding. Coming back to provider mode therefore arrives with no binding and falls into the auto-select, which took the head of the provider list. That list is ordered by row id, so the agent was silently rebound to its OLDEST provider, and the rebind rewrites the draft's model fields, its env text and its config text with that provider's values. With two providers pointing at different models, switching to the second one showed and saved the first one's model name. The panel now remembers the provider each agent was last bound to and prefers it, falling back to the head of the list only for a first-time pick or when the remembered provider is gone. Reported in xintaofei#628.
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.
Fixes #628: with two Claude Code providers pointing at different model names, switching to the second one shows and saves the first one's model name.
Reproduction, which is the "点击cc的认证方式切换供应商" in the issue:
ANTHROPIC_MODEL.agent_setting.env_jsonand~/.claude/settings.json.Cause:
handleClaudeAuthModeChangesetsmodelProviderId: nullwhenever the mode leavesmodel_provider, which is right, because a save in another mode must not persist a binding. Coming back therefore arrives with no binding and falls into the auto-select effect, which calledhandleModelProviderSelect(selectedModelProviders[0].id).list_allorders by row id, so[0]is the oldest provider, A. The Claude branch ofhandleModelProviderSelectis provider-authoritative by design, so it rewritesclaudeMainModel,envTextandconfigTextfrom A while the user believes they are on B.The change: the panel remembers the provider each agent was last bound to and prefers it. The head of the list stays the fallback for a first-time pick, and for a remembered provider that no longer exists.
Test:
providerToRebindTocovers the four cases, and the first one fails on the oldavailable[0]behaviour.Not touched here, but adjacent and worth a separate look: the
official_subscriptionbranch of the same handler buildsallEnvKeysfrom the API url and key only, so the eightANTHROPIC_*_MODELkeys survive an auth-mode change in the draft, the env text andconfig.env.