Skip to content

fix(scheduler): align enhanced_mem_ids with filtered mem_group in mem_read_handler - #2512

Merged
endxxxx merged 2 commits into
MemTensor:dev-v2.0.36from
keeponlight:fix/mem-read-handler-zip-mem-group
Oct 24, 2026
Merged

endxxxx merged 2 commits into
MemTensor:dev-v2.0.36from
keeponlight:fix/mem-read-handler-zip-mem-group

Conversation

@keeponlight

Copy link
Copy Markdown

Description

Fix an ID-to-memory misalignment and truncation bug in MemReadMessageHandler._process_memories_with_reader when constructing legacy playground web log events (addMemory / updateMemory).

In _process_memories_with_reader:

  1. mem_group filters out RawFileMemory items (memory.metadata.memory_type != "RawFileMemory"), and enhanced_mem_ids = text_mem.add(mem_group, user_name=user_name) returns IDs corresponding 1-to-1 with mem_group.
  2. However, the playground legacy event loop zipped enhanced_mem_ids with the unfiltered flattened_memories (zip(enhanced_mem_ids, flattened_memories, strict=False)). Whenever RawFileMemory items were present in flattened_memories, they consumed the enhanced_mem_ids belonging to normal memories, shifted every subsequent ID-to-memory mapping, and caused trailing memories in mem_group to be silently dropped by zip(..., strict=False).

Aligning the zip target with mem_group (zip(enhanced_mem_ids, mem_group, strict=False)) ensures each returned item_id maps to the exact memory added to text_mem.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added unit test test_playground_legacy_events_align_enhanced_ids_with_filtered_mem_group in tests/mem_scheduler/test_mem_read_handler_fast_cleanup.py covering a mixed batch [RawFileMemory, LongTermMemory (add), UserMemory (update with merged_from)] and asserting exact ref_id, id, memory, and memory_type alignment in both addMemory and updateMemory events without truncation.

pytest tests/mem_scheduler/test_mem_read_handler_fast_cleanup.py -vv
ruff check src/memos/mem_scheduler/task_schedule_modules/handlers/mem_read_handler.py tests/mem_scheduler/test_mem_read_handler_fast_cleanup.py
  • Unit Test

Checklist

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

@Memtensor-AI Memtensor-AI added area:scheduler 调度模块 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 17, 2026
@Memtensor-AI
Memtensor-AI requested a review from wustzdy October 17, 2026 12:02
@Memtensor-AI

Memtensor-AI commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2512
Task: 58f6ca128f657779
Base: dev-v2.0.36
Head: fix/mem-read-handler-zip-mem-group

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (3/3 executed). memos_python_core/changed-repo-python: 3/3. Duration: 12s

Branch: fix/mem-read-handler-zip-mem-group

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 17, 2026
@Memtensor-AI Memtensor-AI added status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 and removed status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 labels Oct 24, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (3/3 executed). memos_python_core/changed-repo-python: 3/3. Duration: 12s [advisory, non-gating] AI-generated tests on branch test/auto-gen-58f6ca128f657779-20261024222026: 57/57 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/mem-read-handler-zip-mem-group

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 24, 2026
@endxxxx
endxxxx merged commit 4701866 into MemTensor:dev-v2.0.36 Oct 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduler 调度模块 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants