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: <id>} first, preserving the model id.
This commit is contained in:
Baophan00 2026-07-31 20:17:22 +07:00 committed by Teknium
parent 6989a79745
commit 3ba67fd7bd
1 changed files with 10 additions and 0 deletions

View File

@ -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