fix(toolset): 工具传递改为展开的 tools 列表,不再用 FunctionToolset 包装

前端/DB 仍用 toolset 做逻辑分组管理,但传给 pydantic-ai Agent 时
把 toolset 内的 callable 展开为 tools=[] 扁平列表,MCP server 等
需要 toolset 语义的单独走 toolsets=[] 参数。解决工具"存在但调不了"的问题。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 19:05:59 +00:00
parent 78d03388c0
commit b15eeb9e74
8 changed files with 76 additions and 67 deletions
@@ -64,7 +64,7 @@ class BaseIndividual:
system_prompt: 该 Agent 的基础系统提示词,会和 task_event 拼接成动态提示词。
toolsets: 显式传入的外部工具集;为 ``None`` 时会自动按配置拉取。
"""
from kilostar.utils.mcp_helper import get_all_toolsets_for_scope
from kilostar.utils.mcp_helper import get_all_tools_and_toolsets_for_scope
from kilostar.core.global_state_machine.gsm_snapshot import fetch_snapshot
global_state_machine = ray_actor_hook(
@@ -84,9 +84,11 @@ class BaseIndividual:
agent_factory = AgentFactory()
if toolsets is None:
toolsets = await get_all_toolsets_for_scope(
tools, toolsets = await get_all_tools_and_toolsets_for_scope(
agent_name, toolset_ids=toolset_ids
)
else:
tools = []
self.agent = agent_factory.create_agent(
provider=provider,
@@ -95,6 +97,7 @@ class BaseIndividual:
system_prompt=system_prompt,
deps_type=WorkerIndividualDeps,
agent_name=agent_name,
tools=tools,
toolsets=toolsets,
)