Skip to content

The agent that grows with you

fix: Langfuse migration installs without a prompt at startup and keeps the old plugin key working

Teknium53df274b08f2
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index aea4b0a99d5..3ba2c3fbb74 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -18,8 +18,10 @@ reuses; memory is not a row because its plugin name comes from ``memory.provider
Installs go through the normal catalog install path at the reviewed pin (kill list, dependency
constraints, enable). Unattended dependency consent covers only these rows: the feature shipped in
-core, so its users already accepted its dependencies. Every outcome reaches the user (terminal,
-Desktop, chat); a gateway-start outcome waits for the home's first agent to deliver it.
+core, so its users already accepted its dependencies. Agent/gateway start always installs with it
+(nothing can answer a prompt there); ``hermes update`` in a terminal still asks. Every outcome
+reaches the user (terminal, Desktop, chat); a gateway-start outcome waits for the home's first agent
+to deliver it.
"""
from __future__ import annotations
@@ -120,19 +122,31 @@ def spotify_in_use(home: Path, *, process_env: bool = False) -> bool:
return _toolset_listed(_read_config(home), frozenset({"spotify"}))
-def langfuse_in_use(home: Path, *, process_env: bool = False) -> bool:
- """What made core trace to Langfuse for *home*: its bundled plugin selected in ``plugins.enabled``
- under its key (``observability/langfuse``) or bare name (``langfuse``), and not vetoed by
- ``plugins.disabled`` (which wins, as in the loader). The plugin was opt-in, so keys alone are not use."""
- plugins = _read_config(home).get("plugins")
+def _bundled_plugin_selected(home: Path, plugin: str) -> bool:
+ """*plugin*'s bundled copy was on for *home*: its key or name in ``plugins.enabled`` and neither in
+ ``plugins.disabled`` (which wins, as in the loader), read with the managed overlay applied like the
+ loader's config, so an administrator's pinned list counts."""
+ from gateway import config_loader
+ feature = next(f for f in LEFT_CORE if f.plugin == plugin)
+ try:
+ plugins = config_loader.read_yaml_layers(home).get("plugins")
+ except Exception: # malformed config.yaml: the loader enables nothing from it either
+ logger.debug("left-core: unreadable config for %s", home, exc_info=True)
+ return False
plugins = plugins if isinstance(plugins, dict) else {}
def listed(key: str) -> bool:
names = plugins.get(key)
- return isinstance(names, list) and any(str(n) in {"observability/langfuse", "langfuse"} for n in names)
+ return isinstance(names, list) and any(str(n) in (feature.plugin_key, feature.plugin) for n in names)
return listed("enabled") and not listed("disabled")
+def langfuse_in_use(home: Path, *, process_env: bool = False) -> bool:
+ """What made core trace to Langfuse for *home*: the bundled ``observability/langfuse`` selected
+ (:func:`_bundled_plugin_selected`). The plugin was opt-in, so keys in ``.env`` alone are not use."""
+ return _bundled_plugin_selected(home, "langfuse")
+
+
@dataclass(frozen=True)
class LeftCoreFeature:
plugin: str # catalog entry name == installed plugin name
@@ -163,8 +177,9 @@ class LeftCoreFeature:
# Top-level command the plugin registers in place of core's ``hermes auth <cli>`` login
# (``hermes <cli> login|status|logout``); :func:`moved_command_hint` points the old spelling at it.
cli: str = ""
- # Key of the bundled plugin core shipped (``observability/langfuse``): `hermes plugins <verb>` on it
- # names the catalog plugin instead (:func:`moved_plugin_hint`).
+ # Key of the bundled plugin core shipped (``observability/langfuse``). It stays an alias of the
+ # catalog plugin in ``plugins.enabled`` / ``plugins.disabled`` (the loader's gate, an
+ # administrator's pinned list) and for every `hermes plugins <verb>` (:func:`legacy_plugin_alias`).
plugin_key: str = ""
@@ -192,15 +207,28 @@ LEFT_CORE: tuple[LeftCoreFeature, ...] = (
),
)
+def _install_sentence(feature: LeftCoreFeature) -> str:
+ from hermes_constants import get_hermes_home
+ return (f"{feature.label} moved out of core into the '{feature.plugin}' plugin: install it with "
+ f"`{_install_command(feature.plugin, Path(get_hermes_home()))}`")
+
+
def platform_install_hint(platform: str) -> str:
"""For an unknown platform name that left core: the sentence that names its install command for
the active home, else ``""``. Appended to "unknown platform" errors (``send_message``)."""
- from hermes_constants import get_hermes_home
feature = next((f for f in LEFT_CORE if f.platform and f.platform == platform), None)
- if feature is None:
- return ""
- return (f". {feature.label} moved out of core into the '{feature.plugin}' plugin: install it with "
- f"`{_install_command(feature.plugin, Path(get_hermes_home()))}`")
+ return f". {_install_sentence(feature)}" if feature else ""
+
+
+def legacy_plugin_alias(name: str) -> str:
+ """The catalog plugin a bundled key that left core now names (``observability/langfuse`` ->
+ ``langfuse``), else ``""``."""
+ return next((f.plugin for f in LEFT_CORE if f.plugin_key and f.plugin_key == name), "")
+
+
+def legacy_plugin_keys(plugin: str) -> set[str]:
+ """Bundled keys that now name catalog *plugin* (inverse of :func:`legacy_plugin_alias`)."""
+ return {f.plugin_key for f in LEFT_CORE if f.plugin_key and f.plugin == plugin}
def moved_command_hint(prog: str, value: str, action: str = "") -> str:
@@ -225,15 +253,11 @@ def moved_command_hint(prog: str, value: str, action: str = "") -> str:
def moved_plugin_hint(name: str) -> str:
- """For a plugin name nothing resolves to: the bundled key of a plugin that left core
- (``observability/langfuse``) or its catalog name, the line naming the install command for the
- active home, else ``""``. Appended to "No plugin named ..." errors."""
- from hermes_constants import get_hermes_home
+ """For a plugin name nothing resolves to (so the plugin is not installed): the bundled key of a
+ plugin that left core (``observability/langfuse``) or its catalog name, the line naming the install
+ command for the active home, else ``""``. Appended to "No plugin named ..." errors."""
feature = next((f for f in LEFT_CORE if f.plugin_key and name in (f.plugin_key, f.plugin)), None)
- if feature is None:
- return ""
- return (f"{feature.label} moved out of core into the '{feature.plugin}' plugin: install it with "
- f"`{_install_command(feature.plugin, Path(get_hermes_home()))}`.")
+ return f"{_install_sentence(feature)}." if feature else ""
_attempted: set[str] = set()
@@ -355,14 +379,15 @@ def _pending(home: Path, *, say: Callable[[str], None], process_env: bool = Fals
return out
-def _install_into(home: Path) -> Callable[[str], dict]:
+def _install_into(home: Path, *, consent: Optional[bool] = None) -> Callable[[str], dict]:
def _install(name: str) -> dict:
from hermes_cli.plugins_cmd import dashboard_install_plugin
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
token = set_hermes_home_override(home)
try:
return dashboard_install_plugin("", force=False, enable=True, catalog_name=name,
- assume_deps_consent=_unattended_consent())
+ assume_deps_consent=_unattended_consent() if consent is None
+ else consent)
finally:
reset_hermes_home_override(token)
return _install
@@ -504,8 +529,11 @@ def recover_at_startup(*, say: Optional[Callable[[str], None]] = None) -> list[s
f"fetch it: run `{_install_command(feature.plugin, home)}`.")
return []
installed = []
+ # Agent init cannot answer a dependency prompt: under the CLI the chat input owns the terminal,
+ # so the question hangs at "Initializing agent...". Every row shipped in core, so its users
+ # already accepted its dependencies (as memory_provider_migration.recover_at_startup does).
for feature in features:
- if _install_one(home, feature, install=_install_into(home), say=report):
+ if _install_one(home, feature, install=_install_into(home, consent=True), say=report):
installed.append(feature.plugin)
if say is not None and feature.platform and _gateway_serves(home):
report(f"Restart the gateway (`hermes gateway restart`) so it serves {feature.label}.")
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index 5bc6b43545f..ad061ca6772 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -555,7 +555,8 @@ def _plugin_aliases(key: str, entries: Optional[list] = None) -> set:
The loader matches BOTH the canonical key (``web/firecrawl``) and the manifest name
(``web-firecrawl``), so a stale entry under any form vetoes an enable ("explicit disable wins").
Pass *entries* to reuse one :func:`_discover_all_plugins` scan across several keys."""
- names = {key, key.split("/")[-1]}
+ from hermes_cli.left_core_migration import legacy_plugin_keys
+ names = {key, key.split("/")[-1], *legacy_plugin_keys(key)}
names.update(e[0] for e in (_discover_all_plugins() if entries is None else entries) if e[5] == key)
return names
@@ -672,7 +673,9 @@ def _find_plugin_entry(name: str) -> Optional[tuple]:
``web/exa``) only when unique; else the catalog name the plugin was installed under.
Never guesses between two candidates."""
entries = _discover_all_plugins()
- exact = next((entry for entry in entries if name in (entry[0], entry[5])), None)
+ from hermes_cli.left_core_migration import legacy_plugin_alias
+ target = legacy_plugin_alias(name) or name # ``observability/langfuse`` -> its catalog plugin
+ exact = next((entry for entry in entries if target in (entry[0], entry[5])), None)
if exact is not None:
return exact
leaf_matches = [entry for entry in entries if name == entry[5].split("/")[-1]]
diff --git a/hermes_cli/plugins_discovery.py b/hermes_cli/plugins_discovery.py
index ff4547a32f8..a7d4aafc4a2 100644
--- a/hermes_cli/plugins_discovery.py
+++ b/hermes_cli/plugins_discovery.py
@@ -261,7 +261,9 @@ def gate_manifest(
category-owned kinds (exclusive / model-provider), bundled auto-loads (backend now, platform deferred),
then ``plugins.enabled`` opt-in (path-derived key or legacy bare name)."""
lookup_key = manifest_key(manifest)
- names = {lookup_key, manifest.name}
+ from hermes_cli.left_core_migration import legacy_plugin_keys
+ # A bundled key that left core (``observability/langfuse``) keeps selecting its catalog plugin.
+ names = {lookup_key, manifest.name, *legacy_plugin_keys(lookup_key)}
def _placeholder(error: Optional[str], level: int, message: str, *args, enabled: bool = False) -> ManifestGate:
return ManifestGate("placeholder", enabled=enabled, error=error, log=(level, message, lookup_key, *args))
diff --git a/tests/hermes_cli/test_left_core_migration.py b/tests/hermes_cli/test_left_core_migration.py
index c0593caf88f..5a2a249e508 100644
--- a/tests/hermes_cli/test_left_core_migration.py
+++ b/tests/hermes_cli/test_left_core_migration.py
@@ -207,7 +207,7 @@ def test_migrate_all_homes_migrates_only_the_profile_that_used_it(tmp_path, monk
monkeypatch.setattr(ps, "dependency_homes", lambda: [a, b])
installed_into = []
- def install_into(home):
+ def install_into(home, **_kw):
def _install(name):
installed_into.append((home, name))
return {"ok": True}
@@ -225,7 +225,7 @@ def test_startup_honours_lazy_install_opt_out(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(home))
import pm.install
monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: False)
- monkeypatch.setattr(lcm, "_install_into", lambda h: pytest.fail("installed"))
+ monkeypatch.setattr(lcm, "_install_into", lambda h, **_kw: pytest.fail("installed"))
said = []
assert lcm.recover_at_startup(say=said.append) == []
assert "allow_lazy_installs is off" in said[0] and "plugins install homeassistant" in said[0]
@@ -238,8 +238,13 @@ def test_gateway_start_outcome_waits_for_the_first_agent(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(home))
import pm.install
monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: True)
- monkeypatch.setattr(lcm, "_install_into", lambda h: (lambda name: {"ok": True}))
+ consents = []
+ monkeypatch.setattr(lcm, "_install_into",
+ lambda h, consent=None: consents.append(consent) or (lambda name: {"ok": True}))
assert lcm.recover_at_startup() == ["homeassistant"] # gateway start: nobody to tell yet
+ # Agent init cannot answer a dependency prompt (the chat input owns the terminal): the feature
+ # shipped in core, so its startup install carries consent.
+ assert consents == [True]
said = []
assert lcm.recover_at_startup(say=said.append) == [] # first agent: delivered, not re-attempted
assert len(said) == 1 and said[0].startswith("✓ Home Assistant moved out of core")
@@ -273,7 +278,7 @@ def test_the_migration_installs_once_so_a_removal_sticks(tmp_path, monkeypatch):
assert lcm.migrate_home(home, install=install, say=quiet) == []
monkeypatch.setenv("HERMES_HOME", str(home))
monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: True)
- monkeypatch.setattr(lcm, "_install_into", lambda h: install)
+ monkeypatch.setattr(lcm, "_install_into", lambda h, **_kw: install)
assert lcm.recover_at_startup(say=quiet) == []
assert calls == ["homeassistant"] and not plugin.exists()
@@ -292,7 +297,7 @@ def test_a_failed_startup_install_backs_off_and_reports_one_line(tmp_path, monke
"Details: Cloning into '/h/plugins/.install-1'...\n"
"fatal: unable to access 'https://github.com/x/y/': Could not resolve host: github.com\n")
failing = lambda name: {"ok": False, "error": git_error}
- monkeypatch.setattr(lcm, "_install_into", lambda h: failing)
+ monkeypatch.setattr(lcm, "_install_into", lambda h, **_kw: failing)
said = []
assert lcm.recover_at_startup(say=said.append) == []
assert len(said) == 1 and "\n" not in said[0] and "Could not resolve host: github.com" in said[0]
@@ -317,7 +322,7 @@ def test_repeated_startup_failures_back_off_exponentially(tmp_path, monkeypatch)
monkeypatch.setenv("HERMES_HOME", str(home))
monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: True)
attempts = []
- monkeypatch.setattr(lcm, "_install_into", lambda h: lambda n: attempts.append(n) or {"ok": False, "error": "x"})
+ monkeypatch.setattr(lcm, "_install_into", lambda h, **_kw: lambda n: attempts.append(n) or {"ok": False, "error": "x"})
stamp = mpm._failure_stamp(home, "homeassistant")
def start_after(hours: float) -> None:
@@ -376,24 +381,43 @@ def test_old_spotify_commands_point_at_the_plugin(tmp_path, monkeypatch):
_LANGFUSE_KEYS_ENV = "HERMES_LANGFUSE_PUBLIC_KEY=pk-lf-x\nHERMES_LANGFUSE_SECRET_KEY=sk-lf-x\n"
[email protected](("config", "in_use"), [
- ("plugins:\n enabled: [observability/langfuse]\n", True),
- ("plugins:\n enabled: [langfuse]\n", True), # legacy bare name the loader accepted
- ("plugins:\n enabled: [observability/langfuse]\n disabled: [langfuse]\n", False), # disabled wins
- ("plugins:\n enabled: [other]\n", False),
- ("", False), # keys alone: it was opt-in
[email protected](("config", "managed", "in_use"), [
+ ("plugins:\n enabled: [observability/langfuse]\n", "", True),
+ ("plugins:\n enabled: [langfuse]\n", "", True), # legacy bare name the loader accepted
+ ("plugins:\n enabled: [observability/langfuse]\n disabled: [langfuse]\n", "", False), # disabled wins
+ ("plugins:\n enabled: [other]\n", "", False),
+ ("", "", False), # keys alone: it was opt-in
+ ("", "plugins:\n enabled: [observability/langfuse]\n", True), # an administrator's pinned list
])
-def test_langfuse_in_use_is_the_bundled_plugin_enabled(tmp_path, config, in_use):
+def test_langfuse_in_use_is_the_bundled_plugin_enabled(tmp_path, monkeypatch, config, managed, in_use):
home = _home(tmp_path, env=_LANGFUSE_KEYS_ENV, config=config)
+ managed_dir = tmp_path / "managed"
+ managed_dir.mkdir()
+ if managed:
+ (managed_dir / "config.yaml").write_text(managed, encoding="utf-8")
+ monkeypatch.setenv("HERMES_MANAGED_DIR", str(managed_dir))
assert lcm.langfuse_in_use(home) is in_use
-def test_old_langfuse_plugin_key_points_at_the_catalog_plugin(tmp_path, monkeypatch):
- """`hermes plugins enable observability/langfuse` (every pre-move doc said so) names the install."""
- from hermes_cli.plugins_cmd import _unknown_plugin_message
- monkeypatch.setenv("HERMES_HOME", str(_home(tmp_path)))
+def test_old_langfuse_plugin_key_keeps_naming_the_catalog_plugin(tmp_path, monkeypatch):
+ """`observability/langfuse` (every pre-move doc, an administrator's pinned list) names the install
+ while the plugin is absent, and selects/resolves the installed plugin once it is there."""
+ from hermes_cli.plugins_cmd import _find_plugin_entry, _unknown_plugin_message
+ from hermes_cli.plugins_discovery import gate_manifest
+ from hermes_cli.plugins_manifest import PluginManifest
+ home = _home(tmp_path)
+ monkeypatch.setenv("HERMES_HOME", str(home))
for name in ("observability/langfuse", "langfuse"):
message = _unknown_plugin_message(name)
assert "moved out of core into the 'langfuse' plugin" in message
assert "hermes plugins install langfuse" in message
assert "moved out of core" not in _unknown_plugin_message("nonexistent")
+
+ plugin_dir = home / "plugins" / "langfuse"
+ plugin_dir.mkdir(parents=True)
+ (plugin_dir / "plugin.yaml").write_text("name: langfuse\nversion: 2.0.0\n", encoding="utf-8")
+ (plugin_dir / "__init__.py").write_text("def register(ctx):\n pass\n", encoding="utf-8")
+ assert _find_plugin_entry("observability/langfuse")[5] == "langfuse"
+ manifest = PluginManifest(name="langfuse", source="user", path=str(plugin_dir), key="langfuse")
+ assert gate_manifest(manifest, set(), {"observability/langfuse"}).action == "load"
+ assert gate_manifest(manifest, {"observability/langfuse"}, {"langfuse"}).error == "disabled via config"
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index ea2df5af9f5..7ee649abd2a 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -230,6 +230,7 @@ Environment variables for the official [`langfuse`](https://github.com/NousResea
| `HERMES_LANGFUSE_SAMPLE_RATE` | SDK sampling rate 0.0–1.0 (default: `1.0`) |
| `HERMES_LANGFUSE_MAX_CHARS` | Per-field truncation for serialized payloads (default: `12000`) |
| `HERMES_LANGFUSE_MAX_DEPTH` | Nesting depth kept in captured tool inputs/outputs before values become `<max-depth>` (default: `4`; invalid values warn and keep the default) |
+| `HERMES_LANGFUSE_CAPTURE` | Content capture mode: `metadata` (no content), `sanitized` (default: secret redaction + truncation) or `full` (truncation only) |
| `HERMES_LANGFUSE_DEBUG` | `true` enables verbose plugin logging to `agent.log` |
| `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` / `LANGFUSE_BASE_URL` | Standard Langfuse SDK names. Accepted as fallbacks when the `HERMES_LANGFUSE_*` equivalents are unset. |
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/environment-variables.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/environment-variables.md
index a7651e1882b..96194f96059 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/environment-variables.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/reference/environment-variables.md
@@ -170,6 +170,8 @@ description: "Hermes Agent 使用的所有环境变量完整参考"
| `HERMES_LANGFUSE_RELEASE` | trace 上的发布/版本标签 |
| `HERMES_LANGFUSE_SAMPLE_RATE` | SDK 采样率 0.0–1.0(默认:`1.0`) |
| `HERMES_LANGFUSE_MAX_CHARS` | 序列化载荷的每字段截断长度(默认:`12000`) |
+| `HERMES_LANGFUSE_MAX_DEPTH` | 捕获的工具输入/输出保留的嵌套深度,超出部分变为 `<max-depth>`(默认:`4`;无效值会告警并使用默认值) |
+| `HERMES_LANGFUSE_CAPTURE` | 内容捕获模式:`metadata`(不含内容)、`sanitized`(默认:密钥脱敏 + 截断)或 `full`(仅截断) |
| `HERMES_LANGFUSE_DEBUG` | `true` 可将详细插件日志输出到 `agent.log` |
| `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` / `LANGFUSE_BASE_URL` | 标准 Langfuse SDK 变量名。当对应的 `HERMES_LANGFUSE_*` 未设置时作为回退。 |