huggingface/smolagents · warning · Exception
No results found for query: '{query}'. Use a less restrictiv
Error message
No results found for query: '{query}'. Use a less restrictive query. What it means
Raised by the search tool's forward when the provider response has no organic-results key and no year filter was applied — i.e. the query returned zero organic results. Note the sibling branch: when the key exists but is empty, the tool returns a message instead of raising, so only the complete absence of organic results raises.
Source
Thrown at src/smolagents/default_tools.py:223
}
base_url = "https://google.serper.dev/search"
if filter_year is not None:
params["tbs"] = f"cdr:1,cd_min:01/01/{filter_year},cd_max:12/31/{filter_year}"
response = requests.get(base_url, params=params)
if response.status_code == 200:
results = response.json()
else:
raise ValueError(response.json())
if self.organic_key not in results.keys():
if filter_year is not None:
raise Exception(
f"No results found for query: '{query}' with filtering on year={filter_year}. Use a less restrictive query or do not filter on year."
)
else:
raise Exception(f"No results found for query: '{query}'. Use a less restrictive query.")
if len(results[self.organic_key]) == 0:
year_filter_message = f" with filter year={filter_year}" if filter_year is not None else ""
return f"No results found for '{query}'{year_filter_message}. Try with a more general query, or remove the year filter."
web_snippets = []
if self.organic_key in results:
for idx, page in enumerate(results[self.organic_key]):
date_published = ""
if "date" in page:
date_published = "\nDate published: " + page["date"]
source = ""
if "source" in page:
source = "\nSource: " + page["source"]
snippet = ""
if "snippet" in page:
snippet = "\n" + page["snippet"]View on GitHub (pinned to 30bb116109)
Solutions
- Use a shorter, more general query.
- Check the provider dashboard for quota/billing errors — an error payload often lacks the organic key too.
- Wrap in try/except and return a retry hint to the calling agent.
Example fix
# before
tool.run('"zxy impossible exact phrase"')
# after
tool.run('related broader topic') Defensive patterns
Strategy: retry
Validate before calling
null
Try / catch
try:
res = tool.run(q)
except Exception as e:
if 'No results found' in str(e): res = tool.run(generalize(q))
else: raise Prevention
- Prefer broader queries; refine only when results are noisy.
- Monitor provider quota — error payloads also lack the organic key.
When it happens
Trigger: Calling run(query) without filter_year on a query for which the Serper/SerpAPI response omits the organic key entirely.
Common situations: Overly restrictive queries, provider API quota/billing issues returning error payloads without organic results, or region/language settings that yield no results.
Related errors
- No results found! Try a less restrictive/shorter query.
- No results found for query: '{query}' with filtering on year
- You must install package `ddgs` to run this tool: for instan
- Missing API key. Make sure you have '{api_key_env_name}' in
- Unsupported engine: {self.engine}
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/9ef32c849e39f6fa.
Report an issue: GitHub.