feat: deactivate built-in web_search tools when disabled to allow MCP tools

Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-06 03:12:51 +00:00
parent f009e09894
commit c6118409d0
@@ -49,6 +49,18 @@ class Main(star.Star):
self.sogo_search = Sogo()
self.baidu_initialized = False
# Deactivate built-in web search tools if web_search is disabled
# This allows MCP to provide custom web_search tools
websearch_enable = (
provider_settings.get("web_search", False) if provider_settings else False
)
if not websearch_enable:
func_tool_mgr = self.context.get_llm_tool_manager()
for tool_name in self.TOOLS:
tool = func_tool_mgr.get_func(tool_name)
if tool:
tool.active = False
async def _tidy_text(self, text: str) -> str:
"""清理文本,去除空格、换行符等"""
return text.strip().replace("\n", " ").replace("\r", " ").replace(" ", " ")
@@ -394,6 +406,15 @@ class Main(star.Star):
websearch_enable = prov_settings.get("web_search", False)
provider = prov_settings.get("websearch_provider", "default")
func_tool_mgr = self.context.get_llm_tool_manager()
# Globally activate/deactivate built-in web search tools based on config
# This allows MCP to provide custom web_search tools when built-in is disabled
for tool_name in self.TOOLS:
tool = func_tool_mgr.get_func(tool_name)
if tool:
tool.active = websearch_enable
tool_set = req.func_tool
if isinstance(tool_set, FunctionToolManager):
req.func_tool = tool_set.get_full_tool_set()