fix(setup): defer config.yaml write until after model selection#1188
Closed
ygd58 wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(setup): defer config.yaml write until after model selection#1188ygd58 wants to merge 1 commit intoNousResearch:mainfrom
ygd58 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Contributor
Author
|
Closing — upstream has landed a partial mitigation in main (adding default_model parameter to _update_config_for_provider). This addresses the "Keep current" edge case but the race condition window still exists since config.yaml is written before model selection completes. The full Option A fix (deferring the write until after model selection) remains the correct solution if the race condition is a priority. Happy to reopen if needed. |
_update_config_for_provider() was called immediately after provider selection for zai, kimi-coding, minimax, minimax-cn, and anthropic — before model selection happened. Since the gateway re-reads config.yaml per-message, this created a race condition where the gateway would pick up the new provider but still use the old (incompatible) model name. Fix: capture selected_base_url in each provider block, then call _update_config_for_provider() once after model selection completes, just before save_config(). The in-memory _set_model_provider() calls are kept in place so the config object stays consistent throughout. Fixes NousResearch#1182
407b038 to
d81cb58
Compare
Contributor
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.
Problem
Closes #1182
_update_config_for_provider()was called immediately after provider selection forzai,kimi-coding,minimax,minimax-cn, andanthropic— before model selection happened. Since the gateway re-readsconfig.yamlper-message, this created a race condition where the gateway would pick up the new provider but still use the old (incompatible) model name.Example: switching from OpenRouter (
anthropic/claude-opus-4.6) to MiniMax would briefly writeprovider: minimax+base_url: https://api.minimax.io/v1to disk whilemodel.defaultwas stillanthropic/claude-opus-4.6. Any gateway message sent during setup would fail.Even without a race: selecting "Keep current" at model selection would leave an OpenRouter-formatted model name permanently on a non-OpenRouter provider.
Fix
Capture
selected_base_urlin each affected provider block, then call_update_config_for_provider()once, after model selection completes, just beforesave_config(). The in-memory_set_model_provider()calls are kept in place so the config object stays consistent throughout the setup flow.Affected providers
zaikimi-codingminimaxminimax-cnanthropic