Agent Zero AI framework
Identify the preset and model slot in parameter save errors
Alessandroacbb0cab0119
diff --git a/plugins/_model_config/AGENTS.md b/plugins/_model_config/AGENTS.mdindex 2314e15fd..a85809cc6 100644--- a/plugins/_model_config/AGENTS.md+++ b/plugins/_model_config/AGENTS.md@@ -54,7 +54,7 @@- Venice migration applies chat-only kwargs to chat slots and removes them from embedding slots without discarding embedding-specific kwargs.- On every startup after migration, short-circuit when `usr/plugins/_model_config/presets.yaml` exists. Only a missing collection may fetch `agent0ai/a0-presets`; parse remote and plugin-local fallback YAML through the same validator, strip secrets before persistence, and persist `mode_presets_fallback.yaml` when download or validation fails.- Model-name catalogs open below the input from either a field click or the embedded magnifier. Discard asynchronous results if their provider, API base, model draft, or query changed while the request was pending.-- Additional parameter drafts retain plain-string compatibility but reject malformed JSON-shaped values and invalid KEY=VALUE lines with a standard notification. Reparse every preset slot before saving presets or API keys; invalid drafts stay editable and never silently save stale kwargs.+- Additional parameter drafts retain plain-string compatibility but reject malformed JSON-shaped values and invalid KEY=VALUE lines with a standard notification. Reparse every preset slot before saving presets or API keys; invalid drafts stay editable and never silently save stale kwargs. Save errors identify the preset and model slot even when that draft is no longer selected.## Work Guidancediff --git a/plugins/_model_config/webui/model-config-store.js b/plugins/_model_config/webui/model-config-store.jsindex 624135c90..bb5fe95b0 100644--- a/plugins/_model_config/webui/model-config-store.js+++ b/plugins/_model_config/webui/model-config-store.js@@ -418,7 +418,13 @@ export const store = createStore("modelConfig", {for (const preset of this.presets) {for (const key of ['chat', 'vision', 'utility', 'embedding']) {const slot = preset[key];- if (typeof slot?._kwargs_text === 'string') slot.kwargs = textToKwargs(slot._kwargs_text);+ if (typeof slot?._kwargs_text !== 'string') continue;+ try {+ slot.kwargs = textToKwargs(slot._kwargs_text);+ } catch (e) {+ const title = MODEL_SECTIONS.find(section => section.key === `${key}_model`)?.title || key;+ throw new Error(`${preset.name} (${title}): ${e.message}`);+ }}}await store.persistAllDirtyApiKeys();diff --git a/tests/test_model_parameter_text.py b/tests/test_model_parameter_text.pyindex b00327cd8..6991c6ff5 100644--- a/tests/test_model_parameter_text.py+++ b/tests/test_model_parameter_text.py@@ -18,7 +18,7 @@ const apiKeysState = {}, apiKeysMethods = {}, switcherState = {}, switcherMethodmodule_url = "data:text/javascript;base64," + base64.b64encode(source.encode()).decode()script = r'''import assert from 'node:assert/strict';-const { textToKwargs, kwargsToText, store } = await import(MODULE_URL);+const { textToKwargs, kwargsToText, store, MODEL_SECTIONS } = await import(MODULE_URL);const values = { plain: 'hello', literal: 'true', flag: true, off: false, nothing: null,number: 0.2, object: { list: [1, false] }, empty: '' };assert.deepEqual(textToKwargs(kwargsToText(values)), values);@@ -43,14 +43,16 @@ store.saveGlobalPresets = async presets => { saves++; saved = structuredClone(prfor (const slot of ['chat', 'vision', 'utility', 'embedding']) {store.globalPresets = [{name: 'Test', [slot]: {provider: 'test', name: 'test',kwargs: {old: true}, _kwargs_text: 'param={"enabled":True}'}}];- const editor = store.createPresetEditor('Test');+ store.globalPresets.push({name: 'Other'});+ const editor = store.createPresetEditor('Other');const before = [saves, keySaves];assert.equal(await editor.savePresets(), false);assert.deepEqual([saves, keySaves], before);assert.match(notifications.at(-1).message, /invalid JSON/);+ assert.ok(notifications.at(-1).message.startsWith(`Test (${MODEL_SECTIONS.find(s => s.key === slot + '_model').title}):`));assert.equal(notifications.at(-1).type, 'error');- assert.equal(editor.selectedPreset[slot]._kwargs_text, 'param={"enabled":True}');- editor.selectedPreset[slot]._kwargs_text = 'param={"enabled":true}';+ assert.equal(editor.presets[0][slot]._kwargs_text, 'param={"enabled":True}');+ editor.presets[0][slot]._kwargs_text = 'param={"enabled":true}';assert.equal(await editor.savePresets(), true);assert.deepEqual(saved[0][slot].kwargs, {param: {enabled: true}});}