Skip to content

Feature/memcube log structured logs rework#516

Merged
CaralHsi merged 13 commits intodevfrom
feature/memcube-log-structured-logs-rework
Nov 22, 2025
Merged

Feature/memcube log structured logs rework#516
CaralHsi merged 13 commits intodevfrom
feature/memcube-log-structured-logs-rework

Conversation

@glin93
Copy link
Copy Markdown
Contributor

@glin93 glin93 commented Nov 22, 2025

Description

Summary

Implement structured logging system for MemCube operations with enhanced observability and frontend integration.

实现 MemCube 操作的结构化日志系统,增强可观测性和前端集成能力。

Key Changes:

  1. Structured Logs: Added memcube_log_content, metadata, memcube_name, memory_len fields for six event types (addMessage, addMemory, updateMemory, mergeMemory, archiveMemory, scheduleMemory)
  2. Configurable RabbitMQ: Support different exchange configurations for Playground and Cloud Service via environment variables
  3. Empty Log Filtering: Filter out empty scheduleMemory events to reduce frontend noise
  4. Bug Fixes: Resolved compatibility issues from dev branch updates (API changes, null checks)

主要变更:

  1. 结构化日志:为六种事件类型新增结构化字段
  2. 可配置 RabbitMQ:通过环境变量支持不同环境的 exchange 配置
  3. 空日志过滤:过滤空的调度日志,减少前端干扰
  4. Bug 修复:解决 dev 分支更新带来的兼容性问题

Fix: N/A (Feature enhancement)

Reviewer: @CarltonXiang @tangg555 @CaralHsi


Deployment Notes

Cloud Service only: Add environment variables:
MEMSCHEDULER_RABBITMQ_EXCHANGE_NAME=memos-memory-change
MEMSCHEDULER_RABBITMQ_EXCHANGE_TYPE=directPlayground: No changes needed (uses defaults)

云服务部署: 添加上述环境变量
Playground: 无需修改


Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have created related documentation issue/PR in MemOS-Docs (if applicable) | 我已在 MemOS-Docs 中创建了相关的文档 issue/PR(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

glin1993@outlook.com and others added 13 commits November 20, 2025 18:43
- Replace fullwidth colon (:) with halfwidth colon (:) in all content fields
- Update example file to use English UI text instead of Chinese for consistency
- Ensure backend sends neutral data format for frontend i18n handling

Changes:
- scheduler_logger.py: Use halfwidth colon in content formatting
- general_scheduler.py: Use halfwidth colon in content formatting
- memos_w_scheduler.py: Replace Chinese UI text with English equivalents
Replace list(merged_target_ids)[0] with next(iter(merged_target_ids)) for better performance and readability.
- Format long lines for better readability
- Align dictionary entries and function parameters
- Follow project code style guidelines
- Fix API compatibility: replace self.dispatcher._group_messages_by_user_and_mem_cube()
  with standalone group_messages_by_user_and_mem_cube() function
- Add graceful handling for uninitialized preference memory (pref_mem = None)
- Improve error messages with mem_cube_id context

Fixes:
- AttributeError: SchedulerDispatcher object has no attribute _group_messages_by_user_and_mem_cube
- TypeError: Expected PreferenceTextMemory but got NoneType

Affected handlers:
- _query_message_consumer
- _answer_message_consumer
- _add_message_consumer
- _pref_add_message_consumer

Tests: All handler tests passed (3/3)
…om:MemTensor/MemOS into feature/memcube-log-structured-logs-rework
- Add exchange_name and exchange_type fields to RabbitMQConfig
- Support both fanout (Playground) and direct (Cloud Service) exchange types
- Load exchange config from environment variables if provided
- Maintain backward compatibility with default values (memos-fanout, fanout)
- Enable multi-environment deployment (Playground + Cloud Service)
- Skip logging scheduleMemory events when no memory changes occur
- Only generate logs when memcube_log_content is not empty
- Applies to both working memory and activation memory updates
- Improves frontend UX by reducing noise from empty scheduling events
…work

- Resolved conflicts in scheduler files
- Fixed group_messages_by_user_and_mem_cube usage (now standalone function)
- Added pref_mem None check
- Preserved RabbitMQ config enhancements (exchange_name, exchange_type)
- Preserved empty scheduleMemory log filtering
- Integrated latest dev changes (API refactor, LLM updates, multi_mem_cube)
@CaralHsi CaralHsi merged commit c63555f into dev Nov 22, 2025
20 checks passed
@glin93 glin93 deleted the feature/memcube-log-structured-logs-rework branch November 24, 2025 07:19
tianxing02 pushed a commit to tianxing02/MemOS that referenced this pull request Feb 24, 2026
* feat: reapply structured memcube logs

* refactor: replace fullwidth punctuation with halfwidth in log content

- Replace fullwidth colon (:) with halfwidth colon (:) in all content fields
- Update example file to use English UI text instead of Chinese for consistency
- Ensure backend sends neutral data format for frontend i18n handling

Changes:
- scheduler_logger.py: Use halfwidth colon in content formatting
- general_scheduler.py: Use halfwidth colon in content formatting
- memos_w_scheduler.py: Replace Chinese UI text with English equivalents

* style: fix RUF015 linter warning

Replace list(merged_target_ids)[0] with next(iter(merged_target_ids)) for better performance and readability.

* style: apply ruff formatting

- Format long lines for better readability
- Align dictionary entries and function parameters
- Follow project code style guidelines

* style: format server_router.py (inherited from dev branch)

* feat: add debug console

* feat: add debug console

* fix: resolve scheduler handler compatibility issues

- Fix API compatibility: replace self.dispatcher._group_messages_by_user_and_mem_cube()
  with standalone group_messages_by_user_and_mem_cube() function
- Add graceful handling for uninitialized preference memory (pref_mem = None)
- Improve error messages with mem_cube_id context

Fixes:
- AttributeError: SchedulerDispatcher object has no attribute _group_messages_by_user_and_mem_cube
- TypeError: Expected PreferenceTextMemory but got NoneType

Affected handlers:
- _query_message_consumer
- _answer_message_consumer
- _add_message_consumer
- _pref_add_message_consumer

Tests: All handler tests passed (3/3)

* feat: add debug console

* feat: support configurable RabbitMQ exchange name and type

- Add exchange_name and exchange_type fields to RabbitMQConfig
- Support both fanout (Playground) and direct (Cloud Service) exchange types
- Load exchange config from environment variables if provided
- Maintain backward compatibility with default values (memos-fanout, fanout)
- Enable multi-environment deployment (Playground + Cloud Service)

* feat: filter empty scheduleMemory logs

- Skip logging scheduleMemory events when no memory changes occur
- Only generate logs when memcube_log_content is not empty
- Applies to both working memory and activation memory updates
- Improves frontend UX by reducing noise from empty scheduling events

---------

Co-authored-by: glin1993@outlook.com <>
Co-authored-by: harvey_xiang <harvey_xiang22@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants