diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py index 7764f114fff..9f30b698fc9 100644 --- a/gateway/slash_commands.py +++ b/gateway/slash_commands.py @@ -1361,7 +1361,7 @@ class GatewaySlashCommandsMixin: if result.base_url: _persist_model_cfg["base_url"] = result.base_url if str(result.target_provider or "").strip().lower() != "custom": - clear_model_endpoint_credentials(_persist_model_cfg) + clear_model_endpoint_credentials(_persist_model_cfg, clear_base_url=True) from hermes_cli.config import save_config save_config(_persist_cfg) except Exception as e: @@ -1598,7 +1598,7 @@ class GatewaySlashCommandsMixin: if result.base_url: model_cfg["base_url"] = result.base_url if str(result.target_provider or "").strip().lower() != "custom": - clear_model_endpoint_credentials(model_cfg) + clear_model_endpoint_credentials(model_cfg, clear_base_url=True) from hermes_cli.config import save_config save_config(cfg) except Exception as e: diff --git a/hermes_cli/config.py b/hermes_cli/config.py index bee791543c5..0da399b5b87 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -4131,6 +4131,7 @@ def clear_model_endpoint_credentials( *, clear_api_key: bool = True, clear_api_mode: bool = True, + clear_base_url: bool = False, ) -> Dict[str, Any]: """Remove stale inline endpoint credentials from a model config. @@ -4147,6 +4148,8 @@ def clear_model_endpoint_credentials( model_cfg.pop("api", None) if clear_api_mode: model_cfg.pop("api_mode", None) + if clear_base_url: + model_cfg.pop("base_url", None) return model_cfg diff --git a/tests/gateway/test_model_command_flat_string_config.py b/tests/gateway/test_model_command_flat_string_config.py index 9934d9806b1..8de92e9e57d 100644 --- a/tests/gateway/test_model_command_flat_string_config.py +++ b/tests/gateway/test_model_command_flat_string_config.py @@ -102,7 +102,7 @@ async def test_model_global_persists_when_config_has_flat_string_model(tmp_path, ) assert written["model"]["default"] == "gpt-5.5" assert written["model"]["provider"] == "openrouter" - assert written["model"]["base_url"] == "https://openrouter.ai/api/v1" + assert "base_url" not in written["model"] @pytest.mark.asyncio diff --git a/tests/gateway/test_model_picker_persist.py b/tests/gateway/test_model_picker_persist.py index ca9498389b1..95654030d82 100644 --- a/tests/gateway/test_model_picker_persist.py +++ b/tests/gateway/test_model_picker_persist.py @@ -171,7 +171,7 @@ async def test_picker_tap_persists_by_default(tmp_path, monkeypatch, seed_model) ) assert written["model"]["default"] == "gpt-5.5" assert written["model"]["provider"] == "openrouter" - assert written["model"]["base_url"] == "https://openrouter.ai/api/v1" + assert "base_url" not in written["model"] assert "api_key" not in written["model"] assert "api_mode" not in written["model"]