Repository navigation
skills: apply tool_filter in SkillToolSet.get_tools #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题:
_default_tools缓存路径(新增行 170)在缓存命中时按首个调用的invocation_context过滤后整体返回快照。_is_tool_selected对ToolPredicate会调用self._tool_filter(tool, invocation_context),因此过滤结果依赖调用时的上下文,而缓存列表本身不区分上下文——首次调用固化的过滤结果,后续请求无论传入什么上下文都读取同一份快照。触发条件: 构造时配置了
tool_filter为谓词(is_include_all_tools=False),且get_tools()首次调用发生在无显式上下文的位置(如server/ag_ui/_core/_agui_agent.py:411的tool.get_tools(None)、_llm_agent.py的工具预取),或首次调用与后续调用传入不同上下文。实际影响: 后续所有真实请求的工具名集合与请求自身上下文无关:本应在的动词或工具(如
skill_run、workspace_exec)在 LLM 请求中缺失(convert_toolunion_to_tool_list->get_tools(context)返回快照后,process_request无法声明未包含的工具),LLM 无法调用;反之不应暴露的工具被固化暴露。缓存路径连 predicate 都不再被调用,违背计划"上下文感知过滤"意图。修正方向: 将按请求上下文过滤的结果与缓存分离——缓存仅保存构建好的全量工具列表(
_default_tools.copy()原行为),每次调用都对该副本执行_is_tool_selected;或确保首次调用带真实上下文,并为缓存结果记录生成时上下文、命中时重新过滤。