From f46542b6c6fb176275d028161b4b11e64ac3672f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 25 Mar 2026 18:38:32 -0700 Subject: [PATCH] fix(cli): read root-level provider and base_url from config.yaml into model config (#3112) When users write root-level provider and base_url in config.yaml (instead of nesting under model:), these keys were never merged into defaults['model']. The CLI reads them from CLI_CONFIG['model']['provider'] so root-level keys were silently ignored, causing fallback to OpenRouter. Merge root-level provider and base_url into defaults['model'] after handling the model key, so custom/local provider configs work regardless of nesting. Cherry-picked from PR #2283 by ygd58. Fixes #2281. --- cli.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli.py b/cli.py index 3dc019f5..7f712d70 100644 --- a/cli.py +++ b/cli.py @@ -261,6 +261,18 @@ def load_cli_config() -> Dict[str, Any]: elif isinstance(file_config["model"], dict): # Old format: model is a dict with default/base_url defaults["model"].update(file_config["model"]) + + # Root-level provider and base_url override model config. + # Users may write: + # model: kimi-k2.5:cloud + # provider: custom + # base_url: http://localhost:11434/v1 + # These root-level keys must be merged into defaults["model"] so + # they are picked up by CLI provider resolution. + if "provider" in file_config and file_config["provider"]: + defaults["model"]["provider"] = file_config["provider"] + if "base_url" in file_config and file_config["base_url"]: + defaults["model"]["base_url"] = file_config["base_url"] # Deep merge file_config into defaults. # First: merge keys that exist in both (deep-merge dicts, overwrite scalars)