{"record":{"id":"a3c230e11ef375bd","repo":"crewAIInc/crewAI","slug":"brave-search-api-request-timed-out-after-self-ti","errorCode":null,"errorMessage":"Brave Search API request timed out after {self._timeout}s: {exc}","messagePattern":"Brave Search API request timed out after (.+?)s: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py","lineNumber":201,"sourceCode":"        last_resp: requests.Response | None = None\r\n\r\n        # Retry the request up to _max_retries times\r\n        for attempt in range(_max_retries):\r\n            self._rate_limit()\r\n\r\n            try:\r\n                resp = requests.get(\r\n                    self.search_url,\r\n                    headers=self._headers,\r\n                    params=params,\r\n                    timeout=self._timeout,\r\n                )\r\n            except requests.ConnectionError as exc:\r\n                raise RuntimeError(\r\n                    f\"Brave Search API connection failed: {exc}\"\r\n                ) from exc\r\n            except requests.Timeout as exc:\r\n                raise RuntimeError(\r\n                    f\"Brave Search API request timed out after {self._timeout}s: {exc}\"\r\n                ) from exc\r\n\r\n            logger.debug(\r\n                \"Brave Search API request: %s %s -> %d\",\r\n                \"GET\",\r\n                resp.url,\r\n                resp.status_code,\r\n            )\r\n\r\n            # Response was OK, return the JSON body\r\n            if resp.ok:\r\n                try:\r\n                    result: dict[str, Any] = resp.json()\r\n                    return result\r\n                except ValueError as exc:\r\n                    raise RuntimeError(\r\n                        f\"Brave Search API returned invalid JSON (HTTP {resp.status_code}): {exc}\"\r","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py#L183-L219","documentation":"Raised when requests.get() to Brave's endpoint raises requests.Timeout: the server did not respond within the tool's configured timeout (constructor arg, default 30s, stored as self._timeout). The wrapper includes both the configured seconds and the underlying exception. Like connection errors, timeouts are not retried internally.","triggerScenarios":"Brave API slow under load; a low timeout constructor value (e.g. timeout=5) on high-latency links; oversized result sets (large count parameter) taking longer than the cap; network congestion.","commonSituations":"Mobile/high-latency networks; aggressive timeouts copied from fast internal services; requesting many results per query; Brave-side latency spikes.","solutions":["Increase the timeout at construction: BraveSearchTool(api_key=..., timeout=60).","Reduce response size (fewer results per query) to cut server time.","Wrap calls in your own retry with backoff — the tool does not retry timeouts.","If timeouts are sudden and global, check the Brave API status page."],"exampleFix":"# before\ntool = BraveSearchTool(api_key=key, timeout=5)\n\n# after\ntool = BraveSearchTool(api_key=key, timeout=60)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"except RuntimeError as e:\n    if \"timed out\" in str(e):\n        result = tool._run(query)  # one retry; then raise so caller can back off or degrade\n    else:\n        raise","preventionTips":["Set timeout proportional to expected latency and result size (default 30s is fine for most; raise on slow links).","Request fewer results per query to keep server-side latency low.","Distinguish this from connection errors — a timeout means the host was reached but was slow."],"tags":["network","timeout","configuration","brave-search"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}