Skip to content

feat: add auto_cleanup_working; add image_id/file_info#1169

Merged
CaralHsi merged 8 commits intoMemTensor:dev-20260309-v2.0.9from
CaralHsi:fix/return_message_id
Mar 6, 2026
Merged

feat: add auto_cleanup_working; add image_id/file_info#1169
CaralHsi merged 8 commits intoMemTensor:dev-20260309-v2.0.9from
CaralHsi:fix/return_message_id

Conversation

@CaralHsi
Copy link
Copy Markdown
Collaborator

@CaralHsi CaralHsi commented Mar 5, 2026

Description

Description:
• Add auto_cleanup_working flag to DeleteMemoryRequest.
• When deleting by memory_ids and the flag is enabled, parse metadata.background for [working_binding:] and automatically delete the referenced WorkingMemory nodes after the main deletion.
• Improve delete-request logging to include the new flag.

Related Issue (Required): Fixes @issue_number

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update
import json
import requests

# -----------------------------
# 1. self-hosted product API
# -----------------------------
url = "0.0.0.0:8001"  # or your server IP
ADD_URL = f"http://{url}/product/add"
SEARCH_URL = f"http://{url}/product/search"
GET_URL = f"http://{url}/product/get_memory"
DEL_URL = f"http://{url}/product/delete_memory"
HEADERS = {"Content-Type": "application/json"}


def call(url, data):
    resp = requests.post(url, headers=HEADERS, data=json.dumps(data))
    print("Response:", resp.status_code)
    result = json.loads(resp.text)
    print("Response:", result["data"])
    return result


message_0 = [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "我在研究MemOS。"
                }
            ]
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url":
                            "https://xxxx.png",
                        "image_id": "my_id_01"
                    }
                }
            ]
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "file",
                    "file": {
                        "file_data":
                            "https://xxxxx.pdf",
                        "file_id": "0001",
                    }
                }
            ]
        }
]

# # -----------------------------
# # 2. add memories
# # -----------------------------
user_id = "my_user_id"
cube_id_01 = \
    "my_cube_1"
cube_id_02 = \
    "my_cube_2"

add_payload = {
        "user_id": user_id,
        "writable_cube_ids": [cube_id_01, cube_id_02],
        "messages": message_0,
        "session_id": "conv_001",
        "async_mode": "sync",
    }

fast_nodes = call(ADD_URL, add_payload)


search_payload = {
    "query": "我研究了什么",
    "user_id": user_id,
    "readable_cube_ids": [cube_id_01],
    "relativity": 0.0,
}
searched_res1 = call(SEARCH_URL, search_payload)

get_payload = {
    "mem_cube_id": cube_id_01,
}
get_res = call(GET_URL, get_payload)

user_id = user_id + "01"
cube_id_01 = cube_id_01 + "01"
add_payload = {
        "user_id": user_id,
        "writable_cube_ids": [cube_id_01],
        "messages": message_0,
        "session_id": "conv_001",
        "async_mode": "sync",
        "mode": "fine"
    }

fast_nodes01 = call(ADD_URL, add_payload)


search_payload = {
    "query": "我研究了什么",
    "user_id": user_id,
    "readable_cube_ids": [cube_id_01],
    "relativity": 0.0,
}
searched_res101 = call(SEARCH_URL, search_payload)

get_payload = {
    "mem_cube_id": cube_id_01,
}
get_res01 = call(GET_URL, get_payload)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

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

Reviewer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed
  • Tests have been provided

@CaralHsi CaralHsi marked this pull request as ready for review March 5, 2026 09:42
@CaralHsi CaralHsi changed the title feat: add auto_cleanup_working feat: add auto_cleanup_working; add image_id/file_info Mar 6, 2026
@CaralHsi CaralHsi changed the base branch from dev-20260302-v2.0.8 to dev-20260309-v2.0.9 March 6, 2026 03:50
@CaralHsi CaralHsi merged commit 548c405 into MemTensor:dev-20260309-v2.0.9 Mar 6, 2026
16 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.

1 participant