Bug Description
prepare_reference_data in src/memos/mem_os/utils/reference_utils.py handles TextualMemoryItem objects and raw dicts, but the dict branch assumes every key exists and that id is a string:
>>> prepare_reference_data([{"metadata": {"memory": "m"}}])
KeyError: 'id'
>>> prepare_reference_data([{"id": 12345, "memory": "m", "metadata": {}}])
AttributeError: 'int' object has no attribute 'split'
Both come from memory entries that are not TextualMemoryItem instances (e.g. already-serialized dicts from a cache or an MCP payload), and the exception escapes the streaming pipeline.
Expected Behavior
Dict entries should be normalized safely: a missing id should skip the ref_id derivation (or use the raw value), and a non-string id should be stringified before .split("-").
Environment
MemOS main, python 3.14.
Additional Context
Fix + red/green-verified test ready; PR to follow referencing this issue.
Bug Description
prepare_reference_datainsrc/memos/mem_os/utils/reference_utils.pyhandlesTextualMemoryItemobjects and raw dicts, but the dict branch assumes every key exists and thatidis a string:Both come from memory entries that are not
TextualMemoryIteminstances (e.g. already-serialized dicts from a cache or an MCP payload), and the exception escapes the streaming pipeline.Expected Behavior
Dict entries should be normalized safely: a missing
idshould skip the ref_id derivation (or use the raw value), and a non-stringidshould be stringified before.split("-").Environment
MemOS main, python 3.14.
Additional Context
Fix + red/green-verified test ready; PR to follow referencing this issue.