MemOS icon indicating copy to clipboard operation
MemOS copied to clipboard

split_continuous_references corrupts plain bracketed lists (non-reference text)

Open simpleqt opened this issue 2 months ago • 4 comments

Bug Description

split_continuous_references in src/memos/mem_os/utils/reference_utils.py converts any single [...] block containing commas into split tags, even when the content is not a reference list:

>>> split_continuous_references("The set is [apple, banana] here")
'The set is [apple][banana] here'    # plain prose corrupted

The id part of a reference tag is a hex-looking memory id, so the shape guard should require int:<id> items (as [1:aa, 2:bb] has), not just "has a comma".

Expected Behavior

Blocks whose items are not int:<id> pairs should be returned unchanged.

Environment

MemOS main, python 3.14.

Additional Context

Fix + red/green-verified test ready; PR to follow referencing this issue.

simpleqt avatar Sep 30 '26 15:09 simpleqt

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

Task ID: 9201e950886deeb7 Working branch: bugfix/autodev-2446-20260930155806113 Target branch: latest dev* branch 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.

Memtensor-AI avatar Sep 30 '26 15:09 Memtensor-AI

✅ AutoDev task 9201e950886deeb7 completed.

Summary: Fix #2446: split_continuous_references now guards against plain bracketed prose. Previously the function rewrote any single [...] block containing a comma into split tags, so "The set is [apple, banana] here" was corrupted into "The set is [apple][banana] here". Added a shape guard that only rewrites blocks whose every comma-separated item matches the reference tag shape <int>:<id> (e.g. 1:92ff35fb); otherwise the block is returned unchanged.

Changes: src/memos/mem_os/utils/reference_utils.py gains a module-level _REFERENCE_ITEM_RE regex and a validation step before the split; docstring updated to describe the new condition. New test file tests/mem_os/test_reference_utils.py covers the regression case from the issue, mixed-content brackets (e.g. [1:92ff35fb, banana]), numeric-only lists ([1, 2, 3]), non-integer prefixes ([a:1, b:2]), and the original happy path ([1:92ff35fb, 4:bfe6f044] → split, with and without space after comma).

Verification: pytest tests/mem_os/test_reference_utils.py -q → 11 passed. pytest tests/mem_os/ -q → 47 passed. ruff check + ruff format --check → clean. Task file archived to memos-autodev-specs main.

Base branch: main Branch: bugfix/autodev-2446-20260930155806113 Commit: b6a21c9 PR: https://github.com/MemTensor/MemOS/pull/2450 Assigned to: @syzsunshine219 Reviewers: @WeiminLee

Memtensor-AI avatar Sep 30 '26 16:09 Memtensor-AI

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

github-actions[bot] avatar Nov 04 '26 02:11 github-actions[bot]

This issue has been automatically closed due to inactivity.

github-actions[bot] avatar Nov 14 '26 02:11 github-actions[bot]