From dd7349338bcc5cbf0ba7dfa3bf3dad52e3cbbebe Mon Sep 17 00:00:00 2001 From: Metona Date: Fri, 17 Apr 2026 09:03:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=20AI=20=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E8=B0=83=E7=94=A8=E5=B7=A5=E5=85=B7=E7=9A=84=20prompt?= =?UTF-8?q?=20=E6=8C=87=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增第 7 条「主动使用工具」规则: - 明确告知 AI 在不确定、信息过时、需要实时数据时应主动调用工具 - 列举典型场景与对应工具的映射关系 - 强调宁可多调一次工具,也不要给出过时或编造的信息 --- src/renderer/services/agent-engine.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/services/agent-engine.ts b/src/renderer/services/agent-engine.ts index 26d5486..ede33c8 100644 --- a/src/renderer/services/agent-engine.ts +++ b/src/renderer/services/agent-engine.ts @@ -33,7 +33,13 @@ const TOOL_USAGE_GUIDE = `【工具使用规则】 3. 如果对话中从未出现过相关路径,应先用 search_files 或 list_directory 定位,不要凭空猜测路径。 4. 对同一文件的连续操作(读取→修改、读取→删除),路径必须一致。 5. 当用户要求执行命令时,使用 run_command 工具执行。命令通过工作空间终端实时执行并显示,执行完成后将 stdout/stderr 结果告知用户。 -6. 联网搜索联动:当用户询问需要最新信息的问题时(如版本号、新闻、价格等),先用 web_search 搜索,然后必须从搜索结果中选择最相关的 1-3 个 URL,用 web_fetch 抓取页面详细内容获取准确数据。不要仅凭搜索摘要回答——摘要往往不完整,必须抓取原文才能给出准确答案。`; +6. 联网搜索联动:当用户询问需要最新信息的问题时(如版本号、新闻、价格等),先用 web_search 搜索,然后必须从搜索结果中选择最相关的 1-3 个 URL,用 web_fetch 抓取页面详细内容获取准确数据。不要仅凭搜索摘要回答——摘要往往不完整,必须抓取原文才能给出准确答案。 +7. 主动使用工具:当你不确定答案、信息可能已过时、或需要查阅实时数据时,主动调用工具而不是凭记忆猜测。以下场景必须使用工具: + - 用户问"最新版本"、"现在多少钱"、"最近有什么新闻" → web_search + web_fetch + - 用户让你查看/修改/分析文件 → read_file / list_directory / search_files + - 用户问项目状态、代码内容 → git status / read_file + - 用户让你执行操作 → run_command / write_file 等 + 宁可多调一次工具,也不要给出过时或编造的信息。`; export interface AgentCallbacks { onThinking: (text: string) => void;