Skip to content

fix: log_working_memory_replacement reports incorrect memory_len (delta instead of total) #1790

Closed as not planned

Description

@nuthalapativarun

Problem

In src/memos/mem_scheduler/general_modules/scheduler_logger.py, log_working_memory_replacement has a # TODO: Log output count is incorrect comment at line 167.

The method passes memory_len=len(memcube_content) to create_event_log, where memcube_content only contains the newly added memories (delta). This means the scheduler UI shows the count of changes, not the actual size of the output working memory.

Example:

  • Original working memory: [A, B, C] (3 items)
  • New working memory: [A, B, D] (3 items)
  • memcube_content = [D] → memory_len = 1
  • Correct value: memory_len = 3 (total memories in output)

Expected Behavior

memory_len should reflect the total number of memories in the working memory after replacement (len(new_memory)), consistent with how other log entries represent the output size.

Steps to Reproduce

Trigger a working memory replacement operation via the scheduler and observe the memory_len field in the scheduler log output.

Proposed Fix

Change line 227:

# Before
memory_len=len(memcube_content),
# After
memory_len=len(new_memory),

Files

  • src/memos/mem_scheduler/general_modules/scheduler_logger.py line 167, 227

Activity

  1. added
    area:coreMOS 编排层 / 框架底座 / 跨模块问题
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 26, 2026
  2. Memtensor-AI commented on May 26, 2026

    @Memtensor-AI
    Collaborator

    ⏸️ AutoDev task a1ebc4ccf6299d5d needs manual clarification.

    Reason: 已修复 #1790:log_working_memory_replacement 现在用 len(new_memory) 上报输出工作记忆总大小,移除了 # TODO 注释,并在 tests/mem_scheduler/test_scheduler.py 新增回归测试。Commit ca61c9a 已推送到分支 autodev/MemOS-1790。是否创建 PR?

  3. deleted a comment from MaiHHConnect on May 27, 2026
  4. deleted a comment from MaiHHConnect on May 27, 2026
  5. added
    types:bugSomething isn't working | 功能异常
    ai:codingAI agent is coding | AI 正在编码
    on Jun 1, 2026
  6. self-assigned this
    on Jun 4, 2026
  7. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

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

    Task ID: 13029e350c6901fc
    Working branch: bugfix/autodev-1790
    Target branch: dev-20260604-v2.0.19
    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.

  8. added a commit that references this issue on Jun 4, 2026
    93ba433
  9. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 13029e350c6901fc completed.

    Summary: Fixed incorrect memory_len reporting in log_working_memory_replacement method. The issue was at line 228 in src/memos/mem_scheduler/general_modules/scheduler_logger.py, where memory_len was set to len(memcube_content) (delta count of newly added memories) instead of len(new_memory) (total working memory size after replacement).

    Changes made:

    1. Changed line 228 from memory_len=len(memcube_content) to memory_len=len(new_memory)
    2. Removed the TODO comment at line 169 that marked this as a known issue
    3. Added comprehensive test suite in tests/mem_scheduler/test_scheduler_logger.py with three test cases:
      • test_log_working_memory_replacement_reports_total_memory_len: Verifies the fix by checking that memory_len equals total working memory size (3) not delta (1)
      • test_log_working_memory_replacement_no_changes: Ensures no log is created when memories are identical
      • test_log_working_memory_replacement_all_new: Tests the case when all memories are new (empty original)

    Root cause: The method computed a delta between original and new working memory, stored it in memcube_content, then incorrectly used len(memcube_content) for the memory_len field. This caused the scheduler UI to display the count of changes rather than the actual working memory size.

    Verification: Python syntax check passed. Full pytest requires poetry environment setup which was not available in the execution environment, but the test structure follows existing project patterns and will be validated in CI.

    Base branch: dev-20260604-v2.0.19
    Branch: bugfix/autodev-1790
    Commit: 93ba433
    PR: #1882
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219

  10. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 4, 2026
  11. added
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    and removed
    types:bugSomething isn't working | 功能异常
    area:coreMOS 编排层 / 框架底座 / 跨模块问题
    on Jul 7, 2026
  12. added theissue type on Jul 7, 2026
  13. github-actions commented on Aug 7, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale due to inactivity.

  14. added
    status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.
    on Aug 7, 2026
  15. github-actions commented on Aug 17, 2026

    @github-actions
    Contributor

    This issue has been automatically closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:scheduler调度模块status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions