From 299b7ad56bcd67d5b098bfe3ca5dd75c90910cf7 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 18 Jun 2026 23:10:18 +0800 Subject: [PATCH] refactor: filter persona tools in one pass --- astrbot/core/astr_main_agent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py index 6aa0e523a..3420a18b8 100644 --- a/astrbot/core/astr_main_agent.py +++ b/astrbot/core/astr_main_agent.py @@ -1548,9 +1548,9 @@ async def build_main_agent( ) if persona_allowed_tools is not None and req.func_tool: - for tool in list(req.func_tool): - if tool.name not in persona_allowed_tools: - req.func_tool.remove_tool(tool.name) + req.func_tool.tools = [ + tool for tool in req.func_tool.tools if tool.name in persona_allowed_tools + ] fallback_providers = _get_fallback_chat_providers( provider, plugin_context, config.provider_settings