The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(relay): move to the NeMo Relay 0.9 plugin-host API
mschwab1477d8e659bc
diff --git a/agent/relay_runtime.py b/agent/relay_runtime.pyindex 6daa2cc01a6..0cbe9333d72 100644--- a/agent/relay_runtime.py+++ b/agent/relay_runtime.py@@ -245,6 +245,12 @@ class _ProcessRelayPluginConfiguration:return _RelayPluginConfigurationState.DISABLEDexcept Exception as exc:self._activation = None+ if _is_relay_host_conflict(exc):+ logger.warning(+ "A process-global Relay plugin configuration is already active outside Hermes native "+ "ownership; leaving it unchanged and disabling Hermes-managed Relay middleware for this process"+ )+ return _RelayPluginConfigurationState.FOREIGNlogger.warning("Hermes Relay plugin initialization failed: %s", exc, exc_info=True)return _RelayPluginConfigurationState.FAILEDself._relay = relay@@ -257,41 +263,20 @@ class _ProcessRelayPluginConfiguration:"Hermes Relay plugin cleanup is still pending; refusing to replace the process-global configuration")return _RelayPluginConfigurationState.FAILED- try:- existing_report = relay.plugin.report()- except Exception:- logger.warning(- "Hermes could not determine whether a process-global Relay plugin configuration is already "- "active; refusing to replace it", exc_info=True,- )- return _RelayPluginConfigurationState.FAILED- if existing_report is not None:- logger.warning(- "A process-global Relay plugin configuration is already active outside Hermes native ownership; "- "leaving it unchanged and disabling Hermes-managed Relay middleware for this process"- )- return _RelayPluginConfigurationState.FOREIGNreturn Nonedef _initialize(self, relay: Any) -> bool:"""Initialize Relay from the selected plugins.toml; False when none is selected."""- configured_inputs = _configured_plugin_inputs(relay)- if configured_inputs is None:+ config_path = _configured_plugin_inputs()+ if config_path is None:return False- plugin_config, dynamic_plugins = configured_inputs- if dynamic_plugins:- try:- initialize = relay.plugin.initialize_with_dynamic_plugins- activation = _resolve_plugin_awaitable(initialize(plugin_config, dynamic_plugins))- if activation is None:- raise RuntimeError("NeMo Relay dynamic plugin initialization returned no activation handle")- self._activation = activation- except Exception as exc:- raise RuntimeError("Hermes Relay dynamic plugin activation failed") from exc- if self._activation is None:- # Reached only after explicit opt-in. Relay 0.8 no longer layers repository-local- # configuration onto this explicitly selected payload.- _resolve_plugin_awaitable(relay.plugin.initialize(plugin_config))+ # The explicit file is the whole payload, static components and [[plugins.dynamic]]+ # alike; Relay resolves it in place of user-file discovery and hands back the+ # activation that owns every plugin it loaded.+ 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 = activationreturn Truedef release(self, owner: Any) -> None:@@ -319,11 +304,9 @@ class _ProcessRelayPluginConfiguration:return Truedef close_configuration() -> Any:- if activation is None:- return _resolve_plugin_awaitable(relay.plugin.clear_async())if callable(close := getattr(activation, "close", None)):return _resolve_plugin_awaitable(close())- raise RuntimeError("NeMo Relay dynamic plugin activation has no close method")+ raise RuntimeError("NeMo Relay plugin activation has no close method")for what, step in (("subscriber flush", lambda: _resolve_plugin_awaitable(relay.subscribers.flush_async())),@@ -1232,8 +1215,8 @@ def _load_nemo_relay() -> Any:return importlib.import_module("nemo_relay")-def _configured_plugin_inputs(relay: Any) -> tuple[dict[str, Any], list[Any]] | None:- """Load selected plugin inputs, or return ``None`` when none were selected."""+def _configured_plugin_inputs() -> Path | None:+ """Return the selected plugins.toml once it parses, or ``None`` when none was selected."""configured = os.environ.get(RELAY_PLUGINS_CONFIG_ENV, "").strip()if not configured:if legacy_vars := configured_legacy_relay_env_vars(os.environ):@@ -1251,14 +1234,25 @@ def _configured_plugin_inputs(relay: Any) -> tuple[dict[str, Any], list[Any]] |config = tomllib.load(config_file)if "dynamic_plugins" in config:raise ValueError("Hermes [[dynamic_plugins]] records are unsupported; use Relay [[plugins.dynamic]] records")- dynamic_plugins = relay.plugin.load_dynamic_plugin_activation_specs(config_path) if "plugins" in config else []- return {k: v for k, v in config.items() if k != "plugins"}, dynamic_plugins+ return config_pathexcept Exception as exc:raise _RelayPluginConfigurationLoadError(f"Hermes Relay plugin configuration could not be loaded from {config_path}; continuing without Relay plugins") from exc+# Relay 0.9 has no query for an active plugin host; the only signal is initialize refusing the+# lease. These are the two PluginError::Conflict messages it raises for that.+_RELAY_HOST_CONFLICT_MARKERS = (+ "plugin configuration is already active",+ "owned by an active dynamic plugin host",+)+++def _is_relay_host_conflict(exc: BaseException) -> bool:+ return isinstance(exc, RuntimeError) and any(marker in str(exc) for marker in _RELAY_HOST_CONFLICT_MARKERS)++def _resolve_plugin_awaitable(value: Any) -> Any:"""Resolve Relay's async plugin API from synchronous host construction."""if not inspect.isawaitable(value):diff --git a/hermes_cli/relay_plugin_migrate.py b/hermes_cli/relay_plugin_migrate.pyindex bf2606c6735..8ddc9642edf 100644--- a/hermes_cli/relay_plugin_migrate.py+++ b/hermes_cli/relay_plugin_migrate.py@@ -125,25 +125,13 @@ def dumps_toml(document: Mapping[str, Any]) -> str:def validate_relay_plugin_payload(payload: Mapping[str, Any]) -> list:- """Activate the payload once through Relay's own validator and clear it; returns the diagnostics- (empty = clean). Raises when Relay rejects the document outright."""- import asyncio+ """Run the payload through Relay's own validator; returns the diagnostics (empty = clean).+ Raises when Relay rejects the document outright."""from nemo_relay import plugin- async def _probe():- try:- report = await plugin.initialize(dict(payload))- finally:- await plugin.clear_async()- return list((report or {}).get("diagnostics") or []) if isinstance(report, dict) else []-- try:- asyncio.get_running_loop()- except RuntimeError:- return asyncio.run(_probe())- import concurrent.futures- with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:- return pool.submit(lambda: asyncio.run(_probe())).result()+ report = plugin.validate(dict(payload))+ config_report = report.get("config") if isinstance(report, dict) else None+ return list((config_report or {}).get("diagnostics") or []) if isinstance(config_report, dict) else []def _comment_out_legacy_lines(lines: list[str], names: set[str]) -> list[str]:diff --git a/pyproject.toml b/pyproject.tomlindex e366b8459da..2eb56a84982 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -189,7 +189,7 @@ dependencies = [# 738 CPython reports sys_platform == 'android' and never matched.) Pre-GKI# devices can still slip through; they get the same resolution failure as# before, worked around by installing with `--no-deps` or an older release.- "nemo-relay>=0.8.3,<0.9; (sys_platform == 'darwin' and platform_machine == 'arm64') or (sys_platform == 'linux' and platform_machine == 'x86_64' and 'android' not in platform_release) or (sys_platform == 'linux' and platform_machine == 'aarch64' and 'android' not in platform_release) or (sys_platform == 'win32' and platform_machine == 'AMD64') or (sys_platform == 'win32' and platform_machine == 'ARM64')",+ "nemo-relay>=0.9,<0.10; (sys_platform == 'darwin' and platform_machine == 'arm64') or (sys_platform == 'linux' and platform_machine == 'x86_64' and 'android' not in platform_release) or (sys_platform == 'linux' and platform_machine == 'aarch64' and 'android' not in platform_release) or (sys_platform == 'win32' and platform_machine == 'AMD64') or (sys_platform == 'win32' and platform_machine == 'ARM64')",][project.optional-dependencies]diff --git a/tests/agent/test_relay_runtime_plugins.py b/tests/agent/test_relay_runtime_plugins.pyindex 214d80d24d9..a2869569713 100644--- a/tests/agent/test_relay_runtime_plugins.py+++ b/tests/agent/test_relay_runtime_plugins.py@@ -14,31 +14,25 @@ import pytestfrom agent import relay_runtime+HOST_CONFLICT = RuntimeError(+ "a static plugin configuration is already active; to combine static and dynamic plugins, "+ "provide the static components as the base configuration"+)++class _FakeRelay:def __init__(self,*,initialize_error: Exception | None = None,- dynamic_initialize_error: Exception | None = None,activation_close_error: Exception | None = None,- active_report: Any = None,- report_error: Exception | None = None,) -> None:self.events: list[tuple[Any, ...]] = []self.initialize_error = initialize_error- self.dynamic_initialize_error = dynamic_initialize_errorself.activation_close_error = activation_close_error- self.active_report = active_report- self.report_error = report_error- self.dynamic_plugin_specs: list[dict[str, Any]] = []+ self.initialized_from: list[str | None] = []self.ScopeType = SimpleNamespace(Agent="agent")- self.plugin = SimpleNamespace(- initialize=self._initialize_plugins,- initialize_with_dynamic_plugins=self._initialize_dynamic_plugins,- load_dynamic_plugin_activation_specs=self._load_dynamic_plugin_specs,- clear_async=self._clear_plugins_async,- report=self._report_plugins,- )+ self.plugin = SimpleNamespace(initialize=self._initialize_plugins)self.scope = SimpleNamespace(push=self._scope_push,pop=self._scope_pop,@@ -48,24 +42,24 @@ class _FakeRelay:def get_scope_stack(self) -> None:return None- async def _initialize_plugins(self, config: dict[str, Any]) -> dict[str, Any]:- self.events.append(("plugin.initialize", config))- if self.initialize_error is not None:- raise self.initialize_error- return {"diagnostics": []}-- async def _initialize_dynamic_plugins(+ async def _initialize_plugins(self,config: dict[str, Any],- dynamic_plugins: list[dict[str, Any]],+ additional_plugins_toml: Any = None,) -> Any:- self.events.append(("plugin.initialize_dynamic", config, dynamic_plugins))- if self.dynamic_initialize_error is not None:- raise self.dynamic_initialize_error+ self.events.append(("plugin.initialize", config))+ self.initialized_from.append(+ str(additional_plugins_toml) if additional_plugins_toml is not None else None+ )+ if self.initialize_error is not None:+ raise self.initialize_errorrelay = selfclass _Activation:+ report = {"config": {"diagnostics": []}, "dynamic_plugins": []}+ is_active = True+async def close(self) -> None:relay.events.append(("plugin.activation.close",))if relay.activation_close_error is not None:@@ -73,18 +67,6 @@ class _FakeRelay:return _Activation()- def _load_dynamic_plugin_specs(self, config_path: Any) -> list[dict[str, Any]]:- self.events.append(("plugin.load_dynamic_specs", str(config_path)))- return self.dynamic_plugin_specs-- async def _clear_plugins_async(self) -> None:- self.events.append(("plugin.clear_async",))-- def _report_plugins(self) -> Any:- if self.report_error is not None:- raise self.report_error- return self.active_report-def _scope_push(self, name: str, scope_type: Any, **kwargs: Any) -> Any:handle = ("scope", name, len(self.events))self.events.append(("scope.push", name, scope_type, kwargs))@@ -122,21 +104,13 @@ class _BehavioralFakeRelay(_FakeRelay):def get_scope_stack(self) -> Any:return self._scope_stack.get()- async def _initialize_plugins(self, config: dict[str, Any]) -> dict[str, Any]:- report = await super()._initialize_plugins(config)- self._plugin_source = "static"- return report-- async def _initialize_dynamic_plugins(+ async def _initialize_plugins(self,config: dict[str, Any],- dynamic_plugins: list[dict[str, Any]],+ additional_plugins_toml: Any = None,) -> Any:- activation = await super()._initialize_dynamic_plugins(- config,- dynamic_plugins,- )- self._plugin_source = "dynamic"+ activation = await super()._initialize_plugins(config, additional_plugins_toml)+ self._plugin_source = "explicit"return activationdef _scope_push(self, name: str, scope_type: Any, **kwargs: Any) -> Any:@@ -250,8 +224,7 @@ def test_foreign_active_plugin_configuration_is_left_unchanged(explicit_static_config,caplog,):- foreign_report = {"diagnostics": [], "source": "embedding-host"}- relay = _FakeRelay(active_report=foreign_report)+ relay = _FakeRelay(initialize_error=HOST_CONFLICT)with caplog.at_level("WARNING"):host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")@@ -262,31 +235,30 @@ def test_foreign_active_plugin_configuration_is_left_unchanged(host._plugin_configuration_stateis relay_runtime._RelayPluginConfigurationState.FOREIGN)- assert relay.active_report is foreign_report- assert relay.events == []+ assert relay.events == [("plugin.initialize", {})]+ assert ("plugin.activation.close",) not in relay.eventsassert "already active outside Hermes native ownership" in caplog.textassert "leaving it unchanged" in caplog.textfinally:host.shutdown()+ assert ("subscribers.flush_async",) not in relay.events-def test_unreadable_foreign_plugin_state_fails_safe(- explicit_static_config,- caplog,-):- relay = _FakeRelay(report_error=RuntimeError("report unavailable"))++def test_dynamic_host_conflict_is_foreign_too(explicit_static_config, caplog):+ relay = _FakeRelay(+ initialize_error=RuntimeError(+ "plugin configuration is owned by an active dynamic plugin host"+ )+ )with caplog.at_level("WARNING"):host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")-try:- assert not host.managed_execution_enabled()assert (host._plugin_configuration_state- is relay_runtime._RelayPluginConfigurationState.FAILED+ is relay_runtime._RelayPluginConfigurationState.FOREIGN)- assert relay.events == []- assert "refusing to replace it" in caplog.textfinally:host.shutdown()@@ -431,12 +403,7 @@ def test_present_plugins_section_is_validated_even_when_falsey(config = tmp_path / "plugins.toml"config.write_text("plugins = []", encoding="utf-8")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))- relay = _FakeRelay()-- def reject_invalid_plugins(_config_path):- raise ValueError("'plugins' must be a table")-- relay.plugin.load_dynamic_plugin_activation_specs = reject_invalid_plugins+ relay = _FakeRelay(initialize_error=ValueError("'plugins' must be a table"))with caplog.at_level("WARNING"):host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")@@ -446,9 +413,10 @@ def test_present_plugins_section_is_validated_even_when_falsey(host._plugin_configuration_stateis relay_runtime._RelayPluginConfigurationState.FAILED)- assert relay.events == []+ # Hermes hands the file to Relay as-is; a falsey section is Relay's to reject.+ assert relay.initialized_from == [str(config)]assert "'plugins' must be a table" in caplog.text- assert "continuing without Relay plugins" in caplog.text+ assert "Hermes Relay plugin initialization failed" in caplog.textfinally:host.shutdown()@@ -483,24 +451,24 @@ def test_two_profile_hosts_initialize_once_and_clear_after_final_shutdown(tool_name="terminal",args={"profile": "b"},)- assert rewritten_a["relay_plugin_source"] == "static"- assert rewritten_b["relay_plugin_source"] == "static"+ assert rewritten_a["relay_plugin_source"] == "explicit"+ assert rewritten_b["relay_plugin_source"] == "explicit"assert rewritten_a["relay_scope_stack"] != rewritten_b["relay_scope_stack"]host_a.shutdown()- assert ("plugin.clear_async",) not in relay.events+ assert ("plugin.activation.close",) not in relay.eventshost_b.shutdown()assert relay.events[-2:] == [("subscribers.flush_async",),- ("plugin.clear_async",),+ ("plugin.activation.close",),]assert relay.events.count(("plugin.initialize", {})) == 1- assert relay.events.count(("plugin.clear_async",)) == 1+ assert relay.events.count(("plugin.activation.close",)) == 1pop_index = next(index for index, event in enumerate(relay.events) if event[0] == "scope.pop")- assert pop_index < relay.events.index(("plugin.clear_async",))+ assert pop_index < relay.events.index(("plugin.activation.close",))def test_plugin_initialization_inside_running_event_loop(explicit_static_config):@@ -531,7 +499,7 @@ def test_static_plugin_cleanup_uses_async_apis_inside_running_event_loop(assert relay.events == [("plugin.initialize", {}),("subscribers.flush_async",),- ("plugin.clear_async",),+ ("plugin.activation.close",),]@@ -565,48 +533,15 @@ manifest = "plugins/worker/relay-plugin.toml")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))relay = _BehavioralFakeRelay()- relay.dynamic_plugin_specs = [- {- "plugin_id": "native.policy",- "kind": "rust_dynamic",- "manifest_ref": str(- config.parent / "plugins/native/relay-plugin.toml"- ),- "config": {"mode": "strict"},- },- {- "plugin_id": "worker.policy",- "kind": "worker",- "manifest_ref": str(- config.parent / "plugins/worker/relay-plugin.toml"- ),- "environment_ref": str(config.parent / "environments/worker"),- "config": {},- },- ]host_a = relay_runtime.RelayRuntime(relay=relay, profile_key="profile-a")host_b = relay_runtime.RelayRuntime(relay=relay, profile_key="profile-b")assert host_a.managed_execution_enabled()assert host_b.managed_execution_enabled()- assert relay.events == [- ("plugin.load_dynamic_specs", str(config)),- (- "plugin.initialize_dynamic",- {- "version": 1,- "components": [- {- "kind": "observability",- "enabled": True,- "config": {"version": 1},- }- ],- },- relay.dynamic_plugin_specs,- )- ]+ # Static components and [[plugins.dynamic]] travel together as the explicit file.+ assert relay.events == [("plugin.initialize", {})]+ assert relay.initialized_from == [str(config)]rewritten_a = host_a.apply_tool_request_intercepts(session_id="profile-a-session",@@ -618,8 +553,8 @@ manifest = "plugins/worker/relay-plugin.toml"tool_name="terminal",args={"profile": "b"},)- assert rewritten_a["relay_plugin_source"] == "dynamic"- assert rewritten_b["relay_plugin_source"] == "dynamic"+ assert rewritten_a["relay_plugin_source"] == "explicit"+ assert rewritten_b["relay_plugin_source"] == "explicit"assert rewritten_a["relay_scope_stack"] != rewritten_b["relay_scope_stack"]host_a.shutdown()@@ -630,7 +565,6 @@ manifest = "plugins/worker/relay-plugin.toml"("subscribers.flush_async",),("plugin.activation.close",),]- assert ("plugin.clear_async",) not in relay.eventsassert relay.events.count(("plugin.activation.close",)) == 1pop_index = next(index for index, event in enumerate(relay.events) if event[0] == "scope.pop"@@ -652,10 +586,7 @@ manifest = "relay-plugin.toml"encoding="utf-8",)monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))- relay = _FakeRelay(- dynamic_initialize_error=RuntimeError("worker rejected config")- )- relay.dynamic_plugin_specs = [{"plugin_id": "worker.policy"}]+ relay = _FakeRelay(initialize_error=RuntimeError("worker rejected config"))with caplog.at_level("INFO"):host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")@@ -665,17 +596,14 @@ manifest = "relay-plugin.toml"host._plugin_configuration_stateis relay_runtime._RelayPluginConfigurationState.FAILED)- assert [event[0] for event in relay.events] == [- "plugin.load_dynamic_specs",- "plugin.initialize_dynamic",- ]- assert "dynamic plugin activation failed" in caplog.text+ assert [event[0] for event in relay.events] == ["plugin.initialize"]+ assert "Hermes Relay plugin initialization failed" in caplog.textassert "Relay plugins are active process-wide" not in caplog.textfinally:host.shutdown()assert ("subscribers.flush_async",) not in relay.events- assert ("plugin.clear_async",) not in relay.events+ assert ("plugin.activation.close",) not in relay.eventsdef test_dynamic_activation_lifecycle_inside_running_event_loop(@@ -692,7 +620,6 @@ manifest = "relay-plugin.toml")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))relay = _FakeRelay()- relay.dynamic_plugin_specs = [{"plugin_id": "native.policy"}]async def run_lifecycle() -> None:host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")@@ -702,8 +629,7 @@ manifest = "relay-plugin.toml"asyncio.run(run_lifecycle())assert [event[0] for event in relay.events] == [- "plugin.load_dynamic_specs",- "plugin.initialize_dynamic",+ "plugin.initialize","subscribers.flush_async","plugin.activation.close",]@@ -723,7 +649,6 @@ manifest = "relay-plugin.toml")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))relay = _FakeRelay()- relay.dynamic_plugin_specs = [{"plugin_id": "worker.policy"}]async def run_lifecycle() -> None:host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")@@ -823,7 +748,7 @@ def test_session_close_does_not_flush_during_concurrent_managed_publication(assert relay.events.index(("publication.end",)) < relay.events.index(("subscribers.flush_async",))- assert relay.events[-1] == ("plugin.clear_async",)+ assert relay.events[-1] == ("plugin.activation.close",)def test_failed_dynamic_teardown_retains_activation_and_blocks_replacement(@@ -841,15 +766,6 @@ manifest = "relay-plugin.toml")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))relay = _FakeRelay(activation_close_error=RuntimeError("worker still busy"))- relay.dynamic_plugin_specs = [- {- "plugin_id": "worker.policy",- "kind": "worker",- "manifest_ref": str(tmp_path / "relay-plugin.toml"),- "environment_ref": str(tmp_path / "environment"),- "config": {},- }- ]host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")with caplog.at_level("WARNING"):@@ -867,9 +783,7 @@ manifest = "relay-plugin.toml"try:assert not replacement.managed_execution_enabled()assert relay_runtime._PLUGIN_CONFIGURATION._activation is activation- assert relay.events.count(- ("plugin.initialize_dynamic", {}, relay.dynamic_plugin_specs)- ) == 1+ assert relay.events.count(("plugin.initialize", {})) == 1assert relay.events.count(("plugin.activation.close",)) == 2assert "refusing to replace" in caplog.textfinally:@@ -880,7 +794,7 @@ manifest = "relay-plugin.toml"relay_runtime._PLUGIN_CONFIGURATION.reset_for_tests()-def test_standard_dynamic_records_use_relay_toml_loader(+def test_dynamic_records_are_handed_to_relay_unparsed(tmp_path,monkeypatch,):@@ -894,22 +808,12 @@ manifest = "relay-plugin.toml")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))relay = _FakeRelay()- relay.dynamic_plugin_specs = [- {- "plugin_id": "native.policy",- "kind": "rust_dynamic",- "manifest_ref": str(tmp_path / "relay-plugin.toml"),- "config": {},- }- ]host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")try:assert host.managed_execution_enabled()- assert relay.events == [- ("plugin.load_dynamic_specs", str(config)),- ("plugin.initialize_dynamic", {}, relay.dynamic_plugin_specs),- ]+ assert relay.events == [("plugin.initialize", {})]+ assert relay.initialized_from == [str(config)]finally:host.shutdown()@@ -950,11 +854,14 @@ manifest_ref = "relay-plugin.toml"host.shutdown()-def test_real_binding_loads_standard_dynamic_specs_from_explicit_toml(+def test_real_binding_hands_dynamic_records_to_relay_and_fails_open_on_rejection(tmp_path,monkeypatch,+ caplog,):relay = pytest.importorskip("nemo_relay")+ if getattr(relay, "_native", None) is None:+ pytest.skip("NeMo Relay native binding is unavailable on this platform")manifest = tmp_path / "plugins" / "relay-plugin.toml"manifest.parent.mkdir()manifest.write_text(@@ -982,17 +889,23 @@ mode = "strict")monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config))- plugin_config, specs = relay_runtime._configured_plugin_inputs(relay)+ assert relay_runtime._configured_plugin_inputs() == config- assert plugin_config == {"version": 1}- assert [spec.to_dict() for spec in specs] == [- {- "plugin_id": "fixture.native",- "kind": "rust_dynamic",- "manifest_ref": str(manifest.resolve()),- "config": {"mode": "strict"},- }- ]+ # Relay, not Hermes, now reads and validates the [[plugins.dynamic]] records. This+ # manifest is incomplete for Relay 0.9, and that rejection must fail Hermes open.+ with caplog.at_level("WARNING"):+ host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")+ try:+ assert not host.managed_execution_enabled()+ assert (+ host._plugin_configuration_state+ is relay_runtime._RelayPluginConfigurationState.FAILED+ )+ assert "Hermes Relay plugin initialization failed" in caplog.text+ assert "relay-plugin.toml" in caplog.text+ finally:+ host.shutdown()+ relay_runtime._reset_for_tests()def test_real_binding_ignores_project_config_without_explicit_opt_in(@@ -1036,7 +949,6 @@ mode = "overwrite"monkeypatch.chdir(working_directory)monkeypatch.setenv("XDG_CONFIG_HOME", str(xdg_config_home))monkeypatch.delenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, raising=False)- relay.plugin.clear()host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")try:@@ -1119,7 +1031,6 @@ mode = "overwrite"relay_runtime.RELAY_PLUGINS_CONFIG_ENV,str(selected_config),)- relay.plugin.clear()host = relay_runtime.RelayRuntime(relay=relay, profile_key="profile")try:@@ -1184,7 +1095,6 @@ agent_version = "test"monkeypatch.setenv("XDG_CONFIG_HOME", str(xdg_config_home))monkeypatch.setenv(relay_runtime.RELAY_PLUGINS_CONFIG_ENV, str(config_path))monkeypatch.setattr(relay_runtime, "_load_nemo_relay", lambda: relay)- relay.plugin.clear()runtime_ids: dict[str, str] = {}try:diff --git a/tests/hermes_cli/test_relay_plugin_migrate.py b/tests/hermes_cli/test_relay_plugin_migrate.pyindex c5cd2bbc6fb..9a2e74bc25b 100644--- a/tests/hermes_cli/test_relay_plugin_migrate.py+++ b/tests/hermes_cli/test_relay_plugin_migrate.py@@ -3,7 +3,6 @@ become a validated ``relay-plugins.toml`` per profile home, selected from ``.envfrom __future__ import annotations-import asyncioimport tomllibfrom pathlib import Path@@ -58,9 +57,8 @@ def test_legacy_env_becomes_validated_toml_selected_from_env(profile_env):assert sink["type"] == "file" and sink["filename"] == "hermes-atof.jsonl"assert document["components"][0]["config"]["atif"]["filename_template"] == "trajectory-{session_id}.json"# Relay itself accepts the file Hermes will load at runtime.- report = asyncio.run(nemo_relay.plugin.initialize(document))- asyncio.run(nemo_relay.plugin.clear_async())- assert report.get("diagnostics") == []+ report = nemo_relay.plugin.validate(document)+ assert report["config"]["diagnostics"] == []# .env now selects the file; the legacy lines survive as comments (not deleted), so the# runtime warning + doctor finding go quiet and a second run is a no-op.env = _parse_env(profile_env / ".env")diff --git a/uv.lock b/uv.lockindex 80191e44773..1af3581e5db 100644--- a/uv.lock+++ b/uv.lock@@ -8,7 +8,7 @@ resolution-markers = [][options]-exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.+exclude-newer = "2026-09-04T17:51:26.683963Z"exclude-newer-span = "P14D"[options.exclude-newer-package]@@ -2074,7 +2074,7 @@ requires-dist = [{ name = "microsoft-teams-apps", marker = "extra == 'teams'", specifier = "==2.0.13.4" },{ name = "mistralai", marker = "extra == 'mistral'", specifier = "==2.4.8" },{ name = "modal", marker = "extra == 'modal'", specifier = "==1.3.4" },- { name = "nemo-relay", marker = "(platform_machine == 'aarch64' and 'android' not in platform_release and sys_platform == 'linux') or (platform_machine == 'x86_64' and 'android' not in platform_release and sys_platform == 'linux') or (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'AMD64' and sys_platform == 'win32') or (platform_machine == 'ARM64' and sys_platform == 'win32')", specifier = ">=0.8.3,<0.9" },+ { name = "nemo-relay", marker = "(platform_machine == 'aarch64' and 'android' not in platform_release and sys_platform == 'linux') or (platform_machine == 'x86_64' and 'android' not in platform_release and sys_platform == 'linux') or (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'AMD64' and sys_platform == 'win32') or (platform_machine == 'ARM64' and sys_platform == 'win32')", specifier = ">=0.9,<0.10" },{ name = "numpy", marker = "extra == 'voice'", specifier = "==2.4.3" },{ name = "numpy", marker = "extra == 'wake'", specifier = "==2.4.3" },{ name = "onnxruntime", marker = "extra == 'wake'", specifier = "==1.27.0" },@@ -2942,17 +2942,17 @@ wheels = [[[package]]name = "nemo-relay"-version = "0.8.3"+version = "0.9.0"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/03/73/ac90ccb08faca19b2c8470bdd4d5b9bae89fc5edfde8dae72ee7b1a2d8df/nemo_relay-0.8.3.tar.gz", hash = "sha256:3670c0689f0709354068a1460131e6f01ea44cd7c2b2186930dd20b23cd079ff", size = 1615748, upload-time = "2026-09-02T03:32:45.828Z" }+sdist = { url = "https://files.pythonhosted.org/packages/40/c8/9aa54f9f6072b23db98dc59208c813ad032be17dd56ea1b7df38a3b5ade2/nemo_relay-0.9.0.tar.gz", hash = "sha256:bfe3113b5b0054bd1e992abf33b8174121be2bda832fa7e1e22e1d7c2a57735a", size = 1688244, upload-time = "2026-09-17T16:20:39.982Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/2a/6a/199c2061358684550780bfc3184e588cea6533ec697ae6fa2f36f8881412/nemo_relay-0.8.3-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:2b0a59b8a95d6ed9de099e471318af672b51426a89c2019766ac889b1e23f1d4", size = 10200865, upload-time = "2026-09-02T03:32:15.373Z" },- { url = "https://files.pythonhosted.org/packages/df/90/3486d10c2003cda3bd4ce98d34e40f283faf87dcb1292cddca356a86c6be/nemo_relay-0.8.3-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0c84a93ad0d4bea9a7bf67917874cd4eee24694764456a5f94c9609b1df42904", size = 9199160, upload-time = "2026-09-02T03:32:17.467Z" },- { url = "https://files.pythonhosted.org/packages/18/00/15705b941df64443e50c49139140dd84603f23125ab48f9c122942911439/nemo_relay-0.8.3-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10b08a939678d8f54ad02e5fb086454ffad15f269eae4854e9597956dc96b176", size = 9760299, upload-time = "2026-09-02T03:32:19.255Z" },- { url = "https://files.pythonhosted.org/packages/00/d3/2dac6a938713cfb6f59d8f3e82e991a1635a666f25f8d7fed8a3fa9c56b7/nemo_relay-0.8.3-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:c2fba57f39100068244f8fcaffbdd801a0a8ccc7b9dbee330bb087f3970d8ccc", size = 11287368, upload-time = "2026-09-02T03:32:21.359Z" },- { url = "https://files.pythonhosted.org/packages/e0/d2/f61379d244139306c3832082d446ad6167f50108969b3e8720e62e1b2ae5/nemo_relay-0.8.3-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ae6804050b309a12dae5a7afc8c85b29b601c2c4a4257d365a998b774a2e7d16", size = 11717569, upload-time = "2026-09-02T03:32:23.321Z" },- { url = "https://files.pythonhosted.org/packages/db/96/333f62b4176450154a8908f619e3323b70b43c3b733a0a0752ba3b9232b1/nemo_relay-0.8.3-cp311-abi3-win_amd64.whl", hash = "sha256:b1f006e50e44967821f3a77a2e0001eed8154db01168abcc0681891f9c339fed", size = 9656294, upload-time = "2026-09-02T03:32:25.904Z" },- { url = "https://files.pythonhosted.org/packages/fe/bd/37ab6038111d3cdec1858e584ef9e8fdfe0db07aa6073d66d1303b18d791/nemo_relay-0.8.3-cp311-abi3-win_arm64.whl", hash = "sha256:0d3db4f0a9d1f909acbf659612bfb9859e304b53cd425ef8e0f60ca851e85173", size = 9235572, upload-time = "2026-09-02T03:32:28.042Z" },+ { url = "https://files.pythonhosted.org/packages/d1/74/4e5cdb8ef27444e93fe89593747ab31aeef6b191a44025ebe5529d9bcb13/nemo_relay-0.9.0-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:3592ac7b53aec0a1c6d64c0ea55eb35f5e1aedf340399fe00682a2a7f93760e1", size = 10294612, upload-time = "2026-09-17T16:19:56.441Z" },+ { url = "https://files.pythonhosted.org/packages/fa/13/783e6b409530d45d55d39809169b3f617cecf1ee03077c376e2d15f55817/nemo_relay-0.9.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dec6f5e623785bf171cd2327d80377c0b6b0f48a0fb3ec65921151b0ae7b8c23", size = 9227964, upload-time = "2026-09-17T16:19:59.307Z" },+ { url = "https://files.pythonhosted.org/packages/14/8a/5edfa13b8d66672e6c39f86e52d977701179b01c4d925a5b731a1237f953/nemo_relay-0.9.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32dc3c5506f630c7976e139c247db8f5f926814d3d6477eab2a926885980b956", size = 9831347, upload-time = "2026-09-17T16:20:02.181Z" },+ { url = "https://files.pythonhosted.org/packages/fb/93/17daffa48f4af9d69ea079ec38405547e4b664e58d53225ccac6dce222f4/nemo_relay-0.9.0-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ca667add7abc9c0714e2f5aae6f097cc3b942591a286734bb4b15f56b3e9971c", size = 11396245, upload-time = "2026-09-17T16:20:04.807Z" },+ { url = "https://files.pythonhosted.org/packages/97/2a/588642d0fa5540f8994f938d3b100555e9477e7c0f0984b37d4f153b3d1c/nemo_relay-0.9.0-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:5776578a31ad72f1a5cd08408e78d9d4c2d079df5a4cd9f666ec5fe4a5441a39", size = 11862826, upload-time = "2026-09-17T16:20:08.712Z" },+ { url = "https://files.pythonhosted.org/packages/78/3a/1cf19338e7129df47b94ddcabe69120fa8aff39d8f8a36c8cdbd2a33ea37/nemo_relay-0.9.0-cp311-abi3-win_amd64.whl", hash = "sha256:b3d8b1b82001846f847cc83dbc05f66f9832534408103475b21d0829e4dbf251", size = 9793012, upload-time = "2026-09-17T16:20:11.511Z" },+ { url = "https://files.pythonhosted.org/packages/9f/89/d3f81b4d55c081c2f4580be13c94a7f851bc796077536c8e94d4b73ff528/nemo_relay-0.9.0-cp311-abi3-win_arm64.whl", hash = "sha256:f9d3296b1bdd54f88faef1d2cdbdac852b8aff244532169f42c2f144d9b5dffe", size = 9374047, upload-time = "2026-09-17T16:20:14.322Z" },][[package]]@@ -4283,7 +4283,7 @@ resolution-markers = ["python_full_version < '3.12'",]dependencies = [- { name = "numpy" },+ { name = "numpy", marker = "python_full_version < '3.12'" },]sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", hash = "sha256:95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0", size = 30573822, upload-time = "2026-02-23T00:26:24.851Z" }wheels = [@@ -4338,7 +4338,7 @@ resolution-markers = ["python_full_version == '3.12.*'",]dependencies = [- { name = "numpy" },+ { name = "numpy", marker = "python_full_version >= '3.12'" },]sdist = { url = "https://files.pythonhosted.org/packages/a7/25/c2700dfaf6442b4effaa91af24ebce5dc9d31bb4a69706313aae70d72cd0/scipy-1.18.0.tar.gz", hash = "sha256:67b2ad2ad54c72ca6d04975a9b2df8c3638c34ddd5b28738e94fc2b57929d378", size = 30774447, upload-time = "2026-06-19T15:01:43.456Z" }wheels = [@@ -4975,11 +4975,11 @@ name = "vercel-workers"version = "0.0.25"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "anyio" },- { name = "httpx" },- { name = "pydantic" },- { name = "python-dotenv" },- { name = "vercel" },+ { name = "anyio", marker = "python_full_version >= '3.12'" },+ { name = "httpx", marker = "python_full_version >= '3.12'" },+ { name = "pydantic", marker = "python_full_version >= '3.12'" },+ { name = "python-dotenv", marker = "python_full_version >= '3.12'" },+ { name = "vercel", marker = "python_full_version >= '3.12'" },]sdist = { url = "https://files.pythonhosted.org/packages/30/df/04d37021ad7ca53b7599c313e411d91623c7a005c741f491d1eefb7a9f0c/vercel_workers-0.0.25.tar.gz", hash = "sha256:212ded01400b524be51d251df49f801caf115ad7d48cca7eb168cbeceda3def3", size = 64149, upload-time = "2026-06-20T19:26:27.177Z" }wheels = [diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.mdindex 2a8b7de2a84..7178b375120 100644--- a/website/docs/developer-guide/relay-shared-metrics.md+++ b/website/docs/developer-guide/relay-shared-metrics.md@@ -23,19 +23,21 @@ as a no-op compatibility alias for existing installation commands.> longer activate exporters. Without the new variable, Hermes does not run> Relay plugin discovery, configuration layering, middleware, or exporters.-Hermes requires NeMo Relay 0.8.3 or later within the 0.8 release line. That+Hermes requires NeMo Relay 0.9 or later within the 0.9 release line. Thatline provides the provider-codec and canonical tool-result contracts Hermes-uses for managed provider and tool calls.+uses for managed provider and tool calls, and the owned plugin-host API+(`plugin.initialize` returning an activation, `plugin.validate`) that Hermes+builds its process-wide plugin lifecycle on.## Runtime Dependency and Data BoundaryHermes installs the platform-specific `nemo-relay` native wheel from the-bounded `>=0.8.3,<0.9` dependency range. The published package is built from+bounded `>=0.9,<0.10` dependency range. The published package is built fromthe [NVIDIA NeMo Relay repository](https://github.com/NVIDIA/NeMo-Relay).Unsupported platforms use the explicit no-op runtime described above ratherthan downloading a different implementation.-Operator-supplied typed native plugins must be rebuilt for Relay 0.8. `grpc-v1`+Operator-supplied typed native plugins must be rebuilt for Relay 0.9. `grpc-v1`workers must be regenerated and rebuilt when they use tool callbacks, toolexecution intercepts, or manual tool-end APIs.