#1928·agent-zero

Bug: Edit Model Presets shows a stale preset list (and opens on Default) after presets were changed outside the editor

Author: spcdataproCreated Sep 29, 2026Updated Sep 29, 2026

Bug Description

The native Edit Model Presets modal keeps its own in-memory copy of the presets (modelConfig.globalPresets) and only refreshes it when the editor itself saves. If the presets change by any other route (another browser tab, an API client such as the connector, a plugin that calls model_config.save_presets), the next time the editor is opened it shows the old list:

  • a preset that was just created is missing from the dropdown, and the editor opens on Default instead of the requested preset;
  • a preset whose settings were just changed still shows the old values.

Opening the editor a second time shows the correct data, which makes the problem look intermittent.

The same stale copy is used by the chat model selector (switcherPresets) and by the Settings summary, so they can also show outdated presets until they are refreshed.

Environment

  • Agent Zero v2.13 (e3051fb5, 2026-09-23), Docker
  • Chromium (also seen in BrowserOS)
  • Files: plugins/_model_config/webui/model-config-store.js, plugins/_model_config/webui/main.html

Steps to reproduce (no plugin involved)

  1. Open the WebUI and open Edit Model Presets once (for example from the chat model selector), then close it.
  2. Change the presets from outside the editor. For example, in a shell inside the container:
    python
    from plugins._model_config.helpers import model_config
    presets = model_config.get_presets()
    new = dict(presets[0], name="probe")          # any new preset
    model_config.save_presets(presets + [new])
    (Editing a preset from a second browser tab, or through POST /api/plugins/_a0_connector/v1/model_presets, has the same effect.)
  3. In the first tab, open Edit Model Presets again and select probe.

Expected: the dropdown lists probe and the editor opens on it (or on the preset that was requested).

Actual: probe is not in the dropdown and the editor opens on Default. Closing and opening the editor a second time lists it.

Root cause

main.html gates the editor on flags that stay true after the first load, and builds the draft immediately:

xml
<!-- main.html -->
<div x-data x-init="
       await $store.modelConfig.ensureLoaded();
       ...
       await $store.modelConfig.loadGlobalPresets();          // reloads from the server, but afterwards
       await $store.modelConfig.preparePresetEditor(...)">
  <template x-if="$store.modelConfig._loaded && $store.modelConfig._presetsLoaded">   <!-- already true -->
    <div class="preset-editor"
         x-data="$store.modelConfig.createPresetEditor($store.modelConfig.presetEditorInitialName)">

createPresetEditor() copies the current, stale list:

javascript
// model-config-store.js
createPresetEditor(initialName = '') {
  const presets = clonePlain(this.globalPresets).map(...)      // stale on every open after the first

and loadGlobalPresets() sets _presetsLoaded = true but nothing ever resets it. So on the second and later opens, the template renders at once with the previous globalPresets; the reload started by x-init finishes afterwards and updates the store, but the draft has already been created. The first open works because the gate is still false until the initial load completes. openPresetEditor() (used by the selector, the Settings summary and the onboarding flow) does not reload either.

Suggested fix

Reload the presets before opening the modal. One line in openPresetEditor():

javascript
async openPresetEditor(name = DEFAULT_PRESET_NAME, contextId = '') {
  this.presetEditorInitialName = name || DEFAULT_PRESET_NAME;
  this._lastPresetReferenceChanges = {};
  await this.loadGlobalPresets();            // <-- new: never build the draft from a stale list
  if (contextId) await this.refreshSwitcher(contextId);
  ...

Alternatively, reset _presetsLoaded = false at the start of the editor's x-init so the gate waits for the reload.

Verification

Headless Chromium against a v2.13 container, presets changed from a separate Python process using model_config.save_presets only:

Case Lists the new preset Opens on
Editor opened once, presets changed, editor opened again (current code) no Default
Same, opened a second time yes the new preset
Same, with await loadGlobalPresets() added in openPresetEditor yes, first time the new preset

Notes

  • Plugins that write presets can work around it by calling modelConfig.loadGlobalPresets() (and refreshing switcherPresets) after saving; a fix in the store would make that unnecessary.
  • Unrelated to #1787 (the editor cannot be closed when opened from onboarding), although it is the same modal.