Skip to content

fix(memory): skip working-memory cleanup during reorganize pass - #2193

Closed
RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/issue-1952-is-reorganize-check
Closed

RerankerGuo wants to merge 1 commit into
MemTensor:mainfrom
RerankerGuo:fix/issue-1952-is-reorganize-check

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

Summary

  • Guard MemoryManager.add(mode='sync') so _cleanup_working_memory is skipped when the manager is running inside a reorganize pass (self.is_reorganize=True).
  • During reorg the working-memory pool is being reconstructed from long-term material; pruning it with remove_oldest_memory would silently drop freshly rebuilt nodes.
  • Added unit tests covering both branches (reorganize on / off).

Closes #1952.

Verification

  • ruff format applied (no reformat).
  • ruff check pre-existing warnings only (BLE001/DTZ005 on untouched lines).
  • New tests assert remove_oldest_memory is not invoked when is_reorganize=True and is invoked in normal mode.

Checklist

  • Local ruff format / check ran clean on changed lines.
  • Tests added for new behaviour.
  • Backward compatible — non-reorganize flow unchanged.

@Memtensor-AI Memtensor-AI added area:memory 记忆存储、检索、更新、召回逻辑 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 3, 2026
@Memtensor-AI

Memtensor-AI commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2193
Task: 6e65348cb7a4aac1
Base: main
Head: fix/issue-1952-is-reorganize-check

✅ OpenCodeReview: No comments generated. Looks good to me.

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (10/10 executed). memos_python_core/changed-repo-python: 10/10. Duration: 5s [advisory, non-gating] AI-generated tests on branch test/auto-gen-959e5b5df4cda358-20260803121326: 65/65 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/issue-1952-is-reorganize-check

@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 Aug 3, 2026
MemoryManager.add(mode='sync') previously always invoked
_cleanup_working_memory which prunes the oldest WorkingMemory nodes to
stay within the configured cap. During a reorganize pass the working
pool is being rebuilt from long-term material, so that cleanup would
silently drop freshly reconstructed nodes. Guard the cleanup call
with the existing is_reorganize flag so reorganize preserves the
rebuilt working-memory population while non-reorganize mode keeps the
original eviction behaviour.
Closes #1952.
@RerankerGuo
RerankerGuo force-pushed the fix/issue-1952-is-reorganize-check branch from 777a499 to 668d61e Compare August 5, 2026 05:15
@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 Aug 5, 2026
@RerankerGuo

Copy link
Copy Markdown
Contributor Author

Addressed the automated review finding in 668d61e2: the normal-mode regression test now records remove_oldest_memory.call_count before add() and asserts that add() increments it, so constructor-time calls cannot produce a false positive. I also rebased the branch onto current main. Verification: pytest tests/memories/textual/test_tree_manager.py -q (10 passed) and Ruff check/format on both changed files.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (10/10 executed). memos_python_core/changed-repo-python: 10/10. Duration: 5s [advisory, non-gating] AI-generated tests on branch test/auto-gen-6e65348cb7a4aac1-20260805132025: 78/78 passed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/issue-1952-is-reorganize-check

@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 Aug 5, 2026
@RerankerGuo RerankerGuo closed this by deleting the head repository Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:memory 记忆存储、检索、更新、召回逻辑 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants