---
title: Memory Types
description: "See how Mem0 layers conversation, session, and user memories to keep agents contextual."
icon: "tag"
iconType: "solid"
---

# How Mem0 Organizes Memory

Mem0 separates memory into layers so agents remember the right detail at the right time. Think of it like a notebook: a sticky note for the current task, a daily journal for the session, and an archive for everything a user has shared.

<Info>
  **Why it matters**
  - Keeps conversations coherent without repeating instructions.
  - Lets agents personalize responses based on long-term preferences.
  - Avoids over-fetching data by scoping memory to the correct layer.
</Info>

## Key terms

- **Conversation memory** – In-flight messages inside a single turn (what was just said).
- **Session memory** – Short-lived facts that apply for the current task or channel.
- **User memory** – Long-lived knowledge tied to a person, account, or workspace.
- **Organizational memory** – Shared context available to multiple agents or teams.

```mermaid
graph LR
  A[Conversation turn] --> B[Session memory]
  B --> C[User memory]
  C --> D[Org memory]
  C --> E[Mem0 retrieval layer]
```

## Short-term vs long-term memory

Short-term memory keeps the current conversation coherent. It includes:

- **Conversation history** – recent turns in order so the agent remembers what was just said.
- **Working memory** – temporary state such as tool outputs or intermediate calculations.
- **Attention context** – the immediate focus of the assistant, similar to what a person holds in mind mid-sentence.

Long-term memory preserves knowledge across sessions. It captures:

- **Factual memory** – user preferences, account details, and domain facts.
- **Episodic memory** – summaries of past interactions or completed tasks.
- **Semantic memory** – relationships between concepts so agents can reason about them later.

Mem0 maps these classic categories onto its layered storage so you can decide what should fade quickly versus what should last for months.

## How does it work?

Mem0 stores each layer separately and merges them when you query:

1. **Capture** – Messages enter the conversation layer while the turn is active.
2. **Promote** – Relevant details persist to session or user memory based on your `user_id`, `run_id`, and metadata.
3. **Retrieve** – The search pipeline pulls from all layers, ranking user memories first, then session notes, then raw history.

```python
import os

from mem0 import Memory

memory = Memory()

# Sticky note: conversation memory
memory.add(
    ["I'm Alex and I prefer boutique hotels."],
    user_id="alex",
    run_id="trip-planning-2025",
)

# Later in the session, pull long-term + session context
results = memory.search(
    "Any hotel preferences?",
    filters={"user_id": "alex", "run_id": "trip-planning-2025"},
)
```

<Tip>
  Use `run_id` when you want short-term context to expire automatically; rely on `user_id` for lasting personalization.
</Tip>

## When should you use each layer?

- **Conversation memory** – Tool calls or chain-of-thought that only matter within the current turn.
- **Session memory** – Multi-step tasks (onboarding flows, debugging sessions) that should reset once complete.
- **User memory** – Personal preferences, account state, or compliance details that must persist across interactions.
- **Organizational memory** – Shared FAQs, product catalogs, or policies that every agent should recall.

## How it compares

| Layer | Lifetime | Short or long term | Best for | Trade-offs |
| --- | --- | --- | --- | --- |
| Conversation | Single response | Short-term | Tool execution detail | Lost after the turn finishes |
| Session | Minutes to hours | Short-term | Multi-step flows | Clear it manually when done |
| User | Weeks to forever | Long-term | Personalization | Requires consent/governance |
| Org | Configured globally | Long-term | Shared knowledge | Needs owner to keep current |

<Warning>
  Avoid storing secrets or unredacted PII in user or org memories—Mem0 is retrievable by design. Encrypt or hash sensitive values first.
</Warning>

## Put it into practice

- Use the <Link href="/core-concepts/memory-operations/add">Add Memory</Link> guide to persist user preferences.
- Follow <Link href="/platform/advanced-memory-operations">Advanced Memory Operations</Link> to tune metadata and retrieval.

## See it live

- <Link href="/cookbooks/companions/ai-tutor">AI Tutor with Mem0</Link> shows session vs user memories in action.
- <Link href="/cookbooks/operations/support-inbox">Support Inbox with Mem0</Link> demonstrates shared org memory.

{/* DEBUG: verify CTA targets */}

<CardGroup cols={2}>
  <Card
    title="Explore Memory Operations"
    description="Dive into the add/search/update/delete concepts next."
    icon="circle-check"
    href="/core-concepts/memory-operations/add"
  />
  <Card
    title="See a Cookbook"
    description="Apply layered memories inside a customer support agent."
    icon="rocket"
    href="/cookbooks/operations/support-inbox"
  />
</CardGroup>
