Skip to content

The agent that grows with you

fix(plugins): say what enable and disable did to the running gateway

unsupportedpastelsda898da6a631
diff --git a/hermes_cli/plugins_activation.py b/hermes_cli/plugins_activation.py
index 7c583f44da5..cb834a2ed46 100644
--- a/hermes_cli/plugins_activation.py
+++ b/hermes_cli/plugins_activation.py
@@ -118,8 +118,8 @@ def activate_plugin_now(name: str, *, in_process: bool = True) -> dict[str, Any]
def reload_running_gateway() -> Optional[dict[str, Any]]:
"""Ask the gateway serving this profile (its own socket, else the multiplexer's for a served
- secondary) to force plugin re-discovery, so an enable loads and a disable unloads for every session
- the gateway starts from now on. The ``reload-plugins`` answer, or None when no gateway answered."""
+ secondary) to force plugin re-discovery, so an enable loads and a disable unloads in the running
+ gateway now. The ``reload-plugins`` answer, or None when no gateway answered."""
try:
from gateway.control_socket import reload_gateway_plugins
from hermes_constants import get_default_hermes_root, get_hermes_home
@@ -135,10 +135,11 @@ def reload_running_gateway() -> Optional[dict[str, Any]]:
return None
-def gateway_reload_hint(answer: Optional[dict[str, Any]]) -> str:
- """One honest sentence after a plugin-set change that only the gateway's re-discovery applies."""
+def gateway_reload_hint(answer: Optional[dict[str, Any]], name: str) -> str:
+ """One honest sentence after disabling plugin ``name``, a change only the gateway's re-discovery
+ applies (an open session stops running its commands at once)."""
if answer and answer.get("reloaded"):
- return "The running gateway reloaded its plugins; new sessions use this change."
+ return f"The running gateway reloaded its plugins and unloaded {name}."
if answer is not None: # a gateway answered and refused: say so, with its reason
return (f"The running gateway refused to reload its plugins: {answer.get('error') or 'no reason given'}.\n"
"Only the saved config changed; restart the gateway serving this profile to apply it:\n"
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index 8eb7a66b6ed..01e11246d36 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -726,7 +726,7 @@ def cmd_enable(name: str, allow_tool_override: Optional[bool] = None) -> None:
changed = _activate_key(key, enable=True, console=console)
if changed:
from hermes_cli.plugins_activation import activate_plugin_now, activation_hint
- console.print(f"[green]✓[/green] Plugin [bold]{key}[/bold] enabled. Takes effect on next session.")
+ console.print(f"[green]✓[/green] Plugin [bold]{key}[/bold] enabled.") # the hint says when it applies
console.print(f"[dim]{activation_hint(activate_plugin_now(key, in_process=False))}[/dim]")
else:
console.print(f"[dim]Plugin '{key}' is already enabled.[/dim]")
@@ -763,7 +763,7 @@ def cmd_disable(name: str) -> None:
_toggle_plugin_toolset(key, enable=False, toolset_key=toolset_key)
from hermes_cli.plugins_activation import gateway_reload_hint, reload_running_gateway
console.print(f"[yellow]⊘[/yellow] Plugin [bold]{key}[/bold] disabled.")
- console.print(f"[dim]{gateway_reload_hint(reload_running_gateway())}[/dim]")
+ console.print(f"[dim]{gateway_reload_hint(reload_running_gateway(), key)}[/dim]")
def _read_manifest_info(d: Path, prefix: str):
diff --git a/tests/hermes_cli/test_plugins_disable_reaches_gateway.py b/tests/hermes_cli/test_plugins_disable_reaches_gateway.py
index 3e49359800a..43474f55061 100644
--- a/tests/hermes_cli/test_plugins_disable_reaches_gateway.py
+++ b/tests/hermes_cli/test_plugins_disable_reaches_gateway.py
@@ -130,3 +130,32 @@ def test_disable_without_an_answering_gateway_says_a_restart_is_needed(home, mon
out = capsys.readouterr().out
assert "next session" not in out
assert "hermes gateway restart" in out
+
+
+def test_disable_says_the_running_gateway_unloaded_it(home, monkeypatch, capsys):
+ """Live, an open session stops running the disabled plugin's commands at once: not only new ones."""
+ _gateway(monkeypatch, {"reloaded": True, "plugins": []})
+
+ plugins_cmd.cmd_disable("probe")
+
+ out = " ".join(capsys.readouterr().out.split())
+ assert "running gateway reloaded its plugins and unloaded probe" in out, out
+ assert "new sessions" not in out, out
+
+
[email protected]("reloaded", [True, False])
+def test_enable_prints_only_the_outcome_that_applies(home, monkeypatch, capsys, reloaded):
+ """``enable`` knows whether the running gateway took the plugin: it prints that outcome, never
+ "Takes effect on next session." above a line saying it is active in the running gateway now."""
+ from hermes_cli import plugins_activation
+ save_config({**load_config(), "plugins": {"enabled": [], "disabled": ["probe"]}})
+ outcome = {"gateway_reloaded": reloaded, "restart_required": not reloaded,
+ "activation": {"activated_now": {"hooks": 1}} if reloaded else None}
+ monkeypatch.setattr(plugins_activation, "activate_plugin_now", lambda *_a, **_k: outcome)
+
+ plugins_cmd.cmd_enable("probe", allow_tool_override=False)
+
+ out = " ".join(capsys.readouterr().out.split())
+ assert "Plugin probe enabled." in out and "next session" not in out, out
+ assert ("active in the running gateway now" in out) is reloaded, out
+ assert ("hermes gateway restart" in out) is (not reloaded), out