huggingface/smolagents · warning · Exception
No results found for query: '{query}' with filtering on year
Error message
No results found for query: '{query}' with filtering on year={filter_year}. Use a less restrictive query or do not filter on year. What it means
Raised by the search tool's forward when the API response JSON lacks the organic-results key (e.g. 'organic' for Serper, 'organic_results' for SerpAPI) AND a filter_year was applied. It indicates the query (possibly with the year filter appended) returned no organic results.
Source
Thrown at src/smolagents/default_tools.py:219
else:
params = {
"q": query,
"api_key": self.api_key,
}
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"]View on GitHub (pinned to 30bb116109)
Solutions
- Retry without filter_year.
- Broaden the query (fewer quoted terms, remove site: filters).
- Catch the exception and let the agent decide to drop the year filter.
Example fix
# before
tool.run('quantum computing breakthroughs', filter_year=1995)
# after
tool.run('quantum computing breakthroughs', filter_year=2024) Defensive patterns
Strategy: retry
Validate before calling
null
Try / catch
try:
res = tool.run(q, filter_year=y)
except Exception:
res = tool.run(q) # drop year filter and retry Prevention
- Default to no filter_year and only add it when results are too broad.
- Instruct agents that empty year-filtered results mean: retry without the filter.
When it happens
Trigger: Calling run(query, filter_year=2015) where the provider response has no organic key — i.e. zero organic hits for the year-filtered query (e.g. 'site:nonexistent.com latest news' with filter_year).
Common situations: Agents filtering by year on niche queries, year filters that exclude all results for young topics, or API responses containing only ads/knowledge panels with no organic block.
Related errors
- No results found! Try a less restrictive/shorter query.
- No results found for query: '{query}'. Use a less restrictiv
- 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/cc84817ca4753967.
Report an issue: GitHub.