Skip to content

The agent that grows with you

fix(config-remote): config set/unset name Remote Config, not a config.yaml that is never written

Ben Barclay2e361061710d
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 2d6493235a7..3dcaffe7e89 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -47,8 +47,9 @@ from hermes_constants import get_hermes_home, get_process_hermes_home
from utils import atomic_replace, fast_safe_load, file_cache_version, file_signature, mkstemp_beside
from hermes_cli.config_issues import ConfigIssue, _issue
from hermes_cli.config_backend import (
- ConfigWriteError, config_cache_version, config_exists, config_version, get_config_backend,
- probe_config_readable, read_config_doc, supports_file_tooling, write_config_document)
+ ConfigWriteError, config_cache_version, config_destination, config_exists, config_version,
+ get_config_backend, probe_config_readable, read_config_doc, supports_file_tooling,
+ write_config_document)
from hermes_cli.config_read_errors import (
_CONFIG_PARSE_FAILURES, _FIX_PERMS, _FIX_YAML, FailedConfigRead, _backups_dir_display,
_refuse_failed_read, _refuse_overwrite, _warn_config_parse_failure, _yaml_error_details,
@@ -3451,7 +3452,7 @@ def set_config_value(key: str, value: str, force: bool = False):
if _is_secret_config_key(key) and isinstance(value, str) and value:
from agent.redact import mask_secret
_display_value = mask_secret(value)
- print(f"✓ Set {key} = {_display_value} in {config_path}")
+ print(f"✓ Set {key} = {_display_value} in {config_destination(config_path)}")
if _route_notice:
print(_route_notice)
@@ -3568,7 +3569,7 @@ def unset_config_value(key: str):
_exit_invalid(f"Config key not set: {key}")
_write_user_config(config_path, user_config)
- print(f"✓ Unset {key} from {config_path}")
+ print(f"✓ Unset {key} from {config_destination(config_path)}")
# ---- Command handler ----
diff --git a/hermes_cli/config_backend.py b/hermes_cli/config_backend.py
index ce20702cd09..7b1976883f4 100644
--- a/hermes_cli/config_backend.py
+++ b/hermes_cli/config_backend.py
@@ -106,6 +106,10 @@ class ConfigBackend(Protocol):
"""One line naming where the user layer comes from and its state (status line, doctor)."""
...
+ def destination(self, home: Path) -> str:
+ """Where a write lands, for a user-facing "saved in ..." line (no state, no network)."""
+ ...
+
class ConfigBackendUnavailable(SystemExit):
"""The selected backend cannot serve config. A ``SystemExit`` on purpose: many config readers
@@ -225,6 +229,9 @@ class FileBackend:
def describe(self, home: Path) -> str:
return str(self.config_path(home))
+ def destination(self, home: Path) -> str:
+ return str(self.config_path(home))
+
_FILE_BACKEND = FileBackend()
# Reentrant: publishing the deployment can import modules whose import-time config read selects
@@ -388,6 +395,13 @@ def write_config_document(config_path: PathLike, document: dict, *, extra_conten
backend.write_changes(home, Changes(document=document, extra_content_on_create=extra_content_on_create))
+def config_destination(config_path: PathLike) -> str:
+ """Where a write to *config_path* lands, for "✓ Set ... in <here>" lines: the file path for
+ the file backend and explicit files, the backend's own name for the user layer otherwise."""
+ backend, target, is_layer = _route(config_path)
+ return backend.destination(target) if is_layer else str(target)
+
+
def write_config_key(config_path: PathLike, key_path: str, value: Any) -> None:
"""Set one dotted key (``None`` removes it) — ``atomic_roundtrip_yaml_update`` semantics."""
write_config_keys(config_path, {key_path: value})
diff --git a/plugins/config_backends/remote/backend.py b/plugins/config_backends/remote/backend.py
index 3b6781777d9..83fad2b6611 100644
--- a/plugins/config_backends/remote/backend.py
+++ b/plugins/config_backends/remote/backend.py
@@ -687,6 +687,9 @@ class RemoteBackend:
logger.warning(msg)
print(msg, file=sys.stderr)
+ def destination(self, home: Path) -> str:
+ return f"Remote Config (profile {self._profile_for(home)!r} level)"
+
def describe(self, home: Path) -> str:
st = self._states.get(self._key(home))
head = f"Remote Config {client.base_url()} (instance {client.instance_id() or '<unset>'})"
diff --git a/tests/plugins/config_backends/test_config_set_destination.py b/tests/plugins/config_backends/test_config_set_destination.py
new file mode 100644
index 00000000000..7e1e104f8ed
--- /dev/null
+++ b/tests/plugins/config_backends/test_config_set_destination.py
@@ -0,0 +1,67 @@
+"""`hermes config set/unset` name where the write actually landed.
+
+Remote mode writes the profile level of Remote Config and never a local config.yaml, so the
+success line must not point at ``<home>/config.yaml``; the file backend keeps printing the path.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from plugins.config_backends import remote as remote_pkg
+from plugins.config_backends.remote import backend as backend_mod
+from plugins.config_backends.remote import credentials as cred_mod
+
+from .stub_plane import StubPlane, remote_env
+
+
+def plane(tmp_path, monkeypatch):
+ home = Path(tmp_path) / "home"
+ home.mkdir()
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ with StubPlane() as p:
+ for k, v in remote_env(p).items():
+ monkeypatch.setenv(k, v)
+ monkeypatch.setattr(backend_mod, "BOOT_RETRY_DELAYS", (0.0, 0.0))
+ remote_pkg._reset_for_tests()
+ cred_mod._IDP_CACHE.clear()
+ p.home = home
+ yield p
+ remote_pkg._reset_for_tests()
+ cred_mod._IDP_CACHE.clear()
+
+
+def file_home(tmp_path, monkeypatch):
+ home = Path(tmp_path) / "home"
+ home.mkdir()
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ monkeypatch.delenv("HERMES_CONFIG_BACKEND", raising=False)
+ return home
+
+
+def test_remote_set_and_unset_name_remote_config_not_a_local_file(plane, capsys):
+ from hermes_cli.config import set_config_value, unset_config_value
+
+ set_config_value("agent.max_turns", "7")
+ unset_config_value("agent.max_turns")
+
+ out = capsys.readouterr().out
+ assert "✓ Set agent.max_turns = 7 in Remote Config (profile 'default' level)" in out
+ assert "✓ Unset agent.max_turns from Remote Config (profile 'default' level)" in out
+ assert "config.yaml" not in out
+ assert not (plane.home / "config.yaml").exists()
+
+
+def test_file_set_and_unset_still_print_the_config_path(file_home, capsys):
+ from hermes_cli.config import set_config_value, unset_config_value
+
+ set_config_value("agent.max_turns", "7")
+ unset_config_value("agent.max_turns")
+
+ out = capsys.readouterr().out
+ path = file_home / "config.yaml"
+ assert f"✓ Set agent.max_turns = 7 in {path}\n" in out
+ assert f"✓ Unset agent.max_turns from {path}\n" in out