> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Mem0 and PraisonAI Integration

> Guide for integrating Mem0 (formerly EmbedChain) memory management system with PraisonAI, including tools for storing, retrieving, and managing memories

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Memory Assistant",
    instructions="Remember user preferences across turns.",
    memory=True,
)
agent.start("Remember that I prefer concise bullet answers")
```

The user shares a preference; the agent stores it with Mem0-backed memory for later sessions.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Mem0 and PraisonAI Integration

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

# Mem0 and PaisonAI Integration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonaiagents[memory]"
```

<div className="relative w-full aspect-video">
  <iframe className="absolute top-0 left-0 w-full h-full" src="https://www.youtube.com/embed/KIGSgRxf1cY" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</div>

Mem0 is a tools to store, updated, delete and retrieve memories.
[https://github.com/mem0ai/mem0](https://github.com/mem0ai/mem0)

<Warning>
  **Vector store backend choice matters.** mem0's MongoDB vector store has an upstream bug ([mem0ai/mem0#3185](https://github.com/mem0ai/mem0/issues/3185)) that causes searches to silently return empty. PraisonAI catches this specific `TypeError` and logs a warning, but recovery requires switching to **Qdrant** or **Chroma** as mem0's vector store backend. If you need MongoDB itself, use PraisonAI's built-in [MongoDB Memory](/docs/features/mongodb-memory) adapter instead — it is separate from mem0 and unaffected by this bug. See [Memory Troubleshooting](/docs/features/memory-troubleshooting#why-is-memory-mem0-returning-empty-search-results-mongodb-vector-store) for the fix.
</Warning>

## Quick Start

<Steps>
  <Step title="Install">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents[memory]
    ```
  </Step>

  <Step title="Create a memory-enabled agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="MemoryAgent",
        instructions="Remember user preferences across conversations.",
        memory=True,
    )

    agent.start("My favorite color is blue")
    agent.start("What is my favorite color?")
    ```
  </Step>
</Steps>

## Mem0 previously called EmbedChain

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from mem0 import Memory
from praisonai_tools import BaseTool

class AddMemoryTool(BaseTool):
    name: str = "Add Memory Tool"
    description: str = ("This tool allows storing a new memory with user ID and optional metadata.\n"
                        "Example:\n"
                        "   - Input: text='I am working on improving my tennis skills. Suggest some online courses.', user_id='alice', metadata={'category': 'hobbies'}\n"
                        "   - Output: Memory added with summary 'Improving her tennis skills. Looking for online suggestions.'")

    def _run(self, text: str, user_id: str, metadata: dict = None):
        m = Memory()
        result = m.add(text, user_id=user_id, metadata=metadata)
        return result

class GetAllMemoriesTool(BaseTool):
    name: str = "Get All Memories Tool"
    description: str = ("This tool retrieves all stored memories.\n"
                        "Example:\n"
                        "   - Input: action='get_all'\n"
                        "   - Output: List of all stored memories.")

    def _run(self):
        m = Memory()
        result = m.get_all()
        return result

class SearchMemoryTool(BaseTool):
    name: str = "Search Memory Tool"
    description: str = ("This tool searches for specific memories based on a query and user ID.\n"
                        "Example:\n"
                        "   - Input: query='What are Alice's hobbies?', user_id='alice'\n"
                        "   - Output: Search results related to Alice's hobbies.")

    def _run(self, query: str, user_id: str):
        m = Memory()
        result = m.search(query=query, user_id=user_id)
        return result

class UpdateMemoryTool(BaseTool):
    name: str = "Update Memory Tool"
    description: str = ("This tool updates an existing memory by memory ID and new data.\n"
                        "Example:\n"
                        "   - Input: memory_id='cb032b42-0703-4b9c-954d-77c36abdd660', data='Likes to play tennis on weekends'\n"
                        "   - Output: Memory updated to 'Likes to play tennis on weekends.'")

    def _run(self, memory_id: str, data: str):
        m = Memory()
        result = m.update(memory_id=memory_id, data=data)
        return result

class MemoryHistoryTool(BaseTool):
    name: str = "Memory History Tool"
    description: str = ("This tool gets the history of changes made to a specific memory by memory ID.\n"
                        "Example:\n"
                        "   - Input: memory_id='cb032b42-0703-4b9c-954d-77c36abdd660'\n"
                        "   - Output: History of the specified memory.")

    def _run(self, memory_id: str):
        m = Memory()
        result = m.history(memory_id=memory_id)
        return result
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use a consistent user_id">
    Always pass the same `user_id` for the same user across sessions to retrieve their memories correctly.
  </Accordion>

  <Accordion title="Add memories after task completion">
    Store memories at the end of a session to avoid storing intermediate or incorrect information.
  </Accordion>

  <Accordion title="Search before adding">
    Search existing memories before adding new ones to avoid duplicates.
  </Accordion>

  <Accordion title="Delete stale memories">
    Clean up outdated memories periodically to keep retrieval accurate over time.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
