重建会话记录逻辑

This commit is contained in:
2026-06-04 15:26:23 +08:00
parent 0ecb2babf3
commit 0188240d62
9 changed files with 375 additions and 42 deletions
+12 -3
View File
@@ -11,7 +11,7 @@ const initializePromise = Promise.all([
export default tool({
description:
"管理长期有效的用户偏好或项目事实。支持 add/list/replace/remove。禁止写入 token、password、secret、system prompt 或一次性上下文。scope 仅允许 'user' 或 'workspace'。",
"管理长期有效的用户偏好或项目事实。支持 add/list/replace/remove。新增记忆前必须先查看同 scope 的现有记忆,避免写入近似重复项;如果已有相近内容,应优先 replace/remove 而不是重复 add。禁止写入 token、password、secret、system prompt 或一次性上下文。scope 仅允许 'user' 或 'workspace'。",
args: {
action: tool.schema
.enum(["add", "list", "replace", "remove"])
@@ -95,9 +95,18 @@ export default tool({
return JSON.stringify({
ok: true,
kind: "memory",
decision: result.changed ? "accepted" : "deduped",
detail: result.changed ? "memory stored" : "memory already existed",
decision:
result.changed
? "accepted"
: result.detail === "memory already existed"
? "deduped"
: "rejected",
detail:
result.detail === "similar memory already exists"
? "similar memory already exists; review listed memories before storing a rewritten variant"
: result.detail,
entry: result.entry,
existing_entry: result.similar,
target: scope,
});
}