fix(cli): persist provider on global model switch

This commit is contained in:
Gille 2026-07-22 21:49:06 -06:00 committed by Teknium
parent b3ff5fc5b1
commit 390b03c455
2 changed files with 14 additions and 4 deletions

6
cli.py
View file

@ -8339,8 +8339,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
if persist_global:
HermesCLI._clear_persisted_context_for_model_switch(self, result)
save_config_value("model.default", result.new_model)
if result.provider_changed:
save_config_value("model.provider", result.target_provider)
save_config_value("model.provider", result.target_provider)
# base_url/api_mode were previously never persisted here, so a
# global switch left the OLD provider's endpoint/wire-protocol in
# config.yaml. result.base_url/api_mode are always freshly
@ -8694,8 +8693,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
if persist_global:
HermesCLI._clear_persisted_context_for_model_switch(self, result)
save_config_value("model.default", result.new_model)
if result.provider_changed:
save_config_value("model.provider", result.target_provider)
save_config_value("model.provider", result.target_provider)
# See _apply_model_switch_result above for why base_url/api_mode
# must be synced on every global switch (#25106).
save_config_value("model.base_url", result.base_url or None)

View file

@ -90,6 +90,12 @@ def test_global_switch_persists_base_url_and_api_mode(monkeypatch):
assert saved["model.api_mode"] == "chat_completions"
def test_global_switch_persists_provider_when_runtime_provider_is_unchanged(monkeypatch):
saved = _run_switch(monkeypatch, _make_result(provider_changed=False))
assert saved["model.provider"] == "custom:minimax"
def test_global_switch_clears_base_url_and_api_mode_when_unresolved(monkeypatch):
"""When the resolver returns no base_url/api_mode for the new provider
(e.g. a named provider needing neither), any previous value must be
@ -151,6 +157,12 @@ def test_picker_global_switch_persists_base_url_and_api_mode(monkeypatch):
assert saved["model.api_mode"] == "chat_completions"
def test_picker_global_switch_persists_provider_when_runtime_provider_is_unchanged(monkeypatch):
saved = _run_apply(monkeypatch, _make_result(provider_changed=False))
assert saved["model.provider"] == "custom:minimax"
def test_picker_global_switch_clears_base_url_and_api_mode_when_unresolved(monkeypatch):
"""Picker-path counterpart of `test_global_switch_clears_base_url_and_api_mode_when_unresolved`."""
result = _make_result(base_url="", api_mode="")