From 6fb8c330574fb0118c3e4a8ac2c5fd57fe672c73 Mon Sep 17 00:00:00 2001 From: Christian Gick Date: Thu, 5 Mar 2026 15:47:23 +0200 Subject: [PATCH] fix: Truncate AI reply to 200 chars in memory extraction to prevent doc pollution The AI reply often contains full document content (passport details, etc.) which the memory extraction LLM incorrectly stores as user facts. Limiting to 200 chars avoids including document content while keeping the gist. Co-Authored-By: Claude Opus 4.6 --- bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index c51498b..e8b0668 100644 --- a/bot.py +++ b/bot.py @@ -1396,7 +1396,8 @@ class Bot: {"role": "user", "content": ( f"Existing memories:\n{existing_text}\n\n" f"User message: {user_message[:500]}\n" - f"AI reply: {ai_reply[:500]}\n\n" + # Only include first 200 chars of AI reply to avoid document content pollution + f"AI reply (summary only): {ai_reply[:200]}\n\n" "New facts to remember (JSON array of strings):" )}, ],