feat(web): send honest nanobot UA for Keenable

Keenable is a first-party API, so identify as nanobot/<version> instead
of the shared spoofed-browser User-Agent used by scraping providers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilya Gusev
2026-06-18 00:08:52 +08:00
committed by Xubin Ren
co-authored by Claude Opus 4.8
parent 6fcf65a8e3
commit 4f6e5e9cb8
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -489,8 +489,10 @@ 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", "")
headers = {"Content-Type": "application/json", "User-Agent": self.user_agent}
# First-party API: identify honestly instead of the spoofed browser UA.
headers = {"Content-Type": "application/json", "User-Agent": f"nanobot/{__version__}"}
if api_key:
headers["X-API-Key"] = api_key
try:
+1 -1
View File
@@ -143,7 +143,7 @@ async def test_keenable_search(monkeypatch):
async def mock_post(self, url, **kw):
assert "keenable" in url
assert kw["headers"]["X-API-Key"] == "keen-key"
assert kw["headers"]["User-Agent"] == "nanobot-search-test"
assert kw["headers"]["User-Agent"].startswith("nanobot/")
return _response(json={
"results": [{
"title": "Keen",