Skip to content

The agent that grows with you

fix: install-time config loads work from hermes_cli alone; upgrade probe tolerates extras

teknium1d2b1b8989bd2
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index adf44ade719..a2415e91a47 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -1938,10 +1938,21 @@ def _raw_config_cache_hit(path_key: str, cache_key: Tuple[Any, ...]) -> Optional
return None
-def _read_raw_config_impl(*, want_deepcopy: bool) -> Dict[str, Any]:
- from agent.safe_worker_policy import worker_config_snapshot
+def _worker_config_snapshot() -> Optional[Dict[str, Any]]:
+ """A safe worker's frozen config, or None. Install-time loads run from ``hermes_cli`` alone
+ (the installer's completion step ships no ``agent`` package), and without ``agent`` there
+ is no worker policy to consult."""
+ try:
+ from agent.safe_worker_policy import worker_config_snapshot
+ except ModuleNotFoundError as exc:
+ if exc.name != "agent":
+ raise
+ return None
+ return worker_config_snapshot()
+
- snapshot = worker_config_snapshot()
+def _read_raw_config_impl(*, want_deepcopy: bool) -> Dict[str, Any]:
+ snapshot = _worker_config_snapshot()
if snapshot is not None:
return snapshot
@@ -2024,9 +2035,7 @@ def require_readable_config_before_write(config_path: Optional[Path] = None) ->
non-mapping root — bare-``except`` loaders treat both as ``{}``, so a subsequent write would
replace the recoverable file with only the caller's partial dict. Fails closed."""
if config_path is None:
- from agent.safe_worker_policy import worker_config_snapshot
-
- snapshot = worker_config_snapshot()
+ snapshot = _worker_config_snapshot()
if snapshot is not None:
# A bypass worker's config IS its frozen snapshot; it never reads the profile file.
return copy.deepcopy(snapshot)
@@ -2297,9 +2306,7 @@ def _load_config_cache_hit(path_key: str, cache_sig: Any) -> Optional[Dict[str,
def _load_config_impl(*, want_deepcopy: bool) -> Dict[str, Any]:
- from agent.safe_worker_policy import worker_config_snapshot
-
- snapshot = worker_config_snapshot()
+ snapshot = _worker_config_snapshot()
if snapshot is not None:
return _deep_merge(copy.deepcopy(DEFAULT_CONFIG), snapshot)
@@ -2503,11 +2510,9 @@ def load_env() -> Dict[str, str]:
"""Load ~/.hermes/.env as a dict. Memoised inside ``load_env_file`` (``get_env_value()`` runs
hundreds of times per interactive menu render). Each assignment's value is opaque data for
boundary discovery."""
- from agent.safe_worker_policy import worker_config_snapshot
-
# A frozen-policy worker never opens the profile's files; its secrets arrive
# through the owner-installed scope, so the .env layer is empty here.
- if worker_config_snapshot() is not None:
+ if _worker_config_snapshot() is not None:
return {}
from agent.secret_scope import load_env_file # the one .env tokenizer; also installs profile scopes
diff --git a/tests/e2e/core/upgrade/test_upgrade_path.py b/tests/e2e/core/upgrade/test_upgrade_path.py
index 4afdf00ac2f..7885be1f735 100644
--- a/tests/e2e/core/upgrade/test_upgrade_path.py
+++ b/tests/e2e/core/upgrade/test_upgrade_path.py
@@ -142,6 +142,9 @@ for name in tops + ["hermes_cli.main", "run_agent", "hermes_state"] + added:
try:
mod = importlib.import_module(name)
except BaseException as exc:
+ missing = (getattr(exc, "name", None) or "").split(".")[0]
+ if name in added and isinstance(exc, ModuleNotFoundError) and missing and missing not in tops:
+ continue # an optional extra's SDK (e.g. acp); a stale finder misses the module itself
bad.append(f"{name}: {type(exc).__name__}: {exc}")
continue
where = Path(getattr(mod, "__file__", None) or str(list(getattr(mod, "__path__", [""]))[0])).resolve()