mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
Merge branch 'main' of github.com:NousResearch/hermes-agent into feat/ink-refactor
This commit is contained in:
commit
bf54f1fb2f
83 changed files with 5435 additions and 470 deletions
|
|
@ -550,11 +550,12 @@ class TestGatewayProtection:
|
|||
dangerous, key, desc = detect_dangerous_command(cmd)
|
||||
assert dangerous is False
|
||||
|
||||
def test_systemctl_restart_not_flagged(self):
|
||||
"""Using systemctl to manage the gateway is the correct approach."""
|
||||
def test_systemctl_restart_flagged(self):
|
||||
"""systemctl restart kills running agents and should require approval."""
|
||||
cmd = "systemctl --user restart hermes-gateway"
|
||||
dangerous, key, desc = detect_dangerous_command(cmd)
|
||||
assert dangerous is False
|
||||
assert dangerous is True
|
||||
assert "stop/restart" in desc
|
||||
|
||||
def test_pkill_hermes_detected(self):
|
||||
"""pkill targeting hermes/gateway processes must be caught."""
|
||||
|
|
|
|||
|
|
@ -2837,7 +2837,7 @@ class TestRegistryCollisionWarning:
|
|||
"""registry.register() warns when a tool name is overwritten by a different toolset."""
|
||||
|
||||
def test_overwrite_different_toolset_logs_warning(self, caplog):
|
||||
"""Overwriting a tool from a different toolset emits a warning."""
|
||||
"""Overwriting a tool from a different toolset is REJECTED with an error."""
|
||||
from tools.registry import ToolRegistry
|
||||
import logging
|
||||
|
||||
|
|
@ -2847,11 +2847,13 @@ class TestRegistryCollisionWarning:
|
|||
|
||||
reg.register(name="my_tool", toolset="builtin", schema=schema, handler=handler)
|
||||
|
||||
with caplog.at_level(logging.WARNING, logger="tools.registry"):
|
||||
with caplog.at_level(logging.ERROR, logger="tools.registry"):
|
||||
reg.register(name="my_tool", toolset="mcp-ext", schema=schema, handler=handler)
|
||||
|
||||
assert any("collision" in r.message.lower() for r in caplog.records)
|
||||
assert any("rejected" in r.message.lower() for r in caplog.records)
|
||||
assert any("builtin" in r.message and "mcp-ext" in r.message for r in caplog.records)
|
||||
# The original tool should still be from 'builtin', not overwritten
|
||||
assert reg.get_toolset_for_tool("my_tool") == "builtin"
|
||||
|
||||
def test_overwrite_same_toolset_no_warning(self, caplog):
|
||||
"""Re-registering within the same toolset is silent (e.g. reconnect)."""
|
||||
|
|
|
|||
31
tests/tools/test_memory_tool_import_fallback.py
Normal file
31
tests/tools/test_memory_tool_import_fallback.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Regression tests for memory-tool import fallbacks."""
|
||||
|
||||
import builtins
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
from tools.registry import registry
|
||||
|
||||
|
||||
def test_memory_tool_imports_without_fcntl(monkeypatch, tmp_path):
|
||||
original_import = builtins.__import__
|
||||
|
||||
def fake_import(name, globals=None, locals=None, fromlist=(), level=0):
|
||||
if name == "fcntl":
|
||||
raise ImportError("simulated missing fcntl")
|
||||
return original_import(name, globals, locals, fromlist, level)
|
||||
|
||||
registry.deregister("memory")
|
||||
monkeypatch.delitem(sys.modules, "tools.memory_tool", raising=False)
|
||||
monkeypatch.setattr(builtins, "__import__", fake_import)
|
||||
|
||||
memory_tool = importlib.import_module("tools.memory_tool")
|
||||
monkeypatch.setattr(memory_tool, "get_memory_dir", lambda: tmp_path)
|
||||
|
||||
store = memory_tool.MemoryStore(memory_char_limit=200, user_char_limit=200)
|
||||
store.load_from_disk()
|
||||
result = store.add("memory", "fact learned during import fallback test")
|
||||
|
||||
assert memory_tool.fcntl is None
|
||||
assert registry.get_entry("memory") is not None
|
||||
assert result["success"] is True
|
||||
Loading…
Add table
Add a link
Reference in a new issue