Skip to content

feat(websearch): add AnySearch as a web search provider - #9767

Open
WangPan59 wants to merge 1 commit into
AstrBotDevs:masterfrom
WangPan59:feat/add-anysearch-web-search-provider
Open

feat(websearch): add AnySearch as a web search provider#9767
WangPan59 wants to merge 1 commit into
AstrBotDevs:masterfrom
WangPan59:feat/add-anysearch-web-search-provider

Conversation

@WangPan59

@WangPan59 WangPan59 commented Aug 22, 2026

Copy link
Copy Markdown

Summary

This PR adds AnySearch as a first-class web search provider in AstrBot,
following the same architecture as the existing Exa (#8973), Brave and Firecrawl integrations.

AnySearch is an AI search infrastructure that provides general web search plus
domain-specific retrieval (academic, code docs, finance, legal, security).
It also serves anonymous traffic with a daily free quota, so users can try the
provider without registering an API key first.

What's included

Backend (astrbot/core/tools/web_search_tools.py)

  • AnySearchWebSearchTool (web_search_anysearch) — search with tag / zone / language filters
  • _anysearch_search() — async helper for api.anysearch.com/v1/search
  • _ANYSEARCH_KEY_ROTATOR for multi-key rotation
  • Anonymous mode when no key is configured

Dispatch & config

  • astr_main_agent.py: registered in _apply_web_search_tools() + WEB_SEARCH_CITATION_TOOL_NAMES
  • config/default.py: websearch_anysearch_key: [] default + "anysearch" in provider options

i18n

  • Config metadata for all 3 locales (en-US, zh-CN, ru-RU)

Docs

  • docs/en/use/websearch.md and docs/zh/use/websearch.md updated with an AnySearch section

Tests

  • 7 unit tests covering result mapping, anonymous mode, key rotation on 402,
    fail-fast on 5xx, max_results clamping, snippet fallback, legacy config migration

Notes

  • No breaking change: default values of web_search and websearch_provider are untouched.
  • No new dependency: reuses the existing aiohttp.

Test Results

Unit tests

uv run pytest tests/unit/test_web_search_tools.py -q -k anysearch
....... [100%]
7 passed

Lint checks

ruff check .
All checks passed!

End-to-end test (anonymous mode)

image

Configuration

image

Summary by Sourcery

Add AnySearch as a first-class web search provider with configurable keys, anonymous access, filtering, and citation support.

New Features:

  • Add AnySearch as a selectable web search provider with general and domain-specific retrieval options.
  • Support anonymous AnySearch usage and configurable API-key rotation for quota and authentication failover.

Enhancements:

  • Integrate AnySearch results and citations into the main agent's web search workflow.
  • Expose AnySearch settings across the dashboard configuration and supported locales.
  • Document AnySearch setup and capabilities in the English and Chinese web search guides.

Tests:

  • Add unit coverage for result normalization, anonymous requests, key failover, error handling, result limits, configuration migration, and snippet fallback.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Aug 22, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the integration is wrong, users selecting AnySearch could have queries sent to the wrong external service, consume API quota, or receive failed or misleading results; requests and any exposed query data cannot be undone by reverting. The impact is limited to users who enable this provider, and no application data is persisted or deleted.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant