From fe15b8d71cff0209f7d91bd5d33304a06a811f53 Mon Sep 17 00:00:00 2001 From: thzxx Date: Wed, 24 Jun 2026 22:52:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20memory=E5=B7=A5=E5=85=B7=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=90=8E=E6=B3=A8=E5=85=A5=E7=A1=AC=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=20=E2=80=94=20=E9=98=B2=E6=AD=A2=E6=A8=A1=E5=9E=8B=E6=97=A0?= =?UTF-8?q?=E8=A7=86=E5=AE=9E=E9=99=85=E6=95=B0=E6=8D=AE=E3=80=81=E6=8A=8A?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=8F=90=E7=A4=BA=E8=AF=8D=E5=BD=93=E8=AE=B0?= =?UTF-8?q?=E5=BF=86=E7=BC=96=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/services/agent-engine.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/renderer/services/agent-engine.ts b/src/renderer/services/agent-engine.ts index eb06476..25708b9 100644 --- a/src/renderer/services/agent-engine.ts +++ b/src/renderer/services/agent-engine.ts @@ -1420,6 +1420,16 @@ async function handleExecuting( role: 'tool', tool_name: record.name, content: formatToolResultForModel(record.name, record.result!) }); + // ── 关键工具结果加硬提示,防止模型忽略实际数据去用系统提示词编造 ── + if (record.name === 'memory' && record.status === 'success') { + const action = (record.result as any)?.action; + if (action === 'read_all' || action === 'search') { + ctx.messages.push({ + role: 'system', + content: `⚠️ 以上 tool 消息中的内容是 memory 工具返回的实际记忆数据。你必须严格基于这些数据回答用户,不要编造、不要忽略、不要把系统提示词里的 SOUL/AGENT 内容当成记忆列出来。如果上面显示"记忆为空"才说没有。`, + }); + } + } if (cacheKey) toolResultCache.set(cacheKey, { result: record.result!, timestamp: Date.now() }); // 记录度量 recordToolCall(record.name, record.status, Date.now() - record.timestamp);