Skip to content

Feat/merge api refactor to dev#542

Merged
CaralHsi merged 30 commits intoMemTensor:devfrom
Wang-Daoji:feat/merge_api_refactor_to_dev
Nov 27, 2025
Merged

Feat/merge api refactor to dev#542
CaralHsi merged 30 commits intoMemTensor:devfrom
Wang-Daoji:feat/merge_api_refactor_to_dev

Conversation

@Wang-Daoji
Copy link
Collaborator

Description

Summary: (summary)

Fix: #(issue)

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

Reviewer: @(reviewer)

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

@CaralHsi CaralHsi merged commit 3ed44db into MemTensor:dev Nov 27, 2025
20 checks passed
glin93 pushed a commit that referenced this pull request Nov 27, 2025
* new type

* llm reconstruct and add search api modify

* llm construction

* add delete and get, modify chat

* modify code

* modify code

* modify code

* coding chat

* fix bug in get and delete

* add internet reference in playground chat stream

* remove moscube

* modify code

* fix pre_commit

* fix make test

* finish info transfer

* add info and custom tags

* modify model product fileds

* fix get api bug

* fix bug

* fix bug in pref add info

---------

Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>
glin93 pushed a commit that referenced this pull request Nov 27, 2025
* new type

* llm reconstruct and add search api modify

* llm construction

* add delete and get, modify chat

* modify code

* modify code

* modify code

* coding chat

* fix bug in get and delete

* add internet reference in playground chat stream

* remove moscube

* modify code

* fix pre_commit

* fix make test

* finish info transfer

* add info and custom tags

* modify model product fileds

* fix get api bug

* fix bug

* fix bug in pref add info

---------

Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>
glin93 added a commit that referenced this pull request Nov 28, 2025
* feat: implement task_id monitoring system with Redis-based status tracking

Core Changes:
- Add task_id field to ScheduleMessageItem and ScheduleLogForWebItem schemas
- Implement TaskStatusTracker with Redis backend for task status persistence
- Support task_id to item_id mapping (one task can have multiple items)
- Add /scheduler/status endpoint with task_id query support

Status Tracking:
- TaskStatusTracker records task lifecycle: waiting -> in_progress -> completed/failed
- Redis keys: memos:task_meta:{user_id} for item status
- Redis keys: memos:task_items:{user_id}:{task_id} for task->items mapping
- Aggregated status query: returns 'in_progress' if any item is active

API Changes:
- Add task_id field to MemoryCreateRequest for /product/add monitoring
- Wrap product_router.create_memory() with status tracking
- Update scheduler_handler to query by business task_id or item_id

Integration Fixes:
- Fix single_cube.py to use scheduler.submit_messages() instead of direct queue access
- Fix chat_handler.py to use scheduler.submit_messages() for proper monitoring
- Ensure all messages pass through BaseScheduler for metrics and status tracking

Benefits:
- Frontend can query task status via /scheduler/status?user_id=xxx&task_id=yyy
- Support batch operations monitoring (one task_id, multiple async operations)
- Unified monitoring for add/chat/scheduler operations
- No performance impact (<1ms overhead per task)

* Feat/merge api refactor to dev (#542)

* new type

* llm reconstruct and add search api modify

* llm construction

* add delete and get, modify chat

* modify code

* modify code

* modify code

* coding chat

* fix bug in get and delete

* add internet reference in playground chat stream

* remove moscube

* modify code

* fix pre_commit

* fix make test

* finish info transfer

* add info and custom tags

* modify model product fileds

* fix get api bug

* fix bug

* fix bug in pref add info

---------

Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>

* fix: Complete task_id propagation for addMemory and updateMemory logs

* feat: Refactor task ID handling for clarity and correctness

This commit refactors the handling of task IDs throughout the system to ensure
consistency and correctness, addressing previous ambiguities and potential issues.

Key changes include:
- Streamlining the ScheduleMessageItem to use a single 'task_id' field,
  representing the business-level identifier, thereby removing redundancy and
  Pydantic field clashes.
- Modifying the /product/add API endpoint to correctly distinguish between the
  internal item_id (UUID) and the business-level task_id provided in the request,
  ensuring proper tracking in the status monitoring system.
- Propagating the task_id consistently through MOSProduct, MOSCore, and
  SingleCubeView components, ensuring it reaches the ScheduleMessageItem.
- Verifying that both the Redis-based status monitoring and the web logging
  systems correctly receive and utilize the business-level task_id, eliminating
  race conditions and ensuring accurate tracking.

* fix: Correct SyntaxError in MOSProduct.add method

The previous commit introduced a SyntaxError in the MOSProduct.add method due
to incorrect multi-line argument formatting for the super().add() call. This
commit fixes the syntax by properly enclosing the arguments in parentheses
for multi-line continuation. It also incorporates minor formatting changes
identified by ruff.

* feat: Pass user_name to get_current_memory_size

Modify the call to  in  to
include . This ensures that memory sizes are retrieved
for the correct MemCube/tenant context, aligning with multi-tenant monitoring
requirements outlined in design documents. Previously, this call did not pass
the user context, potentially leading to incorrect memory size reporting in
multi-tenant environments.

* feat: Implement Knowledge Base logging format in GeneralScheduler

This commit implements the new logging format for the 'Knowledge Base'
scenario within the  function of the
.

Key changes:
- Introduced a conditional logging path based on the
   environment variable,
  distinguishing between Knowledge Base logging and existing Playground/Default logging.
- Refactored the memory processing loop to correctly fetch the
  for  operations by querying the graph store for the existing memory item's content.
- Ensured that  and  operations for the Knowledge Base scenario
  produce a single, structured  with
  adhering to the new design document, including the
  and the correctly populated  for updates.
- Maintained backward compatibility for existing Playground/Default logging paths
  by reconstructing their expected data structures.

* fix: Resolve F821 error and duplicate timestamp; enhance KB logging

This commit addresses two new issues introduced in recent changes:
- Corrected an F821 'Undefined name os' error in  by adding the missing import.
- Fixed a  in  which was a result of an incorrect merge during rebase.

Additionally, this commit finalizes the implementation of the 'Knowledge Base'
logging format in  by ensuring that
for  operations is correctly fetched from the graph store. This
guarantees that the new log format fully adheres to the design specifications,
providing complete and accurate information for update events.

* fix: Finalize general_scheduler.py and single_cube.py changes

This commit finalizes the changes to  and .

In :
- The  method has been fully refactored to correctly
  handle Knowledge Base logging, including fetching  for
  UPDATE operations and ensuring proper conditional logging based on
  environment variables.
- The  module is now correctly imported.

In :
- The duplicate  keyword argument in the  method
  has been removed, resolving a .

These changes address all identified issues and ensure the code is clean,
correct, and fully compatible with both Knowledge Base and Playground logging
requirements, adhering to the specified design principles.

* fix(scheduler): Correct misleading logs in reorganize consumer

The  and its helper function
 contained several logging errors
due to being copied from the 'mem_read' consumer without modification.

This commit corrects the following:
- The handler info log now correctly uses the .
- All log messages now refer to 'mem_reorganize' instead of 'mem_read'.
- Exception logs now correctly cite
  and  as the source of the error.

These changes ensure that the logs for the reorganize functionality are
accurate and not misleading, which is critical for monitoring and debugging.
The core business logic of the function, which appears to be missing,
has not been altered.

* refactor(format): Reformat general_scheduler.py with ruff

This commit reformats
to adhere to the project's Ruff formatting standards. This resolves
the 942 files already formatted failure in the CI pipeline.

* fix: restore user_name on async mem_read submission

---------

Co-authored-by: glin1993@outlook.com <>
Co-authored-by: Wang Daoji <75928131+Wang-Daoji@users.noreply.github.com>
Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>
tianxing02 pushed a commit to tianxing02/MemOS that referenced this pull request Feb 24, 2026
* new type

* llm reconstruct and add search api modify

* llm construction

* add delete and get, modify chat

* modify code

* modify code

* modify code

* coding chat

* fix bug in get and delete

* add internet reference in playground chat stream

* remove moscube

* modify code

* fix pre_commit

* fix make test

* finish info transfer

* add info and custom tags

* modify model product fileds

* fix get api bug

* fix bug

* fix bug in pref add info

---------

Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>
tianxing02 pushed a commit to tianxing02/MemOS that referenced this pull request Feb 24, 2026
* feat: implement task_id monitoring system with Redis-based status tracking

Core Changes:
- Add task_id field to ScheduleMessageItem and ScheduleLogForWebItem schemas
- Implement TaskStatusTracker with Redis backend for task status persistence
- Support task_id to item_id mapping (one task can have multiple items)
- Add /scheduler/status endpoint with task_id query support

Status Tracking:
- TaskStatusTracker records task lifecycle: waiting -> in_progress -> completed/failed
- Redis keys: memos:task_meta:{user_id} for item status
- Redis keys: memos:task_items:{user_id}:{task_id} for task->items mapping
- Aggregated status query: returns 'in_progress' if any item is active

API Changes:
- Add task_id field to MemoryCreateRequest for /product/add monitoring
- Wrap product_router.create_memory() with status tracking
- Update scheduler_handler to query by business task_id or item_id

Integration Fixes:
- Fix single_cube.py to use scheduler.submit_messages() instead of direct queue access
- Fix chat_handler.py to use scheduler.submit_messages() for proper monitoring
- Ensure all messages pass through BaseScheduler for metrics and status tracking

Benefits:
- Frontend can query task status via /scheduler/status?user_id=xxx&task_id=yyy
- Support batch operations monitoring (one task_id, multiple async operations)
- Unified monitoring for add/chat/scheduler operations
- No performance impact (<1ms overhead per task)

* Feat/merge api refactor to dev (MemTensor#542)

* new type

* llm reconstruct and add search api modify

* llm construction

* add delete and get, modify chat

* modify code

* modify code

* modify code

* coding chat

* fix bug in get and delete

* add internet reference in playground chat stream

* remove moscube

* modify code

* fix pre_commit

* fix make test

* finish info transfer

* add info and custom tags

* modify model product fileds

* fix get api bug

* fix bug

* fix bug in pref add info

---------

Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.com>

* fix: Complete task_id propagation for addMemory and updateMemory logs

* feat: Refactor task ID handling for clarity and correctness

This commit refactors the handling of task IDs throughout the system to ensure
consistency and correctness, addressing previous ambiguities and potential issues.

Key changes include:
- Streamlining the ScheduleMessageItem to use a single 'task_id' field,
  representing the business-level identifier, thereby removing redundancy and
  Pydantic field clashes.
- Modifying the /product/add API endpoint to correctly distinguish between the
  internal item_id (UUID) and the business-level task_id provided in the request,
  ensuring proper tracking in the status monitoring system.
- Propagating the task_id consistently through MOSProduct, MOSCore, and
  SingleCubeView components, ensuring it reaches the ScheduleMessageItem.
- Verifying that both the Redis-based status monitoring and the web logging
  systems correctly receive and utilize the business-level task_id, eliminating
  race conditions and ensuring accurate tracking.

* fix: Correct SyntaxError in MOSProduct.add method

The previous commit introduced a SyntaxError in the MOSProduct.add method due
to incorrect multi-line argument formatting for the super().add() call. This
commit fixes the syntax by properly enclosing the arguments in parentheses
for multi-line continuation. It also incorporates minor formatting changes
identified by ruff.

* feat: Pass user_name to get_current_memory_size

Modify the call to  in  to
include . This ensures that memory sizes are retrieved
for the correct MemCube/tenant context, aligning with multi-tenant monitoring
requirements outlined in design documents. Previously, this call did not pass
the user context, potentially leading to incorrect memory size reporting in
multi-tenant environments.

* feat: Implement Knowledge Base logging format in GeneralScheduler

This commit implements the new logging format for the 'Knowledge Base'
scenario within the  function of the
.

Key changes:
- Introduced a conditional logging path based on the
   environment variable,
  distinguishing between Knowledge Base logging and existing Playground/Default logging.
- Refactored the memory processing loop to correctly fetch the
  for  operations by querying the graph store for the existing memory item's content.
- Ensured that  and  operations for the Knowledge Base scenario
  produce a single, structured  with
  adhering to the new design document, including the
  and the correctly populated  for updates.
- Maintained backward compatibility for existing Playground/Default logging paths
  by reconstructing their expected data structures.

* fix: Resolve F821 error and duplicate timestamp; enhance KB logging

This commit addresses two new issues introduced in recent changes:
- Corrected an F821 'Undefined name os' error in  by adding the missing import.
- Fixed a  in  which was a result of an incorrect merge during rebase.

Additionally, this commit finalizes the implementation of the 'Knowledge Base'
logging format in  by ensuring that
for  operations is correctly fetched from the graph store. This
guarantees that the new log format fully adheres to the design specifications,
providing complete and accurate information for update events.

* fix: Finalize general_scheduler.py and single_cube.py changes

This commit finalizes the changes to  and .

In :
- The  method has been fully refactored to correctly
  handle Knowledge Base logging, including fetching  for
  UPDATE operations and ensuring proper conditional logging based on
  environment variables.
- The  module is now correctly imported.

In :
- The duplicate  keyword argument in the  method
  has been removed, resolving a .

These changes address all identified issues and ensure the code is clean,
correct, and fully compatible with both Knowledge Base and Playground logging
requirements, adhering to the specified design principles.

* fix(scheduler): Correct misleading logs in reorganize consumer

The  and its helper function
 contained several logging errors
due to being copied from the 'mem_read' consumer without modification.

This commit corrects the following:
- The handler info log now correctly uses the .
- All log messages now refer to 'mem_reorganize' instead of 'mem_read'.
- Exception logs now correctly cite
  and  as the source of the error.

These changes ensure that the logs for the reorganize functionality are
accurate and not misleading, which is critical for monitoring and debugging.
The core business logic of the function, which appears to be missing,
has not been altered.

* refactor(format): Reformat general_scheduler.py with ruff

This commit reformats
to adhere to the project's Ruff formatting standards. This resolves
the 942 files already formatted failure in the CI pipeline.

* fix: restore user_name on async mem_read submission

---------

Co-authored-by: glin1993@outlook.com <>
Co-authored-by: Wang Daoji <75928131+Wang-Daoji@users.noreply.github.com>
Co-authored-by: yuan.wang <yuan.wang@yuanwangdebijibendiannao.local>
Co-authored-by: CaralHsi <caralhsi@gmail.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