mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
fix(honcho): reject whitespace-only search/reasoning queries
Strip query before validation; add regression tests (aligns upstream #11192). Made-with: Cursor
This commit is contained in:
parent
8222b16785
commit
af550a7053
2 changed files with 28 additions and 2 deletions
|
|
@ -1437,7 +1437,7 @@ class HonchoMemoryProvider(MemoryProvider):
|
|||
return json.dumps({"result": card})
|
||||
|
||||
elif tool_name == "honcho_search":
|
||||
query = args.get("query", "")
|
||||
query = (args.get("query") or "").strip()
|
||||
if not query:
|
||||
return tool_error("Missing required parameter: query")
|
||||
max_tokens = min(int(args.get("max_tokens", 800)), 2000)
|
||||
|
|
@ -1450,7 +1450,7 @@ class HonchoMemoryProvider(MemoryProvider):
|
|||
return json.dumps({"result": result})
|
||||
|
||||
elif tool_name == "honcho_reasoning":
|
||||
query = args.get("query", "")
|
||||
query = (args.get("query") or "").strip()
|
||||
if not query:
|
||||
return tool_error("Missing required parameter: query")
|
||||
peer = args.get("peer", "user")
|
||||
|
|
|
|||
|
|
@ -566,6 +566,19 @@ class TestConcludeToolDispatch:
|
|||
peer="hermes",
|
||||
)
|
||||
|
||||
def test_honcho_search_rejects_whitespace_only_query(self):
|
||||
"""Whitespace-only query must not hit Honcho search API."""
|
||||
import json
|
||||
provider = HonchoMemoryProvider()
|
||||
provider._session_initialized = True
|
||||
provider._session_key = "telegram:123"
|
||||
provider._manager = MagicMock()
|
||||
|
||||
result = provider.handle_tool_call("honcho_search", {"query": " \t\n "})
|
||||
parsed = json.loads(result)
|
||||
assert parsed == {"error": "Missing required parameter: query"}
|
||||
provider._manager.search_context.assert_not_called()
|
||||
|
||||
def test_honcho_reasoning_can_target_explicit_peer_id(self):
|
||||
provider = HonchoMemoryProvider()
|
||||
provider._session_initialized = True
|
||||
|
|
@ -587,6 +600,19 @@ class TestConcludeToolDispatch:
|
|||
apply_injection_cap=False,
|
||||
)
|
||||
|
||||
def test_honcho_reasoning_rejects_whitespace_only_query(self):
|
||||
"""Whitespace-only query must not hit Honcho dialectic API."""
|
||||
import json
|
||||
provider = HonchoMemoryProvider()
|
||||
provider._session_initialized = True
|
||||
provider._session_key = "telegram:123"
|
||||
provider._manager = MagicMock()
|
||||
|
||||
result = provider.handle_tool_call("honcho_reasoning", {"query": " "})
|
||||
parsed = json.loads(result)
|
||||
assert parsed == {"error": "Missing required parameter: query"}
|
||||
provider._manager.dialectic_query.assert_not_called()
|
||||
|
||||
def test_honcho_conclude_missing_both_params_returns_error(self):
|
||||
"""Calling honcho_conclude with neither conclusion nor delete_id returns a tool error."""
|
||||
import json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue