A long-term memory management system and method
Patent Information
- Application Number
- CN202611012956.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-08
- Publication Date
- 2026-10-13
AI Technical Summary
[0002]人工智能辅助编程(Artificial Intelligence assisted coding,简称AIcoding)技术已广泛应用于企业软件开发,通过大语言模型辅助代码生成、需求分析等任务,但现有方案的任务效果受限于缺乏有效的长期记忆机制
1.解决云端依赖问题,实现离线运行:本发明系统通过模型服务能力单元(离线嵌入模型、大语言模型)和记忆管理单元(离线向量数据库)的本地部署,所有数据处理和存储均在企业内网完成,完全摆脱对云端服务的依赖。
Smart Images

Figure CN122903525A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of AI-assisted programming, and more particularly to a long-term memory management system and method. Background Technology
[0002] Artificial intelligence-assisted coding (AI coding) technology has been widely applied in enterprise software development, assisting in tasks such as code generation and requirements analysis through large language models. However, the effectiveness of existing solutions is limited by the lack of an effective long-term memory mechanism. Specifically, the long-term memory plugins officially recommended by OpenCode provide functions such as memory retrieval and storage, but they rely on cloud services (including model services, memory management services, and storage services), making them unsuitable for offline environments and deployments on intranets or isolated networks. Data needs to be uploaded to third-party servers, posing compliance risks; network latency affects response speed, failing to meet the data isolation requirements of industries such as finance and government. Traditional memory plugins are customized and adapted for different AI coding tools, lacking universality and still relying on cloud services, making them unsuitable for offline environments within enterprise intranets and failing to meet the data isolation requirements of industries such as finance and government. Summary of the Invention
[0003] The purpose of this invention is to overcome the problems of the prior art and provide a long-term memory management system and method.
[0004] The objective of this invention is achieved through the following technical solution: a long-term memory management system, the system comprising: The model service capability unit includes an offline embedding model and a large language model. The offline embedding model is used to vectorize the input text, and the large language model is used to generate summary information of the input text and perform AI tasks. The task unit includes an AI coding tool, which receives AI task requests from users and issues business activity instructions to the large language model according to the AI task requests, and calls the large language model to execute the AI task; the business activity instructions include workflow labels for the AI task workflow, and the workflow labels include input validation, interaction clarification and output results; The memory agent unit includes an automatic memory skill, which is triggered when the AI task progress executed by the large language model reaches the workflow corresponding to the workflow label, and then initiates a memory operation request to the memory management service. The memory operation request includes a memory retrieval request and a memory storage request. The memory management unit includes a memory management interface, a memory management service, and a vector database. The memory management service receives memory operation requests through the memory management interface. When the memory operation request is a memory retrieval request, the memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the retrieval results to the large language model. When the memory operation request is a memory storage request, the memory management service calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content before storing it in the vector database.
[0005] In one embodiment, the memory proxy unit further includes an automatic memory plugin, which is used to monitor the session lifecycle events of the AI coding tool, including session start, session end, user question, and session compression. When a session start or user question is detected, the automatic memory plugin initiates a memory retrieval request to the memory management service through the memory management interface; when a session end or session compression is detected, the automatic memory plugin initiates a memory storage request to the memory management service through the memory management interface.
[0006] In one embodiment, the memory proxy unit further includes an automatic memory tool, which encapsulates a call interface for a memory management interface, including a retrieval standard interface and a storage standard interface; When a user initiates a memory retrieval request, the memory retrieval request is sent to the memory management service by calling the standard retrieval interface; when a user initiates a memory storage request, the memory storage request is sent to the memory management service by calling the standard storage interface.
[0007] In one embodiment, the memory content stored in the vector database includes a user account field and a memory tag field. The memory tags include personal tags and shared tags. Memory content marked with personal tags is personal memory, and memory content marked with shared tags is shared memory. When performing similarity matching in the vector database, the database scope searched is either shared memory or personal memory where the user account field is the current user account. The system allows users to view, mark, or delete personal memories stored in the vector database. It also categorizes memories into high and low value based on their cumulative search hit frequency, deletes low-value personal memories, and modifies the tags of high-value memories from personal tags to shared tags, thus upgrading the current personal memories to shared memories for users to retrieve.
[0008] It should be further noted that the technical features corresponding to the above examples can be combined or replaced to form new technical solutions.
[0009] The present invention also includes a long-term memory management method, which has the same inventive concept as the system described in any of the above embodiments or a system formed by combining multiple embodiments, and the method includes the following steps: The AI coding tool receives AI task requests from users, issues business activity instructions to the large language model based on the AI task requests, and calls the large language model to execute the AI task; the business activity instructions include workflow tags for the AI task workflow; When the AI task execution progress reaches the workflow corresponding to the workflow label, the automatic memory skill is triggered. The memory management unit initiates a memory operation request to the memory management service through the memory management interface provided by the memory management unit. The memory operation request includes a memory retrieval request and a memory storage request. When the memory operation request is a memory retrieval request, the memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the search results to the large language model. When the memory operation request is a memory storage request, the memory management service calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database.
[0010] In one embodiment, triggering the automatic memory skill when the AI task execution progress reaches the workflow corresponding to the workflow tag includes: When the AI task execution progress reaches the input verification stage corresponding to the workflow label, the automatic memory skill is triggered. The memory management interface sends a memory retrieval request to the memory management service to obtain historical experience of similar tasks as supplementary input for the task execution context. When the AI task execution progress reaches the interactive clarification stage corresponding to the workflow label, the automatic memory skill is triggered. Based on the user's clarification content, the easily misunderstood points and the correct understanding are extracted as memory content. The memory storage request is sent to the memory management service through the memory management interface to realize memory storage. When the AI task execution progress reaches the output result stage corresponding to the workflow label, the automatic memory skill is triggered. Based on the task completion status, the task experience and key points are summarized as memory content. The memory storage request is initiated to the memory management service through the memory management interface to realize memory storage.
[0011] In one embodiment, the method further includes: using an automatic memory plugin to monitor the session lifecycle events of the AI coding tool, the session lifecycle events including session initiation, session end, user question, and session compression; When a session is detected to be starting, the automatic memory plugin uses the contents of the project index file in the current workspace as search keywords to send a memory retrieval request to the memory management service through the memory management interface to obtain relevant project experience. When a user asks a question, the automatic memory plugin uses the user's question information as search keywords and sends a memory retrieval request to the memory management service through the memory management interface to obtain relevant memory information. When the session ends, the automatic memory plugin retrieves the experience of the current session task generated when the current session task is completed as the memory content, and sends a memory storage request to the memory management service through the memory management interface. When session compression is detected, the automatic memory plugin obtains the summary generated by the compression of the current session context as the memory content and sends a memory storage request to the memory management service through the memory management interface.
[0012] In one embodiment, prior to the step of issuing business activity instructions to the large language model, the method further includes: The automatic memory plugin, based on session initiation and / or user queries, retrieves relevant items, related memory information, and AI task requests, and then issues business activity instructions to the large language model.
[0013] In one embodiment, the method further includes: the user actively initiating a memory operation command using an automatic memory tool; when the user actively initiates a memory retrieval request memory operation command, a memory retrieval request is initiated to the memory management service by calling the retrieval standard interface; when the user actively initiates a memory storage request memory operation command, a memory storage request is initiated to the memory management service by calling the storage standard interface.
[0014] In one embodiment, the memory content stored in the vector database includes a user account field and a memory tag field. The memory tags include personal tags and shared tags. Memory content marked with personal tags is personal memory, and memory content marked with shared tags is shared memory. When performing similarity matching in the vector database, the database scope searched is either shared memory or personal memory where the user account field is the current user account. The system allows users to view, mark, or delete personal memories stored in the vector database. It also categorizes memories into high and low value based on their cumulative search hit frequency, deletes low-value personal memories, and modifies the tags of high-value memories from personal tags to shared tags, thus upgrading the current personal memories to shared memories for users to retrieve.
[0015] It should be further noted that the technical features corresponding to the above examples can be combined or replaced to form new technical solutions.
[0016] Compared with the prior art, the beneficial effects of the present invention are: 1. Solve the cloud dependency problem and achieve offline operation: The system of this invention is deployed locally by the model service capability unit (offline embedded model, large language model) and the memory management unit (offline vector database). All data processing and storage are completed on the enterprise intranet, completely eliminating the dependence on cloud services.
[0017] 2. Eliminate data security risks and meet compliance requirements: All memory data (such as code snippets, requirements analysis, and task experience) are stored in the enterprise's internal vector database without the need to upload to third-party servers. Compared with traditional cloud solutions, the risk of data leakage of this invention is reduced to zero, which complies with the security standards of industries such as finance and government and meets the data isolation compliance requirements.
[0018] 3. Enhance the accuracy and flexibility of memory data: In the process of AI (large language model) performing AI tasks, the automatic memory skill is initiated by AI actively. AI interacts directly with memory management service during task execution. Memory data is generated by AI in real time according to the task context (such as the result of requirement clarification and task summary). The automatic memory skill method has higher data accuracy and supports richer memory dimensions (intermediate state of task, points prone to misunderstanding, etc.).
[0019] 4. The memory management interface and automatic memory skills of this invention can be directly registered and used in mainstream AI coding tools such as OpenCode and Cursor, and have versatility and strong platform compatibility.
[0020] 5. Support knowledge accumulation and reuse: The vector database persistently stores local task experience, which can be retrieved and reused for subsequent similar tasks, thereby improving the processing efficiency of similar tasks, reducing repetitive work, and promoting organizational-level knowledge accumulation.
[0021] 6. Modular design facilitates enterprise-level deployment and expansion: Each component of this invention (model service, memory management, memory agent) is independently encapsulated, supporting on-demand deployment and horizontal expansion (such as 1 to N vector database nodes), reducing expansion costs, and supporting smooth upgrades to meet the needs of enterprises of different sizes. Attached Figure Description
[0022] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. The accompanying drawings are provided to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to denote the same or similar parts. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application.
[0023] Figure 1 This is a system block diagram provided according to an embodiment of the present invention; Figure 2 A system block diagram provided for a preferred embodiment of the present invention; Figure 3 This is a flowchart of a method provided in an embodiment of the present invention. Detailed Implementation
[0024] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0026] In one embodiment, such as Figure 1 As shown, a long-term memory management system based on OpenCode includes a model service capability unit, a task unit, a memory agent unit, and a memory management unit. The task unit, memory agent unit, memory management unit, and model service capability unit are connected in sequence. Each unit works together through the MCP (Model Context Protocol) protocol or internal interface to achieve complete memory management in an offline environment.
[0027] The model service capability unit deploys offline embedding models (such as qwen-embedding) and large language models (such as DeepSeek v3). The offline embedding model is used to vectorize the input text, while the large language model is used to generate summary information of the input text. At the same time, the large language model also provides general model capabilities to perform AI conversational tasks such as programming tasks.
[0028] The task unit includes an AI coding tool, specifically OpenCode in this embodiment, which assists developers in completing programming tasks and generating memory data (such as requirements analysis experience and core code logic). Specifically, OpenCode receives AI task requests from users and issues business activity instructions to the large language model based on these requests. The large language model then executes the corresponding AI task according to the business activity instructions. During the execution of the AI task, a memory management service is triggered to achieve memory retrieval and storage. The business activity instructions include workflow tags for the AI task workflow. Workflow tags include input validation, interaction clarification, and output results.
[0029] The memory agent unit includes an automatic memory skill based on the memory interaction method of the Skill specification. This automatic memory skill is triggered when the AI task executed by the large language model reaches the workflow corresponding to the workflow label (such as input validation, interaction clarification, and output results), and then initiates a memory operation request to the memory management service. The memory operation request includes a memory retrieval request and a memory storage request.
[0030] The memory management unit comprises a memory management interface, memory management services, and an offline-deployed vector database. The memory management interface is an external interface based on the MCP protocol, providing standard retrieval and storage interfaces. Through this MCP-based interface and automatic memory skills based on the Skill specification, these skills can be directly registered and used by mainstream AI coding tools such as OpenCode and Cursor, ensuring high platform compatibility. The vector database (e.g., Qdrant) stores memory content and its associated metadata in vector form, including summary information of the memory content. The memory management service (e.g., mem0) receives memory operation requests through the memory management interface; specifically, it receives memory retrieval requests through the standard retrieval interface and memory storage requests through the standard storage interface. When the AI task execution progress reaches the input verification stage (after input verification and before task execution), the memory management service receives a memory retrieval request, calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the retrieval results, i.e., historical experience of similar tasks, to the large language model as part of the task execution context to continue executing the current AI task. When the AI task execution progress reaches the interaction clarification stage (after interaction clarification) and the output result stage (after task output), the memory management service receives a memory storage request, calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database.
[0031] In this embodiment, the user initiates an AI task request through OpenCode. During the execution of the AI task by the AI large language model, when the AI task execution progress reaches the workflow corresponding to the workflow label (input verification, interaction clarification, and output results), the automatic memory skill in the memory agent unit is triggered. The memory agent unit initiates a memory operation request to the memory management service in the memory management unit and accesses the memory management service through the MCP protocol. The memory management service calls the embedding model to perform vectorization processing on the input text and calls the large language model to generate a summary. The memory content is finally stored in the vector database.
[0032] In one embodiment, such as Figure 2As shown, the memory proxy unit also includes an automatic memory plugin, which is an officially compatible plugin that conforms to the Opencode official plugin specification. It is used to listen for session lifecycle events of the AI coding tool, including session start, session end, user question, and session compression. When a session start or user question is detected, the automatic memory plugin initiates a memory retrieval request to the memory management service through the memory management interface. When a session end or session compression is detected, the automatic memory plugin initiates a memory storage request to the memory management service through the memory management interface.
[0033] In one embodiment, such as Figure 2 As shown, the memory agent unit also has an automatic memory tool, which is based on the MCP protocol and encapsulates a call interface for the memory management interface. When a user actively initiates a memory retrieval request, the automatic memory tool calls the retrieval standard interface to initiate a memory retrieval request to the memory management service. When a user actively initiates a memory storage request, the automatic memory tool calls the storage standard interface to initiate a memory storage request to the memory management service.
[0034] In one embodiment, the memory content stored in the vector database includes a user account field and a memory tag field. Further, the user account field is used for memory isolation, and the memory tags are used for memory categorization. Memory tags include personal tags and shared tags. Memory content marked with a personal tag is personal memory, and a user's initial memory is considered personal memory by default. Memory content marked with a shared tag is shared memory. Personal memories can only be retrieved by the memory owner, while shared memories can be retrieved by all users. That is, when performing similarity matching in the vector database, the database search scope is either shared memories or personal memories where the user account field is the current user account.
[0035] When the system of this invention is deployed offline within an enterprise, the user account field is the employee ID field. OpenCode uses the employee ID to establish a memory channel. The memory data written through this channel has the current user's employee ID in the employee ID field, and its memory tag defaults to "person".
[0036] Preferably, the memory management service has a memory review function. Reviewers can view, mark, or delete personal memories stored in the vector database, and classify them into high and low value based on the cumulative frequency of retrieval. Low-value personal memories are deleted, and high-value memory tags are changed from personal tags to shared tags, thus upgrading the current personal memory to a shared memory.
[0037] The present invention also includes a long-term memory management method, which is implemented based on a system formed by any or a combination of the above embodiments, such as... Figure 3 As shown, the method includes the following steps: S10: In the task unit, the AI coding tool, OpenCode, receives the user's AI task request, issues business activity instructions to the large language model according to the AI task request, and calls the large language model to execute AI tasks such as coding tasks. The business activity instructions include the workflow label of the AI task workflow.
[0038] In step S10, the user organizes and breaks down common business activities of the enterprise, develops custom business activity instructions based on the OpenCode framework, and encapsulates and defines the business activities. Specifically, each business activity defines its own workflow and has a unified workflow label, such as: input validation, interaction clarification, task execution, and output results. Each instruction corresponds to a business activity, such as the instruction for requirements analysis: / req / analyze; the user can use the / req / analyze instruction based on OpenCode to complete the requirements analysis activity in software development; in this embodiment, OpenCode receives user input, connects with AI for task processing, receives AI output, and responds to the user.
[0039] When the AI task execution progress reaches the workflow corresponding to the workflow label, the S20 triggers the automatic memory skill and initiates a memory operation request to the memory management service through the memory management interface provided by the memory management unit. The memory operation request includes a memory retrieval request and a memory storage request.
[0040] In step S20, when OpenCode interacts with the large language model, it provides the large language model with a skill catalog, including automatically memorized skills. The trigger conditions for these skills (which can be set via the skill's YAML frontmatter description field) are after input validation, after interaction clarification, and after task output. In this step, the tasks submitted to the large language model are all tasks with defined workflows through proxy and instruction encapsulation. These tasks share the same workflow labels, including: input validation, interaction clarification, task execution, and output result. The three trigger times for the automatically memorized skills correspond to the workflow labels of the AI task. At the three key time points in the task process (after input validation, after interaction clarification, and after output result), the large language model recognizes the existence of automatically memorized skills that need to be used at these times. The large language model actively reads the skill information and performs memory management according to the guidance of the automatically memorized skills. Specifically, when the AI task execution progress reaches the input validation stage, it initiates a memory retrieval request to the memory management service; when the AI task execution progress reaches the interaction clarification stage or the output result stage, it initiates a memory storage request to the memory management service.
[0041] S30: When the memory operation request is a memory retrieval request, the memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the search results, i.e., the historical experience of similar tasks, to the large language model as part of the task execution context to continue executing the current AI task; when the memory operation request is a memory storage request, the memory management service calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database.
[0042] The method of this invention is applied to an offline-deployed long-term memory management system. All memory data generated during the execution of AI programming tasks is stored in the enterprise's internal vector database, without the need to upload to a third-party server, thus eliminating the risk of data leakage. At the same time, the method of this invention allows the AI, namely the large language model, to actively invoke automatic memory skills during the execution of AI tasks. The AI generates memory data in real time based on the task context and directly calls the memory management service, rather than indirectly obtaining it through plugins. This can improve data accuracy and support richer memory dimensions.
[0043] In one embodiment, when the AI task execution progress reaches the workflow corresponding to the workflow label, the automatic memory skill is triggered, including: S201: When the AI task execution progress reaches the input verification stage, the automatic memory skill is triggered. The memory management interface initiates a memory retrieval request to the memory management service to obtain historical experience of similar tasks as supplementary input for the task execution context.
[0044] In step S201, after the input verification stage of the task process, the AI triggers the automatic memory skill and initiates a memory retrieval request to the memory management service. The memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the retrieval results to the large language model as part of the task execution context.
[0045] S202: When the AI task execution progress reaches the interactive clarification stage, the automatic memory skill is triggered. Based on the user's clarification content, the easily misunderstood points and the correct understanding are extracted as memory content. The memory storage request is initiated to the memory management service through the memory management interface to realize memory storage.
[0046] In step S202, after understanding the input information, if there is ambiguity or missing key information in the input that is insufficient to support the AI in completing subsequent tasks, the AI will raise its questions to the user and wait for the user to clarify. The AI combines the user's clarification with the original input to organize the points of misunderstanding, easy misinterpretation, and correct understanding. At this time, the AI's task execution stage is interactive clarification. After the interactive clarification is completed, the automatic memory skill is triggered, and a memory storage request is initiated to the memory management service through the memory management interface. The memory management service calls the large language model to generate summary information of the memory content (the easy misinterpretation points and correct understanding organized during the clarification process), and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database to realize memory storage.
[0047] S203: When the AI task execution progress reaches the output result stage corresponding to the workflow label, the automatic memory skill is triggered. Based on the task completion status, the task experience and key points are summarized as memory content. The memory storage request is initiated to the memory management service through the memory management interface to realize memory storage.
[0048] In step S203, after the AI outputs the result, it triggers the automatic memory skill and initiates a memory storage request to the memory management service through the memory management interface. The memory management service calls the large language model to generate summary information of the memory content (automatically summarizing task experience, pitfalls, and ways to avoid pitfalls based on task completion), and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database to realize memory storage.
[0049] In one embodiment, the method further includes using an automatic memory plugin to listen for session lifecycle events of the AI coding tool: When a session starts, the automatic memory plugin listens for the OpenCode session creation event. When the session is created, it uses the contents of the project index file in the current workspace as the search keywords and sends a memory retrieval request to the memory management service through the standard retrieval interface of the memory management interface to obtain relevant project experience. When a user asks a question, the automatic memory plugin listens for OpenCode session update events, obtains the user's question information, and uses the user's question information as search keywords. It then sends a memory retrieval request to the memory management service through the memory management interface, performs vector retrieval matching in the vector database, and obtains highly similar content, i.e., relevant memory information. This relevant memory information is used as supplementary input for the next round of questions. When the session ends, the automatic memory plugin listens for the OpenCode session idle event, retrieves the session task experience generated when the current session task is completed as the memory content, and calls the storage standard interface to store the memory. During session compression, the automatic memory plugin listens for OpenCode session compression events, obtains the summary generated by the current session context compression in OpenCode as the memory content, and calls the storage standard interface to store the memory.
[0050] In one embodiment, prior to the step of issuing business activity instructions to the large language model, the method further includes: The automatic memory plugin, based on session initiation and / or user queries, retrieves relevant items, related memory information, and AI task requests, and then issues business activity instructions to the large language model.
[0051] In this embodiment, the interaction between the user and the AI essentially involves using instructions developed based on OpenCode to complete corresponding business activities. Specifically, OpenCode merges the user's original input with relevant items retrieved by the automatic memory plugin and related memory information, and sends it to the AI. The AI receives the task input from OpenCode, begins to execute the task, and after completing the task, the AI returns the analysis results to OpenCode; OpenCode then displays the AI's output to the user.
[0052] In one embodiment, the method further includes: the user actively initiating a memory operation command using an automatic memory tool; when the user actively initiates a memory retrieval request memory operation command, a memory retrieval request is initiated to the memory management service by calling the retrieval standard interface; when the user actively initiates a memory storage request memory operation command, a memory storage request is initiated to the memory management service by calling the storage standard interface.
[0053] In one embodiment, the memory content stored in the vector database includes a user account field and a memory tag field. Memory tags include personal tags and shared tags. Memory content marked with a personal tag is personal memory, and memory content marked with a shared tag is shared memory. Each user's written memory is identified by their user account, and the memory tag defaults to personal. Personal memories cannot be retrieved by other users. That is, when performing similarity matching in the vector database, the database search scope is either shared memories or personal memories where the user account field is the current user account.
[0054] Preferably, the auditor can view, mark, or delete personal memories stored in the vector database, and classify them into high and low value based on the cumulative frequency of retrieval. Low-value personal memories are deleted, and high-value memory tags are changed from personal tags to shared tags, so that the current personal memory is upgraded to a shared memory for users to retrieve.
[0055] Combining the above embodiments yields a preferred embodiment of the present invention. Taking offline requirements analysis using OpenCode as an example, the method of the present invention includes the following steps: S100: Deployment phase: Offline deployment of OpenCode, model service capability unit, and memory management service (exposing memory management interface to the outside world through MCP protocol), and registration of automatic memory skills and automatic memory plugins; S200: The agent developers streamlined the requirements analysis process and developed requirements analysis instructions based on OpenCode, as shown below: # Requirements Analysis Entry Command Perform the requirements analysis process and output a concise, structured requirements analysis report.
[0056] ## Execution Process ### Phase 1: Input Validation; ### Phase 2: Interactive Clarification; Phase 3: Task Execution; ### Stage 4: Output Results.
[0057] S300: The user starts the OpenCode process, and the automatic memory plugin and automatic memory skills are registered with OpenCode; OpenCode starts a session to communicate with the user and establishes a memory channel with the memory management service using the current user's employee ID; S400: When a session starts, the automatic memory plugin listens for the session start event and if a project index file exists in the current workspace, it initiates a memory retrieval operation based on the contents of the project index file. When a user initiates a requirement analysis request through a business activity command (using a method such as: / req / analyze "need to add authentication function to the current module"), the automatic memory plugin listens for the session update event and obtains the user's problem retrieval experience of similar tasks, i.e., relevant project experience. S500: Opencode receives relevant project experience and adds it to the user's question, and issues a requirement analysis instruction to the AI. At this time, the data received by the AI is: the content of the requirement analysis instruction, the user's original input, the memory information retrieved by OpenCode, the available tools (memory management interface encapsulated by the MCP protocol) and the skill list (such as automatic memory skills). S600: The AI organizes and verifies the received information. At this time, the AI recognizes the "input verification" label defined in the requirements analysis instruction and finds that there is an automatic memory skill that needs to be executed after "input verification". The AI successfully triggers the automatic memory skill and initiates a memory retrieval request to the memory management service through the memory management interface to retrieve historical experience of similar tasks. The AI initiates a memory retrieval using the organized and verified task input as keywords and stores the retrieved historical experience of similar tasks in the context for use in subsequent task steps. S700: At this point, following the workflow defined in the requirements analysis instructions, the AI executes the second step, "interactive clarification." By organizing and supplementing the task input through memory retrieval, it discovers that some doubts still need clarification. The AI then proactively asks the OpenCode, "Does the authentication function consider concurrency? Is a verification code required?" The user inputs through the OpenCode, "All authentication functions are considered to have 1000 concurrent connections, and no verification code is required." Clarification is now complete. The AI discovers that an automatic memory skill needs to be executed after "interactive clarification," and this automatic memory skill is triggered. The AI will follow the guidance of this automatic memory skill to memorize and store common doubts, misunderstandings, and correct understandings from the authentication requirements analysis, such as "Authentication does not require a verification code, and 1000 concurrent connections are considered uniformly." S800: AI performs requirements analysis activities according to the "task execution" phase guidance in the requirements analysis instructions and outputs a requirements analysis report; S900: After the requirements analysis report is output, the AI will find that there is an automatic memory skill that needs to be executed after the "output results". The AI will organize the experience and pitfalls in this task according to the guidance of the automatic memory skill and initiate a memory storage request. S1000: When the AI task is completed, a task execution summary is sent back to OpenCode, and the OpenCode session becomes idle. The automatic memory plugin listens for the session end event and stores the experience of this task execution and the project progress. S1100: When a user performs a long-term development task in the current session and the session context usage reaches a threshold, OpenCode initiates session compression; the automatic memory plugin listens for the session compression event and stores the summary content generated by the session compression. S1200: When a user actively closes the current session, the automatic memory plugin listens for the session closing event and stores the session task progress. S1300: The auditor reviews the memories, deletes low-value personal memories, and upgrades high-value, universally applicable memories to shared memories.
[0058] Preferably, users can actively initiate memory operation commands using the automatic memory tool to achieve active interaction. When a user actively initiates a memory retrieval request, the user initiates a memory retrieval request to the memory management service by calling the retrieval standard interface; when a user actively initiates a memory storage request, the user initiates a memory storage request to the memory management service by calling the storage standard interface.
[0059] This embodiment is implemented based on an offline deployment system. During AI task execution, the automatic memory skill is invoked. The automatic memory plugin monitors the session lifecycle and proactively interacts with the user through the automatic memory tool. This ensures all data processing and storage are performed within the enterprise, completely eliminating reliance on cloud services and reducing the risk of data leakage to zero, meeting the data isolation compliance requirements of industries such as finance and government. Simultaneously, the automatic memory plugin pre-retrieves relevant project experience and memory information when the session starts and the user asks a question, supplementing the user's question accordingly. The automatic memory skill is proactively triggered by AI in the three stages of input verification, interactive clarification, and output results of the requirements analysis task. This allows AI to directly obtain high-precision memory data generated in real-time during AI task execution from the memory service. Compared to traditional indirect acquisition methods using plugins, this supports richer memory dimensions, improving the accuracy and flexibility of the memory data. Furthermore, auditors can delete low-value personal memories and upgrade high-value, universally applicable personal memories to shared memories, achieving knowledge accumulation and reuse. Subsequent similar tasks can retrieve and reuse these memories, reducing repetitive work, improving task processing efficiency, and promoting organizational-level knowledge accumulation.
[0060] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A long-term memory management system, characterized in that, The system includes: The model service capability unit includes an offline embedding model and a large language model. The offline embedding model is used to vectorize the input text, and the large language model is used to generate summary information of the input text and perform AI tasks. The task unit includes an AI coding tool, which receives AI task requests from users and issues business activity instructions to the large language model according to the AI task requests, and calls the large language model to execute the AI task; the business activity instructions include workflow tags for the AI task workflow; The memory agent unit includes an automatic memory skill, which is triggered when the AI task progress executed by the large language model reaches the workflow corresponding to the workflow label, and then initiates a memory operation request to the memory management service. The memory operation request includes a memory retrieval request and a memory storage request. The memory management unit includes a memory management interface, a memory management service, and a vector database. The memory management service receives memory operation requests through the memory management interface. When the memory operation request is a memory retrieval request, the memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the retrieval results to the large language model. When the memory operation request is a memory storage request, the memory management service calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content before storing it in the vector database.
2. The long-term memory management system according to claim 1, characterized in that, The memory proxy unit also includes an automatic memory plugin, which is used to monitor the session lifecycle events of the AI coding tool, including session start, session end, user question, and session compression. When a session start or user question is detected, the automatic memory plugin initiates a memory retrieval request to the memory management service through the memory management interface; when a session end or session compression is detected, the automatic memory plugin initiates a memory storage request to the memory management service through the memory management interface.
3. The long-term memory management system according to claim 1, characterized in that, The memory proxy unit also includes an automatic memory tool, which encapsulates a call interface for a memory management interface, including a retrieval standard interface and a storage standard interface. When a user initiates a memory retrieval request, the memory retrieval request is sent to the memory management service by calling the standard retrieval interface; when a user initiates a memory storage request, the memory storage request is sent to the memory management service by calling the standard storage interface.
4. The long-term memory management system according to claim 1, characterized in that, The vector database stores memory content including a user account field and a memory tag field. The memory tags include personal tags and shared tags. Memory content marked with a personal tag is personal memory, and memory content marked with a shared tag is shared memory. When performing similarity matching in the vector database, the database scope searched is either shared memory or personal memory where the user account field is the current user account. The system allows users to view, mark, or delete personal memories stored in the vector database. It also categorizes memories into high and low value based on their cumulative search hit frequency, deletes low-value personal memories, and modifies the tags of high-value memories from personal tags to shared tags, thus upgrading the current personal memories to shared memories for users to retrieve.
5. A long-term memory management method, characterized in that, Includes the following steps: The AI coding tool receives AI task requests from users, issues business activity instructions to the large language model based on the AI task requests, and calls the large language model to execute the AI task; the business activity instructions include workflow tags for the AI task workflow; When the AI task execution progress reaches the workflow corresponding to the workflow label, the automatic memory skill is triggered. The memory management unit initiates a memory operation request to the memory management service through the memory management interface provided by the memory management unit. The memory operation request includes a memory retrieval request and a memory storage request. When the memory operation request is a memory retrieval request, the memory management service calls the offline embedding model to vectorize the search keywords, performs similarity matching in the vector database, and returns the search results to the large language model. When the memory operation request is a memory storage request, the memory management service calls the large language model to generate summary information of the memory content, and calls the offline embedding model to vectorize the memory content and the summary information associated with the memory content and store it in the vector database.
6. The long-term memory management method according to claim 5, characterized in that, When the AI task execution progress reaches the workflow corresponding to the workflow label, the automatic memory skill is triggered, including: When the AI task execution progress reaches the input verification stage corresponding to the workflow label, the automatic memory skill is triggered. The memory management interface sends a memory retrieval request to the memory management service to obtain historical experience of similar tasks as supplementary input for the task execution context. When the AI task execution progress reaches the interactive clarification stage corresponding to the workflow label, the automatic memory skill is triggered. Based on the user's clarification content, the easily misunderstood points and the correct understanding are extracted as memory content. The memory storage request is sent to the memory management service through the memory management interface to realize memory storage. When the AI task execution progress reaches the output result stage corresponding to the workflow label, the automatic memory skill is triggered. Based on the task completion status, the task experience and key points are summarized as memory content. The memory storage request is initiated to the memory management service through the memory management interface to realize memory storage.
7. The long-term memory management method according to claim 5, characterized in that, The method further includes: using an automatic memory plugin to monitor the session lifecycle events of the AI encoding tool, the session lifecycle events including session initiation, session end, user questioning, and session compression; When a session is detected to be starting, the automatic memory plugin uses the contents of the project index file in the current workspace as search keywords to send a memory retrieval request to the memory management service through the memory management interface to obtain relevant project experience. When a user asks a question, the automatic memory plugin uses the user's question information as search keywords and sends a memory retrieval request to the memory management service through the memory management interface to obtain relevant memory information. When the session ends, the automatic memory plugin retrieves the experience of the current session task generated when the current session task is completed as the memory content, and sends a memory storage request to the memory management service through the memory management interface. When session compression is detected, the automatic memory plugin obtains the summary generated by the compression of the current session context as the memory content and sends a memory storage request to the memory management service through the memory management interface.
8. The long-term memory management method according to claim 7, characterized in that, Before issuing business activity instructions to the large language model, the following steps are also included: The automatic memory plugin, based on session initiation and / or user queries, retrieves relevant items, related memory information, and AI task requests, and then issues business activity instructions to the large language model.
9. The long-term memory management method according to claim 5, characterized in that, The method further includes: when a user actively initiates a memory operation command using an automatic memory tool, when a user actively initiates a memory retrieval request memory operation command, a memory retrieval request is sent to the memory management service by calling the retrieval standard interface; when a user actively initiates a memory storage request memory operation command, a memory storage request is sent to the memory management service by calling the storage standard interface.
10. The long-term memory management method according to claim 5, characterized in that, The vector database stores memory content including a user account field and a memory tag field. The memory tags include personal tags and shared tags. Memory content marked with a personal tag is personal memory, and memory content marked with a shared tag is shared memory. When performing similarity matching in the vector database, the database scope searched is either shared memory or personal memory where the user account field is the current user account. The system allows users to view, mark, or delete personal memories stored in the vector database. It also categorizes memories into high and low value based on their cumulative search hit frequency, deletes low-value personal memories, and modifies the tags of high-value memories from personal tags to shared tags, thus upgrading the current personal memories to shared memories for users to retrieve.