Skip to content

The agent that grows with you

fix(config): redirect platforms.<name>.<display_setting> to display.platforms.<name>.<setting>

Vibe Coderaf709b31ca88
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index af532c1199a..09fb268c524 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -5841,6 +5841,37 @@ def _coerce_float(value: str):
return f
+def _redirect_platform_display_key(key: str) -> tuple[str, Optional[str]]:
+ """Canonicalize ``platforms.<name>.<display_setting>`` → ``display.platforms.<name>.<setting>``.
+
+ Per-platform *display* settings (streaming, show_reasoning, tool_progress,
+ …) are resolved by the gateway from ``display.platforms.<name>.<setting>``
+ (``gateway/display_config.py::resolve_display_setting``), while the
+ top-level ``platforms.<name>`` block holds only connection config (token,
+ enabled, reply_to_mode, extra, …). Before #71047 a write such as
+ ``hermes config set platforms.telegram.streaming false`` landed on a key
+ the gateway never reads: ``config get`` echoed the new value back while
+ the runtime kept the old ``display.platforms`` one — a silent no-op that
+ looks like a duplicated key to the user.
+
+ Only known display settings (``OVERRIDEABLE_KEYS``) are redirected so real
+ connection keys stay put. Returns ``(canonical_key, note_or_None)``.
+ The gateway import is guarded: the CLI must keep working where the
+ gateway package is not importable.
+ """
+ segs = _split_key_path(key)
+ if len(segs) != 3 or segs[0] != "platforms":
+ return key, None
+ try:
+ from gateway.display_config import OVERRIDEABLE_KEYS as _display_keys
+ except Exception:
+ return key, None
+ if segs[2] not in _display_keys:
+ return key, None
+ canonical = f"display.platforms.{segs[1]}.{segs[2]}"
+ return canonical, f" (note: per-platform display setting — saved as {canonical})"
+
+
def set_config_value(key: str, value: str, force: bool = False):
"""Set a configuration value.
@@ -5906,6 +5937,12 @@ def set_config_value(key: str, value: str, force: bool = False):
# bare success and left the user debugging behavior that never changed.
# Warn after the write so the user gets immediate feedback plus a
# "did you mean" hint, without blocking legitimate unknown keys.
+ # Per-platform display settings live under display.platforms (#71047,
+ # Problem A) — canonicalize BEFORE validation/coercion so the type-aware
+ # coercion and the unknown-key hint both see the path the runtime reads.
+ key, _redirect_note = _redirect_platform_display_key(key)
+ if _redirect_note:
+ print(_redirect_note)
is_known, suggestion = _validate_config_key(key)
# Otherwise it goes to config.yaml
@@ -6121,6 +6158,9 @@ def get_config_value(key: str, *, as_json: bool = False):
env_value = get_env_value(key.upper())
value = _MISSING if env_value is None else env_value
else:
+ # Mirror set_config_value: read the canonical display.platforms path
+ # so ``config get`` reports what the gateway resolves (#71047).
+ key, _ = _redirect_platform_display_key(key)
value = _get_nested(load_config(), key)
if value is _MISSING:
@@ -6166,6 +6206,10 @@ def unset_config_value(key: str):
# refuse-write); returns the mapping so we do not re-parse / collapse.
user_config = require_readable_config_before_write(config_path)
+ # Mirror set_config_value's display.platforms canonicalization (#71047).
+ key, _redirect_note = _redirect_platform_display_key(key)
+ if _redirect_note:
+ print(_redirect_note.replace("saved as", "resolved as"))
removed = _unset_nested(user_config, key)
# Keep .env in sync for keys that terminal_tool reads directly from env vars.
diff --git a/tests/hermes_cli/test_config_set_platforms_redirect.py b/tests/hermes_cli/test_config_set_platforms_redirect.py
new file mode 100644
index 00000000000..d4b83876aab
--- /dev/null
+++ b/tests/hermes_cli/test_config_set_platforms_redirect.py
@@ -0,0 +1,95 @@
+"""Regression tests for #71047 (Problem A): per-platform display settings.
+
+`hermes config set platforms.<name>.<display_setting> <value>` must write to
+`display.platforms.<name>.<display_setting>` — the path the gateway actually
+reads (gateway/display_config.py::resolve_display_setting). Writing to the
+top-level `platforms.<name>` block is silently ignored by the runtime, so the
+edit appeared to succeed while having no effect.
+"""
+
+from pathlib import Path
+
+import pytest
+import yaml
+
+
+def _write_config(hermes_home: Path, data: dict) -> Path:
+ hermes_home.mkdir(parents=True, exist_ok=True)
+ config_path = hermes_home / "config.yaml"
+ config_path.write_text(yaml.dump(data))
+ return config_path
+
+
+def _set(monkeypatch, hermes_home, key, value, force=False):
+ """Isolated call to set_config_value against a temp HERMES_HOME."""
+ monkeypatch.setenv("HERMES_HOME", str(hermes_home))
+ # set_config_value resolves the home live via get_config_path()/get_hermes_home()
+ from hermes_cli.config import set_config_value
+ set_config_value(key, value, force=force)
+
+
+def hermes_home(tmp_path, monkeypatch):
+ home = tmp_path / ".hermes"
+ # A config that already has a top-level platforms block (connection keys)
+ # AND a display.platforms block, mirroring the real-world report.
+ cfg = {
+ "model": {"default": "test-model", "provider": "openrouter"},
+ "platforms": {
+ "telegram": {"token": "secret-bot-token"},
+ },
+ "display": {
+ "skin": "default",
+ "platforms": {
+ "telegram": {"show_reasoning": True},
+ },
+ },
+ }
+ _write_config(home, cfg)
+ return home
+
+
+class TestPerPlatformDisplayRedirect:
+ def test_streaming_redirects_to_display_platforms(self, hermes_home, monkeypatch):
+ """platforms.telegram.streaming must land under display.platforms."""
+ _set(monkeypatch, hermes_home, "platforms.telegram.streaming", "false")
+
+ result = yaml.safe_load((hermes_home / "config.yaml").read_text())
+ # Redirected target exists and is correct
+ assert result["display"]["platforms"]["telegram"]["streaming"] is False
+ # Top-level platforms.telegram must NOT gain a streaming key
+ assert "streaming" not in result["platforms"]["telegram"]
+ # Connection key untouched
+ assert result["platforms"]["telegram"]["token"] == "secret-bot-token"
+
+ def test_show_reasoning_redirects(self, hermes_home, monkeypatch):
+ _set(monkeypatch, hermes_home, "platforms.telegram.show_reasoning", "false")
+ result = yaml.safe_load((hermes_home / "config.yaml").read_text())
+ assert result["display"]["platforms"]["telegram"]["show_reasoning"] is False
+
+ def test_tool_progress_redirects(self, hermes_home, monkeypatch):
+ # ``off`` is coerced to False by the bool-aware coercion in
+ # set_config_value; gateway/display_config._normalise turns False back
+ # into the canonical "off" string at read time, so the persisted value
+ # is the bool.
+ _set(monkeypatch, hermes_home, "platforms.discord.tool_progress", "off")
+ result = yaml.safe_load((hermes_home / "config.yaml").read_text())
+ assert result["display"]["platforms"]["discord"]["tool_progress"] is False
+
+ def test_connection_key_not_redirected(self, hermes_home, monkeypatch):
+ """A real connection key (token) stays in top-level platforms.<name>."""
+ _set(monkeypatch, hermes_home, "platforms.telegram.token", "new-token")
+ result = yaml.safe_load((hermes_home / "config.yaml").read_text())
+ assert result["platforms"]["telegram"]["token"] == "new-token"
+ # Nothing leaked into display.platforms.telegram.token
+ assert "token" not in result["display"]["platforms"]["telegram"]
+
+ def test_no_top_level_platforms_created_when_missing(self, tmp_path, monkeypatch):
+ """When there is no pre-existing top-level platforms block, a display
+ setting write must not invent one."""
+ home = tmp_path / ".hermes"
+ _write_config(home, {"model": {"default": "m"}})
+ _set(monkeypatch, home, "platforms.telegram.streaming", "true")
+ result = yaml.safe_load((home / "config.yaml").read_text())
+ assert result["display"]["platforms"]["telegram"]["streaming"] is True
+ assert "platforms" not in result # no stray top-level platforms block