Skip to content

Your lightweight open-source personal agent.

Fix: add asyncio timeout guard for DuckDuckGo search

hoaresky6bd2950b9937
diff --git a/nanobot/agent/tools/web.py b/nanobot/agent/tools/web.py
index b8aeab47b..a6d7be983 100644
--- a/nanobot/agent/tools/web.py
+++ b/nanobot/agent/tools/web.py
@@ -207,7 +207,10 @@ class WebSearchTool(Tool):
from ddgs import DDGS
ddgs = DDGS(timeout=10)
- raw = await asyncio.to_thread(ddgs.text, query, max_results=n)
+ raw = await asyncio.wait_for(
+ asyncio.to_thread(ddgs.text, query, max_results=n),
+ timeout=self.config.timeout,
+ )
if not raw:
return f"No results for: {query}"
items = [
diff --git a/nanobot/config/schema.py b/nanobot/config/schema.py
index 0b5d6a817..47e35070c 100644
--- a/nanobot/config/schema.py
+++ b/nanobot/config/schema.py
@@ -155,6 +155,7 @@ class WebSearchConfig(Base):
api_key: str = ""
base_url: str = "" # SearXNG base URL
max_results: int = 5
+ timeout: int = 30 # Wall-clock timeout (seconds) for search operations
class WebToolsConfig(Base):