Skip to content

split_continuous_references corrupts plain bracketed lists (non-reference text) #2446

Open

Description

@simpleqt

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.

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    area:coreMOS 编排层 / 框架底座 / 跨模块问题
    status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理
    types:bugSomething isn't working | 功能异常
    on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. Memtensor-AI commented on Sep 30, 2026

    @Memtensor-AI
    Collaborator

    🤖 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.

  4. added a commit that references this issue on Sep 30, 2026
    b6a21c9
  5. Memtensor-AI commented on Sep 30, 2026

    @Memtensor-AI
    Collaborator

    ✅ 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: #2450
    Assigned to: @syzsunshine219
    Reviewers: @WeiminLee

  6. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    on Sep 30, 2026
  7. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

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

  8. added
    status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务ai:testingAI agent is running tests | AI 正在运行测试area:coreMOS 编排层 / 框架底座 / 跨模块问题status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions