Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(web): use shared user-agent and send X-Keenable-Title
Ilya Gusev092b07c7aae0
diff --git a/nanobot/agent/tools/web.py b/nanobot/agent/tools/web.pyindex 6d4de1383..78ec89f41 100644--- a/nanobot/agent/tools/web.py+++ b/nanobot/agent/tools/web.py@@ -489,10 +489,12 @@ class WebSearchTool(Tool):return f"Error: {e}"async def _search_keenable(self, query: str, n: int) -> str:- from nanobot import __version__api_key = self.config.api_key or os.environ.get("KEENABLE_API_KEY", "")- # First-party API: identify honestly instead of the spoofed browser UA.- headers = {"Content-Type": "application/json", "User-Agent": f"nanobot/{__version__}"}+ headers = {+ "Content-Type": "application/json",+ "User-Agent": self.user_agent,+ "X-Keenable-Title": "nanobot",+ }if api_key:headers["X-API-Key"] = api_keytry:diff --git a/tests/tools/test_web_search_tool.py b/tests/tools/test_web_search_tool.pyindex 169295e25..4e46f90f3 100644--- a/tests/tools/test_web_search_tool.py+++ b/tests/tools/test_web_search_tool.py@@ -143,7 +143,8 @@ async def test_keenable_search(monkeypatch):async def mock_post(self, url, **kw):assert "keenable" in urlassert kw["headers"]["X-API-Key"] == "keen-key"- assert kw["headers"]["User-Agent"].startswith("nanobot/")+ assert kw["headers"]["User-Agent"] == "nanobot-search-test"+ assert kw["headers"]["X-Keenable-Title"] == "nanobot"return _response(json={"results": [{"title": "Keen", "url": "https://keenable.ai", "description": "short", "snippet": "longer excerpt"}]})