From b273ba2a190b72ad6909257af4d4bfbbacad98e7 Mon Sep 17 00:00:00 2001 From: BillionToken Date: Sat, 21 Mar 2026 01:18:47 +0800 Subject: [PATCH] fix(config): respect disabled system functions in web search tools (#6584) Co-authored-by: BillionClaw --- astrbot/builtin_stars/web_searcher/main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/astrbot/builtin_stars/web_searcher/main.py b/astrbot/builtin_stars/web_searcher/main.py index d13ca1579..cca1b43fb 100644 --- a/astrbot/builtin_stars/web_searcher/main.py +++ b/astrbot/builtin_stars/web_searcher/main.py @@ -567,9 +567,9 @@ class Main(star.Star): if provider == "default": web_search_t = func_tool_mgr.get_func("web_search") fetch_url_t = func_tool_mgr.get_func("fetch_url") - if web_search_t: + if web_search_t and web_search_t.active: tool_set.add_tool(web_search_t) - if fetch_url_t: + if fetch_url_t and fetch_url_t.active: tool_set.add_tool(fetch_url_t) tool_set.remove_tool("web_search_tavily") tool_set.remove_tool("tavily_extract_web_page") @@ -578,9 +578,9 @@ class Main(star.Star): elif provider == "tavily": web_search_tavily = func_tool_mgr.get_func("web_search_tavily") tavily_extract_web_page = func_tool_mgr.get_func("tavily_extract_web_page") - if web_search_tavily: + if web_search_tavily and web_search_tavily.active: tool_set.add_tool(web_search_tavily) - if tavily_extract_web_page: + if tavily_extract_web_page and tavily_extract_web_page.active: tool_set.add_tool(tavily_extract_web_page) tool_set.remove_tool("web_search") tool_set.remove_tool("fetch_url") @@ -590,9 +590,8 @@ class Main(star.Star): try: await self.ensure_baidu_ai_search_mcp(event.unified_msg_origin) aisearch_tool = func_tool_mgr.get_func("AIsearch") - if not aisearch_tool: - raise ValueError("Cannot get Baidu AI Search MCP tool.") - tool_set.add_tool(aisearch_tool) + if aisearch_tool and aisearch_tool.active: + tool_set.add_tool(aisearch_tool) tool_set.remove_tool("web_search") tool_set.remove_tool("fetch_url") tool_set.remove_tool("web_search_tavily") @@ -602,7 +601,7 @@ class Main(star.Star): logger.error(f"Cannot Initialize Baidu AI Search MCP Server: {e}") elif provider == "bocha": web_search_bocha = func_tool_mgr.get_func("web_search_bocha") - if web_search_bocha: + if web_search_bocha and web_search_bocha.active: tool_set.add_tool(web_search_bocha) tool_set.remove_tool("web_search") tool_set.remove_tool("fetch_url")