feat: delete by file_ids removes memories that a remaining file still supports
Pre-submission checklist | 提交前检查
- [x] I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及 (closest: #927, which added
file_idsfor traceability) - [x] I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
- [x] This issue is specific to MemOS and not a general software issue | 该问题是针对 MemOS 的,而不是一般软件问题
Problem Statement | 问题陈述
A memory can come from more than one file. When items are merged into one memory, multi_modal_struct.py aggregates the file_ids of all of them (L336-L386), so a fact stated in two uploaded documents can end up as one node with file_ids: [A, B].
Deleting by file removes that node whole. TreeTextMemory.delete_by_filter collects every memory whose file_ids contains the id (tree.py L432), and delete_node_by_prams deletes every node matching $file_id IN n.file_ids (neo4j.py L1971; the other graph stores follow the same pattern).
The docs say that all memories derived from the deleted files are cleaned up. That is right for a memory derived only from A. But a memory that B still supports goes too: B is still in the cube and still says it, yet the agent can no longer recall it. The delete is physical, so nothing records that it happened.
Proposal (deterministic, no model call)
- Preview. A
dry_runflag on delete byfile_idsreturns the memories that would be removed, in two lists: derived only from these files, and also supported by files that remain. - No silent loss for the second list. Two options:
- keep such a node, remove the deleted ids from
file_idsandsources, and mark it (for examplelost_file_ids) so a later pass or the user can check whether its text still holds on the remaining files; - or delete it, but return it in the response together with its remaining file ids, so it can be extracted again from them.
- keep such a node, remove the deleted ids from
- Report. The delete response lists, for each deleted file, the memory ids removed and the ids kept.
All three are set operations on file_ids that the store already keeps.
We work on the same problem for teams of agents. There, removing a source is never a silent delete. Before anything is written, a preview lists what would lose its ground. Afterwards, a report names what fell, which grounds went, which still stand, and which records on other sources say much the same. Happy to test a branch on a two-document case.
Willingness to Implement | 实现意愿
- [ ] I'm willing to implement this myself | 我愿意自己解决
- [x] I would like someone else to implement this | 我希望其他人来解决