forgetproof Try the button

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#

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#

KeyWhat it holds
verdictThe worst verdict across the stores: CLEAN, RESIDUE_REMAINS, UNVERIFIABLE when a store could not be checked, QUEUED when one waits for run_queued.
subject_valuesHow many distinct texts were looked for. Never the texts.
storesOne row per store behind the Memory: its kind (history, qdrant, chroma, remote, unsupported), its path, and its reach (fix, queue or none).
receiptsOne signed receipt per store that was fixed in this call, in the same order.
queuedOne marker per store queued instead, with its target and queued_at.
not_coveredOne sentence per store the integration cannot see.
correlation_idThe 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#

Next steps#