fix: Prevent memory extraction from storing document facts as user facts

The memory extraction prompt was extracting facts from RAG search results
(e.g., passport holder names) and storing them as if they were facts about
the user. Added explicit instruction to only extract facts the user directly
states about themselves.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-03-05 15:27:47 +02:00
parent e2bac92959
commit aa175b8fb9

5
bot.py
View File

@@ -1379,11 +1379,14 @@ class Bot:
model=model, model=model,
messages=[ messages=[
{"role": "system", "content": ( {"role": "system", "content": (
"You extract memorable facts about users from conversations. " "You extract memorable facts about the USER from conversations. "
"Return a JSON array of strings — each string is a concise fact worth remembering. " "Return a JSON array of strings — each string is a concise fact worth remembering. "
"Include: name, language preference, location, occupation, interests, preferences, " "Include: name, language preference, location, occupation, interests, preferences, "
"family, pets, projects, important dates, or any personal detail shared. " "family, pets, projects, important dates, or any personal detail shared. "
"Do NOT include: the current question/topic, temporary info, or things the AI said. " "Do NOT include: the current question/topic, temporary info, or things the AI said. "
"Do NOT extract facts from documents or search results mentioned in the AI reply — "
"those are about OTHER people/entities, not the user. Only extract facts the user "
"directly states about themselves. "
"Do NOT duplicate existing memories (rephrase or skip if already known). " "Do NOT duplicate existing memories (rephrase or skip if already known). "
"Return [] if nothing new is worth remembering." "Return [] if nothing new is worth remembering."
)}, )},