You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
split_continuous_references leaves references merged when comma styles are mixed #2417
split_continuous_references in src/memos/mem_os/utils/reference_utils.py splits a combined reference tag [1:aaa, 4:bbb] into [1:aaa][4:bbb] via two sequential str.replace passes: one for ", " and one for ",". The first pass that matches rewrites the content substring, so the second pass can no longer find the original content. When an LLM emits mixed separator styles in one tag, only the last boundary is split:
The function is on the streaming chat path (api/handlers/chat_handler.py → process_streaming_references_complete), so the merged references are rendered as literal text instead of individual reference tags.
Expected Behavior
Every comma between the brackets splits a reference boundary regardless of the whitespace that follows it.
Environment
MemOS main (a7367d0), python 3.14.
Additional Context
Fix + red/green-verified unit tests in tests/mem_os/test_reference_utils.py ready; PR to follow referencing this issue.
Summary: Fixes #2417: split_continuous_references in src/memos/mem_os/utils/reference_utils.py no longer strands bare commas when a reference tag mixes , and , separator styles. The two sequential str.replace passes (one for ", ", one for ",") mutated the text on the first pass, so the second pass could not find the original content substring and any surviving bare commas were left un-split — producing merged references like [1:92ff35fb,4:bfe6f044][7:abcd1234] that render as literal text on the streaming chat path.
The fix replaces the two passes with a single re.sub(r",\s*", "][", content_between_brackets), so every comma between the brackets becomes a split boundary regardless of trailing whitespace. All guard clauses (single [, single ], comma present between brackets) are preserved bit-for-bit; multi-tag and non-reference inputs are unaffected.
Tests: added tests/mem_os/test_reference_utils.py with 17 cases covering the exact reproduction from the issue plus other separator variants (bare, comma-space, multi-space, tab) and the existing guard clauses. All 17 pass; the full tests/mem_os/ regression suite (53 tests) also passes; ruff check and ruff format are clean on the touched files. Before the fix, 5 of the new cases (including the issue's exact reproduction) failed red as expected.
Base branch:main Branch:bugfix/autodev-2417-20260928032002157 Commit:fa495aa PR:#2419 Assigned to:@syzsunshine219 Reviewers:@WeiminLee
Activity
Memtensor-AI commentedon Sep 28, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
75c34c73ae1d5dedWorking branch:
bugfix/autodev-2417-20260928032002157Target branch:
latest dev* branchWorkflow: 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.
fix: split_continuous_references handles mixed comma separators (MemT…
Memtensor-AI commentedon Sep 28, 2026
✅ AutoDev task
75c34c73ae1d5dedcompleted.Summary: Fixes #2417:
split_continuous_referencesinsrc/memos/mem_os/utils/reference_utils.pyno longer strands bare commas when a reference tag mixes,and,separator styles. The two sequentialstr.replacepasses (one for", ", one for",") mutated the text on the first pass, so the second pass could not find the original content substring and any surviving bare commas were left un-split — producing merged references like[1:92ff35fb,4:bfe6f044][7:abcd1234]that render as literal text on the streaming chat path.The fix replaces the two passes with a single
re.sub(r",\s*", "][", content_between_brackets), so every comma between the brackets becomes a split boundary regardless of trailing whitespace. All guard clauses (single[, single], comma present between brackets) are preserved bit-for-bit; multi-tag and non-reference inputs are unaffected.Tests: added
tests/mem_os/test_reference_utils.pywith 17 cases covering the exact reproduction from the issue plus other separator variants (bare, comma-space, multi-space, tab) and the existing guard clauses. All 17 pass; the fulltests/mem_os/regression suite (53 tests) also passes;ruff checkandruff formatare clean on the touched files. Before the fix, 5 of the new cases (including the issue's exact reproduction) failed red as expected.Base branch:
mainBranch:
bugfix/autodev-2417-20260928032002157Commit:
fa495aaPR: #2419
Assigned to: @syzsunshine219
Reviewers: @WeiminLee
github-actions commentedon Nov 1, 2026
This issue has been automatically marked as stale due to inactivity.
github-actions commentedon Nov 9, 2026
This issue has been automatically closed due to inactivity.