Skip to content

fix: remove erroneous dollar-sign from BrightDataSearchTool search URLs and expose results_count in schema#5518

Open
octo-patch wants to merge 1 commit intocrewAIInc:mainfrom
octo-patch:fix/brightdata-serp-url-construction
Open

fix: remove erroneous dollar-sign from BrightDataSearchTool search URLs and expose results_count in schema#5518
octo-patch wants to merge 1 commit intocrewAIInc:mainfrom
octo-patch:fix/brightdata-serp-url-construction

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #5269

Problem

BrightDataSearchTool.get_search_url used JavaScript template-literal syntax inside Python f-strings. Python treats $ as a literal character, so every constructed URL contained a stray dollar sign:

  • Google: https://www.google.com/search?q=$hello%20world
  • Bing: https://www.bing.com/search?q=$some+query
  • Yandex: https://yandex.com/search/?text=$query

This caused all SERP searches to fail because the search engine received $<query> instead of the actual query string.

Additionally, results_count was read from **kwargs with a hard-coded default of "10", making it completely invisible to the Pydantic schema. Agents had no way to control the number of results returned.

Solution

  1. Removed the $ prefix from all three f-string URL templates in get_search_url.
  2. Added results_count to BrightDataSearchToolSchema as a typed int | None field with default=10, so agents can explicitly pass the desired number of results.
  3. Added results_count as an explicit parameter to _run, replacing the hidden kwargs.get("results_count", "10") pattern.
  4. Added tests verifying correct URL construction and results_count handling.

Testing

New unit tests added to brightdata_serp_tool_test.py:

  • test_get_search_url_google — verifies no $ in Google URL
  • test_get_search_url_bing — verifies no $ in Bing URL
  • test_get_search_url_yandex — verifies no $ in Yandex URL
  • test_run_default_results_count_is_10 — verifies default num=10
  • test_run_with_custom_results_count — verifies custom count is forwarded

Note: This PR was created with AI assistance. Per the CONTRIBUTING.md guidelines, the llm-generated label should be applied (label does not yet exist in the repo).

…expose results_count in schema

get_search_url used JavaScript template-literal syntax in Python
f-strings, producing literal dollar signs in every search URL.
All three URL builders (Google, Bing, Yandex) are fixed by
removing the stray dollar prefix.

results_count was silently read from kwargs with a hard-coded
default of 10, making it invisible to the agent tool-schema and
impossible to control at call time. It is now a typed, documented
field on BrightDataSearchToolSchema and an explicit parameter on
_run, so agents can pass it directly.

Fixes crewAIInc#5269.

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] BrightData SERP tool uses JavaScript template syntax in Python f-strings, breaking all search queries

1 participant