Skip to content

// Persistent agent memory with Mem0 — fact extraction, add()/search() retrieval, per-user/session scoping in the LLM loop.

Mem0 Memory Layer

skill --stat
  • last update

    Jun 24, 2026

  • license

    MITv1.0.0

  • format

    SKILL.md

quickstart.sh
3 steps
  1. Install

    // Downloads SKILL.md into ~/.claude/skills/mem0-agent-memory/

    $ curl -fsSL --create-dirs -o ~/.claude/skills/mem0-agent-memory/SKILL.md https://claudeskil.com/skills/mem0-agent-memory/SKILL.md
  2. Invoke

    // Inside Claude Code, type the skill name as a slash command

    > /mem0-agent-memory fine-tune on this CSV
  3. Or copy this from the README

    // extracted bash block

    $ curl -fsSL --create-dirs -o ~/.claude/skills/mem0-agent-memory/SKILL.md https://claudeskil.com/skills/mem0-agent-memory/SKILL.md
    pip install mem0ai
mem0-agent-memory/
references
SKILL.md
readonly
name:
Mem0 Memory Layer
slug:
mem0-agent-memory
version:
v1.0.0
license:
MIT
author:
@chiragthummar16
categories:
tags:
#mem0#agent-memory#llm#rag#python
description:

Persistent agent memory with Mem0 — fact extraction, add()/search() retrieval, per-user/session scoping in the LLM loop.

README.md

mem0-agent-memory/README.md
8 sections

Mem0 Memory Layer

Give your agent a memory that survives across turns, sessions, and users. This skill wires Mem0 into your agent's call loop so it extracts durable facts from conversations, stores them in a vector store, and retrieves the relevant ones before each response. It's for Python developers building chatbots, support agents, or assistants that need to remember who the user is and what they said last week — without stuffing the whole history into the prompt.

When to use it

  • A user tells your agent "I'm vegetarian" or "I use TypeScript" and you want that recalled in future sessions.
  • You're building a multi-tenant assistant and need memories isolated per user_id.
  • Your context window is overflowing with chat history and you'd rather retrieve only the facts that matter for the current query.
  • You need an audit trail of how a stored fact changed over time.

How it works

The core is two calls. Memory.add(messages, user_id=...) runs an LLM pass that extracts atomic facts from the turn, then reconciles them against existing memories — adding, updating, or deleting as needed (it won't store five copies of "likes coffee"). Memory.search(query, user_id=...) does semantic retrieval and returns ranked memories to inject into your prompt.

Scope everything with user_id, agent_id, and run_id (session). Round out the lifecycle with get_all(), get(memory_id), update(), delete()/delete_all(), and history(memory_id) to inspect changes. search() and get_all() accept metadata filters for narrowing by your own tags.

Two backends share the same API: self-hosted Memory (you bring the vector store, LLM, and embedder via a config dict) and hosted MemoryClient (managed by Mem0, API-key auth).

Usage

bash
curl -fsSL --create-dirs -o ~/.claude/skills/mem0-agent-memory/SKILL.md https://claudeskil.com/skills/mem0-agent-memory/SKILL.md
pip install mem0ai
python
from mem0 import Memory

m = Memory()  # or Memory.from_config(cfg) to pick vector store / LLM

# After a turn, persist facts
m.add(
    [{"role": "user", "content": "I'm allergic to peanuts"}],
    user_id="alex",
)

# Before the next response, retrieve and inject
hits = m.search("what can this user eat?", user_id="alex", limit=3)
context = "\n".join(h["memory"] for h in hits["results"])

Tips & gotchas

  • add() makes its own LLM calls for extraction — it has latency and token cost. Call it after responding, not in the hot path, or batch it.
  • Don't store raw transcripts. Mem0 distills facts; passing huge blobs wastes the extraction budget. Pass the recent turns.
  • Migrating from MemoryClient to self-hosted Memory? The method names match, but configure the same embedder or your existing vectors won't match queries.
  • Always pass at least one scope id. Memories added without user_id/agent_id/run_id are hard to retrieve cleanly later.

FAQ

Self-hosted vs hosted — which? Use Memory (self-hosted) when you need data residency or your own Qdrant/pgvector/Chroma. Use MemoryClient when you'd rather not run infrastructure.

Does it support async? Yes — AsyncMemory mirrors the sync API for add/search/etc.

How are conflicting facts handled? add() detects contradictions and updates the existing memory rather than appending; use history() to see the prior value.

$ cat reviews/

Reviews

// No reviews yet. Be the first.
Loading review form…

$ ls related/

explore all →