> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/tools/mem0.md).

# mem0

[Mem0](https://mem0.ai/) is a powerful memory management system designed specifically for AI agents. It provides a persistent, searchable memory store that enables agents to remember past interactions, learn from experiences, and maintain context across conversations and workflow executions.

With Mem0, you can:

* **Store agent memories**: Save conversation history, user preferences, and important context
* **Retrieve relevant information**: Use semantic search to find the most relevant past interactions
* **Build context-aware agents**: Enable your agents to reference past conversations and maintain continuity
* **Personalize interactions**: Tailor responses based on user history and preferences
* **Implement long-term memory**: Create agents that learn and adapt over time
* **Scale memory management**: Handle memory needs for multiple users and complex workflows

In Agent Forge, the Mem0 integration enables your agents to maintain persistent memory across workflow executions. This allows for more natural, context-aware interactions where agents can recall past conversations, remember user preferences, and build upon previous interactions. By connecting Agent Forge with Mem0, you can create agents that feel more human-like in their ability to remember and learn from past experiences. The integration supports adding new memories, searching existing memories semantically, and retrieving specific memory records. This memory management capability is essential for building sophisticated agents that can maintain context over time, personalize interactions based on user history, and continuously improve their performance through accumulated knowledge.

### Usage Instructions

Add, search, retrieve, and delete memories using Mem0. Store conversation history, user preferences, and context across workflow executions for enhanced AI agent capabilities.

### Tools

#### `mem0_add_memories`

Add memories to Mem0 for persistent storage and retrieval

**Input**

| Parameter  | Type   | Required | Description                                    |
| ---------- | ------ | -------- | ---------------------------------------------- |
| `userId`   | string | Yes      | User ID associated with the memory             |
| `messages` | json   | Yes      | Array of message objects with role and content |
| `apiKey`   | string | Yes      | Your Mem0 API key                              |

**Output**

| Parameter       | Type | Description        |
| --------------- | ---- | ------------------ |
| `ids`           | any  | Memory identifiers |
| `memories`      | any  | Memory data        |
| `searchResults` | any  | Search results     |

#### `mem0_search_memories`

Search for memories in Mem0 using semantic search

**Input**

| Parameter | Type   | Required | Description                            |
| --------- | ------ | -------- | -------------------------------------- |
| `userId`  | string | Yes      | User ID to search memories for         |
| `query`   | string | Yes      | Search query to find relevant memories |
| `limit`   | number | No       | Maximum number of results to return    |
| `apiKey`  | string | Yes      | Your Mem0 API key                      |

**Output**

| Parameter       | Type | Description        |
| --------------- | ---- | ------------------ |
| `ids`           | any  | Memory identifiers |
| `memories`      | any  | Memory data        |
| `searchResults` | any  | Search results     |

#### `mem0_get_memories`

Retrieve memories from Mem0 by ID or filter criteria

**Input**

| Parameter   | Type   | Required | Description                                                  |
| ----------- | ------ | -------- | ------------------------------------------------------------ |
| `userId`    | string | Yes      | User ID to retrieve memories for                             |
| `memoryId`  | string | No       | Specific memory ID to retrieve                               |
| `startDate` | string | No       | Start date for filtering by created\_at (format: YYYY-MM-DD) |
| `endDate`   | string | No       | End date for filtering by created\_at (format: YYYY-MM-DD)   |
| `limit`     | number | No       | Maximum number of results to return                          |
| `apiKey`    | string | Yes      | Your Mem0 API key                                            |

**Output**

| Parameter       | Type | Description        |
| --------------- | ---- | ------------------ |
| `ids`           | any  | Memory identifiers |
| `memories`      | any  | Memory data        |
| `searchResults` | any  | Search results     |

### Notes

* Category: `tools`
* Type: `mem0`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://whitepaper.aitech.io/agentforge/tools/mem0.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
