hoaresky 6bd2950b99 Fix: add asyncio timeout guard for DuckDuckGo search
DDGS's internal `timeout=10` relies on `requests` read-timeout semantics,
which only measure the gap between bytes — not total wall-clock time.
When the underlying HTTP connection enters CLOSE-WAIT or the server
dribbles data slowly, this timeout never fires, causing `ddgs.text` to
hang indefinitely via `asyncio.to_thread`.

Since `asyncio.to_thread` cannot cancel the underlying OS thread, the
agent's session lock is never released, blocking all subsequent messages
on the same session (observed: 8+ hours of unresponsiveness).

Fix:
- Add `timeout` field to `WebSearchConfig` (default: 30s, configurable
  via config.json or NANOBOT_TOOLS__WEB__SEARCH__TIMEOUT env var)
- Wrap `asyncio.to_thread` with `asyncio.wait_for` to enforce a hard
  wall-clock deadline

Closes #2804

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 02:21:51 +08:00
..
2026-02-01 07:36:42 +00:00