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: mem0/configs/prompts.py
+81-4Lines changed: 81 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -208,14 +208,91 @@
208
208
}
209
209
"""
210
210
211
+
PROCEDURAL_MEMORY_SYSTEM_PROMPT="""
212
+
You are a memory summarization system that records and preserves the complete interaction history between a human and an AI agent. You are provided with the agent’s execution history over the past N steps. Your task is to produce a comprehensive summary of the agent's output history that contains every detail necessary for the agent to continue the task without ambiguity. **Every output produced by the agent must be recorded verbatim as part of the summary.**
213
+
214
+
### Overall Structure:
215
+
- **Overview (Global Metadata):**
216
+
- **Task Objective**: The overall goal the agent is working to accomplish.
217
+
- **Progress Status**: The current completion percentage and summary of specific milestones or steps completed.
218
+
219
+
- **Sequential Agent Actions (Numbered Steps):**
220
+
Each numbered step must be a self-contained entry that includes all of the following elements:
221
+
222
+
1. **Agent Action**:
223
+
- Precisely describe what the agent did (e.g., "Clicked on the 'Blog' link", "Called API to fetch content", "Scraped page data").
224
+
- Include all parameters, target elements, or methods involved.
225
+
226
+
2. **Action Result (Mandatory, Unmodified)**:
227
+
- Immediately follow the agent action with its exact, unaltered output.
228
+
- Record all returned data, responses, HTML snippets, JSON content, or error messages exactly as received. This is critical for constructing the final output later.
229
+
230
+
3. **Embedded Metadata**:
231
+
For the same numbered step, include additional context such as:
232
+
- **Key Findings**: Any important information discovered (e.g., URLs, data points, search results).
233
+
- **Navigation History**: For browser agents, detail which pages were visited, including their URLs and relevance.
234
+
- **Errors & Challenges**: Document any error messages, exceptions, or challenges encountered along with any attempted recovery or troubleshooting.
235
+
- **Current Context**: Describe the state after the action (e.g., "Agent is on the blog detail page" or "JSON data stored for further processing") and what the agent plans to do next.
236
+
237
+
### Guidelines:
238
+
1. **Preserve Every Output**: The exact output of each agent action is essential. Do not paraphrase or summarize the output. It must be stored as is for later use.
239
+
2. **Chronological Order**: Number the agent actions sequentially in the order they occurred. Each numbered step is a complete record of that action.
240
+
3. **Detail and Precision**:
241
+
- Use exact data: Include URLs, element indexes, error messages, JSON responses, and any other concrete values.
242
+
- Preserve numeric counts and metrics (e.g., "3 out of 5 items processed").
243
+
- For any errors, include the full error message and, if applicable, the stack trace or cause.
244
+
4. **Output Only the Summary**: The final output must consist solely of the structured summary with no additional commentary or preamble.
245
+
246
+
### Example Template:
247
+
248
+
```
249
+
**Task Objective**: Scrape blog post titles and full content from the OpenAI blog.
250
+
**Progress Status**: 10% complete — 5 out of 50 blog posts processed.
251
+
252
+
1. **Agent Action**: Opened URL "https://openai.com"
253
+
**Action Result**:
254
+
"HTML Content of the homepage including navigation bar with links: 'Blog', 'API', 'ChatGPT', etc."
255
+
**Key Findings**: Navigation bar loaded correctly.
"HTML content loaded for the blog post including full article text."
275
+
**Key Findings**: Extracted blog title "ChatGPT Updates – March 2025" and article content excerpt.
276
+
**Current Context**: Blog post content extracted and stored.
277
+
278
+
5. **Agent Action**: Extracted blog title and full article content from "https://openai.com/blog/chatgpt-updates"
279
+
**Action Result**:
280
+
"{ 'title': 'ChatGPT Updates – March 2025', 'content': 'We\'re introducing new updates to ChatGPT, including improved browsing capabilities and memory recall... (full content)' }"
281
+
**Key Findings**: Full content captured for later summarization.
282
+
**Current Context**: Data stored; ready to proceed to next blog post.
283
+
284
+
... (Additional numbered steps for subsequent actions)
metadata (dict, optional): Metadata to store with the memory. Defaults to None.
103
102
filters (dict, optional): Filters to apply to the search. Defaults to None.
104
103
infer (bool, optional): Whether to infer the memories. Defaults to True.
105
-
prompt (str, optional): Prompt to use for memory deduction. Defaults to None.
106
-
104
+
memory_type (str, optional): Type of memory to create. Defaults to None. By default, it creates the short term memories and long term (semantic and episodic) memories. Pass "procedural_memory" to create procedural memories.
105
+
prompt (str, optional): Prompt to use for the memory creation. Defaults to None.
107
106
Returns:
108
107
dict: A dictionary containing the result of the memory addition operation.
109
108
result: dict of affected events with each dict has the following key:
0 commit comments