Skip to content

The agent that grows with you

fix(config): meet the code-health ratchet and keep pm's runtime tree off the YAML stack

kshitijk4poorab3e4affd626
diff --git a/gateway/run.py b/gateway/run.py
index b1f214c65cb..c063e4f4140 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -43,7 +43,8 @@ from agent.interrupt_compat import request_hard_interrupt
from agent.message_metadata import ABSORBED_MESSAGE_UIDS, MESSAGE_UID, copy_identity_fields, is_compaction_scaffolding, scaffolding_replay_fields
from agent.turn_context import compression_made_progress
from agent.session_activity import ActivityProvenance, AwakeIdleMeter
-from hermes_cli.config import _is_ssh_remote_tilde_cwd, cfg_get
+from hermes_cli.config import _is_ssh_remote_tilde_cwd, cfg_get, config_exists
+from gateway.run_common import _csv_or_list_to_set
from hermes_cli.fallback_config import pre_agent_fallback_notice
from gateway.turn_executor import _UnboundedThreadExecutor
@@ -1182,15 +1183,6 @@ def _uses_telegram_observed_group_context(channel_prompt: Optional[str]) -> bool
return bool(channel_prompt and _TELEGRAM_OBSERVED_CONTEXT_PROMPT_MARKER in channel_prompt)
-def _csv_or_list_to_set(raw: Any) -> set[str]:
- """Normalize a config list or comma-separated scalar into a string set."""
- if raw is None:
- return set()
- if isinstance(raw, list):
- return {str(part).strip() for part in raw if str(part).strip()}
- return {part.strip() for part in str(raw).split(",") if part.strip()}
-
-
def _slack_ignored_channels_from_gateway_config(config: Any, adapter: Any = None) -> set[str]:
"""Return Slack channels that the generic gateway must never dispatch.
@@ -1601,7 +1593,6 @@ def _bridge_max_turns_from_config(home: Path) -> None:
"""Re-bridge agent.max_turns (+ sessions.*) per turn; managed overlay applies or it reverts.
Skipped inside a served secondary's scope: the env slots are the launch profile's and
hermes_state reads the routed profile's ``sessions.*`` from its own config under scope."""
- from hermes_cli.config_backend import config_exists
from gateway.platforms._shared import profile_scoped
if profile_scoped():
return
@@ -1622,7 +1613,6 @@ def _current_max_iterations() -> int:
``int()`` crash. A routed profile (HERMES_HOME override, multiplexed turns) reads ITS
``agent.max_turns`` straight from config: the ``HERMES_MAX_ITERATIONS`` bridge is one process-wide
slot holding the launch profile's value, so every secondary would inherit the default's budget."""
- from hermes_cli.config_backend import config_exists
_reload_runtime_env_preserving_config_authority()
from hermes_cli.config import resolve_turn_limit as _resolve_turn_limit
override = get_hermes_home_override()
@@ -2130,7 +2120,6 @@ def _load_bridge_config(config_path: Path) -> dict:
_config_path = _hermes_home / 'config.yaml'
_cfg: dict = {}
-from hermes_cli.config_backend import config_exists
if config_exists(_config_path):
try:
_cfg = _load_bridge_config(_config_path)
diff --git a/gateway/run_common.py b/gateway/run_common.py
index 6d92cec9aaf..937f8f0c196 100644
--- a/gateway/run_common.py
+++ b/gateway/run_common.py
@@ -4,5 +4,16 @@ Kept import-cycle free (imports nothing from ``gateway.run``) because these valu
are used as default-argument sentinels, which must resolve at ``def`` time.
"""
+from typing import Any
+
# Sentinel for "caller did not pass metadata" vs "caller passed None".
_UNSET = object()
+
+
+def _csv_or_list_to_set(raw: Any) -> set[str]:
+ """Normalize a config list or comma-separated scalar into a string set."""
+ if raw is None:
+ return set()
+ if isinstance(raw, list):
+ return {str(part).strip() for part in raw if str(part).strip()}
+ return {part.strip() for part in str(raw).split(",") if part.strip()}
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py
index 0aedc131741..bedbbb77ac0 100644
--- a/hermes_cli/auth.py
+++ b/hermes_cli/auth.py
@@ -255,7 +255,7 @@ BUILTIN_PROVIDER_IDS = frozenset(PROVIDER_REGISTRY)
# a plugin never observes a partially initialized auth module (CONTRACT: during discovery a plugin may
# rely only on ``ProviderConfig`` and ``PROVIDER_REGISTRY`` from here — nothing defined below).
from hermes_cli.config import (
- atomic_config_replace, get_hermes_home, get_config_path, read_raw_config, require_readable_config_before_write)
+ atomic_config_replace, config_exists, get_hermes_home, get_config_path, read_raw_config, require_readable_config_before_write)
# Plugin profiles (plugins/model-providers/<name>/) are mirrored into PROVIDER_REGISTRY with the
# auth_type they declare; the mirror lives in the sibling so it can be re-run after discovery.
@@ -2417,7 +2417,6 @@ def _logout_default_provider_from_config() -> Optional[str]:
def _reset_config_provider() -> Path:
"""Reset config.yaml provider back to auto after logout."""
- from hermes_cli.config_backend import config_exists
config_path = get_config_path()
if not config_exists(config_path):
return config_path
diff --git a/hermes_cli/backup.py b/hermes_cli/backup.py
index f85eeebac93..3f4d95fce92 100644
--- a/hermes_cli/backup.py
+++ b/hermes_cli/backup.py
@@ -35,12 +35,15 @@ from hermes_cli.backup_restore import (
_default_new_file_mode,
_detect_prefix,
_extract_member_atomically,
+ _get_config_path_value,
_import_db_member,
_restore_auth_json,
_restore_destination_epoch,
_safe_restore_db,
+ _set_config_path_value,
_validate_backup_zip,
)
+from hermes_cli.config_backend import require_file_tooling
logger = logging.getLogger(__name__)
@@ -595,7 +598,6 @@ def run_backup(args) -> bool:
the caller turns False into exit status 1 so a cron/systemd timer never publishes a "successful"
archive that is missing state.db. Hard failures keep raising ``SystemExit``.
"""
- from hermes_cli.config_backend import require_file_tooling
require_file_tooling("`hermes backup`")
hermes_root = get_default_hermes_root()
@@ -733,7 +735,6 @@ def _import_member_rel(member: str, prefix: str) -> tuple[str, bool]:
def run_import(args) -> Optional[int]:
"""Restore a Hermes backup; return 1 on damaged archives or incomplete restores."""
- from hermes_cli.config_backend import require_file_tooling
require_file_tooling("`hermes import`")
zip_path = Path(args.zipfile).expanduser().resolve()
@@ -745,11 +746,8 @@ def run_import(args) -> Optional[int]:
print(f"Error: Not a valid zip file: {zip_path}")
sys.exit(1)
- # The restore target must be the home the command operates under — the
- # same path printed as "Target:" via display_hermes_home(). Resolving
- # through get_default_hermes_root() instead maps a profile home
- # (<root>/profiles/<name>) back to <root>, silently retargeting the
- # restore at the live root while the profile directory stays empty.
+ # The home this command operates under (the "Target:" display_hermes_home() prints):
+ # get_default_hermes_root() would map a profile home back to <root> and restore the live root.
hermes_root = get_hermes_home()
with zipfile.ZipFile(zip_path, "r") as zf:
@@ -1544,7 +1542,6 @@ def restore_quick_snapshot(
Returns True if at least one file was restored and the listed auth.json
was not refused or skipped.
"""
- from hermes_cli.config_backend import require_file_tooling
require_file_tooling("Snapshot restore")
from gateway.runtime_ownership import OwnershipConflict, exclusive_maintenance
home = hermes_home or get_hermes_home()
@@ -1879,26 +1876,6 @@ def _read_raw_yaml_dict(path: Path) -> Optional[dict[str, Any]]:
return data if isinstance(data, dict) else None
-def _get_config_path_value(data: dict[str, Any], dotted: tuple[str, ...]) -> Any:
- node: Any = data
- for key in dotted:
- if not isinstance(node, dict):
- return None
- node = node.get(key)
- return node
-
-
-def _set_config_path_value(data: dict[str, Any], dotted: tuple[str, ...], value: Any) -> None:
- node = data
- for key in dotted[:-1]:
- child = node.get(key)
- if not isinstance(child, dict):
- child = {}
- node[key] = child
- node = child
- node[dotted[-1]] = value
-
-
def restore_config_model_settings_if_rewritten(
snapshot_id: str,
hermes_home: Optional[Path] = None,
diff --git a/hermes_cli/backup_restore.py b/hermes_cli/backup_restore.py
index cbe59eb3726..81e9f92e0b2 100644
--- a/hermes_cli/backup_restore.py
+++ b/hermes_cli/backup_restore.py
@@ -18,7 +18,7 @@ import tempfile
import zipfile
from contextlib import closing, contextmanager
from pathlib import Path
-from typing import List, Optional, Tuple
+from typing import Any, Dict, List, Optional, Tuple
from hermes_state_holders import read_only_db_uri
from hermes_cli.backup_sqlite import _safe_copy_db
@@ -656,3 +656,23 @@ def _import_db_member_exclusive(
os.unlink(tmp_name)
except OSError:
pass
+
+
+def _get_config_path_value(data: Dict[str, Any], dotted: Tuple[str, ...]) -> Any:
+ node: Any = data
+ for key in dotted:
+ if not isinstance(node, dict):
+ return None
+ node = node.get(key)
+ return node
+
+
+def _set_config_path_value(data: Dict[str, Any], dotted: Tuple[str, ...], value: Any) -> None:
+ node = data
+ for key in dotted[:-1]:
+ child = node.get(key)
+ if not isinstance(child, dict):
+ child = {}
+ node[key] = child
+ node = child
+ node[dotted[-1]] = value
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index c44e94e5cb9..11a7bf1e7f6 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -23,8 +23,6 @@ import subprocess
import sys
import tempfile
import threading
-import time
-import unicodedata
from contextlib import contextmanager, suppress
from dataclasses import dataclass
from decimal import Decimal, InvalidOperation
@@ -48,7 +46,8 @@ from hermes_constants import (
from hermes_constants import get_hermes_home, get_process_hermes_home
from utils import atomic_replace, fast_safe_load, file_signature, mkstemp_beside
from hermes_cli.config_backend import (
- config_version, read_config_doc, supports_file_tooling, write_config_document)
+ config_exists, config_version, probe_config_readable, read_config_doc, supports_file_tooling, # noqa: F401 config_exists re-exported for facades
+ 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,
@@ -1007,50 +1006,6 @@ _FB_SINGLE_REQUIRED_FIELDS = (
("model", "Add: model: anthropic/claude-sonnet-4 (or another model)"))
-def _validate_voice(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
- voice_cfg = config.get("voice")
- if not (isinstance(voice_cfg, dict) and "submit_mode" in voice_cfg):
- return
- submit_mode = voice_cfg.get("submit_mode")
- normalized = submit_mode.strip().lower() if isinstance(submit_mode, str) else None
- if normalized not in {"direct", "draft"}:
- _issue(issues, "error", f"voice.submit_mode must be 'direct' or 'draft', got {submit_mode!r}",
- "Set voice.submit_mode to direct (submit immediately) or draft (edit before sending)")
-
-
-def _validate_timezone(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
- """``timezone`` must be an IANA name the runtime can load.
-
- ``hermes_time._get_zoneinfo()`` swallows an invalid name behind a single WARNING in the
- gateway log, then runs the agent clock AND every cron schedule on server-local time.
- Surface it here, where doctor and the startup check both look. Silent when the
- interpreter has no tz database at all (bare Windows without ``tzdata``) — nothing can be
- judged there.
- """
- if "timezone" not in config:
- return
- tz = config.get("timezone")
- hint = ("Use an IANA zone name such as America/New_York or Asia/Tokyo (see "
- "`timedatectl list-timezones`). With an invalid value the agent clock and cron "
- "schedules silently fall back to server-local time. HERMES_TIMEZONE overrides "
- "this key when set.")
- if tz is not None and not isinstance(tz, str):
- _issue(issues, "error", f"timezone must be an IANA zone name string, got {tz!r}", hint)
- return
- if not (isinstance(tz, str) and tz.strip()):
- return
- name = tz.strip()
- try:
- import zoneinfo
- zoneinfo.ZoneInfo("UTC") # is a tz database available at all?
- except Exception:
- return
- try:
- zoneinfo.ZoneInfo(name)
- except Exception:
- _issue(issues, "error", f"timezone {name!r} is not a valid IANA zone name", hint)
-
-
def _validate_entry_list(
entries: list, label: str, issues: list[ConfigIssue], fields, *, non_dict: tuple[str, str, str],
) -> None:
@@ -1103,31 +1058,6 @@ def _validate_fallback_model(fb: Any, issues: list[ConfigIssue]) -> None:
suffix=" — fallback will be disabled")
-def _validate_web_backends(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
- """A stale web backend selection otherwise fails only at the first web_search/web_extract
- call with a generic "no registered provider" error; warn at startup instead."""
- # See #99199.
- web_cfg = config.get("web")
- if not isinstance(web_cfg, dict):
- return
- try:
- from tools.tool_backend_helpers import removed_backend_note
- except Exception:
- return
- seen: set = set()
- for _key in ("backend", "search_backend", "extract_backend"):
- _val = str(web_cfg.get(_key) or "").strip().lower()
- if not _val or _val in seen:
- continue
- seen.add(_val)
- note = removed_backend_note("web", _val)
- if note:
- _issue(issues, "warning",
- f"web.{_key} is set to '{_val}', but {note} — "
- "web_search/web_extract will fail until it is changed",
- "Run 'hermes tools' and pick a different Web Search & Extract provider")
-
-
def _container_slots() -> dict[str, str]:
"""Dotted key -> ``"list"``/``"mapping"`` for every slot the schema fixes to a container:
``DEFAULT_CONFIG`` (sections included) plus the known-container table for roots it omits."""
@@ -1180,6 +1110,7 @@ def validate_config_structure(config: Optional[dict[str, Any]] = None) -> list[C
from hermes_cli.config_home import config_load_issue
return [config_load_issue(exc)]
+ from hermes_cli.config_value_checks import _validate_timezone, _validate_voice, _validate_web_backends
issues: list[ConfigIssue] = []
_validate_voice(config, issues)
_validate_timezone(config, issues)
@@ -2318,11 +2249,9 @@ def _load_config_cache_hit(path_key: str, cache_sig: Any) -> Optional[dict[str,
# A read error (EMFILE/EIO/sharing violation) can clear without touching the file's
# signature: serve the fallback only while the file still cannot be read.
try:
- read_config_doc(path_key)
+ probe_config_readable(path_key)
except OSError:
return hit
- except Exception:
- pass # readable again; the reload reports the parse error
return None
env_snapshot = cached[n + 1] if len(cached) > n + 1 else {}
if all(_env_ref_lookup(k) == v for k, v in env_snapshot.items()):
diff --git a/hermes_cli/config_backend.py b/hermes_cli/config_backend.py
index 87c71c3630c..7a4dfb72535 100644
--- a/hermes_cli/config_backend.py
+++ b/hermes_cli/config_backend.py
@@ -195,6 +195,17 @@ def config_version(config_path: PathLike) -> Tuple[Any, ...]:
return backend.version(target) if is_layer else backend.version_path(target)
+def probe_config_readable(config_path: PathLike) -> None:
+ """Raise ``OSError`` while a local config file cannot be opened; no parse. A non-file user
+ layer has no local read to fail, so only explicit files and the file backend probe."""
+ backend, target, is_layer = _route(config_path)
+ if is_layer and not backend.supports_file_tooling():
+ return
+ path = backend.config_path(target) if is_layer else target
+ with open(path, "rb") as f:
+ f.read(1)
+
+
def config_exists(config_path: PathLike) -> bool:
backend, target, is_layer = _route(config_path)
return backend.exists(target) if is_layer else target.exists()
diff --git a/hermes_cli/config_value_checks.py b/hermes_cli/config_value_checks.py
new file mode 100644
index 00000000000..50525425395
--- /dev/null
+++ b/hermes_cli/config_value_checks.py
@@ -0,0 +1,75 @@
+"""Value checks for single config sections (voice, timezone, web backends), run by
+``hermes_cli.config.validate_config_structure`` for doctor and the startup warnings."""
+
+from typing import Any, Dict, List
+
+from hermes_cli.config import ConfigIssue, _issue
+
+
+def _validate_voice(config: Dict[str, Any], issues: List[ConfigIssue]) -> None:
+ voice_cfg = config.get("voice")
+ if not (isinstance(voice_cfg, dict) and "submit_mode" in voice_cfg):
+ return
+ submit_mode = voice_cfg.get("submit_mode")
+ normalized = submit_mode.strip().lower() if isinstance(submit_mode, str) else None
+ if normalized not in {"direct", "draft"}:
+ _issue(issues, "error", f"voice.submit_mode must be 'direct' or 'draft', got {submit_mode!r}",
+ "Set voice.submit_mode to direct (submit immediately) or draft (edit before sending)")
+
+
+def _validate_timezone(config: Dict[str, Any], issues: List[ConfigIssue]) -> None:
+ """``timezone`` must be an IANA name the runtime can load.
+
+ ``hermes_time._get_zoneinfo()`` swallows an invalid name behind a single WARNING in the
+ gateway log, then runs the agent clock AND every cron schedule on server-local time.
+ Surface it here, where doctor and the startup check both look. Silent when the
+ interpreter has no tz database at all (bare Windows without ``tzdata``) — nothing can be
+ judged there.
+ """
+ if "timezone" not in config:
+ return
+ tz = config.get("timezone")
+ hint = ("Use an IANA zone name such as America/New_York or Asia/Tokyo (see "
+ "`timedatectl list-timezones`). With an invalid value the agent clock and cron "
+ "schedules silently fall back to server-local time. HERMES_TIMEZONE overrides "
+ "this key when set.")
+ if tz is not None and not isinstance(tz, str):
+ _issue(issues, "error", f"timezone must be an IANA zone name string, got {tz!r}", hint)
+ return
+ if not (isinstance(tz, str) and tz.strip()):
+ return
+ name = tz.strip()
+ try:
+ import zoneinfo
+ zoneinfo.ZoneInfo("UTC") # is a tz database available at all?
+ except Exception:
+ return
+ try:
+ zoneinfo.ZoneInfo(name)
+ except Exception:
+ _issue(issues, "error", f"timezone {name!r} is not a valid IANA zone name", hint)
+
+
+def _validate_web_backends(config: Dict[str, Any], issues: List[ConfigIssue]) -> None:
+ """A stale web backend selection otherwise fails only at the first web_search/web_extract
+ call with a generic "no registered provider" error; warn at startup instead."""
+ # See #99199.
+ web_cfg = config.get("web")
+ if not isinstance(web_cfg, dict):
+ return
+ try:
+ from tools.tool_backend_helpers import removed_backend_note
+ except Exception:
+ return
+ seen: set = set()
+ for _key in ("backend", "search_backend", "extract_backend"):
+ _val = str(web_cfg.get(_key) or "").strip().lower()
+ if not _val or _val in seen:
+ continue
+ seen.add(_val)
+ note = removed_backend_note("web", _val)
+ if note:
+ _issue(issues, "warning",
+ f"web.{_key} is set to '{_val}', but {note} — "
+ "web_search/web_extract will fail until it is changed",
+ "Run 'hermes tools' and pick a different Web Search & Extract provider")
diff --git a/hermes_cli/profile_memory_config.py b/hermes_cli/profile_memory_config.py
index c3e0da23545..c9f87d8a9e6 100644
--- a/hermes_cli/profile_memory_config.py
+++ b/hermes_cli/profile_memory_config.py
@@ -61,10 +61,19 @@ def clone_memory_provider_config(source_dir: Path, profile_dir: Path, provider:
return copied
+def _load_config_dict(profile_dir: Path) -> Optional[dict]:
+ """A profile's config.yaml mapping read through the config backend; None when absent or unreadable."""
+ from hermes_yaml import YAMLError
+ 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
+ return None
+ return data if isinstance(data, dict) else None
+
+
def cloned_memory_provider(profile_dir: Path) -> Optional[str]:
"""Name of the external provider whose config *profile_dir* now carries, for the CLI notice."""
- from hermes_cli.profiles import _load_config_dict
-
provider = active_memory_provider(_load_config_dict(profile_dir))
if provider and ((profile_dir / provider).is_dir() or (profile_dir / f"{provider}.json").is_file()):
return provider
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index e4e0fba8580..ea4ef50fe64 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -24,6 +24,7 @@ from hermes_constants import (
LOCAL_RUNTIME_ROOT_DIRS, PROFILE_ID_RE, clear_named_profile_deleted, mark_named_profile_deleted,
named_profile_has_identity, named_profile_is_deleted, named_profile_is_live,
)
+from hermes_cli.config_backend import config_exists, config_version, require_file_tooling
logger = logging.getLogger(__name__)
@@ -585,7 +586,6 @@ def remove_wrapper_script(name: str) -> bool:
def _migrate_profile_config_if_outdated(profile_dir: Path) -> None:
"""Migrate a copied config.yaml to the current schema (non-interactive, scoped to the new
profile); otherwise the first desktop/doctor view shows a scary ``v0 -> latest`` warning."""
- from hermes_cli.config_backend import config_exists
if not config_exists(profile_dir / "config.yaml"):
return
# Creation must not fail over an unmigratable old config; `hermes doctor --fix` surfaces
@@ -706,19 +706,6 @@ def _load_yaml_dict(path: Path) -> Optional[dict]:
return data if isinstance(data, dict) else None
-def _load_config_dict(profile_dir: Path) -> Optional[dict]:
- """:func:`_load_yaml_dict` for a profile's config.yaml, read through the config backend."""
- from hermes_cli.config_backend import config_exists, read_config_doc
- path = profile_dir / "config.yaml"
- if not config_exists(path):
- return None
- try:
- data = read_config_doc(path) or {}
- except Exception:
- return None
- return data if isinstance(data, dict) else None
-
-
# (path, kind) -> (file signature, the small derived value). `list_profiles` re-reads three YAML
# files PER PROFILE, and it is the shared body of `GET /api/profiles` and `profiles.list`, which the
# Bots roster polls every 5s per connection — so an installer-seeded config.yaml (the annotated
@@ -769,7 +756,6 @@ def _read_distribution_meta(profile_dir: Path) -> tuple:
def _read_config_model(profile_dir: Path) -> tuple:
"""Read model/provider from a profile's config.yaml. Returns (model, provider)."""
- from hermes_cli.config_backend import config_exists
config_path = profile_dir / "config.yaml"
if not config_exists(config_path):
return None, None
@@ -793,7 +779,6 @@ def _read_config_model(profile_dir: Path) -> tuple:
def _seed_model_config(profile_dir: Path) -> None:
"""Copy (not link) the active profile's model block into a fresh profile so it is usable;
profiles stay independent islands afterwards."""
- from hermes_cli.config_backend import config_exists
config_path = profile_dir / "config.yaml"
if config_exists(config_path):
return
@@ -1084,7 +1069,6 @@ def profile_is_standalone(home: Path) -> bool:
never standalone — it IS the host — and warns once per process if the key is set there."""
global _STANDALONE_WARNED
from hermes_yaml import YAMLError
- from hermes_cli.config_backend import config_version
home = Path(home)
cfg_path = home / "config.yaml"
@@ -1179,7 +1163,6 @@ def profiles_to_serve(multiplex: bool, *, include_standalone: bool = False,
def _resolve_clone_source(clone_from: Optional[str]) -> Path:
"""Directory to clone from: the named profile, or the active profile when ``None``."""
- from hermes_cli.config_backend import require_file_tooling
require_file_tooling("Profile clone")
if clone_from is None:
from hermes_constants import get_hermes_home
@@ -1396,7 +1379,7 @@ def _bootstrap_profile_dir(profile_dir: Path, source_dir: Optional[Path],
for relpath in _CLONE_SUBDIR_FILES:
_clone_file(source_dir, profile_dir, relpath)
_clone_plugins(source_dir, profile_dir)
- from hermes_cli.profile_memory_config import active_memory_provider, clone_memory_provider_config
+ from hermes_cli.profile_memory_config import _load_config_dict, active_memory_provider, clone_memory_provider_config
clone_memory_provider_config(source_dir, profile_dir, active_memory_provider(_load_config_dict(source_dir)))
if sync_imports: # a plain file at the profile root, written by the agent-importers plugin
_clone_file(source_dir, profile_dir, "import-sync.json")
diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py
index 635a12722b8..ee3390a0e93 100644
--- a/plugins/platforms/telegram/adapter.py
+++ b/plugins/platforms/telegram/adapter.py
@@ -2589,14 +2589,13 @@ class TelegramAdapter(TelegramHeldInboundMixin, TelegramTopicRoutingMixin, BaseP
def _persist_dm_topic_thread_id(self, chat_id: int, topic_name: str, thread_id: int, replace_existing: bool = False) -> None:
"""Save a newly created thread_id back into config.yaml so it survives restarts."""
- from hermes_cli.config_backend import config_exists
try:
from hermes_constants import get_hermes_home
+ from hermes_cli.config import atomic_config_write, config_exists, read_user_config_raw
config_path = get_hermes_home() / "config.yaml"
if not config_exists(config_path):
logger.warning("[%s] Config file not found at %s, cannot persist thread_id", self.name, config_path)
return
- from hermes_cli.config import atomic_config_write, read_user_config_raw
config = read_user_config_raw(config_path)
# platforms.telegram.extra.dm_topics — create the path for topics not predeclared in config.yaml.
dm_topics = config.setdefault("platforms", {}).setdefault("telegram", {}).setdefault("extra", {}).setdefault("dm_topics", [])
@@ -2686,7 +2685,7 @@ class TelegramAdapter(TelegramHeldInboundMixin, TelegramTopicRoutingMixin, BaseP
async def _register_command_menu(self) -> None:
"""Register the command menu (from COMMAND_REGISTRY) in every scope — Telegram picks the
narrowest matching one per chat type; forum topics are handled lazily by _ensure_forum_commands."""
- from telegram import BotCommand, BotCommandScopeAllPrivateChats, BotCommandScopeAllGroupChats, BotCommandScopeDefault
+ from telegram import BotCommandScopeAllPrivateChats, BotCommandScopeAllGroupChats, BotCommandScopeDefault
from hermes_cli.commands_platforms import telegram_menu_commands, telegram_menu_max_commands
if not self._bot:
return
@@ -7280,7 +7279,6 @@ async def _standalone_send(pconfig, chat_id, message, *, thread_id=None, media_f
def interactive_setup() -> None:
"""Configure Telegram credentials and allowlist via the CLI setup wizard (lazy import)."""
- from hermes_cli import setup as _setup_mod
setup_platforms._setup_telegram()
diff --git a/pm/plugins_state.py b/pm/plugins_state.py
index 8be64dd5ad3..30bcf3bdd30 100644
--- a/pm/plugins_state.py
+++ b/pm/plugins_state.py
@@ -31,9 +31,12 @@ def read_home_selection(home: Path) -> Optional[dict[str, Any]]:
"""
# Missing YAML support is a broken runtime, not an empty plugin selection.
from ruamel.yaml.error import YAMLError
- from hermes_cli.config_backend import read_config_doc
+ from hermes_cli.config_backend import config_exists, read_config_doc
config_path = home / "config.yaml"
+ # Existence first: a home without config needs no YAML stack (PM's own runtime tree has none).
+ if not config_exists(config_path):
+ return None
try:
config = read_config_doc(config_path)
except FileNotFoundError:
diff --git a/website/docs/developer-guide/config-backend.md b/website/docs/developer-guide/config-backend.md
index d9e4c6faa29..aa93f55b41a 100644
--- a/website/docs/developer-guide/config-backend.md
+++ b/website/docs/developer-guide/config-backend.md
@@ -8,8 +8,8 @@ description: "Where a profile's user config.yaml is read and written: the Config
Every read, stat, existence check and write of a profile's user `config.yaml` goes through
`hermes_cli/config_backend.py`. The backend is chosen once per process from
-`HERMES_CONFIG_BACKEND`, never from a config value: `file` is the default, and `remote` is
-[Remote Config](../user-guide/remote-config.md) (`plugins/config_backends/remote/`).
+`HERMES_CONFIG_BACKEND`, never from a config value: `file` (the default) is the only backend in
+this build; any other value stops the process with a clear error instead of falling back to defaults.
## Helpers
@@ -17,13 +17,12 @@ Every read, stat, existence check and write of a profile's user `config.yaml` go
|---|---|
| `read_config_doc(path)` | Parsed user layer (raises like `open` + `fast_safe_load`) |
| `read_config_doc_readonly(path)` | Signature-cached read; never mutate the result |
-| `config_version(path)` | Cache signature (the file's stat tuple, or the remote version) |
-| `config_exists(path)` | Whether the layer exists (a remote layer always does) |
+| `config_version(path)` | Cache signature (the file's stat tuple) |
+| `config_exists(path)` | Whether the layer exists |
| `write_config_document(path, doc)` / `write_config_key(path, key, value)` | Writes; callers normally use `atomic_config_write` / `atomic_config_replace` |
| `supports_file_tooling()` / `require_file_tooling(what)` | Gate for tools that copy, edit or back up the file itself (`config edit`, backup/restore, profile clone) |
-Caches keyed on `config_version` miss when a remote poll installs a new layer, exactly as
-they do after a local file edit. The managed scope (`/etc/hermes`) stays an overlay on top
+Caches keyed on `config_version` miss whenever the backend's layer changes. The managed scope (`/etc/hermes`) stays an overlay on top
of whatever user layer the backend returns.
## Lints