feat: add Serper search fallback + search cache + concurrency limiter#4
Open
andyzengmath wants to merge 4 commits into
Open
feat: add Serper search fallback + search cache + concurrency limiter#4andyzengmath wants to merge 4 commits into
andyzengmath wants to merge 4 commits into
Conversation
Add PowerShell and CMD examples for running the proxy on Windows, since launch.sh is bash-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DuckDuckGo Lite has become unreliable due to aggressive CAPTCHA/bot detection on automated requests. This causes web search to silently fail with empty results. Replace with Exa and Parallel MCP endpoints (same approach used by OpenCode) as the primary search backend: - Uses JSON-RPC 2.0 MCP protocol (tools/call method) - Traffic split 50/50 between Exa and Parallel by default - Automatic cross-fallback (if one fails, tries the other) - Works without API keys out of the box - 25-second timeout per request Provider priority chain: 1. Brave Search API (if BRAVE_API_KEY set) 2. Exa/Parallel MCP (primary, free, no key needed) 3. DuckDuckGo Lite (fallback, may hit CAPTCHAs) 4. DuckDuckGo Instant Answer (last resort) New env vars (all optional): - WEBSEARCH_PROVIDER: force "exa" or "parallel" - EXA_API_KEY: optional key for Exa - PARALLEL_API_KEY: optional key for Parallel
- Add Serper.dev (Google SERP API) as fallback search provider via SERPER_API_KEY env var - Reorder provider chain: Exa/Parallel MCP (free) → Brave → Serper → DDG Lite → DDG Instant - Add 5-min search result cache to deduplicate identical queries across parallel agents - Add concurrency semaphore (max 2 concurrent searches) to prevent DDG rate-limit storms - Route all search calls through throttled wrapper (executeWebSearchThrottled) Fixes cascading 'DDG Lite error: fetch failed' / 'All search providers failed' errors that occur when multi-agent workflows (e.g. Workflow tool) fire many parallel web searches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Reorder provider list to match new priority (MCP first, paid APIs as fallback) - Add Serper.dev to provider list and config table - Document rate-limit protection (cache + concurrency semaphore) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Problem
When multiple subagents run web searches in parallel (e.g. via the
Workflowtool orAgenttool), DuckDuckGo aggressively rate-limits requests, causing cascading failures:This is a known issue — DDG was never designed for programmatic use at agent scale.
Solution
Three changes to
proxy.mjs:1. Serper.dev as fallback search provider
SERPER_API_KEYenv var2. Search result cache (5-min TTL)
📋 Search cache hit:for visibility3. Concurrency semaphore (max 2 concurrent searches)
⏳ Search queued:)Updated Provider Chain
New Environment Variable
SERPER_API_KEYTesting
Verified Serper returns results:
Verified cache + concurrency with 4 parallel searches (2 unique, 2 duplicates):
Only 2 API calls instead of 4 — cache saved 50%.
Depends On
This PR builds on #3 (MCP providers). The provider chain assumes Exa/Parallel MCP are available as the primary free providers.
🤖 Generated with Claude Code