Skip to content

The agent that grows with you

fix(relay): honor ambient plugin configuration

Alex Fournierab8a99c730d0
diff --git a/agent/relay_runtime.py b/agent/relay_runtime.py
index 580ecb8f647..e90ea9ecb90 100644
--- a/agent/relay_runtime.py
+++ b/agent/relay_runtime.py
@@ -147,7 +147,7 @@ def _same_handle(a: Any, b: Any) -> bool:
# Process-wide plugin-configuration result shared by every currently hosted profile.
-_RelayPluginConfigurationState = Enum("_RelayPluginConfigurationState", "UNINITIALIZED DISABLED ACTIVE FOREIGN FAILED")
+_RelayPluginConfigurationState = Enum("_RelayPluginConfigurationState", "UNINITIALIZED ACTIVE FOREIGN FAILED")
class _RelayPluginConfigurationLoadError(RuntimeError):
@@ -234,15 +234,15 @@ class _ProcessRelayPluginConfiguration:
self._state = self._preflight(relay) or self._activate(relay)
if self._state is _RelayPluginConfigurationState.ACTIVE:
logger.info(
- "Relay plugins are active process-wide and apply to all profiles hosted by this Hermes process."
+ "The Relay plugin host is active process-wide and applies to all profiles hosted by this "
+ "Hermes process."
)
self._owners.add(id(owner))
return self._state
def _activate(self, relay: Any) -> _RelayPluginConfigurationState:
try:
- if not self._initialize(relay):
- return _RelayPluginConfigurationState.DISABLED
+ self._initialize(relay)
except Exception as exc:
self._activation = None
if _is_relay_host_conflict(exc):
@@ -265,17 +265,14 @@ class _ProcessRelayPluginConfiguration:
return _RelayPluginConfigurationState.FAILED
return None
- def _initialize(self, relay: Any) -> bool:
- """Initialize Relay from the selected plugins.toml; False when none is selected."""
+ def _initialize(self, relay: Any) -> None:
+ """Initialize Relay with its ambient or explicitly selected configuration."""
config_path = _configured_plugin_inputs()
- if config_path is None:
- return False
- # Relay replaces the user file with the explicit file, then applies the system file above it.
+ # An explicit file replaces Relay's user file; its system file always remains above either source.
activation = _resolve_plugin_awaitable(relay.plugin.initialize({}, additional_plugins_toml=config_path))
if activation is None:
raise RuntimeError("NeMo Relay plugin initialization returned no activation handle")
self._activation = activation
- return True
def release(self, owner: Any) -> None:
"""Release one host and clear Relay after the final host exits."""
@@ -324,7 +321,7 @@ atexit.register(_PLUGIN_CONFIGURATION.retry_pending_cleanup)
class RelayRuntime:
- """Own Relay session scopes and optional process plugin configuration."""
+ """Own Relay session scopes and the process plugin configuration."""
def __init__(self, relay: Any = None, *, profile_key: str | None = None) -> None:
self.relay = relay or _load_nemo_relay()
@@ -1214,15 +1211,16 @@ def _load_nemo_relay() -> Any:
def _configured_plugin_inputs() -> Path | None:
- """Return the selected plugins.toml once it parses, or ``None`` when none was selected."""
+ """Return the parseable explicit override, or ``None`` to use Relay discovery."""
configured = os.environ.get(RELAY_PLUGINS_CONFIG_ENV, "").strip()
if not configured:
if legacy_vars := configured_legacy_relay_env_vars(os.environ):
logger.warning(
- "Legacy NeMo Relay exporter variables are set but no %s was provided — NO traces are being "
- "exported. %s no longer activate Relay exporters. Run `hermes migrate relay` (or `hermes update`, "
- "which runs it for every profile) to generate %s from them and select it in .env.",
- RELAY_PLUGINS_CONFIG_ENV, ", ".join(legacy_vars),
+ "Legacy NeMo Relay exporter variables are set but no %s was provided. %s no longer configure "
+ "Relay exporters; any standard user or system plugins.toml still applies. Run `hermes migrate "
+ "relay` (or `hermes update`, which runs it for every profile) to generate %s and select it in .env.",
+ RELAY_PLUGINS_CONFIG_ENV,
+ ", ".join(legacy_vars),
get_hermes_home() / "relay-plugins.toml",
)
return None
diff --git a/hermes_cli/config_migrations.py b/hermes_cli/config_migrations.py
index de1d2caae9d..bfd908d3d8a 100644
--- a/hermes_cli/config_migrations.py
+++ b/hermes_cli/config_migrations.py
@@ -503,8 +503,8 @@ def _migrate_to_38(results: Dict[str, Any], quiet: bool) -> None:
_persist_migration(config)
message = (
"Removed legacy Relay plugin from plugins.enabled: "
- f"{', '.join(removed)}. Configure native Relay plugins with "
- "HERMES_NEMO_RELAY_PLUGINS_TOML.")
+ f"{', '.join(removed)}. Configure a standard user or system Relay plugins.toml, or use "
+ "HERMES_NEMO_RELAY_PLUGINS_TOML for an explicit user-file override.")
results["warnings"].append(message)
if not quiet:
print(f" ⚠ {message}")
diff --git a/hermes_cli/doctor_config.py b/hermes_cli/doctor_config.py
index 1bc51efe3e5..a6edda904ca 100644
--- a/hermes_cli/doctor_config.py
+++ b/hermes_cli/doctor_config.py
@@ -62,7 +62,8 @@ def collect_relay_plugin_cutover_findings(raw_config: dict | None, env_map: dict
findings: list[tuple[str, str]] = []
plugins = raw_config.get("plugins") if isinstance(raw_config, dict) else None
if isinstance(plugins, dict):
- findings += [(f"plugins.enabled: {key}", f"remove it and configure {RELAY_PLUGINS_CONFIG_ENV}")
+ findings += [(f"plugins.enabled: {key}", "remove it and configure a standard user or system Relay plugins.toml; "
+ f"use {RELAY_PLUGINS_CONFIG_ENV} for an explicit user-file override")
for key in legacy_relay_plugin_keys(plugins.get("enabled"))]
effective_env = dict(env_map or {})
# Fall through to process env ONLY when no explicit env_map was given: run_doctor passes None and wants
@@ -73,7 +74,7 @@ def collect_relay_plugin_cutover_findings(raw_config: dict | None, env_map: dict
effective_env[name] = os.environ[name]
if not str(effective_env.get(RELAY_PLUGINS_CONFIG_ENV, "")).strip():
findings += [(name, f"run `hermes migrate relay` to generate relay-plugins.toml and set {RELAY_PLUGINS_CONFIG_ENV}; "
- "this variable is now ignored and no traces are exported")
+ "this legacy variable is now ignored and does not configure an exporter")
for name in configured_legacy_relay_env_vars(effective_env)]
return findings
diff --git a/hermes_cli/plugins.py b/hermes_cli/plugins.py
index 15fa39d7154..82f0cd0bfbd 100644
--- a/hermes_cli/plugins.py
+++ b/hermes_cli/plugins.py
@@ -1330,7 +1330,8 @@ class PluginManager(PluginLoaderMixin, PluginDispatchMixin, PluginLedgerMixin):
stale_relay_keys = legacy_relay_plugin_keys(enabled)
if stale_relay_keys:
logger.warning("Removed Hermes plugin %s is still listed in plugins.enabled; "
- "remove it and configure native Relay plugins with %s",
+ "remove it and configure a standard user or system Relay plugins.toml, or use %s "
+ "for an explicit user-file override",
", ".join(stale_relay_keys), RELAY_PLUGINS_CONFIG_ENV)
# Later sources win on key collision (project > user > bundled); gate the winners, then
# load survivors in requires_plugins order (see resolve_plugin_load_order).
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index e97052674fc..69ca6617a19 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -1119,7 +1119,8 @@ def cmd_enable(name: str, allow_tool_override: Optional[bool] = None) -> None:
if plugin in LEGACY_RELAY_PLUGIN_KEYS:
_fail(console, (
f"[red]Plugin '{plugin}' was removed.[/red] Relay lifecycle is owned "
- f"by Hermes core; configure {RELAY_PLUGINS_CONFIG_ENV} instead."))
+ "by Hermes core; configure a standard user or system Relay plugins.toml, or use "
+ f"{RELAY_PLUGINS_CONFIG_ENV} for an explicit user-file override."))
_refuse_legacy_relay(name)
resolved = _resolve_plugin_key_and_source(name)
diff --git a/hermes_cli/plugins_discovery.py b/hermes_cli/plugins_discovery.py
index 06a544943ca..81b8b22c1f0 100644
--- a/hermes_cli/plugins_discovery.py
+++ b/hermes_cli/plugins_discovery.py
@@ -192,8 +192,8 @@ def gate_manifest(
# Relay lifecycle is core-owned; an old plugin copy would compete for its registries.
if names & LEGACY_RELAY_PLUGIN_KEYS:
error = (
- "removed — Relay lifecycle is owned by Hermes core; configure "
- f"{RELAY_PLUGINS_CONFIG_ENV} instead"
+ "removed — Relay lifecycle is owned by Hermes core; configure a standard user or system Relay "
+ f"plugins.toml, or use {RELAY_PLUGINS_CONFIG_ENV} for an explicit user-file override"
)
return _placeholder(error, logging.WARNING, "Refusing to load removed Hermes Relay plugin '%s'; %s", error)
if names & disabled:
diff --git a/hermes_cli/relay_plugin_migrate.py b/hermes_cli/relay_plugin_migrate.py
index f50834ac474..6445626f29d 100644
--- a/hermes_cli/relay_plugin_migrate.py
+++ b/hermes_cli/relay_plugin_migrate.py
@@ -1,12 +1,10 @@
"""Migrate legacy ``HERMES_NEMO_RELAY_ATIF_*`` / ``ATOF_*`` exporter vars into a Relay ``plugins.toml``.
-The Relay cutover (Aug 2026) stopped honouring the legacy exporter variables: a profile that still
-carries them and no ``HERMES_NEMO_RELAY_PLUGINS_TOML`` logs one warning and initialises NO exporters,
-so users who followed the earlier docs lost every trace silently. This module turns those variables
-into ``<profile home>/relay-plugins.toml`` (built from the ``nemo_relay.observability`` dataclasses so
-the file is exactly what Relay validates), points ``HERMES_NEMO_RELAY_PLUGINS_TOML`` at it, and
-comments the legacy lines out. It runs from ``hermes update`` for every profile home and from
-``hermes relay migrate`` for the active one.
+The Relay cutover (Aug 2026) stopped honouring the legacy exporter variables. This module turns
+those variables into ``<profile home>/relay-plugins.toml`` (built from the
+``nemo_relay.observability`` dataclasses so the file is exactly what Relay validates), points
+``HERMES_NEMO_RELAY_PLUGINS_TOML`` at it, and comments the legacy lines out. It runs from
+``hermes update`` for every profile home and from ``hermes migrate relay`` for the active one.
"""
from __future__ import annotations
@@ -209,7 +207,7 @@ def migrate_all_profile_relay_envs(*, validate: bool = True) -> list[RelayMigrat
def print_relay_migration_report(results: list[RelayMigrationResult]) -> None:
- """Loud, actionable notice for `hermes update` / `hermes relay migrate`."""
+ """Loud, actionable notice for `hermes update` / `hermes migrate relay`."""
migrated = [r for r in results if r.migrated]
failed = [r for r in results if r.validation_error]
if not migrated and not failed:
@@ -217,14 +215,14 @@ def print_relay_migration_report(results: list[RelayMigrationResult]) -> None:
print()
if migrated:
print("\033[1;33m⚠ NeMo Relay exporter configuration migrated\033[0m")
- print(" The legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* variables stopped producing traces after the")
- print(" Relay cutover. Each profile below now has a generated relay-plugins.toml selected by")
+ print(" Relay no longer reads the legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* variables.")
+ print(" Each profile below now has a generated relay-plugins.toml selected by")
print(f" {RELAY_PLUGINS_CONFIG_ENV} in its .env (legacy lines commented out, not deleted):")
for r in migrated:
extra = f" ({len(r.diagnostics)} Relay diagnostic(s))" if r.diagnostics else ""
label = r.home.name if r.home.parent.name == "profiles" else "default"
print(f" • {label}: {r.toml_path}{extra}")
- print(" Restart the gateway to resume exports. Review the file and adjust paths if needed.")
+ print(" Restart the gateway to apply the migrated exporter settings. Review the file and adjust paths if needed.")
for r in failed:
print(f" ✗ {r.home}: could not migrate Relay exporter vars — {r.validation_error}")
print(f" Write {r.home / RELAY_PLUGINS_TOML_NAME} by hand and set {RELAY_PLUGINS_CONFIG_ENV}.")
diff --git a/hermes_cli/subcommands/migrate.py b/hermes_cli/subcommands/migrate.py
index f65be647cff..c7530ced244 100644
--- a/hermes_cli/subcommands/migrate.py
+++ b/hermes_cli/subcommands/migrate.py
@@ -29,8 +29,7 @@ def build_migrate_parser(subparsers) -> None:
migrate_relay = migrate_subparsers.add_parser(
"relay", help="Convert legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* exporter vars into relay-plugins.toml",
- description="The NeMo Relay cutover stopped reading the legacy exporter variables; a .env that still "
- "carries them (and no HERMES_NEMO_RELAY_PLUGINS_TOML) exports nothing. Generate "
+ description="The NeMo Relay cutover stopped reading the legacy exporter variables. Generate "
"<hermes home>/relay-plugins.toml from them, point HERMES_NEMO_RELAY_PLUGINS_TOML at it, "
"and comment the legacy lines out. `hermes update` runs this for every profile automatically.")
migrate_relay.add_argument(
diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.py
index 048942af38a..0386c4319d7 100644
--- a/hermes_cli/update_cmd_maint.py
+++ b/hermes_cli/update_cmd_maint.py
@@ -923,8 +923,11 @@ def _print_post_update_notices_and_self_heals() -> None:
('cua-driver refresh failed: %s', _refresh_cua_driver_after_update),
('Checkpoint footprint notice failed: %s', _print_checkpoint_footprint_notice),
('Plugin compat notice failed: %s', _print_plugin_compat_notice),
- # Legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* vars produce no traces since the Relay cutover;
- # generate each profile's relay-plugins.toml instead of leaving exports silently dead.
+ # Named profiles stopped inheriting the root auth.json (#111724): name every profile that
+ # now has no provider of its own so nobody finds out from a dead bot.
+ ('Profile credential notice failed: %s', _print_profiles_without_credentials_notice),
+ # Relay ignores legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* vars; migrate each profile to
+ # relay-plugins.toml so those exporter settings remain effective.
('Relay exporter migration failed: %s', _migrate_relay_exporter_env),
):
with _best_effort(message):
diff --git a/tests/agent/test_relay_runtime_plugins.py b/tests/agent/test_relay_runtime_plugins.py
index 422cfb08de8..5fecedf4964 100644
--- a/tests/agent/test_relay_runtime_plugins.py
+++ b/tests/agent/test_relay_runtime_plugins.py
@@ -156,27 +156,31 @@ def explicit_static_config(tmp_path, monkeypatch):
return config
-def test_unset_config_disables_plugin_initialization(monkeypatch):
+def test_unset_config_uses_relay_discovery(monkeypatch):
monkeypatch.delenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, raising=False)
relay = _FakeRelay()
host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")
try:
- assert not host.managed_execution_enabled()
+ assert host.managed_execution_enabled()
assert (
host._plugin_configuration_state
- is relay_runtime._RelayPluginConfigurationState.DISABLED
+ is relay_runtime._RelayPluginConfigurationState.ACTIVE
)
+ assert relay.initialized_from == [None]
host.ensure_session({"session_id": "session"})
- assert relay.events[0][0:2] == ("scope.push", relay_runtime.SESSION_SCOPE)
- assert not any(event[0].startswith("plugin.") for event in relay.events)
+ assert relay.events[0] == ("plugin.initialize", {})
+ assert relay.events[1][0:2] == ("scope.push", relay_runtime.SESSION_SCOPE)
finally:
host.shutdown()
- assert not any(event[0] == "subscribers.flush_async" for event in relay.events)
+ assert relay.events[-2:] == [
+ ("subscribers.flush_async",),
+ ("plugin.activation.close",),
+ ]
-def test_first_profile_plugin_decision_applies_to_later_profile(
+def test_first_profile_ambient_plugin_decision_applies_to_later_profile(
tmp_path,
monkeypatch,
):
@@ -190,17 +194,18 @@ def test_first_profile_plugin_decision_applies_to_later_profile(
host_b = relay_runtime.RelayRuntime(relay=relay, profile_key="profile-b")
try:
- assert not host_a.managed_execution_enabled()
- assert not host_b.managed_execution_enabled()
+ assert host_a.managed_execution_enabled()
+ assert host_b.managed_execution_enabled()
assert (
host_a._plugin_configuration_state
- is relay_runtime._RelayPluginConfigurationState.DISABLED
+ is relay_runtime._RelayPluginConfigurationState.ACTIVE
)
assert (
host_b._plugin_configuration_state
- is relay_runtime._RelayPluginConfigurationState.DISABLED
+ is relay_runtime._RelayPluginConfigurationState.ACTIVE
)
- assert not any(event[0].startswith("plugin.") for event in relay.events)
+ assert relay.events == [("plugin.initialize", {})]
+ assert relay.initialized_from == [None]
finally:
host_a.shutdown()
host_b.shutdown()
@@ -315,7 +320,7 @@ def test_real_binding_leaves_foreign_plugin_host_unchanged(
relay_runtime._resolve_plugin_awaitable(activation.close())
-def test_legacy_exporter_env_without_plugins_toml_warns_and_stays_disabled(
+def test_legacy_exporter_env_warns_without_disabling_ambient_discovery(
monkeypatch,
caplog,
):
@@ -328,15 +333,17 @@ def test_legacy_exporter_env_without_plugins_toml_warns_and_stays_disabled(
host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")
try:
- assert not host.managed_execution_enabled()
+ assert host.managed_execution_enabled()
assert (
host._plugin_configuration_state
- is relay_runtime._RelayPluginConfigurationState.DISABLED
+ is relay_runtime._RelayPluginConfigurationState.ACTIVE
)
- assert relay.events == []
+ assert relay.events == [("plugin.initialize", {})]
+ assert relay.initialized_from == [None]
assert "no HERMES_NEMO_RELAY_PLUGINS_TOML was provided" in caplog.text
assert "HERMES_NEMO_RELAY_ATOF_ENABLED" in caplog.text
assert "HERMES_NEMO_RELAY_ATIF_EXPORT_TIMEOUT_S" in caplog.text
+ assert "standard user or system plugins.toml still applies" in caplog.text
finally:
host.shutdown()
@@ -486,8 +493,8 @@ def test_two_profile_hosts_initialize_once_and_clear_after_final_shutdown(
assert host_b.managed_execution_enabled()
assert (
caplog.text.count(
- "Relay plugins are active process-wide and apply to all profiles "
- "hosted by this Hermes process."
+ "The Relay plugin host is active process-wide and applies to all "
+ "profiles hosted by this Hermes process."
)
== 1
)
@@ -648,7 +655,7 @@ manifest = "relay-plugin.toml"
)
assert [event[0] for event in relay.events] == ["plugin.initialize"]
assert "Hermes Relay plugin initialization failed" in caplog.text
- assert "Relay plugins are active process-wide" not in caplog.text
+ assert "The Relay plugin host is active process-wide" not in caplog.text
finally:
host.shutdown()
@@ -956,7 +963,7 @@ mode = "strict"
relay_runtime._reset_for_tests()
-def test_real_binding_ignores_project_config_without_explicit_opt_in(
+def test_real_binding_discovers_user_and_ignores_project_config(
tmp_path,
monkeypatch,
):
@@ -967,49 +974,31 @@ def test_real_binding_ignores_project_config_without_explicit_opt_in(
project_root = tmp_path / "project"
working_directory = project_root / "workspace"
config_directory = project_root / ".nemo-relay"
- atof_dir = tmp_path / "atof"
working_directory.mkdir(parents=True)
config_directory.mkdir()
- (config_directory / "plugins.toml").write_text(
- f"""
-version = 1
-
-[[components]]
-kind = "observability"
-enabled = true
-
-[components.config]
-version = 3
-
-[components.config.atof]
-enabled = true
-
-[[components.config.atof.sinks]]
-type = "file"
-output_directory = "{atof_dir}"
-filename = "events.jsonl"
-mode = "overwrite"
-""".strip(),
- encoding="utf-8",
- )
+ project_config = config_directory / "plugins.toml"
+ project_config.write_text("", encoding="utf-8")
xdg_config_home = tmp_path / "xdg"
- xdg_config_home.mkdir()
+ user_config = xdg_config_home / "nemo-relay" / "plugins.toml"
+ user_config.parent.mkdir(parents=True)
+ user_config.write_text("", encoding="utf-8")
monkeypatch.chdir(working_directory)
monkeypatch.setenv("XDG_CONFIG_HOME", str(xdg_config_home))
monkeypatch.delenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, raising=False)
host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")
try:
- assert not host.managed_execution_enabled()
- host.ensure_session({"session_id": "native-no-plugins"})
+ assert host.managed_execution_enabled()
+ report = relay_runtime._PLUGIN_CONFIGURATION._activation.report
+ config_paths = set(report["config_paths"])
+ assert str(user_config) in config_paths
+ assert str(project_config) not in config_paths
finally:
host.shutdown()
relay_runtime._reset_for_tests()
- assert not (atof_dir / "events.jsonl").exists()
-
-def test_real_binding_ignores_project_config_with_explicit_opt_in(
+def test_real_binding_explicit_config_replaces_user_and_ignores_project(
tmp_path,
monkeypatch,
):
@@ -1021,58 +1010,17 @@ def test_real_binding_ignores_project_config_with_explicit_opt_in(
working_directory = project_root / "workspace"
config_directory = project_root / ".nemo-relay"
selected_directory = tmp_path / "selected-config"
- project_atof_dir = tmp_path / "project-atof"
- selected_atof_dir = tmp_path / "selected-atof"
working_directory.mkdir(parents=True)
config_directory.mkdir()
selected_directory.mkdir()
- (config_directory / "plugins.toml").write_text(
- f"""
-version = 1
-
-[[components]]
-kind = "observability"
-enabled = true
-
-[components.config]
-version = 3
-
-[components.config.atof]
-enabled = true
-
-[[components.config.atof.sinks]]
-type = "file"
-output_directory = "{project_atof_dir}"
-filename = "events.jsonl"
-mode = "overwrite"
-""".strip(),
- encoding="utf-8",
- )
+ project_config = config_directory / "plugins.toml"
+ project_config.write_text("", encoding="utf-8")
selected_config = selected_directory / "plugins.toml"
- selected_config.write_text(
- f"""
-version = 1
-
-[[components]]
-kind = "observability"
-enabled = true
-
-[components.config]
-version = 4
-
-[components.config.atof]
-enabled = true
-
-[[components.config.atof.sinks]]
-type = "file"
-output_directory = "{selected_atof_dir}"
-filename = "events.jsonl"
-mode = "overwrite"
-""".strip(),
- encoding="utf-8",
- )
+ selected_config.write_text("", encoding="utf-8")
xdg_config_home = tmp_path / "xdg"
- xdg_config_home.mkdir()
+ user_config = xdg_config_home / "nemo-relay" / "plugins.toml"
+ user_config.parent.mkdir(parents=True)
+ user_config.write_text("", encoding="utf-8")
monkeypatch.chdir(working_directory)
monkeypatch.setenv("XDG_CONFIG_HOME", str(xdg_config_home))
monkeypatch.setenv(
@@ -1083,14 +1031,15 @@ mode = "overwrite"
host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")
try:
assert host.managed_execution_enabled()
- host.ensure_session({"session_id": "native-explicit-plugins"})
+ report = relay_runtime._PLUGIN_CONFIGURATION._activation.report
+ config_paths = set(report["config_paths"])
+ assert str(selected_config) in config_paths
+ assert str(user_config) not in config_paths
+ assert str(project_config) not in config_paths
finally:
host.shutdown()
relay_runtime._reset_for_tests()
- assert (selected_atof_dir / "events.jsonl").is_file()
- assert not (project_atof_dir / "events.jsonl").exists()
-
def test_real_binding_keeps_two_profile_trajectories_separate_in_shared_exporters(
tmp_path,
diff --git a/tests/conftest.py b/tests/conftest.py
index 1773ba1c20e..dd5dbe99d16 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -341,6 +341,7 @@ _HERMES_BEHAVIORAL_VARS = frozenset({
"HERMES_EXEC_ASK",
"HERMES_HOME_MODE",
"HERMES_AGENT_USE_LEGACY_SESSION_KEYS",
+ "HERMES_NEMO_RELAY_PLUGINS_TOML",
# Kanban path/board pins must never leak from a developer shell or
# dispatched worker into tests; otherwise tests can write fake tasks to
# the real ~/.hermes/kanban.db instead of the per-test HERMES_HOME.
@@ -494,9 +495,9 @@ _HERMES_BEHAVIORAL_VARS = frozenset({
def _hermetic_environment(tmp_path, monkeypatch):
"""Blank out all credential/behavioral env vars so local and CI match.
- Also redirects HOME and HERMES_HOME to per-test tempdirs so code that
- reads ``~/.hermes/*`` can't touch the real one, and pins TZ/LANG so
- datetime/locale-sensitive tests are deterministic.
+ Also redirects HERMES_HOME and XDG_CONFIG_HOME to per-test tempdirs so
+ code under test cannot read the developer's Hermes or Relay configuration,
+ and pins TZ/LANG so datetime/locale-sensitive tests are deterministic.
"""
# 1. Blank every credential-shaped env var that's currently set.
for name in list(os.environ.keys()):
@@ -541,6 +542,9 @@ def _hermetic_environment(tmp_path, monkeypatch):
if not HOST_LOCK_DIR_AT_CONFTEST_IMPORT:
monkeypatch.delenv("XDG_STATE_HOME", raising=False)
monkeypatch.setenv("HERMES_GATEWAY_LOCK_DIR", str(tmp_path / "gateway-locks"))
+ fake_xdg_config_home = tmp_path / "xdg_config"
+ fake_xdg_config_home.mkdir()
+ monkeypatch.setenv("XDG_CONFIG_HOME", str(fake_xdg_config_home))
# Keep the subprocess-surviving isolation marker pointed at THIS test's
# home (#82770): children spawned by the test inherit it by default, so
# hermes_state's live-DB guard stays armed in them even when the test
diff --git a/website/docs/developer-guide/middleware.md b/website/docs/developer-guide/middleware.md
index bf921314a0e..6b236f7cb88 100644
--- a/website/docs/developer-guide/middleware.md
+++ b/website/docs/developer-guide/middleware.md
@@ -245,8 +245,9 @@ Execution middleware may call `next_call(modified_args)` to pass a changed
payload to later middleware and the base tool dispatcher.
Plugin-specific examples should live with the plugin that owns the behavior.
-NeMo Relay execution middleware is installed through an explicitly selected
-Relay `plugins.toml`; see
+NeMo Relay execution middleware is installed through Relay's discovered user
+and system configuration, or through an explicit `plugins.toml` selected with
+`HERMES_NEMO_RELAY_PLUGINS_TOML`; see
[Relay shared metrics](relay-shared-metrics.md).
## Safety Notes
diff --git a/website/docs/developer-guide/observer-hooks.md b/website/docs/developer-guide/observer-hooks.md
index 6a7d1389fb0..3c30581e9f4 100644
--- a/website/docs/developer-guide/observer-hooks.md
+++ b/website/docs/developer-guide/observer-hooks.md
@@ -325,7 +325,8 @@ The bundled Langfuse plugin demonstrates direct hook-based observability for
turns, provider requests, and tool calls.
The native NeMo Relay SDK integration maps Hermes session, turn, LLM, and tool
-lifecycles to Relay. Explicit Relay plugin configuration can add
+lifecycles to Relay. Relay's discovered user and system configuration, or an
+explicit file selected with `HERMES_NEMO_RELAY_PLUGINS_TOML`, can add
[ATOF, ATIF, or OTEL](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/about)
exporters and execution middleware; see
[Relay shared metrics](relay-shared-metrics.md).
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index da178275326..f8412db5d94 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -18,10 +18,11 @@ as a no-op compatibility alias for existing installation commands.
> This removes the Hermes `observability/nemo_relay` plugin. Existing users
> must remove `observability/nemo_relay` (or its legacy `nemo_relay` alias)
> from `plugins.enabled` and move exporter configuration into a Relay
-> `plugins.toml` selected with `HERMES_NEMO_RELAY_PLUGINS_TOML`. The legacy
-> `HERMES_NEMO_RELAY_ATOF_*` and `HERMES_NEMO_RELAY_ATIF_*` variables no
-> longer activate exporters. Without the new variable, Hermes does not run
-> Relay plugin discovery, configuration layering, middleware, or exporters.
+> `plugins.toml`. `HERMES_NEMO_RELAY_PLUGINS_TOML` can select an explicit
+> file, and `hermes update` or `hermes migrate relay` creates one when
+> migrating legacy `HERMES_NEMO_RELAY_ATOF_*` and
+> `HERMES_NEMO_RELAY_ATIF_*` settings. Those legacy variables no longer
+> configure Relay exporters themselves.
On supported platforms, Hermes requires NeMo Relay 0.9 for managed provider
and tool calls.
@@ -58,13 +59,13 @@ This choice is read from the profile's own `config.yaml`. A machine-managed
configuration overlay cannot enable or disable shared metrics on the profile's
behalf.
-Relay plugin activation remains explicitly opt-in. Set
-`HERMES_NEMO_RELAY_PLUGINS_TOML` to select a `plugins.toml`. When set, Relay
-uses that file instead of the user configuration and applies the machine-wide
-system configuration at higher precedence. Repository-local configuration is
-ignored. If the selected file cannot be loaded, Hermes reports the error and
-continues without Relay plugins rather than falling back to another
-configuration.
+Hermes uses Relay's normal process-wide plugin discovery. Without an explicit
+selection, Relay loads the user `plugins.toml` and then the machine-wide system
+configuration at higher precedence. `HERMES_NEMO_RELAY_PLUGINS_TOML` replaces
+the user file with an explicit file; the system configuration still applies
+above it. Repository-local configuration is ignored. If an explicitly selected
+file cannot be loaded, Hermes reports the error and continues without Relay
+plugins rather than falling back to another configuration.
## Session-Span Segmentation for Continuous Sessions
@@ -99,7 +100,7 @@ static middleware, dynamic plugins, subscribers, exporters, and guardrail
policy. After initialization succeeds, Hermes logs:
```text
-Relay plugins are active process-wide and apply to all profiles hosted by this Hermes process.
+The Relay plugin host is active process-wide and applies to all profiles hosted by this Hermes process.
```
Profile scopes still preserve causal isolation inside that shared policy.
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index 02f934f62e2..59e1dc9064f 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -810,7 +810,7 @@ Advanced per-platform knobs for throttling the outbound message batcher. Most us
| Variable | Description |
|----------|-------------|
-| `HERMES_NEMO_RELAY_PLUGINS_TOML` | Explicit path to the standard NeMo Relay `plugins.toml` loaded process-wide by Hermes core. When unset, Hermes does not initialize Relay middleware, dynamic plugins, or exporters. The removed `HERMES_NEMO_RELAY_ATOF_*` and `HERMES_NEMO_RELAY_ATIF_*` variables are ignored (a `.env` that still carries them exports nothing); `hermes update` / `hermes migrate relay` converts them into `<hermes home>/relay-plugins.toml` and sets this variable — see the [migration note and full example](../user-guide/features/built-in-plugins.md#nemo-relay-native-integration-migration-note). See [NeMo Relay observability configuration](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/about). |
+| `HERMES_NEMO_RELAY_PLUGINS_TOML` | Optional explicit path to a standard NeMo Relay `plugins.toml` loaded process-wide by Hermes core. When unset, Relay uses its normal user configuration followed by the higher-precedence machine-wide system configuration. When set, this file replaces the user configuration while the system configuration still applies above it. The removed `HERMES_NEMO_RELAY_ATOF_*` and `HERMES_NEMO_RELAY_ATIF_*` variables are ignored; `hermes update` / `hermes migrate relay` converts them into `<hermes home>/relay-plugins.toml` and sets this variable — see the [migration note and full example](../user-guide/features/built-in-plugins.md#nemo-relay-native-integration-migration-note). See [NeMo Relay observability configuration](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/about). |
## Agent Behavior
diff --git a/website/docs/user-guide/features/built-in-plugins.md b/website/docs/user-guide/features/built-in-plugins.md
index 1afafcf34ef..93271064db4 100644
--- a/website/docs/user-guide/features/built-in-plugins.md
+++ b/website/docs/user-guide/features/built-in-plugins.md
@@ -207,9 +207,9 @@ Hermes-prefixed and standard SDK env vars (`LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECR
NeMo Relay is no longer a bundled Hermes plugin. Do not run `hermes plugins enable observability/nemo_relay`; Hermes core now owns the Relay session, turn, LLM, and tool lifecycles.
-To opt into Relay middleware or exporters, create a standard Relay `plugins.toml`, then set `HERMES_NEMO_RELAY_PLUGINS_TOML` to that file before starting Hermes. The policy is process-wide for every profile hosted by that Hermes process. See the [NeMo Relay observability configuration](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/about) for ATOF, ATIF, and OpenTelemetry options.
+Configure Relay middleware or exporters through a standard Relay `plugins.toml`. Hermes loads Relay's user configuration and then its machine-wide system configuration. Set `HERMES_NEMO_RELAY_PLUGINS_TOML` before starting Hermes only when you want an explicit file to replace the user configuration; the system configuration still has higher precedence. The policy is process-wide for every profile hosted by that Hermes process. See the [NeMo Relay observability configuration](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/about) for ATOF, ATIF, and OpenTelemetry options.
-The old `HERMES_NEMO_RELAY_ATOF_*` and `HERMES_NEMO_RELAY_ATIF_*` settings no longer activate exporters — a `.env` that still carries them (and no `HERMES_NEMO_RELAY_PLUGINS_TOML`) exports **nothing**, and the gateway logs one warning saying so. `hermes doctor` reports these stale settings when no replacement `plugins.toml` is selected.
+The old `HERMES_NEMO_RELAY_ATOF_*` and `HERMES_NEMO_RELAY_ATIF_*` settings no longer configure exporters. When `HERMES_NEMO_RELAY_PLUGINS_TOML` is unset, the gateway warns about remaining legacy variables and `hermes doctor` reports them. Independently discovered Relay user or system exporters still apply.
**Automatic migration.** `hermes update` (and `hermes migrate relay`, or `hermes migrate relay --all-profiles` for every profile home) converts the legacy variables into `<hermes home>/relay-plugins.toml`, sets `HERMES_NEMO_RELAY_PLUGINS_TOML` in that profile's `.env`, and comments the legacy lines out (nothing is deleted). Under a multiplexed gateway every profile home gets its own file. The generated file is validated through Relay before it is written; this is the shape it produces (note the `type = "file"` sink discriminator — a sink without it is rejected):