forget

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mem0 Forget

Mem0 遗忘功能

Delete specific memories from mem0.
从mem0中删除特定记忆。

Execution

执行流程

Step 1: Parse input

步骤1:解析输入

The user provides either:
  • A search query:
    /mem0:forget auth module decisions
  • A memory ID:
    /mem0:forget <memory_id>
If no argument, ask: "What should I forget? Provide a search query or memory ID."
用户提供以下任一内容:
  • 搜索查询:
    /mem0:forget auth module decisions
  • 记忆ID:
    /mem0:forget <memory_id>
如果未提供参数,询问:"我应该遗忘什么?请提供搜索查询或记忆ID。"

Step 2: Find memories

步骤2:查找记忆

If memory ID provided (looks like a UUID or hex string):
  • Call
    get_memory
    with the ID to verify it exists.
  • Show:
    Found: "<memory content first 120 chars>" (created <date>)
If search query provided:
  • Call
    search_memories
    with:
    • query=<user's query>
    • filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<project_id>"}]}
    • top_k=10
  • Show numbered list:
    Found <N> memories matching "<query>":
    1. <content, 120 chars> (type: <type>, created: <date>) [ID: <short_id>]
    2. ...
如果提供了记忆ID(格式类似UUID或十六进制字符串):
  • 调用
    get_memory
    接口传入该ID以验证其是否存在。
  • 显示:
    已找到:"<记忆内容前120个字符>"(创建于<日期>)
如果提供了搜索查询
  • 调用
    search_memories
    接口,参数如下:
    • query=<用户的查询内容>
    • filters={"AND": [{"user_id": "<当前用户ID>"}, {"app_id": "<项目ID>"}]}
    • top_k=10
  • 显示编号列表:
    找到<N>条匹配"<查询内容>"的记忆:
    1. <内容,120字符>(类型:<类型>,创建于:<日期>)[ID:<短ID>]
    2. ...

Step 3: Confirm

步骤3:确认

Ask: "Delete which memories? Enter numbers (e.g., 1,3,5), 'all', or 'cancel'."
For a single memory ID, ask: "Delete this memory? [y/N]"
Never delete without confirmation. This is destructive.
询问:"要删除哪些记忆?请输入编号(例如:1,3,5)、'all'(全部)或'cancel'(取消)。"
如果是单个记忆ID,询问:"是否删除该记忆?[y/N]"
未经确认绝不能删除,此操作具有破坏性。

Step 4: Delete

步骤4:删除

For each confirmed memory, call
delete_memory
with the memory ID.
对于每个确认要删除的记忆,调用
delete_memory
接口传入对应的记忆ID。

Step 5: Report

步骤5:反馈结果

Deleted <N> memories.
If any deletions failed, report which ones and why.
已删除<N>条记忆。
如果有删除失败的情况,反馈对应的记忆ID及失败原因。

Undo recent writes

撤销最近写入的内容

If the user says "undo last N memories" or "undo last write":
  1. Read session stats to get recently written memory IDs:
    bash
    SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}}/scripts"
    python3 "$SCRIPT_DIR/session_stats.py" peek
  2. Parse the
    recent_ids
    array from the JSON output. Each entry has
    id
    ,
    category
    ,
    ts
    .
  3. Show the last N entries (default 1) and ask for confirmation.
  4. Delete confirmed entries via
    delete_memory
    .
If
recent_ids
is empty, tell the user: "No recent memory IDs tracked this session. Try
/mem0:tour
to browse recent memories, or
/mem0:forget <search query>
to find specific ones."
如果用户输入"undo last N memories"或"undo last write":
  1. 读取会话统计信息以获取最近写入的记忆ID:
    bash
    SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}}/scripts"
    python3 "$SCRIPT_DIR/session_stats.py" peek
  2. 解析JSON输出中的
    recent_ids
    数组,每个条目包含
    id
    category
    ts
    字段。
  3. 显示最近的N条记录(默认1条)并请求确认。
  4. 通过
    delete_memory
    接口删除确认的条目。
如果
recent_ids
为空,告知用户:"本次会话未跟踪到最近的记忆ID。尝试使用
/mem0:tour
浏览最近的记忆,或使用
/mem0:forget <搜索查询>
查找特定记忆。"",