Skip to content

Fix #1790: fix: log_working_memory_replacement reports incorrect memory_len (delta instea#1882

Open
Memtensor-AI wants to merge 1 commit into
dev-20260604-v2.0.19from
bugfix/autodev-1790
Open

Fix #1790: fix: log_working_memory_replacement reports incorrect memory_len (delta instea#1882
Memtensor-AI wants to merge 1 commit into
dev-20260604-v2.0.19from
bugfix/autodev-1790

Conversation

@Memtensor-AI
Copy link
Copy Markdown
Collaborator

Description

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.

Related Issue (Required): Fixes #1790

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Executor did not report tests.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

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)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219 please review this PR.

Reviewer Checklist

…otal size

- Changed memory_len from len(memcube_content) to len(new_memory)
- memcube_content contains only delta (added memories)
- new_memory contains the complete working memory after replacement
- Removed TODO comment at line 169
- Added comprehensive test suite in tests/mem_scheduler/test_scheduler_logger.py

Fixes #1790
@Memtensor-AI
Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

All tests passed (35/35 executed, 36 skipped). memos_local_plugin/smoke: 0 passed, 1 skipped, memos_local_plugin/contract: 35 passed, 35 skipped. Duration: 4s

Branch: bugfix/autodev-1790

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

Labels

ai-generated bug Something isn't working | 功能异常

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants