Agent Zero AI framework
feat: Preset reset on Default, expanded fields & cross-modal nav
keyboardstaffda7e33549c9a
diff --git a/plugins/_model_config/api/model_presets.py b/plugins/_model_config/api/model_presets.pyindex a4fad7bba..e21e4ed57 100644--- a/plugins/_model_config/api/model_presets.py+++ b/plugins/_model_config/api/model_presets.py@@ -17,4 +17,8 @@ class ModelPresets(ApiHandler):model_config.save_presets(presets)return {"ok": True, "presets": presets}+ elif action == "reset":+ presets = model_config.reset_presets()+ return {"ok": True, "presets": presets}+return Response(status=400, response=f"Unknown action: {action}")diff --git a/plugins/_model_config/default_presets.yaml b/plugins/_model_config/default_presets.yamlindex 69b693a4a..1a575dff9 100644--- a/plugins/_model_config/default_presets.yaml+++ b/plugins/_model_config/default_presets.yaml@@ -4,19 +4,29 @@name: "openai/gpt-5.2-chat"api_key: ""api_base: ""+ ctx_length: 128000+ ctx_history: 0.7+ vision: trueutility:provider: "openrouter"name: "openai/gpt-5-nano"api_key: ""api_base: ""+ ctx_length: 128000+ ctx_input: 0.7- name: "Intelligence"chat:provider: "openrouter"name: "anthropic/claude-opus-4.6"api_key: ""api_base: ""+ ctx_length: 128000+ ctx_history: 0.7+ vision: trueutility:provider: "openrouter"name: "google/gemini-3-flash-preview"api_key: ""api_base: ""+ ctx_length: 128000+ ctx_input: 0.7diff --git a/plugins/_model_config/extensions/webui/chat-nav-after/model-switcher.html b/plugins/_model_config/extensions/webui/chat-nav-after/model-switcher.htmlindex 094e40a71..2bae38a2b 100644--- a/plugins/_model_config/extensions/webui/chat-nav-after/model-switcher.html+++ b/plugins/_model_config/extensions/webui/chat-nav-after/model-switcher.html@@ -81,7 +81,7 @@openModal('/plugins/_model_config/webui/main.html');showDropdown = false;">- <span class="material-symbols-outlined" style="font-size: 14px;">settings</span>+ <span class="material-symbols-outlined" style="font-size: 14px;">tune</span><span>Edit Presets</span></div></div>@@ -113,7 +113,7 @@border: none;}.model-switcher-btn.has-override {- color: var(--color-text);+ /* color: var(--color-text); */}.model-switcher-label {max-width: 160px;diff --git a/plugins/_model_config/helpers/model_config.py b/plugins/_model_config/helpers/model_config.pyindex 8ba92a069..0676d3834 100644--- a/plugins/_model_config/helpers/model_config.py+++ b/plugins/_model_config/helpers/model_config.py@@ -1,3 +1,4 @@+import osimport modelsfrom helpers import plugins, filesfrom helpers import yaml as yaml_helper@@ -50,6 +51,14 @@ def save_presets(presets: list) -> None:files.write_file(path, yaml_helper.dumps(presets))+def reset_presets() -> list:+ """Delete user presets so get_presets() falls back to bundled defaults. Returns the default presets."""+ path = _get_presets_path()+ if os.path.exists(path):+ os.remove(path)+ return get_presets()++def get_preset_by_name(name: str) -> dict | None:"""Find a preset by name from the global presets list."""for p in get_presets():diff --git a/plugins/_model_config/webui/config.html b/plugins/_model_config/webui/config.htmlindex b2eccc8ea..7b83e5996 100644--- a/plugins/_model_config/webui/config.html+++ b/plugins/_model_config/webui/config.html@@ -11,6 +11,14 @@x-init="await $store.modelConfig.ensureLoaded();$store.modelConfig.initConfigFields(config);+ const _origReset = context.resetToDefault.bind(context);+ context.resetToDefault = async () => {+ const before = context.settings;+ await _origReset();+ if (context.settings !== before) {+ await $store.modelConfig.resetGlobalPresets();+ }+ };"><template x-if="config && $store.modelConfig._loaded"><div class="model-config-sections">@@ -32,6 +40,13 @@</label></div></div>++ <div class="override-presets-link" x-show="config.chat_model.allow_chat_override">+ <button class="text-button" @click="openModal('/plugins/_model_config/webui/main.html')">+ <span class="material-symbols-outlined" style="font-size:15px;">tune</span>+ <span>Edit Presets</span>+ </button>+ </div></div><!-- Model Sections (Main, Utility, Embedding) -->@@ -280,6 +295,13 @@.model-section .section-title {margin-top: 0;}+ .override-presets-link {+ margin-top: 4px;+ }+ .override-presets-link .text-button {+ font-size: 0.78rem;+ gap: 4px;+ }.eye-toggle {position: absolute;right: 8px;diff --git a/plugins/_model_config/webui/main.html b/plugins/_model_config/webui/main.htmlindex de0987d8b..dee6c8603 100644--- a/plugins/_model_config/webui/main.html+++ b/plugins/_model_config/webui/main.html@@ -97,7 +97,7 @@<div class="field"><div class="field-label"><div class="field-title">API key</div>- <div class="field-description">Leave empty to use the default API key for this provider.</div>+ <div class="field-description">Authentication key for this provider. Shared across all model slots using the same provider.</div></div><div class="field-control" style="position:relative;" x-data="{ showKey: false, _revealed: '' }"><input :type="showKey ? 'text' : 'password'" x-model="preset.chat.api_key" autocomplete="off"@@ -123,6 +123,76 @@</div><div class="field-control"><input type="text" x-model="preset.chat.api_base" /></div></div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Context length</div>+ <div class="field-description">Maximum number of tokens in the context window. System prompt, chat history, RAG and response all count towards this limit.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.chat.ctx_length" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Context window space for chat history</div>+ <div class="field-description">Portion of context window dedicated to chat history visible to the agent. Smaller size will result in shorter and more summarized history.</div>+ </div>+ <div class="field-control">+ <input type="range" min="0.01" max="1" step="0.01" x-model.number="preset.chat.ctx_history" />+ <span class="range-value" x-text="preset.chat.ctx_history || ''"></span>+ </div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Supports Vision</div>+ <div class="field-description">Models capable of Vision can for example natively see the content of image attachments.</div>+ </div>+ <div class="field-control">+ <label class="toggle">+ <input type="checkbox" x-model="preset.chat.vision" />+ <span class="toggler"></span>+ </label>+ </div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Requests per minute limit</div>+ <div class="field-description">Limits the number of requests per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.chat.rl_requests" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Input tokens per minute limit</div>+ <div class="field-description">Limits the number of input tokens per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.chat.rl_input" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Output tokens per minute limit</div>+ <div class="field-description">Limits the number of output tokens per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.chat.rl_output" /></div>+ </div>+ <div class="field field-full">+ <div class="field-label">+ <div class="field-title">Additional parameters</div>+ <div class="field-description">Any other parameters supported by <a href='https://docs.litellm.ai/docs/set_keys' target='_blank'>LiteLLM</a>. Format is KEY=VALUE on individual lines. Value can be JSON objects; unquoted is treated as object/number, quoted as string.</div>+ </div>+ <div class="field-control">+ <textarea x-model="preset.chat._kwargs_text"+ @change="preset.chat.kwargs = $store.modelConfig.textToKwargs(preset.chat._kwargs_text)"></textarea>+ </div>+ </div>+ <div class="field field-full">+ <div class="field-label">+ <div class="field-title">Browser HTTP Headers</div>+ <div class="field-description">Custom HTTP headers sent with browser requests. The browser agent uses the main model. Format is KEY=VALUE, one per line.</div>+ </div>+ <div class="field-control">+ <textarea x-model="preset.chat._browser_headers_text"+ @change="preset.chat.browser_http_headers = $store.modelConfig.textToHeaders(preset.chat._browser_headers_text)"></textarea>+ </div>+ </div><div class="preset-subheader">Utility Model <span style="opacity:0.5; font-size:0.75rem;">(optional — falls back to the configured Utility Model)</span></div><div class="field">@@ -176,7 +246,7 @@<div class="field"><div class="field-label"><div class="field-title">API key</div>- <div class="field-description">Leave empty to use the default API key for this provider.</div>+ <div class="field-description">Authentication key for this provider. Shared across all model slots using the same provider.</div></div><div class="field-control" style="position:relative;" x-data="{ showKey: false, _revealed: '' }"><input :type="showKey ? 'text' : 'password'" x-model="preset.utility.api_key" autocomplete="off"@@ -203,20 +273,84 @@</div><div class="field-control"><input type="text" x-model="preset.utility.api_base" /></div></div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Context length</div>+ <div class="field-description">Maximum number of tokens in the context window. System prompt, chat history, RAG and response all count towards this limit.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.utility.ctx_length" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Context window space for utility input</div>+ <div class="field-description">Portion of context window used for utility model input messages.</div>+ </div>+ <div class="field-control">+ <input type="range" min="0.01" max="1" step="0.01" x-model.number="preset.utility.ctx_input" />+ <span class="range-value" x-text="preset.utility.ctx_input || ''"></span>+ </div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Requests per minute limit</div>+ <div class="field-description">Limits the number of requests per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.utility.rl_requests" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Input tokens per minute limit</div>+ <div class="field-description">Limits the number of input tokens per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.utility.rl_input" /></div>+ </div>+ <div class="field">+ <div class="field-label">+ <div class="field-title">Output tokens per minute limit</div>+ <div class="field-description">Limits the number of output tokens per minute. Waits if the limit is exceeded. Set to 0 to disable.</div>+ </div>+ <div class="field-control"><input type="number" x-model.number="preset.utility.rl_output" /></div>+ </div>+ <div class="field field-full">+ <div class="field-label">+ <div class="field-title">Additional parameters</div>+ <div class="field-description">Any other parameters supported by <a href='https://docs.litellm.ai/docs/set_keys' target='_blank'>LiteLLM</a>. Format is KEY=VALUE on individual lines. Value can be JSON objects; unquoted is treated as object/number, quoted as string.</div>+ </div>+ <div class="field-control">+ <textarea x-model="preset.utility._kwargs_text"+ @change="preset.utility.kwargs = $store.modelConfig.textToKwargs(preset.utility._kwargs_text)"></textarea>+ </div>+ </div></div></div></template>- <button class="text-button preset-add-btn"- @click="- presets = [...presets, {- name: 'Preset ' + (presets.length + 1),- chat: { provider: '', name: '', api_key: '', api_base: '' },- utility: { provider: '', name: '', api_key: '', api_base: '' }- }]">- <span class="material-symbols-outlined" style="font-size:16px;">add</span>- <span>Add Preset</span>- </button>+ <div class="presets-actions">+ <button class="text-button preset-add-btn"+ @click="+ presets = [...presets, {+ name: 'Preset ' + (presets.length + 1),+ chat: { provider: '', name: '', api_key: '', api_base: '', ctx_length: 128000, ctx_history: 0.7, vision: true, rl_requests: 0, rl_input: 0, rl_output: 0, kwargs: {}, browser_http_headers: {}, _kwargs_text: '', _browser_headers_text: '' },+ utility: { provider: '', name: '', api_key: '', api_base: '', ctx_length: 128000, ctx_input: 0.7, rl_requests: 0, rl_input: 0, rl_output: 0, kwargs: {}, _kwargs_text: '' }+ }]">+ <span class="material-symbols-outlined" style="font-size:16px;">add</span>+ <span>Add Preset</span>+ </button>+ <button class="text-button" @click="(async () => {+ await import('/components/plugins/plugin-settings-store.js');+ const pluginMeta = { name: '_model_config', always_enabled: true, per_project_config: true, per_agent_config: true, has_config_screen: true };+ if ($store.pluginToggle?.open) await $store.pluginToggle.open(pluginMeta);+ await $store.pluginSettingsPrototype.open('_model_config', { perProjectConfig: true, perAgentConfig: true });+ openModal('components/plugins/plugin-settings.html');+ })()">+ <span class="material-symbols-outlined" style="font-size:15px;">settings</span>+ <span>Settings</span>+ </button>+ <button class="text-button" @click="openModal('/plugins/_model_config/webui/api-keys.html')">+ <span class="material-symbols-outlined" style="font-size:15px;">key</span>+ <span>API Keys</span>+ </button>+ </div><div class="presets-footer"><button class="button" @click="$store.modelConfig.saveGlobalPresets(presets)">@@ -290,7 +424,11 @@padding-top: 8px;border-top: 1px dashed var(--color-border);}- .preset-add-btn {+ .presets-actions {+ display: flex;+ gap: 12px;+ flex-wrap: wrap;+ align-items: center;margin-top: 4px;}.eye-toggle {diff --git a/plugins/_model_config/webui/model-config-store.js b/plugins/_model_config/webui/model-config-store.jsindex f8938a626..7e0027053 100644--- a/plugins/_model_config/webui/model-config-store.js+++ b/plugins/_model_config/webui/model-config-store.js@@ -67,6 +67,14 @@ export const store = createStore("modelConfig", {init() {},+ _normalizePresets(rawPresets) {+ return (rawPresets || []).map(p => ({+ name: p.name || '',+ chat: { provider: '', name: '', api_key: '', api_base: '', ctx_length: 128000, ctx_history: 0.7, vision: true, rl_requests: 0, rl_input: 0, rl_output: 0, kwargs: {}, browser_http_headers: {}, _kwargs_text: kwargsToText(p.chat?.kwargs), _browser_headers_text: Object.entries(p.chat?.browser_http_headers || {}).map(([k, v]) => k + '=' + v).join('\n'), ...(p.chat || {}) },+ utility: { provider: '', name: '', api_key: '', api_base: '', ctx_length: 128000, ctx_input: 0.7, rl_requests: 0, rl_input: 0, rl_output: 0, kwargs: {}, _kwargs_text: kwargsToText(p.utility?.kwargs), ...(p.utility || {}) },+ }));+ },+async ensureLoaded() {if (this._loaded) return;const data = await this._fetchConfigData();@@ -121,11 +129,7 @@ export const store = createStore("modelConfig", {body: JSON.stringify({ action: 'get' })});const data = await res.json();- this.globalPresets = (data.presets || []).map(p => ({- name: p.name || '',- chat: { provider: '', name: '', api_key: '', api_base: '', ...(p.chat || {}) },- utility: { provider: '', name: '', api_key: '', api_base: '', ...(p.utility || {}) },- }));+ this.globalPresets = this._normalizePresets(data.presets);} catch (e) {console.error('Failed to load global presets:', e);this.globalPresets = [];@@ -134,11 +138,22 @@ export const store = createStore("modelConfig", {},async saveGlobalPresets(presets) {+ // Strip UI-only fields before saving+ const clean = presets.map(p => {+ const c = { name: p.name };+ for (const slot of ['chat', 'utility']) {+ if (p[slot]) {+ const { _kwargs_text, _browser_headers_text, ...rest } = p[slot];+ c[slot] = rest;+ }+ }+ return c;+ });try {await fetchApi(`${API_BASE}/model_presets`, {method: 'POST',headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({ action: 'save', presets })+ body: JSON.stringify({ action: 'save', presets: clean })});this.globalPresets = presets;this.switcherPresets = presets.filter(p => p.name);@@ -149,6 +164,22 @@ export const store = createStore("modelConfig", {}},+ async resetGlobalPresets() {+ try {+ const res = await fetchApi(`${API_BASE}/model_presets`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ action: 'reset' })+ });+ const data = await res.json();+ this.globalPresets = this._normalizePresets(data.presets);+ this.switcherPresets = this.globalPresets.filter(p => p.name);+ this._presetsLoaded = true;+ } catch (e) {+ console.error('Failed to reset presets:', e);+ }+ },+// API Key operationsasync saveApiKey(provider, value) {await fetchApi(`${API_BASE}/api_keys`, {@@ -318,7 +349,7 @@ export const store = createStore("modelConfig", {getSwitcherLabel() {const o = this.switcherOverride;- if (!o) return 'Default';+ if (!o) return 'Default LLM';return o.preset_name || o.name || o.provider || 'Custom';},diff --git a/plugins/_model_config/webui/models-summary.html b/plugins/_model_config/webui/models-summary.htmlindex ed051076f..11d403577 100644--- a/plugins/_model_config/webui/models-summary.html+++ b/plugins/_model_config/webui/models-summary.html@@ -18,6 +18,7 @@<div style="display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;"><button class="btn btn-field" @click="(async () => {+ await import('/components/plugins/plugin-settings-store.js');const pluginMeta = { name: '_model_config', always_enabled: true, per_project_config: true, per_agent_config: true, has_config_screen: true };if ($store.pluginToggle?.open) await $store.pluginToggle.open(pluginMeta);await $store.pluginSettingsPrototype.open('_model_config', { perProjectConfig: true, perAgentConfig: true });@@ -25,8 +26,11 @@})()">Configure Models</button>+ <button class="btn btn-field" @click="openModal('/plugins/_model_config/webui/main.html')">+ Configure Presets+ </button><button class="btn btn-field" @click="openModal('/plugins/_model_config/webui/api-keys.html')">- Manage API Keys+ Configure API Keys</button></div>