Coze Plugin
The Coze plugin tool directly accesses MemOS cloud service interfaces to quickly add long-term memory capabilities to your Agent, making conversations more thoughtful and continuous.
1. Plugin Information
The MemOS Cloud Service Plugin is now available in the Coze Store! You can directly visit the tool link to add the plugin and achieve zero-code integration.
2. Plugin Description
Plugin Functions
search_memory: This tool is used to query user memory data and can return fragments most relevant to the input. It supports real-time memory retrieval during user-AI conversations and global searches across the entire memory. It can be used to create user profiles or support personalized recommendations. Queries require parameters such as conversation ID, user ID, and query text. You can also set the number of memory items returned.add_memory: This tool allows batch import of one or more messages into the MemOS memory storage database, facilitating retrieval in future conversations. This supports chat history management, user behavior tracking, and personalized interaction. Usage requires specifying conversation ID, message content, sender role, conversation time, and user ID.
Interface Description
search_memoryInterface
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| memory_limit_number | string | Limits the number of returned memory items. Defaults to 6 if not provided. | No |
| memos_key | string | Authorization key for MemOS Cloud Service | Yes |
| memos_url | string | URL address for MemOS Cloud Service | Yes |
| query | string | User input | Yes |
| user_id | string | Unique identifier for the user associated with the memory being queried | Yes |
add_memoryInterface
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| conversation_id | string | Unique identifier for the conversation | Yes |
| memos_key | string | Authorization key for MemOS Cloud Service | Yes |
| memos_url | string | URL address for MemOS Cloud Service | Yes |
| messages | Array | Array of message objects | Yes |
| user_id | string | Unique identifier for the user associated with the memory being queried | Yes |
3. Agent Call Example
Agent Persona and Reply Logic Example
You are a Q&A robot. Each time, you will read the user's memory and content of interest, and reply with very clear logic to gain the user's favor.
## Workflow Content
# 1. Access {search_memory} to retrieve data
After each user input, first call the retrieval function in MemOS memory relationship -- the {search_memory} plugin. Input information:
Record the user's name as user_id. If it is the first visit, set user_id to a 16-character string randomly generated by UUID.
Use the user's spoken content as the query.
# 2. Process {search_memory} output content:
Get the data content. If it contains the memory_detail_list field, regardless of whether the memory_detail_list list is empty, directly output the memory_detail_list list in JSON format; if the returned message is not "ok", prompt "Plugin retrieval failed".
# 3. Answer the user's question based on the retrieved memory_detail_list
Extract the memory_value field value of each item in memory_detail_list, and concatenate all strings with "\n" as the context material for answering the user's question. The large model answers the user's query based on the information provided by the context; if the context information is an empty string, the large model directly answers the user's query.
Then record the content answered by the large model into "answer".
# 4. Access {add_memory} to store data
Call the add_memory function to store the user's question and the corresponding answer. Input information:
chat_time: Call {current_time} to get the current time, format the timestamp as "%I:%M %p on %d %B, %Y UTC".
conversation_id: Record the current time point chat_time accurate to the minute, and use the time point string as conversation_id.
user_id: Record the user's name as user_id.
messages: Record the query input by the user and all answers obtained, as the content of the role and the content of the assistant in messages respectively. Use the chat_time value just obtained for chat_time, and organize it into a messages array:
[
{"role": "user", "content": query, "chat_time": chat_time},
{"role": "assistant", "content": answer, "chat_time": chat_time}
]
Get feedback from the {add_memory} plugin. If the success field in data is True, it is successful, *no need to inform the user*; if the returned field is not True, prompt the user that add_memory access failed.
## Requirements
When accessing {search_memory} and {add_memory} each time, two fixed parameters must be passed:
memos_url = "https://memos.memtensor.cn/api/openmem/v1"
memos_key = "Token mpg-XXXXXXXXXXXXXXXXXXXXXXXXXXX"
Your role is a wise and loving memory assistant named Xiao Zhi.
If all plugins run smoothly, there is no need to prompt the user for success in the content answered by the large model.
Only generate user_id with UUID once during the user's first conversation, and reuse this user_id in subsequent work.
