crewAIInc/crewAI · error · RuntimeError
Brave Search API request timed out after {self._timeout}s: {
Error message
Brave Search API request timed out after {self._timeout}s: {exc} What it means
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.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py:201
last_resp: requests.Response | None = None
# Retry the request up to _max_retries times
for attempt in range(_max_retries):
self._rate_limit()
try:
resp = requests.get(
self.search_url,
headers=self._headers,
params=params,
timeout=self._timeout,
)
except requests.ConnectionError as exc:
raise RuntimeError(
f"Brave Search API connection failed: {exc}"
) from exc
except requests.Timeout as exc:
raise RuntimeError(
f"Brave Search API request timed out after {self._timeout}s: {exc}"
) from exc
logger.debug(
"Brave Search API request: %s %s -> %d",
"GET",
resp.url,
resp.status_code,
)
# Response was OK, return the JSON body
if resp.ok:
try:
result: dict[str, Any] = resp.json()
return result
except ValueError as exc:
raise RuntimeError(
f"Brave Search API returned invalid JSON (HTTP {resp.status_code}): {exc}"
View on GitHub (pinned to 754d7323be)
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.
Example fix
# before tool = BraveSearchTool(api_key=key, timeout=5) # after tool = BraveSearchTool(api_key=key, timeout=60)
Defensive patterns
Strategy: retry
Try / catch
except RuntimeError as e:
if "timed out" in str(e):
result = tool._run(query) # one retry; then raise so caller can back off or degrade
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Mobile/high-latency networks; aggressive timeouts copied from fast internal services; requesting many results per query; Brave-side latency spikes.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Failed to download template: {e}
- Error fetching content from URL {url}: {e!s}
- BRAVE_API_KEY environment variable is required
- Invalid headers: {e}
- Brave Search API connection failed: {exc}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/a3c230e11ef375bd.
Report an issue: GitHub.