A Practical Guide to Layered Agent Model Configuration

    An agent can show as configured in a setup wizard and still fall back to an unknown or empty model at chat time. This guide separates what was written to disk from what the running process actually loads, and explains how five configuration layers combine—primary model, task routing, provider profiles, environment and secrets, and runtime overrides—plus a typical failure path, a sample layout, and a verification checklist.

    An agent can show as “configured” in the setup wizard and still fall back to an unknown or empty model when you chat. The UI only reflects whether the last write succeeded. It does not guarantee that the runtime reads the same configuration. For a stable setup, treat “written to a file” and “actually adopted by the process” as separate questions, and understand how several configuration layers stack.

    Where configuration lives

    On a desktop, an agent usually stores state in the current user’s local application data directory, not in the install directory. Upgrades then do not overwrite personal settings, and multiple users do not contaminate one another. The core is typically two text files: one structured main configuration, and one environment-variable file.

    The structured main configuration is usually a hierarchical text format. It fits nested objects: the default model, provider, API root, call mode, timeouts, and routing rules can live in one tree. The environment file is plain key-value text, reserved for secrets, proxy addresses, and parameters that differ on a given machine. Splitting secrets from structure lets you back up the configuration skeleton without spreading secrets with it.

    Edit either file in any plain-text editor. Save as UTF-8 without a BOM, and do not mix spaces and tabs for indentation. Hierarchical formats are indentation-sensitive; one wrong level can drop a whole section or fail the parse.

    What each of the five layers controls

    The first layer is the primary model: the model identifier used by default for everyday chat, the provider alias, the API root, the call mode, and a reference to the key. The main chat path almost always reads this layer first. Prefer a stable identifier such as “provider-namespace/model-name” rather than a short name the gateway cannot route. The call mode must match the gateway’s actual protocol. Chat completions and a streaming-events interface are not the same field set. If the mode is wrong, the process may silently fall back to an unnamed model.

    The second layer is task routing. Code completion, long-form summarization, tool calls, and low-cost chat often should not share one model. A routing table points task type or context length at different model identifiers. The primary model is only the default. Once a task hits a more specific rule, the primary model is not used. If you change only the primary model and still see the old behavior, routing is often still pointing elsewhere.

    The third layer is the provider profile. The same model identifier can map to several endpoints: an official-compatible gateway, an internal corporate forwarder, or a metered plan entry. The profile records the root URL, the auth-header style, and whether an extra path prefix is required. The root should include the scheme and version segment. Whether a trailing slash is kept must match how the client concatenates paths. Otherwise the request hits the wrong path and is treated as “model not found.”

    The fourth layer is environment variables and secret resolution. The main configuration can hold a placeholder reference; the real secret lives in the environment file or the system environment. At startup the process loads the environment first, then resolves references in the main configuration. If the UI wrote the main configuration, but the service was started from another working directory or another user, it reads a different environment file. The result looks like an empty key and an unknown provider. After you change a plan or rotate a key, confirm that the process that is actually running reloaded the new value—not only the copy open in the editor.

    The fifth layer is runtime override: a one-shot command-line argument, a temporary switch for the current session, or a default written back by an admin command. An explicit temporary override has the highest priority, but it usually is not persisted. If an admin command changes only memory, or only one key segment, a restart returns to the old value in the file. When debugging, separate “this session” from “the next start.”

    A useful priority order is: an explicit runtime setting, then a matching task-routing entry, then the primary-model default. For the same field, a loaded environment variable overrides a plaintext placeholder in the file. If a later fragment is deep-merged, keys that do not appear keep their old values, so changing one line does not clear historical routes.

    A typical failure path

    A common sequence is: the wizard reports success, but the screenshot shows an unknown model name; an admin command suggested by the logs resets the default model, and chat still fails; the primary-model field is edited again and again while routing and the environment are ignored. A subtler case appears after an upgrade: the client no longer accepts a certain plan endpoint or an old call mode. An old machine still works because it cached the old version; a fresh install fails. Check first whether the root URL, call mode, and auth style are still supported by the current version, instead of pasting the same key repeatedly.

    Another difference comes from the plan itself. Some endpoints expose only a subset of models, or reject multi-turn tool-calling clients such as agents. With only one plan you cannot compare, so do not rush to call it a client defect. Verify with a minimal request: fix the model identifier, root URL, and call mode, send the shortest possible chat turn, and see whether the response is an auth failure, “model not found,” or a protocol field mismatch. For an auth failure, check where the key comes from. For a missing model, check the identifier and routing. For a protocol mismatch, check the call mode and path concatenation.

    Sample configuration

    The fields below show roles only. They are not a proprietary interface for any one product. Replace them with the identifiers and addresses you actually use.

    1. model:
    2. default: example-provider/example-model
    3. provider: primary
    4. base_url: https://api.example.invalid/v1
    5. api_key: ${MODEL_API_KEY}
    6. api_mode: chat_completions
    7. routing:
    8. - task: tool_call
    9. model: example-provider/example-model
    10. - task: summary
    11. model: example-provider/lighter-model
    12. providers:
    13. primary:
    14. base_url: https://api.example.invalid/v1
    15. api_mode: chat_completions

    Put the secret in the environment file, for example MODEL_API_KEY=replace-with-your-key, and do not commit it to version control. If the main configuration contains both a plaintext key and a reference, the merge rule of your implementation decides which wins. The safer practice is to keep only the reference in the main configuration.

    Checklist before you rely on it

    Before editing, copy the main configuration and the environment file, and confirm the process working directory and the user it runs as. After the change, fully quit and start again so an old process is not still holding the old environment. In the startup log, read the resolved model identifier, provider, and call mode—not only the wizard checkbox. Confirm that task routing does not send chat to an empty model. Verify the main path with a short turn that uses no tools, then verify the tool-call path. After a key rotation, search for a second environment file. After a client upgrade, check the current version’s documentation for call-mode changes; do not blindly overwrite with the whole file from an old machine.

    Security and collaboration

    The configuration directory often contains secrets. Redact them before you package logs or send them to someone else for analysis. The sample address uses an obviously invalid domain so it is not accidentally pointed at production. When a team shares configuration, share only the structural skeleton and the routing policy; each person injects secrets locally. If model inference or the gateway runs in the cloud, put the root URL and authentication on a single egress point and leave the client with a reference only, which makes rotation and audit easier.

    Treat agent model configuration as five stacked layers, not one form field. Unknown models and “the command changed it but nothing happened” then have a fixed order of checks: which file the process actually reads, whether routing overrides the primary model, and finally whether the provider root, call mode, and key all came from the same load.