fix: 子代理无法使用内置工具(如 web_search_tavily)#7939
Open
Blueteemo wants to merge 2 commits intoAstrBotDevs:masterfrom
Open
fix: 子代理无法使用内置工具(如 web_search_tavily)#7939Blueteemo wants to merge 2 commits intoAstrBotDevs:masterfrom
Blueteemo wants to merge 2 commits intoAstrBotDevs:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider avoiding the implicit
getattr(builtin_tool, "active", True)check by ensuring builtin tools conform to the same interface as registered tools (e.g., always exposing anactiveattribute), which will make the filtering logic more consistent and less error-prone. - If
iter_builtin_tools()can ever return the same tool objects that are already present inllm_tools.func_list, it may be worth ensuringToolSetdeduplicates or explicitly guarding against adding duplicates here.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider avoiding the implicit `getattr(builtin_tool, "active", True)` check by ensuring builtin tools conform to the same interface as registered tools (e.g., always exposing an `active` attribute), which will make the filtering logic more consistent and less error-prone.
- If `iter_builtin_tools()` can ever return the same tool objects that are already present in `llm_tools.func_list`, it may be worth ensuring `ToolSet` deduplicates or explicitly guarding against adding duplicates here.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Related Knowledge 1 document with suggested updates is ready for review. AstrBotTeam's Space pr4697的改动View Suggested Changes@@ -247,6 +247,7 @@
- 当 `SubAgent.tools` 设置为 `None` 时,表示"所有可用工具",与主代理行为一致
- 此时 handoff 工具集包括:
- 所有已注册的活跃工具(从 `llm_tools` 注册表获取,排除 HandoffTool 避免递归)
+ - 所有内置工具(builtin tools),例如 web_search_tavily(从 `tool_mgr.iter_builtin_tools()` 获取的活跃工具)
- 所有运行时 Computer Use 工具(根据 `computer_use_runtime` 配置动态添加)
2. **空工具列表(无工具)**: |
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the _build_handoff_toolset function in astrbot/core/astr_agent_tool_exec.py to include builtin tools when initializing the toolset for sub-agents. Review feedback highlights a security concern where adding all builtin tools indiscriminately might bypass configuration-based restrictions, such as shell execution or web search toggles. Additionally, there is a suggestion to use tool_mgr instead of llm_tools to ensure the toolset remains consistent with the specific execution context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
子代理配置 tools=None 时,只能使用 MCP 工具和插件工具,无法使用内置工具(如 web_search_tavily)。
根本原因
_build_handoff_toolset 方法在 ools=None 时只遍历 llm_tools.func_list,但这个列表不包含内置工具。
修复方案
在遍历 llm_tools.func_list 后,也遍历 ool_mgr.iter_builtin_tools() 添加内置工具。
关联 Issue
Fixes #7870
Summary by Sourcery
Bug Fixes: