Rendered from docs/mem0.md; raw Markdown.
mem0: a verified delete#
forgetproof.integrations.mem0 wraps the delete and delete_all calls of a mem0 Memory so that what mem0 deletes is also gone from the files mem0 keeps, and so that you get a signed receipt saying so. This page covers what mem0 keeps after a delete, the install, the three calls with their output, what the result holds, and what the integration cannot see.
Status: not yet on PyPI; install from a checkout of the source.
mem0 is the memory layer many agents are built on. It keeps each memory as a point in a vector store, Qdrant in local mode by default, and keeps a history of every change in history.db, a SQLite file. When your agent calls memory.delete(id), mem0 removes the point and appends a DELETE row to that history with the memory's full text, next to the ADD and UPDATE rows that already carry it. The memory is gone from get() and search(), and memory.history(id) still returns its text. Qdrant local deletes its row and leaves the bytes in the SQLite file's free space until the file is rewritten. ForgetProof is the engine that finds that residue and erases it. A receipt is the engine's signed statement of what a scan found before and after the erasure, with counts and file hashes and never a value. The glossary has the rest.
Before you begin#
- You need Python 3.11 or later and mem0ai 2.2.1 or later, with a
Memorywhose vector store is Qdrant in local mode or a Chroma persist directory. AMemorywith a remote vector store works too; the receipts then say that store was not checked. - You call the integration from the process that owns the
Memory, as part of your own delete flow. It closes theMemory's files for the duration of one call and reopens them, so theMemorymust not be in use on another thread while the call runs. - The subject of each erasure is the memory's own text, read before the delete and held in memory for the duration of the call. It is never printed, logged or written anywhere by the integration.
Install#
From a checkout of the source, with mem0 as an extra:
pip install -e '.[mem0]'
A working install imports:
python -c "from forgetproof.integrations.mem0 import forget_memory, forget_user, VerifiedMemory; print('ok')"
This prints ok. If it fails on mem0, mem0ai is not installed in this environment; the extra installs it.
Delete one memory#
Call forget_memory where you would have called memory.delete:
from mem0 import Memory
from forgetproof.integrations.mem0 import forget_memory
memory = Memory.from_config({...}) # your own configuration
result = forget_memory(memory, memory_id, correlation_id="case-4471")
print(result["verdict"], result["subject_values"], [s["kind"] for s in result["stores"]])
With the default Qdrant local store this prints:
CLEAN 1 ['history', 'qdrant']
The call reads the memory's text and every earlier version of it from mem0, lets mem0 delete it, closes the Memory's connection to history.db and its Qdrant client, erases every history row of the memory and rewrites both files without their free space, rescans each for the text, and reopens the two handles. The Memory works as before once it returns. memory.history(memory_id) now returns an empty list.
result["receipts"] holds one signed receipt per store. The first is for history.db:
receipt = result["receipts"][0]
print(receipt["verdict"], receipt["actions"], receipt["canaries"])
CLEAN ['deleted 2 history row(s) of 1 deleted memory', 'vacuumed history.db (secure_delete on)'] [{'canary': 1, 'found_in': []}]
A canary is one text the engine looked for after the erasure, named by its number only; found_in lists the files it was still in, and an empty list means none. If the memory does not exist, the call raises ValueError and nothing is deleted.
Delete everything about one user#
Call forget_user where you would have called memory.delete_all(user_id=...):
from forgetproof.integrations.mem0 import forget_user
result = forget_user(memory, "john", receipt_path="receipts/john.json")
print(result["verdict"], result["subject_values"])
For a user with four memories this prints CLEAN 4, or a larger count when some were corrected, since each earlier version is a subject value of its own. The same result is written to receipts/john.json as JSON. When the user has no memories the call raises ValueError: there is nothing to delete, so nothing to verify.
Wrap the Memory#
VerifiedMemory is a Memory whose delete and delete_all do the above and return both mem0's own result and the receipts. Everything else is the wrapped Memory's own:
from forgetproof.integrations.mem0 import VerifiedMemory
memory = VerifiedMemory(Memory.from_config({...}), correlation_id="agent-pim")
memory.add([{"role": "user", "content": "..."}], user_id="john") # mem0's own add
outcome, result = memory.delete(memory_id)
outcome, result = memory.delete_all(user_id="john")
print(outcome["message"], result["verdict"])
This prints Memories deleted successfully! CLEAN. The first word is mem0's; the second is the engine's.
Verify a receipt#
Each receipt in result["receipts"] verifies on its own, here or on another machine:
from forgetproof.receipt import verify_signature
for receipt in result["receipts"]:
verify_signature(receipt)
This prints nothing when every signature holds and raises ValueError when a receipt was altered. The receipt carries the public key that signed it; verify_signature(receipt, expected_key) also checks that it is the key you expect.
The result#
| Key | What it holds |
|---|---|
verdict | The worst verdict across the stores: CLEAN, RESIDUE_REMAINS, UNVERIFIABLE when a store could not be checked, QUEUED when one waits for run_queued. |
subject_values | How many distinct texts were looked for. Never the texts. |
stores | One row per store behind the Memory: its kind (history, qdrant, chroma, remote, unsupported), its path, and its reach (fix, queue or none). |
receipts | One signed receipt per store that was fixed in this call, in the same order. |
queued | One marker per store queued instead, with its target and queued_at. |
not_covered | One sentence per store the integration cannot see. |
correlation_id | The label you passed, carried into every receipt as well. |
A Chroma persist directory is never rewritten while the application that opened it is running, because chromadb keeps the store's state in process memory and would write it back. The request is queued instead, encrypted under a local key, and verdict reads QUEUED. Before your application next opens the store, call forgetproof.forget.run_queued(path) with the directory, which erases, rescans and returns the receipts then. The history database is fixed and receipted at once either way.
Limits#
- The integration sees
history.dband a vector store on this machine's disk: Qdrant in local mode, or a Chroma persist directory. A Qdrant server, a Chroma server, pgvector, Pinecone or any other remote index is listed innot_covered, andverdictreadsUNVERIFIABLE. What those services keep of a deleted point is theirs to answer for. - Backups, sync folders and snapshots of the two files are not reached. The engine's copies report, carried in each receipt under
copies, names the ones it can see next to the store. - The embedding provider saw the text when the memory was stored, and the LLM saw the conversation it was extracted from. Their logs are outside this machine.
- mem0 keeps the last ten messages of each conversation in a
messagestable inhistory.dbwhen memories are added with inference on. Those are live data mem0 keeps on purpose, not residue, and the integration leaves them. When a deleted memory's text is in them word for word, the receipt saysRESIDUE_REMAINSand nameshistory.db. - The
Memoryis unusable for the duration of one call, since its two file handles are closed and reopened. mem0's entity store, when yourMemoryhas used it, is rebuilt from the reopened client on its next use. - The synchronous
Memoryis covered.AsyncMemoryis not. - The tests run against mem0ai 2.2.1 and qdrant-client 1.20 with mem0's default Qdrant local layout, on Windows, Linux and macOS. Another vector store on local disk that the engine does not read, FAISS for example, is listed as
unsupportedand not checked.
Next steps#
- The receipt verifier: how a receipt is checked in JavaScript, offline with a pinned key if you want, and what its fields mean.
- The glossary: receipt, verdict and the other words this page uses.
- The changelog: what changed in which release.