feat: ensure essential tools are always included in LLM tool selection and update tests

- Add mechanism to always include core tools (e.g., file operations, command execution) in LLMToolSelectorMiddleware
- Update MoviePilotToolFactory to provide filtered always-include tool names based on loaded tools
- Set default LLM_MAX_TOOLS to 30 in config
- Refactor agent initialization to support always_include parameter
- Enhance tests to cover always_include logic and async agent creation
This commit is contained in:
jxxghp
2026-04-30 13:04:52 +08:00
parent 28a2386f2f
commit 53f6897d62
4 changed files with 74 additions and 9 deletions
+7 -2
View File
@@ -407,6 +407,10 @@ class MoviePilotAgent:
# 工具列表
tools = self._initialize_tools()
max_tools = settings.LLM_MAX_TOOLS
always_include_tools = (
MoviePilotToolFactory.get_tool_selector_always_include_names(tools)
)
# 中间件
middlewares = [
@@ -438,11 +442,12 @@ class MoviePilotAgent:
]
# 工具选择
if settings.LLM_MAX_TOOLS > 0:
if max_tools > 0:
middlewares.append(
LLMToolSelectorMiddleware(
model=non_streaming_llm,
max_tools=settings.LLM_MAX_TOOLS,
max_tools=max_tools,
always_include=always_include_tools,
)
)