huggingface/smolagents · warning · Exception

No results found! Try a less restrictive/shorter query.

Error message

No results found! Try a less restrictive/shorter query.

What it means

Raised by DuckDuckGoSearchTool.forward when the ddgs text search returns zero results for the query. The tool treats an empty result set as an exceptional outcome so the agent knows the query failed rather than silently receiving nothing.

Source

Thrown at src/smolagents/default_tools.py:144

    def __init__(self, max_results: int = 10, rate_limit: float | None = 1.0, **kwargs):
        super().__init__()
        self.max_results = max_results
        self.rate_limit = rate_limit
        self._min_interval = 1.0 / rate_limit if rate_limit else 0.0
        self._last_request_time = 0.0
        try:
            from ddgs import DDGS
        except ImportError as e:
            raise ImportError(
                "You must install package `ddgs` to run this tool: for instance run `pip install ddgs`."
            ) from e
        self.ddgs = DDGS(**kwargs)

    def forward(self, query: str) -> str:
        self._enforce_rate_limit()
        results = self.ddgs.text(query, max_results=self.max_results)
        if len(results) == 0:
            raise Exception("No results found! Try a less restrictive/shorter query.")
        postprocessed_results = [f"[{result['title']}]({result['href']})\n{result['body']}" for result in results]
        return "## Search Results\n\n" + "\n\n".join(postprocessed_results)

    def _enforce_rate_limit(self) -> None:
        import time

        # No rate limit enforced
        if not self.rate_limit:
            return

        now = time.time()
        elapsed = now - self._last_request_time
        if elapsed < self._min_interval:
            time.sleep(self._min_interval - elapsed)
        self._last_request_time = time.time()


class GoogleSearchTool(Tool):

View on GitHub (pinned to 30bb116109)

Solutions

  1. Retry with a shorter, more general query.
  2. If it persists for all queries, suspect ddgs rate limiting — reduce call frequency or wait, and ensure you're on a recent ddgs version.
  3. Catch the exception in agent code and feed the error message back to the LLM so it reformulates the query.

Example fix

# before
tool.run('"exact phrase" site:example.com rare-term')
# after
tool.run('rare term example.com')
Defensive patterns

Strategy: retry

Validate before calling

null

Try / catch

try:
    out = tool.run(query)
except Exception as e:
    if 'No results found' in str(e):
        out = tool.run(shorten(query))  # retry with simplified query
    else:
        raise

Prevention

When it happens

Trigger: Calling duck_tool.run("<very restrictive/long query>") where ddgs.text(query, max_results=...) returns []. Often queries with excessive quoted phrases, rare terms, or site: filters.

Common situations: Agents issuing overly specific search queries, automated loops that concatenate context into the query, or transient DuckDuckGo empty responses (rate limiting sometimes manifests as empty results).

Related errors


AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28). Data as JSON: /api/errors/efb3500582a4fe9f. Report an issue: GitHub.