The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): the go-live notice names skills and tool prefixes, not every tool
alt-glitch4db1b88fe945
diff --git a/hermes_cli/plugins_activation_live.py b/hermes_cli/plugins_activation_live.pyindex 41a00b8b805..aa8c17cff62 100644--- a/hermes_cli/plugins_activation_live.py+++ b/hermes_cli/plugins_activation_live.py@@ -4,7 +4,7 @@point (``skill_view`` resolves ``<plugin>:<skill>``). MCP servers are not: nothing connects them until``reload.mcp``. :func:`connect_plugin_mcp` connects the plugin's servers one by one (the connectorflow's ``register_mcp_servers({name: config})``), and :func:`live_notice` renders what became usable-as the note an open chat receives on its next turn.+as the note an open chat receives on its next tool result or turn (``agent/plugin_live_notes.py``).MCP tools are deferred behind ``tool_search`` / ``tool_describe`` / ``tool_call``, so adding them to alive session leaves the model-facing tool array (and the cached prompt prefix) byte-identical.@@ -84,45 +84,36 @@ def plugin_skills(plugin_key: str) -> list[dict[str, str]]:def live_notice(activation: dict[str, Any]) -> str:- """The note an open chat gets on its next turn: connected MCP servers with their tools and what- waits for the next session. Empty without servers. The plugin's skills are not listed here: every- turn announces any skill the chat's system prompt does not list (``agent/skills_index_delta.py``),- whichever way it arrived."""- servers = (activation.get("live_now") or {}).get("mcp_servers") or []- deferred = activation.get("deferred") or {}- if not servers:+ """The note an open chat gets on its next tool result or turn (``agent/plugin_live_notes.py``): the+ plugin's skills and, per MCP server, its tool prefix and count or why it did not connect. Tools are+ not listed one by one: the note stays in the chat's history and rides every later request, and+ ``tool_search`` lists them on demand. Empty when nothing of the plugin is live now."""+ live = activation.get("live_now") or {}+ servers, skills = live.get("mcp_servers") or [], live.get("skills") or []+ if not servers and not skills:return ""- lines = [f"[plugin installed: {activation.get('name') or activation.get('key')}]"]- connected = [s for s in servers if s.get("connected")]- if connected:- lines.append("MCP servers now connected; call their tools with tool_describe / tool_call:")- for server in connected:- lines.append(f"- {server['name']}")- listing = _tool_listing(server["tools"])- if listing:- lines.extend(f" {line}" for line in listing.splitlines())- for server in (s for s in servers if not s.get("connected")):- lines.append(f"- {server['name']}: not connected ({server.get('error') or 'unknown error'})")+ name = activation.get("name") or activation.get("key")+ lines = [f"[System note: plugin {name} was installed and is live in this chat now (a Hermes note, "+ "not tool output)."]+ lines.extend(f"- Skill {skill['name']}: load it with skill_view." for skill in skills)+ for server in servers:+ if server.get("connected"):+ lines.append(f"- MCP server {server['name']}: {len(server['tools'])} tools, "+ f"{_tool_prefix(server['name'])}*.")+ else:+ lines.append(f"- MCP server {server['name']}: not connected ({server.get('error') or 'unknown error'}).")+ if any(server.get("connected") for server in servers):+ lines.append("Its MCP tools are deferred: find them with tool_search, read one with tool_describe, "+ "run it with tool_call.")+ deferred = activation.get("deferred") or {}later = [f"{len(deferred['tools'])} Python tools" if deferred.get("tools") else "",f"{len(deferred['prompt'])} prompt sections" if deferred.get("prompt") else ""]if any(later):lines.append("Next session: " + ", ".join(p for p in later if p) + ".")- return "\n".join(lines)+ return "\n".join(lines) + "]"-def _tool_listing(names: list[str]) -> str:- """``name: first sentence`` per tool."""- try:- from tools.registry import registry- from tools.tool_search_catalog import _short_desc- definitions = registry.get_definitions(set(names), quiet=True)- except Exception:- return ""- rows = []- for definition in definitions:- fn = definition.get("function") or definition- name = str(fn.get("name") or "")- if name:- desc = _short_desc(fn.get("description") or "")- rows.append(f"{name}: {desc}" if desc else name)- return "\n".join(sorted(rows))+def _tool_prefix(server: str) -> str:+ """``mcp__<server>__``: the start of every registered tool name of ``server``."""+ from tools.mcp_tool_schema import MCP_TOOL_NAME_PREFIX, sanitize_mcp_name_component+ return f"{MCP_TOOL_NAME_PREFIX}{sanitize_mcp_name_component(server)}__"diff --git a/tests/e2e/core/mcp_plugins/test_plugin_activation.py b/tests/e2e/core/mcp_plugins/test_plugin_activation.pyindex 6da18d4d9a8..8c8d8b68684 100644--- a/tests/e2e/core/mcp_plugins/test_plugin_activation.py+++ b/tests/e2e/core/mcp_plugins/test_plugin_activation.py@@ -176,7 +176,7 @@ def test_plugin_enabled_mid_chat_is_usable_in_that_chat_with_an_unchanged_tools_assert _canon(after["messages"][0]) == _canon(before["messages"][0]), ("enabling a plugin mid-chat rewrote the open chat's system prompt (prompt-cache prefix)")# The open chat is told what just became usable (one-shot turn note), outside the prefix.- assert f"[plugin installed: {PLUGIN}]" in _canon(after["messages"][1:]), (+ assert f"[System note: plugin {PLUGIN} was installed" in _canon(after["messages"][1:]), (f"the open chat was never told the plugin went live; its turn ended with {after['messages'][-1]}")fresh = host.new_session()diff --git a/tests/hermes_cli/test_plugins_live_notice.py b/tests/hermes_cli/test_plugins_live_notice.pynew file mode 100644index 00000000000..6b461be7e75--- /dev/null+++ b/tests/hermes_cli/test_plugins_live_notice.py@@ -0,0 +1,59 @@+"""``live_notice``: what an open chat is told when a plugin goes live in it.++The notice stays in the chat's history and rides every later request, so it names how to reach the+plugin (its skills, each MCP server's tool prefix) and never lists the tools one by one: a live run+delivered a 4,994-char notice that listed all of Blender's tools.+"""++from __future__ import annotations++import pytest++from agent.prompt_builder import CONTROL_FRAME_OPENERS+from hermes_cli.plugins_activation_live import live_notice+from tools.registry import registry++SKILL = "agent-plugin-blender-5a80e4ba:blender"+TOOLS = ["mcp__blender__execute_blender_code", "mcp__blender__get_objects_summary",+ "mcp__blender__render_viewport_to_path"]+++def blender_tools():+ """The server's tools as the registry holds them once it connected."""+ for name in TOOLS:+ registry.register(name=name, toolset="mcp-blender", handler=lambda args, **kw: "{}",+ schema={"name": name, "description": f"Run {name}. More detail.",+ "parameters": {"type": "object", "properties": {}}})+ yield TOOLS+ for name in TOOLS:+ registry.deregister(name)+++def _activation(servers, skills=(SKILL,), deferred=None):+ return {"name": "blender", "key": "blender", "deferred": deferred or {},+ "live_now": {"mcp_servers": servers, "skills": [{"name": s, "description": ""} for s in skills]}}+++def test_the_notice_names_the_skill_and_the_tool_prefix_and_lists_no_tool(blender_tools):+ note = live_notice(_activation([+ {"name": "blender", "connected": True, "tools": blender_tools},+ {"name": "blender-render", "connected": False, "tools": [], "error": "spawn failed"},+ ]))++ assert f"{SKILL}: load it with skill_view" in note+ assert "MCP server blender: 3 tools, mcp__blender__*." in note+ assert "MCP server blender-render: not connected (spawn failed)." in note+ assert all(tool not in note for tool in blender_tools)+ for bridge in ("tool_search", "tool_describe", "tool_call"):+ assert bridge in note+ # A Hermes control frame, so a hosted room relabels a reply that copies it.+ assert note.startswith("[") and note[1:].startswith(CONTROL_FRAME_OPENERS) and note.endswith("]")+ assert len(note) < 600+++def test_a_plugin_with_only_skills_is_still_announced_and_one_with_nothing_live_is_not():+ note = live_notice(_activation([]))++ assert SKILL in note and "tool_search" not in note+ assert live_notice(_activation([], skills=())) == ""