Run Reddit and X searches in parallel, fix timeout handling

- Refactor run_research() to use ThreadPoolExecutor for parallel execution
- Reddit timeout/crash no longer blocks X search from running
- Add catch for ConnectionResetError/OSError in http.py
- Per-item error handling in Reddit enrichment (one failure doesn't crash all)
- Increase API timeouts from 60/90/120 to 90/120/180 seconds
- Add ClawdBot setup example to README

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Van Horn
2026-01-25 13:33:41 -08:00
parent 86422a74af
commit 3a4a727f4b
5 changed files with 223 additions and 94 deletions
+6
View File
@@ -102,6 +102,12 @@ def request(
log(f"JSON decode error: {e}")
last_error = HTTPError(f"Invalid JSON response: {e}")
raise last_error
except (OSError, TimeoutError, ConnectionResetError) as e:
# Handle socket-level errors (connection reset, timeout, etc.)
log(f"Connection error: {type(e).__name__}: {e}")
last_error = HTTPError(f"Connection error: {type(e).__name__}: {e}")
if attempt < retries - 1:
time.sleep(RETRY_DELAY * (attempt + 1))
if last_error:
raise last_error
+2 -2
View File
@@ -110,8 +110,8 @@ def search_reddit(
"Content-Type": "application/json",
}
# Adjust timeout based on depth
timeout = 60 if depth == "quick" else 90 if depth == "default" else 120
# Adjust timeout based on depth (generous for OpenAI web_search which can be slow)
timeout = 90 if depth == "quick" else 120 if depth == "default" else 180
# Note: allowed_domains accepts base domain, not subdomains
# We rely on prompt to filter out developers.reddit.com, etc.
+2 -2
View File
@@ -88,8 +88,8 @@ def search_x(
"Content-Type": "application/json",
}
# Adjust timeout based on depth
timeout = 60 if depth == "quick" else 90 if depth == "default" else 120
# Adjust timeout based on depth (generous for API response time)
timeout = 90 if depth == "quick" else 120 if depth == "default" else 180
# Use Agent Tools API with x_search tool
payload = {