Skip to content

The agent that grows with you

fix(profile): an unparseable config never fails the post-clone memory notice

kshitijk4poorcd5375ac8beb
diff --git a/hermes_cli/profile_memory_config.py b/hermes_cli/profile_memory_config.py
index c9f87d8a9e6..9725cc056d3 100644
--- a/hermes_cli/profile_memory_config.py
+++ b/hermes_cli/profile_memory_config.py
@@ -67,7 +67,9 @@ def _load_config_dict(profile_dir: Path) -> Optional[dict]:
from hermes_cli.config_backend import read_config_doc
try:
data = read_config_doc(profile_dir / "config.yaml") or {}
- except (YAMLError, OSError, UnicodeError): # FileNotFoundError included: no config
+ # FileNotFoundError included (no config). ValueError: the YAML constructors raise it bare for
+ # values like ``2024-02-30`` / ``!!int abc``; this read is a best-effort notice and never fails a clone.
+ except (YAMLError, OSError, ValueError):
return None
return data if isinstance(data, dict) else None
diff --git a/tests/hermes_cli/test_profile_memory_config.py b/tests/hermes_cli/test_profile_memory_config.py
new file mode 100644
index 00000000000..ba515b6de65
--- /dev/null
+++ b/tests/hermes_cli/test_profile_memory_config.py
@@ -0,0 +1,30 @@
+"""cloned_memory_provider: a best-effort post-clone notice that never fails ``hermes profile create``."""
+
+import pytest
+
+from hermes_cli.profile_memory_config import cloned_memory_provider
+
+
+ "memory:\n provider: honcho\nwhen: 2024-02-30\n", # YAML constructor raises a bare ValueError
+ "memory: [unclosed\n", # YAMLError
+ b"memory:\n provider: \xff\n", # UnicodeDecodeError
+])
+def test_unreadable_config_means_no_notice(tmp_path, body):
+ (tmp_path / "honcho").mkdir()
+ path = tmp_path / "config.yaml"
+ if isinstance(body, bytes):
+ path.write_bytes(body)
+ else:
+ path.write_text(body, encoding="utf-8")
+ assert cloned_memory_provider(tmp_path) is None
+
+
+def test_missing_config_means_no_notice(tmp_path):
+ assert cloned_memory_provider(tmp_path) is None
+
+
+def test_configured_provider_with_copied_state_is_named(tmp_path):
+ (tmp_path / "honcho").mkdir()
+ (tmp_path / "config.yaml").write_text("memory:\n provider: honcho\n", encoding="utf-8")
+ assert cloned_memory_provider(tmp_path) == "honcho"