Skip to content

The agent that grows with you

fix(skills): cache empty plugin skill projection

Hermes Agentfd8835ca872e
diff --git a/agent/skill_commands.py b/agent/skill_commands.py
index 3e3c802d1a2..8c7988d6c42 100644
--- a/agent/skill_commands.py
+++ b/agent/skill_commands.py
@@ -569,7 +569,7 @@ def get_plugin_skill_commands() -> Dict[str, Dict[str, Any]]:
home = str(get_hermes_home())
with _publish_lock:
cached = _plugin_skill_commands
- is_fresh = bool(cached) and _plugin_skill_commands_home == home
+ is_fresh = _plugin_skill_commands_home == home
if not is_fresh:
cached = _scan_plugin_skill_commands()
disabled = get_disabled_skill_names()
diff --git a/tests/agent/test_plugin_skill_boundary.py b/tests/agent/test_plugin_skill_boundary.py
index 8e335fa9839..4fcb3a8d44f 100644
--- a/tests/agent/test_plugin_skill_boundary.py
+++ b/tests/agent/test_plugin_skill_boundary.py
@@ -36,10 +36,6 @@ def _make_plugin_skill(home: Path, plugin_name: str, skill: str, body: str, desc
desc_line = f"description: {description}\n" if description else ""
md.write_text(f"---\nname: {skill}\n{desc_line}---\n{body}\n")
config = home / "config.yaml"
- enabled = plugin_name
- if config.exists():
- text = config.read_text()
- enabled = f"{text.rstrip().rsplit('[', 1)[0].rstrip().rstrip(',')}, {plugin_name}" if False else enabled
config.write_text(f"plugins:\n enabled: [{plugin_name}]\n")
return md
@@ -58,6 +54,16 @@ def plugin_home(tmp_path, monkeypatch):
class TestProjectionCache:
+ def test_empty_projection_is_cached_until_invalidation(self, plugin_home):
+ """An initialized empty registry is fresh too; don't rediscover on each lookup."""
+ import agent.skill_commands as sc
+
+ sc.invalidate_plugin_skill_commands()
+ with patch.object(sc, "_scan_plugin_skill_commands", wraps=sc._scan_plugin_skill_commands) as scan:
+ assert sc.get_plugin_skill_commands() == {}
+ assert sc.get_plugin_skill_commands() == {}
+ assert scan.call_count == 1
+
def test_repeat_lookup_does_not_reread_plugin_skill_files(self, plugin_home):
"""B1: a cached interactive lookup must not touch plugin SKILL.md again."""
import agent.skill_commands as sc
@@ -90,6 +96,17 @@ class TestProjectionCache:
sc.invalidate_plugin_skill_commands()
assert sc.get_interactive_skill_commands()["/fresh-probe:guide"]["description"] == "New"
+ def test_disabled_filter_is_applied_to_cached_projection_live(self, plugin_home):
+ """Config-only skill disabling takes effect without rebuilding the registry projection."""
+ import agent.skill_commands as sc
+
+ _make_plugin_skill(plugin_home, "disabled-probe", "guide", "Body.")
+ assert "/disabled-probe:guide" in sc.get_plugin_skill_commands()
+ (plugin_home / "config.yaml").write_text(
+ "plugins:\n enabled: [disabled-probe]\nskills:\n disabled: [guide]\n"
+ )
+ assert "/disabled-probe:guide" not in sc.get_plugin_skill_commands()
+
def test_profile_switch_self_heals_without_invalidation(self, plugin_home, tmp_path, monkeypatch):
"""The cache is keyed on the resolved home: switching profiles must never
serve the other profile's plugin skills."""
diff --git a/tests/gateway/test_skill_slash_native_boundary.py b/tests/gateway/test_skill_slash_native_boundary.py
index 89d6b3f64ca..3885d1d0e48 100644
--- a/tests/gateway/test_skill_slash_native_boundary.py
+++ b/tests/gateway/test_skill_slash_native_boundary.py
@@ -60,8 +60,12 @@ def _rewrite(event_text: str, tmp_path, monkeypatch, plugin_home):
)
runner._hm_skill_slash_rewrite = GatewayInboundMixin._hm_skill_slash_rewrite.__get__(runner)
source = SessionSource(platform=Platform.DISCORD, chat_id="c1")
- event = SimpleNamespace(text=event_text, get_command_args=lambda: "")
- return runner._hm_skill_slash_rewrite(event, source, "qk", event_text[1:].split()[0])
+ event = SimpleNamespace(
+ text=event_text,
+ get_command_args=lambda: event_text.split(maxsplit=1)[1] if len(event_text.split(maxsplit=1)) > 1 else "",
+ )
+ reply = runner._hm_skill_slash_rewrite(event, source, "qk", event_text[1:].split()[0])
+ return reply, event
finally:
plugins_mod._reset_plugin_managers_for_tests()
@@ -94,8 +98,11 @@ class TestGatewayStackedNativeBoundary:
_make_plugin_skill(plugin_home, "stack-probe", "guide", "Plugin body.")
with patch("tools.skills_tool.SKILLS_DIR", tmp_path / "skills"):
- reply = _rewrite("/local-skill /stack-probe:guide do it", tmp_path, monkeypatch, plugin_home)
+ reply, event = _rewrite("/local-skill /stack-probe:guide do it", tmp_path, monkeypatch, plugin_home)
assert reply is None # rewrote the event, did not bounce it as unknown
+ assert "Local body." in event.text
+ assert "Plugin body." not in event.text
+ assert "do it" in event.text
def test_plugin_only_stacked_token_bounces_unknown(self, tmp_path, monkeypatch):
"""A leading ``/plugin:guide`` (no filesystem skill) bounces unknown."""
@@ -104,5 +111,5 @@ class TestGatewayStackedNativeBoundary:
_make_plugin_skill(plugin_home, "stack-probe", "guide", "Plugin body.")
with patch("tools.skills_tool.SKILLS_DIR", tmp_path / "skills"):
- reply = _rewrite("/stack-probe:guide do it", tmp_path, monkeypatch, plugin_home)
+ reply, _event = _rewrite("/stack-probe:guide do it", tmp_path, monkeypatch, plugin_home)
assert reply is not None and "Unknown command" in reply