mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:04:08 +03:00
a529212a00
A model that called web_search with query='' sent it to the configured backend (Perplexity: VALIDATION_ERROR) and then through the whole fallback chain (Firecrawl: "Query cannot be empty"), producing provider errors the model could not act on. web_search_tool now returns a plain tool error naming the missing argument, without calling any provider. Fixes #152227
21 lines
726 B
Python
21 lines
726 B
Python
"""An empty ``web_search`` query is refused before any backend is called."""
|
|
import json
|
|
|
|
import pytest
|
|
|
|
import tools.web_tools
|
|
from tools.registry import registry
|
|
|
|
assert tools.web_tools.web_search_tool # importing registers web_search
|
|
|
|
|
|
@pytest.mark.parametrize("args", [{"query": ""}, {"query": " "}])
|
|
def test_empty_query_is_refused_without_calling_a_provider(args, monkeypatch):
|
|
def _no_provider(*_a, **_k):
|
|
raise AssertionError("an empty query must not reach a search provider")
|
|
|
|
monkeypatch.setattr("tools.web_tools._memoized_search", _no_provider)
|
|
result = json.loads(registry.dispatch("web_search", args))
|
|
assert result["success"] is False
|
|
assert "non-empty 'query'" in result["error"]
|