Skip to content

The agent that grows with you

fix: a preinstalled Home Assistant plugin no longer turns its tools on everywhere

teknium1bd591f3d4911
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index e31ea965da3..4a99f9f02cd 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -142,18 +142,29 @@ def _core_carried(feature: LeftCoreFeature, selection: list) -> bool:
return any(carries(str(name)) for name in selection)
+_SCOPED_KEY = "_left_core_scoped" # config.yaml: rows whose toolset scope this home already converted
+
+
+def _scope_kept(config: dict, feature: LeftCoreFeature) -> bool:
+ done = config.get(_SCOPED_KEY)
+ return not feature.toolsets or (isinstance(done, list) and feature.plugin in map(str, done))
+
+
def _keep_toolset_scope(home: Path, feature: LeftCoreFeature) -> None:
"""Record *feature*'s toolsets in ``known_plugin_toolsets[platform]`` (= off) for every platform
where core had them off: a saved ``platform_toolsets`` list that does not carry them, or no list
- on an ``off_platforms`` platform. Platforms core resolved them on for are left alone. Runs before
- any install, automatic or the user's own, so the plugin never turns them on where the user had
- scoped them out. Idempotent; raises when config.yaml cannot be read or written."""
- if not feature.toolsets:
- return
+ on an ``off_platforms`` platform. Platforms core resolved them on for are left alone.
+
+ A one-time conversion per home and row, independent of installation: a plugin installed before
+ the update (it stays inert on a core that still ships the feature) still needs it. Completion is
+ marked under ``_left_core_scoped`` in the same config write, so a later run never undoes a choice
+ the user made since (``hermes tools``). Raises when config.yaml cannot be read or written."""
from hermes_cli.config import atomic_config_write, read_user_config_raw
from hermes_cli.toolset_validation import parse_platform_toolsets_value
path = home / "config.yaml"
config = read_user_config_raw(path)
+ if _scope_kept(config, feature):
+ return
saved = config.get("platform_toolsets")
saved = saved if isinstance(saved, dict) else {}
selections = {str(p): parse_platform_toolsets_value(v) for p, v in saved.items()}
@@ -161,37 +172,42 @@ def _keep_toolset_scope(home: Path, feature: LeftCoreFeature) -> None:
selections.setdefault(platform, None)
known = config.get("known_plugin_toolsets")
known = known if isinstance(known, dict) else {}
- changed = False
for platform, selection in selections.items():
if selection is None and platform not in feature.off_platforms:
continue # no (valid) saved list: core's default composite carried the toolsets
if selection is not None and _core_carried(feature, selection):
continue
current = known.get(platform) if isinstance(known.get(platform), list) else []
- missing = [ts for ts in feature.toolsets if ts not in current]
- if missing:
+ if missing := [ts for ts in feature.toolsets if ts not in current]:
known[platform] = sorted({*map(str, current), *missing})
- changed = True
- if changed:
+ if known:
config["known_plugin_toolsets"] = known
- atomic_config_write(path, config)
+ done = config.get(_SCOPED_KEY)
+ config[_SCOPED_KEY] = sorted({*(map(str, done) if isinstance(done, list) else ()), feature.plugin})
+ atomic_config_write(path, config)
def _pending(home: Path, *, say: Callable[[str], None], process_env: bool = False) -> list[LeftCoreFeature]:
"""Rows *home* uses whose plugin is not installed and that the catalog ships (a catalog miss is
- reported through *say*). Writes only the toolset scope (:func:`_keep_toolset_scope`); a row whose
- scope cannot be recorded is reported and skipped, never installed unscoped."""
+ reported through *say*). Converts the toolset scope of every row *home* uses once
+ (:func:`_keep_toolset_scope`), installed or not; a row whose scope cannot be recorded is
+ reported and skipped, never installed unscoped."""
from hermes_cli.memory_provider_migration import catalog_source
out = []
for feature in LEFT_CORE:
- if plugin_present(feature.plugin, home) or not feature.in_use(home, process_env=process_env):
+ present = plugin_present(feature.plugin, home)
+ if present and _scope_kept(_read_config(home), feature):
+ continue
+ if not feature.in_use(home, process_env=process_env):
continue
try:
_keep_toolset_scope(home, feature)
except Exception as exc:
- say(f" ⚠ {feature.label} moved out of core into the '{feature.plugin}' plugin, which was not "
- f"installed: its per-platform toolset selection could not be kept ({exc}). Run "
- f"`{_install_command(feature.plugin, home)}` and check `hermes tools`.")
+ say(f" ⚠ {feature.label} moved out of core into the '{feature.plugin}' plugin: its per-platform "
+ f"toolset selection could not be kept ({exc}). Check `hermes tools`"
+ + ("." if present else f" and run `{_install_command(feature.plugin, home)}`."))
+ continue
+ if present:
continue
if catalog_source(feature.plugin) is None:
say(f" ⚠ {feature.label} moved out of core into the '{feature.plugin}' plugin, which this "
diff --git a/plugins/AGENTS.md b/plugins/AGENTS.md
index d29966cda0f..5e0bfb1302a 100644
--- a/plugins/AGENTS.md
+++ b/plugins/AGENTS.md
@@ -29,6 +29,8 @@ command. A hook with no concrete consumer is speculative infrastructure and is r
`plugin-catalog/homeassistant.yaml`) keep their names/config/env and get a row in
`hermes_cli/left_core_migration.py::LEFT_CORE` (catalog plugin + read-only "this home uses it"
predicate); `hermes update` and agent/gateway start install the plugin for homes that used it.
+ Installing and converting core-era state are separate steps: the toolset-scope conversion runs
+ once per home and row (`_left_core_scoped` in config.yaml) even when the plugin is already there.
Core special cases become `PlatformEntry` seams the plugin sets (`trusted_inbound`,
`display_tier`, `shared_env_prefixes`), never a name check.
- **No new third-party-product plugins (June 2026).** Observability/metrics backends, vendor SaaS
diff --git a/tests/hermes_cli/test_left_core_migration.py b/tests/hermes_cli/test_left_core_migration.py
index b06912d03d4..e6552912b58 100644
--- a/tests/hermes_cli/test_left_core_migration.py
+++ b/tests/hermes_cli/test_left_core_migration.py
@@ -137,6 +137,35 @@ def test_a_disabled_or_present_plugin_is_left_alone(tmp_path):
assert lcm.migrate_home(home, install=lambda n: pytest.fail("reinstalled"), say=print) == []
+def test_a_preinstalled_plugin_gets_the_scope_conversion_once(tmp_path):
+ """A plugin installed before the update (inert while core shipped HA) is not proof the core-era
+ toolset scope was converted; the conversion runs once and never undoes a later user choice."""
+ from hermes_cli.config import read_user_config_raw, save_config
+ from hermes_cli.tools_config import _enabled_plugin_toolsets, _save_platform_tools
+ home = _home(tmp_path, env="HASS_TOKEN=abc\n", config="platform_toolsets:\n telegram: [web]\n")
+ (home / "plugins" / "homeassistant").mkdir(parents=True)
+ selections = {"telegram": ["web"], "acp": ["hermes-acp"], "webhook": ["hermes-webhook"]}
+
+ def ha_on() -> dict:
+ config = lcm._read_config(home)
+ selections["telegram"] = config["platform_toolsets"]["telegram"]
+ return {p: bool(_enabled_plugin_toolsets(config, p, sel, {"homeassistant"})) for p, sel in selections.items()}
+
+ lcm.migrate_home(home, install=lambda n: pytest.fail("reinstalled"), say=print)
+ assert ha_on() == {"telegram": False, "acp": False, "webhook": False}
+
+ config = read_user_config_raw(home / "config.yaml")
+ _save_platform_tools(config, "telegram", {"web", "homeassistant"}) # the user's later choice
+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override
+ token = set_hermes_home_override(home)
+ try:
+ save_config(config)
+ finally:
+ reset_hermes_home_override(token)
+ lcm.migrate_home(home, install=lambda n: pytest.fail("reinstalled"), say=print)
+ assert ha_on() == {"telegram": True, "acp": False, "webhook": False}
+
+
def test_catalog_miss_is_reported_not_installed(tmp_path, monkeypatch):
import hermes_cli.memory_provider_migration as mpm
monkeypatch.setattr(mpm, "catalog_source", lambda name: None)