fix(tools): make web_search resilient via multi-engine fallback (#231)#232
Merged
Conversation
web_search relied on ddgs's default 'auto' backend, which leads with DuckDuckGo — heavily rate-limited from cloud/shared IPs. When DDG threw, the whole tool returned ❌ (issue #231) even though Google/ Bing/Brave/Mojeek/Yahoo were reachable. - Pass an explicit ordered backend list so ddgs falls through a throttled engine to the next; override via VIBE_TRADING_SEARCH_BACKENDS - Retry transient failures with linear backoff (3 attempts) - Treat "No results found" as an ok+empty envelope, not an error - On persistent failure, return an actionable message (retry / set backend env / use read_url) instead of a bare exception string - Report the backend list used in the ok envelope Tests: new tests/test_web_search_tool.py (6 cases, mocked ddgs) cover multi-backend pass-through, env override, retry-then-succeed, no-results, persistent-failure message, and max_results cap.
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.
Summary
Makes
web_searchresilient to single-engine rate limiting. Fixes #231, where the tool showed a red ❌ "web search failure" while the run still completed viaread_url— the symptom of DuckDuckGo (the defaultddgsautobackend's lead engine) being throttled from cloud/shared IPs.Why
ddgsis a metasearch aggregator (DuckDuckGo, Google, Bing, Brave, Mojeek, Yahoo, …), all key-free. The previous code relied on the defaultbackend="auto", which leads with DuckDuckGo; when DDG threw, the whole tool returned an error even though the other engines were reachable. (Reproduced: theduckduckgobackend returns "No results found." intermittently whilegoogle/bing/brave/mojeeksucceed for the same query.)Changes
duckduckgo, google, bing, brave, mojeek, yahoo) so ddgs falls through a throttled engine to the next. Overridable viaVIBE_TRADING_SEARCH_BACKENDS(e.g. pin togoogle, bing)."No results found"as anok+ empty-results envelope, not an error.read_url) instead of a bare exception string.okenvelope.duckduckgo_searchfallback (calls without thebackendkwarg when ddgs isn't present).Test Plan
agent/tests/test_web_search_tool.py— 6 cases (mocked ddgs): multi-backend pass-through, env override, retry-then-succeed, no-results→ok-empty, persistent-failure message, max_results cap. All pass.web_search(security scanner + MCP regression) passes; tool registry still discoversweb_search(48 tools).Checklist
src/agent/,src/session/,src/providers/)