Skip to content

The agent that grows with you

fix(config): parse list/mapping literals in hermes config set

Sam Liu6f2a4676a9bf
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index cd226a92ad3..2b638305d58 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -5292,6 +5292,33 @@ def set_config_value(key: str, value: str, force: bool = False):
coerced_value = int(value)
elif value.replace('.', '', 1).isdigit():
coerced_value = float(value)
+ elif value.lstrip()[:1] in ('[', '{'):
+ # List/mapping literals -- e.g.
+ # hermes config set platform_toolsets.line '["file","web"]'
+ # Without this, such values were stored as a raw STRING, and every
+ # reader that gates on isinstance(..., list) (``_get_platform_tools``,
+ # ``_get_enabled_set``, ...) silently ignored them and fell back to
+ # its default -- the setting looked saved but never took effect.
+ # Folded INSIDE the string-typed guard so a genuinely string-typed
+ # setting whose value merely starts with '[' or '{' is left intact
+ # (preserves the guard added in e4ea0a0ed).
+ try:
+ parsed = yaml.safe_load(value)
+ if isinstance(parsed, (list, dict)):
+ coerced_value = parsed
+ else:
+ print(
+ f"Warning: value for '{key}' looks like a list/mapping but "
+ f"parsed as {type(parsed).__name__}; storing as string.",
+ file=sys.stderr,
+ )
+ except yaml.YAMLError:
+ print(
+ f"Warning: value for '{key}' looks like a list/mapping but is "
+ f"not valid YAML/JSON; storing as string. Most isinstance-gated "
+ f"readers will ignore a string here.",
+ file=sys.stderr,
+ )
value = coerced_value
# Normalize a scalar ``model`` key before writing sub-keys so that
diff --git a/tests/hermes_cli/test_config_set_list_values.py b/tests/hermes_cli/test_config_set_list_values.py
new file mode 100644
index 00000000000..1dff8290072
--- /dev/null
+++ b/tests/hermes_cli/test_config_set_list_values.py
@@ -0,0 +1,71 @@
+"""``hermes config set`` must parse list/mapping literals, not store them as strings.
+
+Before this fix, ``hermes config set platform_toolsets.discord '["file","web"]'``
+stored the value as a raw STRING. Every reader that gates on
+``isinstance(..., list)`` — ``_get_platform_tools``, ``_get_enabled_set``,
+``_get_disabled_set`` — then silently ignored it and fell back to its default,
+so the setting looked saved but never took effect (observed in the wild as a
+platform running on the wrong toolset bundle for weeks).
+"""
+import pytest
+
+
+def user_home(tmp_path, monkeypatch):
+ home = tmp_path / "home"
+ home.mkdir()
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ monkeypatch.delenv("HERMES_MANAGED_DIR", raising=False)
+ import hermes_cli.config as cfg
+ from hermes_cli import managed_scope
+
+ cfg._LOAD_CONFIG_CACHE.clear()
+ cfg._RAW_CONFIG_CACHE.clear()
+ managed_scope.invalidate_managed_cache()
+ return home
+
+
+def test_list_literal_is_parsed_to_list(user_home):
+ from hermes_cli.config import set_config_value, read_raw_config
+
+ set_config_value("platform_toolsets.line", '["clarify", "file", "web"]')
+ raw = read_raw_config()
+ assert raw["platform_toolsets"]["line"] == ["clarify", "file", "web"]
+
+
+def test_mapping_literal_is_parsed_to_dict(user_home):
+ from hermes_cli.config import set_config_value, read_raw_config
+
+ set_config_value("display.tool_progress_overrides", '{"terminal": "off"}')
+ raw = read_raw_config()
+ assert raw["display"]["tool_progress_overrides"] == {"terminal": "off"}
+
+
+def test_yaml_flow_list_is_parsed(user_home):
+ from hermes_cli.config import set_config_value, read_raw_config
+
+ set_config_value("plugins.enabled", "[model-providers/gemini]")
+ raw = read_raw_config()
+ assert raw["plugins"]["enabled"] == ["model-providers/gemini"]
+
+
+def test_invalid_list_literal_warns_and_stores_string(user_home, capsys):
+ from hermes_cli.config import set_config_value, read_raw_config
+
+ set_config_value("platform_toolsets.line", '["unclosed')
+ captured = capsys.readouterr()
+ assert "not valid" in captured.err.lower() or "warning" in captured.err.lower()
+ raw = read_raw_config()
+ assert raw["platform_toolsets"]["line"] == '["unclosed'
+
+
+def test_scalar_values_unaffected(user_home):
+ from hermes_cli.config import set_config_value, read_raw_config
+
+ set_config_value("agent.max_turns", "300")
+ set_config_value("display.compact", "true")
+ set_config_value("tts.provider", "edge")
+ raw = read_raw_config()
+ assert raw["agent"]["max_turns"] == 300
+ assert raw["display"]["compact"] is True
+ assert raw["tts"]["provider"] == "edge"
diff --git a/website/docs/user-guide/configuring-models.md b/website/docs/user-guide/configuring-models.md
index a14b345dae0..422cdc57a3b 100644
--- a/website/docs/user-guide/configuring-models.md
+++ b/website/docs/user-guide/configuring-models.md
@@ -288,13 +288,20 @@ model_aliases:
provider: x-ai
```
-**Short string form (`model.aliases.<name>: provider/model`)** — convenient from the shell because `hermes config set` only writes scalar values, but it can't carry a custom `base_url`:
+**Short string form (`model.aliases.<name>: provider/model`)** — convenient from the shell because `hermes config set` writes scalars and now also parses inline list/mapping literals, though this short alias form still can't carry a custom `base_url`:
```bash
hermes config set model.aliases.fav anthropic/claude-opus-4.6
hermes config set model.aliases.grok x-ai/grok-4
```
+> `hermes config set` also accepts inline **list/mapping literals** (JSON/YAML flow style). Quote them so your shell passes them through intact:
+>
+> ```bash
+> hermes config set platform_toolsets.line '["clarify", "file", "web"]'
+> hermes config set display.tool_progress_overrides '{"terminal": "off"}'
+> ```
+
Both paths feed the same loader (`hermes_cli/model_switch.py`). Entries declared in `model_aliases:` take precedence over `model.aliases:` entries with the same name.
Then `/model fav` or `/model grok` in chat. User aliases shadow built-in short names (`sonnet`, `kimi`, `opus`, etc.). See [Custom model aliases](/reference/slash-commands#custom-model-aliases) for the full reference.