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
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5269
Problem
BrightDataSearchTool.get_search_urlused JavaScript template-literal syntax inside Python f-strings. Python treats$as a literal character, so every constructed URL contained a stray dollar sign:https://www.google.com/search?q=$hello%20worldhttps://www.bing.com/search?q=$some+queryhttps://yandex.com/search/?text=$queryThis caused all SERP searches to fail because the search engine received
$<query>instead of the actual query string.Additionally,
results_countwas read from**kwargswith 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
$prefix from all three f-string URL templates inget_search_url.results_counttoBrightDataSearchToolSchemaas a typedint | Nonefield withdefault=10, so agents can explicitly pass the desired number of results.results_countas an explicit parameter to_run, replacing the hiddenkwargs.get("results_count", "10")pattern.Testing
New unit tests added to
brightdata_serp_tool_test.py:test_get_search_url_google— verifies no$in Google URLtest_get_search_url_bing— verifies no$in Bing URLtest_get_search_url_yandex— verifies no$in Yandex URLtest_run_default_results_count_is_10— verifies defaultnum=10test_run_with_custom_results_count— verifies custom count is forwarded