feat(chat): align AI tool-use with GPT-4.1/Anthropic standards -- Fix1: AGENT_GUIDE in system prompt (Persistence/Tool-calling/Planning), Fix2: install_app def improved, Fix3: max_tool_rounds 5->15
CI / gate (push) Has been cancelled
CI / gate (push) Has been cancelled
This commit is contained in:
1 parent
a2504bce34
commit
e1e50e884e
2 files changed
+27
-3
No files matched your search
@@ -1164,6 +1164,26 @@ def _build_system_prompt(
|
|||||||
|
|
||||||
|
|
||||||
system_parts = ["你是AIFlow平台的AI助手,具备专业的知识储备和工具调用能力。"]
|
system_parts = ["你是AIFlow平台的AI助手,具备专业的知识储备和工具调用能力。"]
|
||||||
|
|
||||||
|
# === Agent 工具使用标准指引(对标 OpenAI GPT-4.1 / Anthropic ReAct) ===
|
||||||
|
system_parts.append("""【工具使用规则——请严格遵守】
|
||||||
|
|
||||||
|
1. 持久性:请持续工作直到用户的问题完全解决,不要中途放弃。
|
||||||
|
如果一次操作未得到期望结果,请尝试替代方法或不同参数组合,直到成功。
|
||||||
|
|
||||||
|
2. 工具优先:如果你不确定某个信息,或需要获取外部数据、实时信息来完成用户请求,
|
||||||
|
请务必使用工具来获取——绝对不要猜测或编造答案。
|
||||||
|
|
||||||
|
3. 规划与反思:调用工具前,先思考需要什么信息、按什么顺序调用。结果返回后,
|
||||||
|
检查是否符合预期;不符合则调整计划重试。
|
||||||
|
|
||||||
|
4. 何时不调用工具:纯闲聊/问候/简单常识性问题/用户明确要求不要用工具时。
|
||||||
|
|
||||||
|
5. 工具调用顺序:先获取信息的工具(搜索/查询),再执行操作的工具(创建/修改)。
|
||||||
|
不要跳过必要的前置查询步骤。
|
||||||
|
|
||||||
|
6. 工具结果反馈:工具返回的结果是客观事实,请忠实地引用,不要虚构或修改。
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4355,11 +4355,15 @@ async def _send_message_core(
|
|||||||
if isinstance(function_definitions, list):
|
if isinstance(function_definitions, list):
|
||||||
function_definitions.append({
|
function_definitions.append({
|
||||||
"name": "install_app",
|
"name": "install_app",
|
||||||
"description": "当用户提供技能/Skill、MCP 服务或 Agent 的链接(如 GitHub 仓库、mcp.so、modelscope 等)并希望安装到平台时使用。自动识别类型(skill/mcp/agent)并安装,随后可在对话中直接使用。",
|
"description": "安装新的技能(Skill)、MCP 服务或外部 Agent 到平台。\n"
|
||||||
|
"\n"
|
||||||
|
"【何时调用】用户明确提供链接并表示要安装/导入/添加时。例如:'帮我安装这个技能 https://github.com/...'\n"
|
||||||
|
"【何时不调用】用户只询问安装方法、讨论某个工具但没有提供可安装链接时。\n"
|
||||||
|
"【注意】安装完成后该技能/MCP/Agent 可在本对话中直接使用,无需额外配置。",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"url": {"type": "string", "description": "要安装的技能/MCP/Agent 地址(URL)"},
|
"url": {"type": "string", "description": "要安装的资源完整地址。必须是 http/https URL,支持 GitHub 仓库、mcp.so、modelscope 等平台链接。"},
|
||||||
"type": {"type": "string", "enum": ["auto", "skill", "mcp", "agent"], "description": "安装类型,auto 表示自动识别(默认)"},
|
"type": {"type": "string", "enum": ["auto", "skill", "mcp", "agent"], "description": "安装类型,auto 表示自动识别(默认)"},
|
||||||
},
|
},
|
||||||
"required": ["url"],
|
"required": ["url"],
|
||||||
@@ -4562,7 +4566,7 @@ async def _send_message_core(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
max_tool_rounds = 5
|
max_tool_rounds = 15 # 对齐 GPT-4.1/Anthropic 标准: 足够完成复杂多步工具调用
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user