From 3ba67fd7bd0837c76835a5c7d347d6319e924079 Mon Sep 17 00:00:00 2001 From: Baophan00 <109447498+Baophan00@users.noreply.github.com> Date: Fri, 31 Jul 2026 20:17:22 +0700 Subject: [PATCH] fix(config): preserve scalar model id when setting model sub-keys When model is a bare scalar (e.g. 'model: gpt-4o'), running 'hermes config set model.provider openai' silently destroyed the model id because _set_nested replaced the scalar with an empty dict before writing the sub-key. Now the scalar is normalized to {default: } first, preserving the model id. --- hermes_cli/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index 14c64481ff2b4..8419ba25f99f4 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -4860,6 +4860,16 @@ def set_config_value(key: str, value: str, force: bool = False): coerced_value = float(value) value = coerced_value + # Normalize a scalar ``model`` key before writing sub-keys so that + # ``hermes config set model.provider openai`` doesn't silently + # destroy the model id when ``model`` is a bare string shorthand + # (e.g. ``model: gpt-4o``). Without this _set_nested replaces the + # scalar with an empty dict, dropping the model id permanently. + _model_key = key.strip().lower() + if _model_key.startswith("model."): + _model_val = user_config.get("model") + if isinstance(_model_val, str) and _model_val: + user_config["model"] = {"default": _model_val} # Guard against #74995: a single-segment key that names an existing # mapping would silently overwrite the entire section with a scalar # (e.g. ``hermes config set model gpt-5.6-sol`` when model already