mirror of
https://gitee.com/qqtt-ah/ai-crm.git
synced 2026-11-23 23:49:19 +08:00
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Agent 编排:按会话 scene 装载工具。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Any
|
||
|
||
from application.memory_service import MemoryService
|
||
from config.settings import Settings
|
||
from domain.models import SCENE_ECOM_GOODS_PUBLISH, SCENE_GENERAL, Actor
|
||
|
||
|
||
async def load_tools_for_turn(
|
||
settings: Settings,
|
||
*,
|
||
actor: Actor,
|
||
memory: MemoryService,
|
||
scene: str = SCENE_GENERAL,
|
||
client_tools: list[Any] | None = None,
|
||
) -> list[Any]:
|
||
"""general:builtin + memory + MCP;历史发布场景仅 builtin(渠道工具已下线)。"""
|
||
from agent.tools.builtin import builtin_tools
|
||
from agent.tools.memory import memory_tools
|
||
from infrastructure.mcp.client import load_mcp_tools
|
||
|
||
scene_value = (scene or SCENE_GENERAL).strip() or SCENE_GENERAL
|
||
tools: list[Any] = [*builtin_tools()]
|
||
|
||
if scene_value == SCENE_ECOM_GOODS_PUBLISH:
|
||
# 商品发布能力已随电商模块移除,不再挂 MCP / 前端 ui_ 工具
|
||
return tools
|
||
|
||
tools.extend(memory_tools(memory, actor))
|
||
mcp_tools = await load_mcp_tools(
|
||
settings, company_id=actor.company_id, user_id=actor.user_id
|
||
)
|
||
tools.extend(mcp_tools)
|
||
if client_tools:
|
||
tools.extend(client_tools)
|
||
return tools
|