main
md 59 lines 3.88 KB
Rendered Raw
1 # Model Configuration
2
3 Manage the reusable model presets used for Agent Zero's main, utility, and embedding models.
4
5 ## Model Presets
6
7 - `Default` is always present, appears first, and cannot be renamed or deleted.
8 - Every runtime configuration resolves from a preset. There is no separate durable model configuration layer.
9 - Preset definitions are global and live in `usr/plugins/_model_config/presets.yaml`. Plugin defaults in `mode_presets_fallback.yaml` are used only when a saved collection cannot be initialized.
10 - Non-default presets may omit advanced fields or model slots; omitted values resolve from `Default`, while provider-specific `kwargs` are replaced or cleared instead of leaking between providers.
11 - API keys remain in the approved environment/settings flow and are never written into preset YAML.
12
13 ## Scoped Selection
14
15 Global, project, project/profile, and agent-profile scopes store only a preset name in their standard plugin `config.json`:
16
17 ```json
18 {"model_preset": "Balance"}
19 ```
20
21 For example, a project selection is stored at:
22
23 ```text
24 /a0/usr/projects/<project>/.a0proj/plugins/_model_config/config.json
25 ```
26
27 The normal plugin resolution order selects the most specific available reference. A missing or deleted reference safely resolves to `Default`. Chats may store an explicit preset reference in `chat_model_override`; clearing it returns the chat to its scoped selection.
28
29 ## User Interfaces
30
31 - Agent Settings shows the global selection, its three resolved models, and actions for preset editing, API keys, and per-project/agent settings.
32 - The full plugin settings modal uses the generic scope selector and stores only the chosen preset at that scope.
33 - The closed chat switcher shows the effective preset plus the main model's short name; its menu supports a chat-only selection or returning to the scoped preset.
34 - The adjacent profile switcher shows the active agent's effective title and avatar and links to Create, Edit, and Manage agents.
35 - The preset editor exposes the shared API key for each selected provider and saves key changes separately from secret-free preset definitions.
36 - Project Settings selects from the same global preset definitions.
37
38 ## Initial Presets And Migration
39
40 The startup migration converts the prior global full model configuration into `Default`, preserves existing global presets, promotes distinct scoped full configurations and legacy project presets into uniquely named global presets, and rewrites scoped config files to selection-only JSON. Original files receive a `.pre-unified-presets.bak` backup before replacement; the migration is idempotent.
41
42 At every startup, legacy migration runs first. If `usr/plugins/_model_config/presets.yaml` then exists, initialization returns immediately without network access. Otherwise the plugin makes one bounded request for [`agent0ai/a0-presets/model_presets.yaml`](https://github.com/agent0ai/a0-presets/blob/main/model_presets.yaml), validates the whole collection, removes secret fields, and saves it locally. A download, parse, or validation failure processes and saves plugin-local `mode_presets_fallback.yaml` through the same validation path, so initialization remains usable offline.
43
44 ## Key Files
45
46 - `helpers/model_config.py` owns preset validation, resolution, compatibility config shapes, and runtime model construction.
47 - `api/model_presets.py` owns global preset editing, scoped selection, and reference repair after rename/delete/reset.
48 - `extensions/python/startup_migration/_10_migrate_model_config.py` owns legacy conversion.
49 - `extensions/python/startup_migration/_20_bootstrap_model_presets.py` owns missing-collection initialization and plugin-local fallback.
50 - `webui/preset-overview.html` is the shared Settings/plugin-settings summary widget.
51 - `webui/main.html` is the preset editor.
52
53 ## Plugin Metadata
54
55 - Name: `_model_config`
56 - Settings section: `agent`
57 - Per-project config: `true`
58 - Per-agent config: `true`
59 - Always enabled: `true`