Skip to content

Conversation

tangg555
Copy link
Collaborator

fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o log submittion in MOS

Description

Summary: (summary)
fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o log submittion in MOS

Fix: #(issue)
#5

Docs Issue/PR: (docs-issue-or-pr-link)

Reviewer: @(reviewer)
@fridayL

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 的人

Copy link
Collaborator

@fridayL fridayL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary
This PR refactors the memory scheduler and working memory update logic, improves error handling, and introduces a decorator for exception logging. Key changes include:

Unifying scheduler initialization functions.
Replacing internal attributes for current user and memory cube from private (current) to public (current_).
Improving logging and error handling throughout memory management modules.
Adding a decorator (log_exceptions) for automatic exception logging.
Refactoring code for clarity and robustness, especially around message handling and memory update flows.
Minor bug fixes (typos, error messages, default values).
Updates test code to match new attribute names.
Detailed Review

  1. Scheduler Initialization & Config Handling
    The two separate scheduler initialization functions are merged into a single run_with_scheduler_init function. This simplifies code maintenance and usage.
    The code now loads configuration files more cleanly, directly using MOSConfig.from_yaml_file.
    When an AuthConfig is present, OpenAI credentials are injected into the config, improving flexibility and reducing manual steps.
    Good: Simplifies the entrypoint and reduces redundancy.

  2. Attribute Renaming
    Internal attributes like _current_user_id, _current_mem_cube_id, and _current_mem_cube are renamed to current_user_id, current_mem_cube_id, and current_mem_cube, and their usages are updated across the codebase.
    Good: Improves clarity and consistency, especially with property setters/getters.

  3. Exception Logging Decorator
    Adds a log_exceptions decorator in misc_utils.py, used widely in the scheduler logger module to automatically catch and log exceptions (including stack traces).
    Good: Centralizes error handling, reduces boilerplate, and improves debugging capabilities.

  4. Improved Error Handling & Logging
    Several methods in modules/scheduler_logger.py now check for missing keys and log more informative messages.
    When parsing user input (userinput_memory_ids), errors are caught and logged.
    LLM reranking failures now log the raw response for easier troubleshooting.
    Good: Makes the system more robust against malformed input and model errors.

  5. Message and Label Flow
    Changes the label for certain messages from ADD_LABEL to QUERY_LABEL to better reflect the intent.
    Refactors message consumer flows for queries, answers, and memory addition to be more robust and easier to follow.
    Good: Clarifies the role of each message and improves maintainability.

  6. General Code Quality
    Uses type hints and more descriptive variable names throughout.
    Removes unused imports and code.
    Updates test cases to use new attribute names.
    Good: Overall improvement in readability and reliability.

Suggestions / Potential Issues
Testing: Be sure to test edge cases, especially around error handling and new decorator usage. Verify that all exceptions are properly logged and do not cause silent failures.
Logging Volume: With the new decorator, logging may be more frequent. Make sure log levels and outputs are tuned for production use to avoid log spam.
Backward Compatibility: Attribute renaming may affect external code if attributes were used directly. Ensure all usages are updated.
Performance: Exception logging and additional checks can have minor performance impacts. Monitor if this becomes an issue in high-throughput scenarios.
Overall Impression
This PR is a solid refactor that improves code clarity, error handling, and maintainability. The new decorator is a good addition, and the merged initialization function streamlines the workflow. The changes are logical and well-structured.

Recommendation:
Approve after verifying tests pass and the new error handling works as intended in practice.

@fridayL fridayL merged commit d3e5d3b into MemTensor:dev Jul 23, 2025
20 checks passed
tangg555 added a commit to tangg555/MemOS that referenced this pull request Jul 29, 2025
MemTensor#147)

* fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs of log submittion in MOS

* fix bugs: modify mos product, and add more exception catch code
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