fix(core): validate and trim entity IDs in delete_all() (#5735)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Kartik <kartik.labhshetwar@mem0.ai>
This commit is contained in:
rafid001
2026-06-25 16:14:30 +05:30
committed by GitHub
co-authored by Cursor Kartik
parent d2ff83cf72
commit 890473f891
4 changed files with 52 additions and 1 deletions
+8
View File
@@ -1762,6 +1762,10 @@ class Memory(MemoryBase):
agent_id (str, optional): ID of the agent to delete memories for. Defaults to None.
run_id (str, optional): ID of the run to delete memories for. Defaults to None.
"""
user_id = _validate_and_trim_entity_id(user_id, "user_id")
agent_id = _validate_and_trim_entity_id(agent_id, "agent_id")
run_id = _validate_and_trim_entity_id(run_id, "run_id")
filters: Dict[str, Any] = {}
if user_id:
filters["user_id"] = user_id
@@ -3331,6 +3335,10 @@ class AsyncMemory(MemoryBase):
agent_id (str, optional): ID of the agent to delete memories for. Defaults to None.
run_id (str, optional): ID of the run to delete memories for. Defaults to None.
"""
user_id = _validate_and_trim_entity_id(user_id, "user_id")
agent_id = _validate_and_trim_entity_id(agent_id, "agent_id")
run_id = _validate_and_trim_entity_id(run_id, "run_id")
filters = {}
if user_id:
filters["user_id"] = user_id