fix(memory): honor empty extraction results
Memind CI / Test, build, and release guards (push) Successful in 2m55s
Memind CI / Test, build, and release guards (push) Successful in 2m55s
This commit is contained in:
@@ -109,6 +109,7 @@ function buildMemoryPrompt(messages) {
|
||||
'你是 TKMind 的用户长期记忆提取器。',
|
||||
'请从下面的用户对话中提取可以长期复用的个人记忆。',
|
||||
'只记录用户明确表达或强证据支持的信息,不要猜测,不要记录临时闲聊。',
|
||||
'不要把问题、请求、指令或待办本身当作用户事实;问句没有提供答案时不要记录。',
|
||||
'不要记录密码、密钥、身份证、手机号、银行卡等敏感信息。',
|
||||
'只返回 JSON 对象,不要 Markdown,不要解释。',
|
||||
'格式:{"memories":[{"label":"preference|habit|interest|goal|fact|experience|knowledge","text":"一句完整中文记忆","confidence":0.0-1.0}]}',
|
||||
@@ -382,7 +383,9 @@ export function createConversationMemoryService(pool, options = {}) {
|
||||
warnLlmExtractionFailed(err);
|
||||
}
|
||||
}
|
||||
if (!memories?.length) memories = fallbackMemoriesFromMessages(messages);
|
||||
// An empty array is an authoritative LLM decision that the batch contains no
|
||||
// durable memory. Only fall back when extraction was unavailable (`null`).
|
||||
if (memories == null) memories = fallbackMemoriesFromMessages(messages);
|
||||
const stored = await storeMemories(userId, messages, memories);
|
||||
await markAnalyzed(messages.map((message) => message.id));
|
||||
return { ok: true, analyzed: messages.length, memories: stored };
|
||||
|
||||
Reference in New Issue
Block a user