fix: ToolMessage contained an incorrect error message when all search engines returned empty results #1279
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.
Features
browser_usetool’sweb_searchaction crashes withlist index out of rangewhen all configured search engines (Google / DuckDuckGo / Baidu / Bing) return empty results (results: []).first_search_resultinweb_search_toolto validate the result list length and, when empty, return a meaningful error message instead of raising an index error.Feature Docs
Influence
For normal scenarios where at least one search engine returns results, behavior remains unchanged.
In edge cases where all search engines return empty results (e.g., due to being blocked by a captcha while still returning HTTP 200 and HTML content):
list index out of rangeexception no longer occurs.Result
i used gpt-oss-120b.
Reproduced an environment where all engines return
results: [](captcha on Bing in my case) and verified:Before the fix:
Error: Browser action 'web_search' failed: list index out of rangeis raised.contentthen contains:web_searchagain with the same (or very similar) query:After the fix:
browser_use, and the repeated same-query behavior is mitigated.