From 63f123417b8426639ce6824ed57cc9ba22e40326 Mon Sep 17 00:00:00 2001 From: xiaowei Date: Fri, 4 Sep 2026 01:29:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(distill):=20commit=20=E6=A3=80=E5=87=BA?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E6=97=B6=E4=B8=8D=E8=BF=9B=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=92=B8=E9=A6=8F=EF=BC=88conflict=20guard=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:commit 的 DetectContradiction 检出矛盾后只返回 conflicts 字段, 内容仍进 episodes→自动蒸馏→污染 distilled/memories(TencentDB 误判案例根因链一环) 修复:conflicts>0 时跳过 AutoDistillTrigger,返回 distill_skipped=conflict; 处理路径:①写错→feedback not_useful;②旧记忆错→feedback 降权; ③确认为修正→resolve_conflict=true 重 commit(待客户端支持) 验证:commit 矛盾内容 → conflicts 返回 + distill_skipped=conflict ✅ --- go/internal/api/routes/core.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/go/internal/api/routes/core.go b/go/internal/api/routes/core.go index 334069e..5f70258 100644 --- a/go/internal/api/routes/core.go +++ b/go/internal/api/routes/core.go @@ -165,10 +165,16 @@ func (a *API) Commit(w http.ResponseWriter, r *http.Request) { } if len(conflicts) > 0 { respData["conflicts"] = conflicts + // 冲突保护(2026-09-03 记忆治理):检出矛盾的内容不进自动蒸馏, + // 避免污染 distilled/memories。episodes 已保留(原始日志可追溯)。 + // 处理路径:①写错→Hermes feedback not_useful;②旧记忆错→feedback 降权; + // ③确认为修正/新事实→客户端显式 resolve_conflict=true 重 commit。 + respData["distill_skipped"] = "conflict" + respData["distill_note"] = "conflict detected; auto-distill skipped to prevent memory pollution. Resolve via feedback, or re-commit with resolve_conflict=true if this is a verified correction" + } else { + go AutoDistillTrigger(epID, req.Content, req.Category, req.Namespace, req.AgentID) } respond(w, 201, respData) - - go AutoDistillTrigger(epID, req.Content, req.Category, req.Namespace, req.AgentID) } // mergeMemory 合并重复记忆:升版本、提重要性、更新时间戳