From c2bf347dc37de8087759aa2ad0e2d2dcf19a54b7 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sun, 9 Aug 2026 14:17:29 +0800 Subject: [PATCH] fix(chat-engine): instruct LLM not to call document tool for existing memory Memory context is already injected into system prompt, so add explicit instruction telling the LLM to use it directly instead of calling the document tool to re-read memories. Co-authored-by: CodeFree --- server/service/agent/chat-engine.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/service/agent/chat-engine.ts b/server/service/agent/chat-engine.ts index 8297fb2..5954f17 100644 --- a/server/service/agent/chat-engine.ts +++ b/server/service/agent/chat-engine.ts @@ -251,9 +251,11 @@ export async function executeChat(params: ChatEngineParams): Promise 标签内是你的持久记忆,已注入上下文。回答问题时优先参考这些记忆,不要重复调用 document 工具读取已有记忆。"; systemPrompt = systemPrompt - ? `${systemPrompt}\n\n${memoryContext}` - : memoryContext; + ? `${systemPrompt}${memoryInstruction}\n${memoryContext}` + : `${memoryInstruction}\n${memoryContext}`; } }