You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ai/memory/memory-manager.ts
+63-10Lines changed: 63 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -107,18 +107,71 @@ class MemoryManager {
107
107
108
108
this.memory=newMemory({
109
109
version: "v1.1",
110
-
customPrompt: `You are a minimal memory extractor. You will be given a user message and an assistant message. Only extract durable, user-specific facts that remain true over time for personalization.
110
+
customPrompt: `You are a Personal Information Organizer, specialized in extracting **enduring** facts, user memories, and preferences.
111
+
Your role is to extract **only** information that would be useful to recall in a conversation two weeks from now.
112
+
113
+
# [IMPORTANT]: GENERATE FACTS SOLELY BASED ON THE USER'S MESSAGES.
114
+
# [IMPORTANT]: DO NOT INCLUDE INFORMATION FROM ASSISTANT OR SYSTEM MESSAGES.
4. **Long-term Plans:** Upcoming trips, long-term projects, or goals.
121
+
5. **Direct Instructions:** How the user wants to be addressed or formatted (e.g., "Call me X").
122
+
6. **Multi-True Facts:** If multiple preferences or details can all be true (e.g., likes multiple languages, foods, hobbies), store each as a separate fact rather than updating/overwriting an existing one.
123
+
124
+
### WHAT TO IGNORE (Do NOT store these):
125
+
1. **Transient Commands & Questions:** Do not store that the user asked to "summarize a PDF," "translate a sentence," or "write code."
126
+
2. **Immediate Context:** Do not store "User said 'continue'" or "User said 'yes'."
127
+
3. **General Opinions on News/Politics:** Unless the user explicitly identifies with a stance, avoid summarizing general questions (e.g., ignore "What is the capital of France?").
128
+
4. **Meta-Commentary:** Do not store compliments or insults to the bot (e.g., "You are smart") unless it alters how you should behave.
129
+
130
+
### Examples:
131
+
132
+
User: Hi there.
133
+
Assistant: Hello! How can I help you today?
134
+
Output: {{"facts" : []}}
135
+
136
+
User: Can you summarize this article for me?
137
+
Assistant: Sure, please paste the text.
138
+
Output: {{"facts" : []}}
139
+
(Reasoning: This is a transient task, not a fact about the user.)
140
+
141
+
User: I am a vegetarian, so please don't suggest any meat dishes.
142
+
Assistant: Noted, I will provide vegetarian options only.
143
+
Output: {{"facts" : ["Is a vegetarian", "Does not eat meat"]}}
144
+
145
+
User: I'm planning a hiking trip to Patagonia next November.
146
+
Assistant: That sounds amazing!
147
+
Output: {{"facts" : ["Planning a hiking trip to Patagonia in November"]}}
148
+
149
+
User: Who is the president of the US?
150
+
Assistant: The current president is...
151
+
Output: {{"facts" : []}}
152
+
153
+
User: My dog's name is Buster. He's a golden retriever.
154
+
Assistant: Buster sounds adorable.
155
+
Output: {{"facts" : ["Has a dog named Buster", "Dog is a golden retriever"]}}
156
+
157
+
User: Actually, I moved. I live in Chicago now, not New York.
158
+
Assistant: Got it, updated your location.
159
+
Output: {{"facts" : ["Lives in Chicago", "No longer lives in New York"]}}
160
+
161
+
User: I hate Python, I prefer coding in Rust.
162
+
Assistant: Understood.
163
+
Output: {{"facts" : ["Dislikes Python", "Prefers coding in Rust"]}}
164
+
165
+
User: test
166
+
Assistant: System operational.
167
+
Output: {{"facts" : []}}
168
+
169
+
Return the facts in JSON format as shown above.
111
170
112
171
Rules:
113
-
- Focus on stable preferences, long-term plans, personal details, or recurring constraints.
114
-
- Ignore the assistant's suggestions, analysis, and any transient task details.
115
-
- Do not store one-off requests, instructions about the current task, or tool/implementation details.
116
-
- Do not store anything that is not explicitly stated by the user.
117
-
- Store memories in third person: "The user is.../The User has..."
118
-
- If nothing qualifies, return an empty list.
119
-
- Output must be JSON: {"facts": ["..."]}
120
-
121
-
Return only JSON with a facts array.`,
172
+
- If no *enduring* facts are found, return an empty list for "facts".
173
+
- Detect the language of the user input and record facts in that same language.
174
+
- Write fully self-contained facts (e.g., "Lives in Chicago" instead of "Lives there").`,
0 commit comments