Skip to content

The agent that grows with you

fix(env_loader): defer secret_sources registry import until a source is enabled

Halldrixabf4dfc1b859
diff --git a/hermes_cli/env_loader.py b/hermes_cli/env_loader.py
index 311a30647fb..b52483da185 100644
--- a/hermes_cli/env_loader.py
+++ b/hermes_cli/env_loader.py
@@ -637,6 +637,19 @@ def _apply_external_secret_sources(home_path: Path) -> None:
# on its next load_hermes_dotenv() call instead of never.
return
+ # Defer the registry import until we know a secrets source is enabled —
+ # agent.secret_sources.bitwarden eagerly loads cryptography._rust.pyd,
+ # which causes the Windows updater to self-lock before its preflight
+ # (the updater itself maps the .pyd before the dependency sync runs).
+ # A config with no enabled sources costs one dict scan; a config with
+ # enabled sources pays the crypto load exactly once, on demand.
+ any_enabled = any(
+ isinstance(v, dict) and v.get("enabled", True)
+ for v in cfg.values()
+ )
+ if not any_enabled:
+ return
+
try:
from agent.secret_sources.registry import apply_all
except ImportError: