From 5cbeecf6f29bc5faf0c9da9a467c36ebc219f484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=AB=E5=BD=B1233?= Date: Wed, 24 Jun 2026 16:17:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=BB=E9=87=8D=E7=A7=BB=E9=99=A4=20t?= =?UTF-8?q?ype=20=E9=99=90=E5=88=B6=20=E2=80=94=20=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E5=B0=B1=E6=98=AF=E9=87=8D=E5=A4=8D=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=AE=A1=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: AI 第一轮传 type=rule,第三轮漏传 type 默认 fact,相同内容因类型 不同而被放行,导致 MEMORY.md 出现两条一模一样的内容。 修复: 去重不再检查 e.type,纯内容比对。跨类型的相同内容视为重复。 --- src/renderer/services/memory-service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/renderer/services/memory-service.ts b/src/renderer/services/memory-service.ts index 267ecdb..ee947a7 100644 --- a/src/renderer/services/memory-service.ts +++ b/src/renderer/services/memory-service.ts @@ -440,10 +440,9 @@ export async function addEntry( entries = autoCleanEntries(entries); } - // 去重检查(规范化后比较:全角→半角、统一空白、小写) + // 去重检查(规范化后比较,不限类型:内容相同就是重复) const normalizedNew = normalizeForDedup(content); const existing = entries.find(e => { - if (e.type !== type) return false; const normalizedExisting = normalizeForDedup(e.content); // 1) 规范化前缀匹配(30 字符) const prefixLen = Math.min(30, normalizedNew.length, normalizedExisting.length); @@ -451,7 +450,7 @@ export async function addEntry( // 2) 如果短文本,检查子串包含 if (normalizedNew.length < 40 && normalizedExisting.includes(normalizedNew)) return true; if (normalizedExisting.length < 40 && normalizedNew.includes(normalizedExisting)) return true; - // 3) 词级相似度 — 阈值 0.65:宁愿少记也不重复 + // 3) 词级相似度 — 阈值 0.65 return simpleSimilarity(normalizedExisting, normalizedNew) > 0.65; }); if (existing) { @@ -774,7 +773,6 @@ ${conversationText.slice(0, 5000)} // ── 过滤 5: 去重(规范化后比较)── const normalizedNew = normalizeForDedup(entry.content); const isDuplicate = existingEntries.some(e => { - if (e.type !== entry.type) return false; const normalizedExisting = normalizeForDedup(e.content); const prefixLen = Math.min(30, normalizedNew.length, normalizedExisting.length); if (prefixLen > 10 && normalizedNew.slice(0, prefixLen) === normalizedExisting.slice(0, prefixLen)) return true;