Skip to content

删除记忆接口返回成功但记忆未实际删除 #2331

Open

Description

@Memtensor-AI

删除一条记忆后接口返回成功,但刷新页面后该记忆仍然存在并可以被检索到,重复删除三次结果相同。预期彻底删除,实际删除未生效。OpenClaw 知识库中已有 delete/memory 接口说明,但当前现象为接口返回 success 但未实际删除,且稳定复现,属于明确的产品 Bug。

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    on Sep 2, 2026
  2. added
    ai:codingAI agent is coding | AI 正在编码
    area:api云服务 / FastAPI / OpenAPI / MCP
    types:bugSomething isn't working | 功能异常
    on Sep 2, 2026
  3. Memtensor-AI commented on Sep 2, 2026

    @Memtensor-AI
    CollaboratorAuthor

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: b4115f14279d5b84
    Working branch: bugfix/autodev-2331-20260902095324632
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  4. Memtensor-AI commented on Sep 2, 2026

    @Memtensor-AI
    CollaboratorAuthor

    ✅ AutoDev task b4115f14279d5b84 completed.

    Summary: Fixed bug #2331: delete memory API returned success but the memory remained searchable after deletion.

    Root cause: Neo4jCommunityGraphDB.delete_node_by_prams in src/memos/graph_dbs/neo4j_community.py only removed nodes from the Neo4j graph but never purged the corresponding embedding vectors from vec_db (Qdrant). Since all search calls go through vector similarity on vec_db, stale vectors caused deleted memories to keep surfacing in search results. The clear() method and the reorganize path both cleaned vec_db correctly — delete_node_by_prams simply omitted that step.

    Fix: replaced the pre-delete count query with an ID-collecting query (MATCH ... RETURN n.id AS id), then called self.vec_db.delete(collected_ids) after the graph DETACH DELETE. A vec_db failure is caught and logged as a warning rather than re-raised, so a transient vector store error does not roll back an already-committed graph deletion. Added 5 regression tests in tests/graph_dbs/test_delete_vec_cleanup.py covering delete-by-memory-ids, delete-by-filter, empty-list early-return, no-args early-return, and vec_db failure resilience. All 5 tests pass; all 36 existing graph_dbs tests continue to pass; ruff lint clean.

    Base branch: main
    Branch: bugfix/autodev-2331-20260902095324632
    Commit: a6d065e
    PR: #2332
    Assigned to: @whipser030
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller

  5. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Sep 2, 2026
  6. samvallad33 commented on Oct 1, 2026

    @samvallad33

    这是删除语义不完整的问题:接口返回 success 但内容仍然可被检索,说明删除动作和检索路径没有对齐。Vestige Strata 对这类问题的做法是,purge 必须同时移除内容和 embedding,只保留不含内容的审计墓碑(tombstone),并且每次删除都会返回可验证的回执(receipt)——所以「到底删没删」是一个可以用回执回答的问题,而不是一个 HTTP 状态码。检索侧我们只支持精确句柄(id/前缀/标签),被 purge 的记忆在结构上不可能再被相似度搜索捞回来。这个案例属于 MemOS 的产品 bug(已稳定复现),但对删除语义的设计有参考价值。(Disclosure: I built Strata — free and open: https://github.com/samvallad33/vestige · brew install samvallad33/tap/vestige)

  7. KongFUN2018 commented on Oct 10, 2026

    @KongFUN2018

    补充一个真实部署上的完整故障链实测(v2.0.33,neo4j-community + Qdrant):

    这个 bug 的影响比"删除后仍可被检索到"更严重 —— 孤儿点会逐步淹没向量召回窗口,最终导致该用户的检索静默失效:

    1. 我们的健康探针用户每 15 分钟写入一条相似文本并删除。delete_node_by_prams 每次都只删 Neo4j 节点、Qdrant 向量残留,两天积累 ~520 个孤儿点。
    2. 此后向量检索 top-20 全部命中孤儿(内容近乎相同,相似度全部集中在 0.729–0.736 的窄带),而后续的 Neo4j 二次校验(_fetch_return_fields)把这些命中全部滤掉 → 搜索稳定返回 0 结果,但写入与向量化完全正常(vector_sync=success、点确实存在于 Qdrant)。排查时极易误判为"检索侧故障"。
    3. 用户可见症状:刚写入的记忆立刻搜索返回空;删除操作越多,搜索越差(召回窗口被死数据占满)。

    实测证据:

    • 修复前:add → delete 后 Qdrant 该用户点数不变(点残留)
    • 打上修复后:add → Qdrant +1;delete → Qdrant -1
    • 历史孤儿一次性清理(qdrant_point_ids - neo4j_node_ids,我们部署上共 668 个)后,检索立即恢复正常

    另外注意到本 issue 的修复 PR #2332 已 closed 且未合并(dev-v2.0.33 线上仍存在该问题),特此提醒当前主线该缺陷仍存活。

  8. added a commit that references this issue on Oct 22, 2026
    fa103c0
  9. added a commit that references this issue on Nov 19, 2026
    ad9cf7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务ai:testingAI agent is running tests | AI 正在运行测试area:api云服务 / FastAPI / OpenAPI / MCPstatus:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions