From e74ca8a131c000230867ac4b4a9441fcb9e36f0b Mon Sep 17 00:00:00 2001 From: zh Date: Mon, 28 Sep 2026 20:30:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(agent):=20=E5=B9=B3=E5=8F=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=8F=90=E7=A4=BA=E8=AF=8D=EF=BC=8C=E6=B6=88=E6=8E=89?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E7=9A=84=E8=83=BD=E5=8A=9B=E5=B9=BB=E8=A7=89?= =?UTF-8?q?=EF=BC=88A3.8=20=E5=89=8D=E7=BD=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 真引擎点亮后第一轮回复声称「可以阅读、修改和调试代码,并执行命令」——那是 Pi 自带的编码助手提示词,而平台已用 --no-builtin-tools 关掉了它的全部工具,属于能力幻觉。新增 server/app/system-prompt.ts:说明平台角色、工具只来自能力目录、没有的工具直接说做不到、写操作先出确认卡、数据以业务系统为准;应用服务建运行时会话时注入。实测对比:改前「我是 pi 编码助手…可以执行命令」,改后「我是连接 APS、ERP、EMS 等业务系统的智能体助手…」,追问「能读本机文件吗」→「不能。…没有读取本机文件的能力。」 --- server/app/service.ts | 2 ++ server/app/system-prompt.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 server/app/system-prompt.ts diff --git a/server/app/service.ts b/server/app/service.ts index 2a2333b..8a1b46e 100644 --- a/server/app/service.ts +++ b/server/app/service.ts @@ -14,6 +14,7 @@ import { createRulePlanner, plannerToFakeTurn } from '../agent/rule-planner.js'; import { toToolDescriptors } from '../agent/tools.js'; import type { SessionRepository } from '../core/storage/sessions.js'; import { runTurn } from './turn-runner.js'; +import { PLATFORM_SYSTEM_PROMPT } from './system-prompt.js'; import type { Provider } from '@aps/provider-sdk'; import { badRequest, conflict } from './errors.js'; import { ProjectStore } from './projects.js'; @@ -235,6 +236,7 @@ export class ApplicationService { sessionId, subject: { userId: record.owner.userId, tenantId: record.owner.tenantId }, projectId: record.summary.projectId, + system: PLATFORM_SYSTEM_PROMPT, tools: toToolDescriptors(this.registry.list()), history: record.messages, }); diff --git a/server/app/system-prompt.ts b/server/app/system-prompt.ts new file mode 100644 index 0000000..53a01cb --- /dev/null +++ b/server/app/system-prompt.ts @@ -0,0 +1,16 @@ +/** + * 平台系统提示词(A3.8 的一部分,先在真引擎点亮时补上)。 + * + * 为什么必须有:Pi 自带的是「编码助手」提示词,会声称自己能读写文件、执行命令。 + * 平台把它的工具全关了(--no-builtin-tools),这种承诺就是幻觉——实测第一轮回复就说 + * 「可以帮你阅读、修改和调试代码,并执行命令」,这是必须消掉的。 + */ +export const PLATFORM_SYSTEM_PROMPT = [ + '你是「多系统智能体平台」的助手,通过平台连接 APS、ERP、EMS 等外部业务系统。', + '', + '必须遵守的规则:', + '1. 你能做的事只取决于本轮提供的工具,这些工具来自平台的能力目录。没有对应工具时,直接说明做不到;不要声称能阅读文件、执行命令或访问本机。', + '2. 涉及写操作(发布、修改、删除、导入)时,先说明影响范围,由平台弹出确认卡,用户确认后才执行。', + '3. 业务数据以业务系统返回的结果为准,不要编造;不确定就问清楚,不要自己猜参数。', + '4. 用中文回答,先说结论,保持简洁。', +].join('\n'); \ No newline at end of file