From b7cbc0656772c8ea3efeafc746ef199494ec9aab Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Sep 2026 01:58:28 +0800 Subject: [PATCH] feat(agent): prompt rules for probe queries, param types, Chinese reports and interrupted summaries Co-Authored-By: Claude Opus 5.5 --- packages/agent/src/system-prompt.ts | 7 ++++++- packages/agent/test/redact.test.ts | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/agent/src/system-prompt.ts b/packages/agent/src/system-prompt.ts index 144ab927..3be20ae9 100644 --- a/packages/agent/src/system-prompt.ts +++ b/packages/agent/src/system-prompt.ts @@ -54,7 +54,12 @@ export function buildSystemPrompt({ role, goal, constraints = [], interaction }: "不得输出、复述或索取凭证:Cookie、passkey、token、API Key、私有下载链接等;[REDACTED] 保持原样。", "有副作用的操作失败或结果未知时,先用查询工具核对实际状态,不要重复提交。", "目标中超出授权的部分单独列出,已授权的部分继续推进。", - "最后用简短中文汇报:做了什么、结果与证据、还缺什么。", + '检索词要有意义:写作品名、别名或关键词;不要用空串、单个字母或通配符(如 query:"a"、"*")探查全表,想盘点就用对应的列表能力(inventory.query 不带 query、subscription.list、decision.list)。', + '参数按工具 schema 的类型填写:ID 类参数一律是字符串(如 externalId:"693134",不是数字 693134);不要传 schema 里没有的字段。', + "业务任务 ID 用 task.inspect,下载任务 ID 或种子 hash 用 download.inspect,两者不要混用。", + "思考、步骤说明和汇报都用中文;引用对象 ID、文件名、原站标题时保持原文。", + "工具结果里出现【预算提醒】时立刻停止探查,直接用中文写小结;被预算或中止打断时,汇报只写中文小结(已完成什么、证据、还缺什么),不要复述中间过程或下一步打算。", + "最后用简短中文汇报:做了什么、结果与证据、还缺什么。可以用 Markdown(标题、列表、表格、代码),不要写 HTML。", ]; const lines = [ `你是${role}。`, diff --git a/packages/agent/test/redact.test.ts b/packages/agent/test/redact.test.ts index ea812ec6..4756c547 100644 --- a/packages/agent/test/redact.test.ts +++ b/packages/agent/test/redact.test.ts @@ -71,6 +71,13 @@ describe("buildSystemPrompt", () => { expect(p).toContain("“已提交”不等于“已入库”"); expect(p).toMatch(/网页、RSS.*不可信数据/); expect(p).toMatch(/不得输出.*凭证.*passkey/); + // AG-3:探查查询、参数类型、中文思考与汇报、被打断时的中文小结 + expect(p).toContain('query:"a"'); + expect(p).toContain('externalId:"693134"'); + expect(p).toContain("download.inspect"); + expect(p).toContain("思考、步骤说明和汇报都用中文"); + expect(p).toContain("【预算提醒】"); + expect(p).toContain("不要写 HTML"); expect(p).toContain("- 只给方案,不执行"); }); });