Skip to content

Conversation

@glin93
Copy link
Contributor

@glin93 glin93 commented Nov 20, 2025

Description

Summary: Implement structured logging for memcube events with new event types (addMessage, addMemory, updateMemory, mergeMemory, scheduleMemory). Replace simple text logs with structured JSON format containing memcube_log_content, metadata, memcube_name, and memory_len fields. Use halfwidth punctuation for i18n compatibility and ensure backend sends complete data for frontend processing.

Fix: N/A (feature implementation based on PRD requirements)

Docs Issue/PR: N/A

Reviewer: @CaralHsi @tangg555 @lijicode

Changes

Core Implementation

  • Schema Enhancement (message_schemas.py): Added new fields for structured logging

    • memcube_log_content: Array of structured content items
    • metadata: Detailed metadata for each memory
    • memcube_name: Display name (UserMemCube/PublicMemCube)
    • memory_len: Count of items involved in event
  • Event Creation (scheduler_logger.py): New create_event_log() method for structured events

    • Batch aggregation for multi-item operations
    • Automatic memcube name mapping
    • Complete metadata population
  • Event Emission (general_scheduler.py): Integrated structured logging in workflows

    • addMessage: User/Assistant messages
    • addMemory: New memories added
    • updateMemory: Existing memories updated
    • mergeMemory: Memories merged with source/result tracking
  • Label Mapping (base_scheduler.py): Normalize old labels to new event types

    • Backward compatible with existing constants
    • Automatic memory_len calculation
    • snake_case field normalization

Backward Compatibility

  • Existing log_content field preserved
  • Old label constants still supported
  • Graceful fallback for missing fields
  • No breaking changes to public APIs

Branch Strategy

This PR is re-developed from the latest dev branch (after commit #507) to avoid merge conflicts. The original development was on an older branch forked from commit #497, but was redone cleanly on the current dev to ensure compatibility with recent changes (log rotation, redis_scheduler, etc.).

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 added 5 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
@CarltonXiang CarltonXiang merged commit bdc536e into dev Nov 21, 2025
20 checks passed
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.

3 participants