Agent Zero AI framework
Clear provider-specific kwargs on provider change
Alessandro948409c2449e
diff --git a/plugins/_model_config/AGENTS.md b/plugins/_model_config/AGENTS.mdindex c0efd47cc..0bf427f72 100644--- a/plugins/_model_config/AGENTS.md+++ b/plugins/_model_config/AGENTS.md@@ -19,6 +19,7 @@- Coordinate OAuth-backed providers with `_oauth` instead of hardcoding provider-specific auth here.- `model_config_get` exposes `model_configured` as a derived chat-model readiness flag from provider, model name, and API-key availability.- Applying a model preset may inherit durable tuning such as context windows and rate limits, but must replace or clear per-slot `kwargs` so provider-specific extra params never leak across model providers.+- Changing a model provider in the settings UI must clear `api_base` and `kwargs` because both may be provider-specific.- Repair provider-specific model-config aliases at the model-config read/build boundary; keep provider-specific repairs out of provider-agnostic core wrappers such as `models.py`.- `modelConfig.createPresetEditor()` owns local preset drafts, row actions, and stable UI-only row keys so deletion or renaming cannot rebind nested model fields.- Model-name catalogs open below the input from either a field click or the embedded magnifier.diff --git a/plugins/_model_config/README.md b/plugins/_model_config/README.mdindex 9fe3bc8fd..61274b2d4 100644--- a/plugins/_model_config/README.md+++ b/plugins/_model_config/README.md@@ -77,7 +77,7 @@ The project preset file uses the same plain YAML list schema as global presets.name: openai/gpt-5.4-mini```-Preset slots are partial overlays. Missing fields inherit from the current effective config, so a preset can switch only the model identity while preserving tuned context windows, rate limits, and nested `kwargs`. The `utility` and `embedding` slots are optional and only apply when they declare a provider or model name; otherwise those configured models are inherited. Selecting a preset for a project writes the merged result into the project's `config.json`.+Preset slots are partial overlays. Missing fields inherit from the current effective config, so a preset can switch only the model identity while preserving tuned context windows and rate limits. Provider-specific `kwargs` are replaced or cleared. The `utility` and `embedding` slots are optional and only apply when they declare a provider or model name; otherwise those configured models are inherited. Selecting a preset for a project writes the merged result into the project's `config.json`.## Plugin Metadatadiff --git a/plugins/_model_config/webui/model-field.html b/plugins/_model_config/webui/model-field.htmlindex ac0057985..2e30df718 100644--- a/plugins/_model_config/webui/model-field.html+++ b/plugins/_model_config/webui/model-field.html@@ -28,7 +28,7 @@<div class="field-control"><select x-model="model.provider"x-effect="$nextTick(() => { if (providers.length) $el.value = model.provider })"- @change="model.api_base = ''">+ @change="model.api_base = ''; model.kwargs = {}; model._kwargs_text = ''"><option value="">— select —</option><template x-for="p in providers" :key="p.value"><option :value="p.value" x-text="p.label"></option>diff --git a/tests/test_model_config_api_keys.py b/tests/test_model_config_api_keys.pyindex a130d4944..ddd09f31c 100644--- a/tests/test_model_config_api_keys.py+++ b/tests/test_model_config_api_keys.py@@ -231,7 +231,7 @@ def test_connector_model_switcher_notifies_state_sync(monkeypatch):assert calls == [("ctx-1", "a0_connector.model_switcher")]-def test_model_config_provider_switch_resets_custom_api_base():+def test_model_config_provider_switch_resets_provider_specific_fields():model_field_path = PROJECT_ROOT / "plugins" / "_model_config" / "webui" / "model-field.html"content = model_field_path.read_text(encoding="utf-8")select_start = content.index('<select x-model="model.provider"')@@ -239,7 +239,9 @@ def test_model_config_provider_switch_resets_custom_api_base():provider_select = content[select_start:select_end]assert 'x-model="model.provider"' in provider_select- assert '@change="model.api_base = \'\'"' in provider_select+ assert "model.api_base = ''" in provider_select+ assert "model.kwargs = {}" in provider_select+ assert "model._kwargs_text = ''" in provider_selectdef test_model_config_model_field_opens_search_on_click():