{"record":{"id":"efb3500582a4fe9f","repo":"huggingface/smolagents","slug":"no-results-found-try-a-less-restrictive-shorter-q","errorCode":null,"errorMessage":"No results found! Try a less restrictive/shorter query.","messagePattern":"No results found! Try a less restrictive/shorter query\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"src/smolagents/default_tools.py","lineNumber":144,"sourceCode":"    def __init__(self, max_results: int = 10, rate_limit: float | None = 1.0, **kwargs):\n        super().__init__()\n        self.max_results = max_results\n        self.rate_limit = rate_limit\n        self._min_interval = 1.0 / rate_limit if rate_limit else 0.0\n        self._last_request_time = 0.0\n        try:\n            from ddgs import DDGS\n        except ImportError as e:\n            raise ImportError(\n                \"You must install package `ddgs` to run this tool: for instance run `pip install ddgs`.\"\n            ) from e\n        self.ddgs = DDGS(**kwargs)\n\n    def forward(self, query: str) -> str:\n        self._enforce_rate_limit()\n        results = self.ddgs.text(query, max_results=self.max_results)\n        if len(results) == 0:\n            raise Exception(\"No results found! Try a less restrictive/shorter query.\")\n        postprocessed_results = [f\"[{result['title']}]({result['href']})\\n{result['body']}\" for result in results]\n        return \"## Search Results\\n\\n\" + \"\\n\\n\".join(postprocessed_results)\n\n    def _enforce_rate_limit(self) -> None:\n        import time\n\n        # No rate limit enforced\n        if not self.rate_limit:\n            return\n\n        now = time.time()\n        elapsed = now - self._last_request_time\n        if elapsed < self._min_interval:\n            time.sleep(self._min_interval - elapsed)\n        self._last_request_time = time.time()\n\n\nclass GoogleSearchTool(Tool):","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/default_tools.py#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Retry with a shorter, more general query.","If it persists for all queries, suspect ddgs rate limiting — reduce call frequency or wait, and ensure you're on a recent ddgs version.","Catch the exception in agent code and feed the error message back to the LLM so it reformulates the query."],"exampleFix":"# before\ntool.run('\"exact phrase\" site:example.com rare-term')\n# after\ntool.run('rare term example.com')","handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"try:\n    out = tool.run(query)\nexcept Exception as e:\n    if 'No results found' in str(e):\n        out = tool.run(shorten(query))  # retry with simplified query\n    else:\n        raise","preventionTips":["Keep agent-generated queries short; instruct the model to avoid heavy quoting/filters.","Catch and feed the message back to the LLM so it reformulates."],"tags":["search-tool","empty-results","smolagents"],"backgroundTag":"search-no-results","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}