Skip to content

The agent that grows with you

fix(config): preserve scalar model id when setting model sub-keys

Baophan003ba67fd7bd08
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 14c64481ff2..8419ba25f99 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