Skip to content

The agent that grows with you

refactor(config): the remaining version-or-None sites use config_version_or_none

kshitijk4poor7651d401447e
diff --git a/agent/moa_loop.py b/agent/moa_loop.py
index ff0d1400375..d33b46a6d2a 100644
--- a/agent/moa_loop.py
+++ b/agent/moa_loop.py
@@ -126,11 +126,8 @@ def _resolve_preset_cached(preset_name: str) -> tuple[dict[str, Any], Any]:
(skips resolve_moa_preset's full validation of the moa block on every create())."""
from hermes_cli.config import get_config_path, load_config
from hermes_cli.moa_config import resolve_moa_preset
- from hermes_cli.config_backend import config_version
- try:
- cfg_stamp = config_version(get_config_path())
- except OSError:
- cfg_stamp = None
+ from hermes_cli.config_backend import config_version_or_none
+ cfg_stamp = config_version_or_none(get_config_path())
moa_raw = load_config().get("moa") or {}
key = (cfg_stamp, preset_name)
with _preset_cache_lock:
diff --git a/agent/skill_utils.py b/agent/skill_utils.py
index a829436603c..03c087c4ed4 100644
--- a/agent/skill_utils.py
+++ b/agent/skill_utils.py
@@ -210,11 +210,9 @@ def _raw_config_cache_clear() -> None:
def _config_cache_key(config_path: Path) -> Optional[tuple[str, int, int, int, int]]:
"""``(path, *backend version)`` identity of config.yaml, or None when unreadable/absent."""
- try:
- from hermes_cli.config_backend import config_version
- return (str(config_path), *config_version(config_path))
- except OSError:
- return None
+ from hermes_cli.config_backend import config_version_or_none
+ version = config_version_or_none(config_path)
+ return None if version is None else (str(config_path), *version)
def _load_raw_config() -> dict[str, Any]:
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index 772946da562..f2a0e49fa61 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -864,7 +864,7 @@ class CLIInfoMixin:
cache** (the next message re-sends the full input prefix, expensive on long-context / high-reasoning
models). See #1474.
"""
- from hermes_cli.config_backend import config_exists, config_version, read_config_doc
+ from hermes_cli.config_backend import config_version_or_none, read_config_doc
now = time.monotonic()
if now - self._last_config_check < CONFIG_WATCH_INTERVAL:
@@ -873,11 +873,8 @@ class CLIInfoMixin:
from hermes_cli.config import get_config_path as _get_config_path
cfg_path = _get_config_path()
- if not config_exists(cfg_path):
- return
- try:
- sig = config_version(cfg_path)
- except OSError:
+ sig = config_version_or_none(cfg_path)
+ if sig is None:
return
if sig == self._config_sig:
return # unchanged — fast path
diff --git a/tests/hermes_cli/test_config_backend.py b/tests/hermes_cli/test_config_backend.py
index f9a78566bca..4bded8a61f9 100644
--- a/tests/hermes_cli/test_config_backend.py
+++ b/tests/hermes_cli/test_config_backend.py
@@ -75,6 +75,7 @@ class TestFileBackend:
assert cb.version_token(version) == version[0] / 1_000_000_000 > 0
# An opaque non-file version still yields a stable non-zero number.
assert cb.version_token(("etag-1",)) == cb.version_token(("etag-1",)) != 0
+ assert cb.version_token(("etag-1",)) != cb.version_token(("etag-2",))
def test_read_version_and_bom(self, home):
path = home / "config.yaml"