Delete Memory • AI Agent SDK

delete_memory: Delete a specific memory by ID.

delete_memory

Method

</div>

This is a method of the Memory class in the memory module.

Delete a specific memory by ID.

This is the unified deletion method that searches across all memory types and all backends (SQLite, ChromaDB, Mem0, MongoDB).

Particularly useful for:

  • Cleaning up image-based memories after processing to free context window
  • Removing outdated or incorrect information
  • Privacy compliance (selective erasure)

Signature

python
def delete_memory(memory_id: str, memory_type: Optional[str]) -> bool

Parameters

ParamField str

The unique ID of the memory to delete

ParamField Optional[str]

Optional type hint to narrow search: ‘short_term’, ‘long_term’ If None, searches all types.

Returns

ResponseField bool

True if memory was found and deleted, False otherwise

Usage

python
# Delete a specific image analysis memory
    memory.delete_memory("1705123456789")

    # Delete with type hint for faster lookup
    memory.delete_memory("1705123456789", memory_type="short_term")

Uses

  • delete_short_term
  • delete_long_term

Used By

Source

View on GitHub

praisonaiagents/memory/memory.py at line 1595


Related Documentation