Skip to content

[Bug]: web_search Google provider silently caps results at 10 #2102

@jaffarkeikei

Description

@jaffarkeikei

Description

The Google Custom Search API limits results to 10 per request, but _search_google silently caps results at 10 without informing the user or implementing pagination for higher counts.

Current behavior

def _search_google(...):
    response = httpx.get(
        "https://www.googleapis.com/customsearch/v1",
        params={
            "key": api_key,
            "cx": cse_id,
            "q": query,
            "num": min(num_results, 10),  # Silent cap at 10
            # ...
        }
    )

If a user requests 15 results, they silently get only 10 with no indication that their request was truncated.

Steps to reproduce

result = web_search(
    query="test",
    num_results=15,
    provider="google"
)
print(result['total'])  # Shows 10, not 15
print(result.get('truncated'))  # No indication of truncation

Expected behavior

Either:

  1. Implement pagination to fetch 10+ results using the start parameter
  2. Return an error when num_results > 10 for Google
  3. Add a warning in the response that results were truncated

Environment

  • File: tools/src/aden_tools/tools/web_search_tool/web_search_tool.py:35

Suggested fix

Option 1: Add truncation warning

result = {
    "query": query,
    "results": results,
    "total": len(results),
    "provider": "google",
}
if num_results > 10:
    result["warning"] = f"Google API limited results to 10 (requested {num_results})"
return result

Option 2: Implement pagination (for 10+ results)

# Make multiple API calls with 'start' parameter
# First call: start=1 (results 1-10)
# Second call: start=11 (results 11-20)
# etc.

Happy to submit a PR for this!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions