feat(mem_reader): add reasoning_chain field to summarizer output#1300
feat(mem_reader): add reasoning_chain field to summarizer output#1300abakane1 wants to merge 4 commits intoMemTensor:openclaw-local-plugin-20260324from
Conversation
- Support milliseconds, microseconds, and seconds timestamp formats - Fixes incorrect days calculation when timestamps use different formats - Closes issue with 36500 days display error
Add optional 'reasoning_chain' field to memory summarizer output: - New field captures: goal, decision, correction, preference, attention - Enables memory systems to store not just facts but reasoning context - Backward compatible (field is optional) Co-designed with user: correction & reasoning chain requires active questioning during conversation, not just passive summarization. Full design: github.com/MemTensor/MemOS/pull/XXX
- Add tab switch between Summary and Reasoning tabs in memory cards - 5-field reasoning chain display: goal, decision, correction, preference, attention - Color-coded labels for each reasoning field - Only show Reasoning tab when reasoning_chain data exists - i18n: Chinese and English labels
|
reasoning_chain was added to SIMPLE_STRUCT_MEM_READER_PROMPT but not SIMPLE_STRUCT_MEM_READER_PROMPT_ZH. Chinese conversations won't get reasoning chains at all. None of the examples include reasoning_chain in their output JSON. LLMs copy example structure more than they read schema text — expect frequent omission. Need at least one example with the field. reasoning_chain: dict | None — a typed Pydantic model with the 5 fields would be safer and self-documenting. Frontend checks val !== 'N/A' but LLMs will write "n/a", "Not applicable", "无" etc. Easier to just use null in the prompt. The timestamp format fix in loadStats() is a separate bugfix, doesn't belong in this feature PR. reasoning_chain 只改了英文 prompt,中文 SIMPLE_STRUCT_MEM_READER_PROMPT_ZH 没动,中文对话完全不会生成推理链。 所有 example 的输出 JSON 里都没带 reasoning_chain。LLM 抄示例比读 schema 认真得多,不补示例这个字段大概率会被跳过。 reasoning_chain: dict | None 太松了,5 个字段定义成 Pydantic model 更稳。 前端拿 val !== 'N/A' 做过滤,但 LLM 很可能写成 "n/a"、"不适用" 之类。prompt 里直接让填 null 更省事。 loadStats() 的时间戳格式修复是独立 bug fix,混在 feature PR 里不太合适,建议拆出去。 |
PR ReviewThis PR adds a The implementation is clean, well-structured, and purely additive — it does not modify existing behavior, only extends the data model and UI. The code follows existing patterns and conventions. 此 PR 在 summarizer 输出中新增了
|
|
Changes to the memreader should be implemented in a configurable manner; otherwise, they may impact the online cloud service. 对于 memreader 的修改需要以可配置的方式实现,否则可能会影响线上云服务。 |
Summary
Add optional
reasoning_chainfield to memory summarizer output JSON schema.Problem
Current MemOS summarizer extracts "what happened" from conversations but lacks "why it happened" and "what it means for future interactions". This causes memory misalignment when the AI retrieves facts without understanding the underlying reasoning.
Solution
Extend the summarizer output schema with a new optional
reasoning_chainobject:{ "memory_list": [...], "summary": "...", "reasoning_chain": { "goal": "what was the user's core goal", "decision": "decisions made and why", "correction": "any corrections or misunderstandings", "preference": "preference updates", "attention": "what to be careful about in future" } }Design Context
This feature is part of a three-layer correction & reasoning chain protocol:
reasoning_chainfield in memory output.The three layers must be implemented together for this to be effective.
Changes
src/memos/templates/mem_reader_prompts.py: Addreasoning_chainfield + instruction to promptsrc/memos/memories/textual/item.py: Addreasoning_chainfield toTreeNodeTextualMemoryMetadatasrc/memos/mem_reader/simple_struct.py: Passreasoning_chainthrough to memory item metadataBackward Compatibility
reasoning_chainare unaffectedType of change
How Has This Been Tested?