Spaces:
Sleeping
Sleeping
Commit History
-
Add a circuit breaker to the multi-backend search fallback (item from review)
ClaudeUnverified signature/serp/search (and the MCP `search` tool) tries DuckDuckGo, then Brave, then Bing per query with no memory between calls - if a backend is rate-limiting or has blocked this deployment's IP, every single query still pays its full timeout hammering that backend before falling through, which only makes the block worse. - circuit_breaker.py: a small per-key CircuitBreaker (new module, no third- party dependency) - opens after `failure_threshold` consecutive failures for a key, short-circuits further calls during `cooldown_seconds`, then allows one half-open trial; success closes it, another failure reopens it for a fresh cooldown. Unit-tested with a fake clock for determinism. - app.py: wired a module-level `_backend_circuit_breaker` (3 failures, 60s cooldown) into `_search_one`'s backend loop. _search_one/`/serp/search` had zero test coverage before this - added characterization tests for its current fallback behavior first (first- success, falls-through-on-failure, all-fail er…ba2278a