An agent memory management method and device based on a decoder memory component

By introducing a decoder memory component into the agent memory management method, the problems of logical consistency and high computational resource consumption in long-term agent interactions are solved, and efficient and secure long-term memory management and knowledge acquisition are achieved.

CN121480741BActive Publication Date: 2026-06-09BEIJING THREATBOOK TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING THREATBOOK TECHNOLOGY CO LTD
Filing Date
2026-01-09
Publication Date
2026-06-09

Smart Images

  • Figure CN121480741B_ABST
    Figure CN121480741B_ABST
Patent Text Reader

Abstract

The application provides an agent memory management method and device based on a decoder memory component, wherein the method comprises: acquiring user input data; inputting the user input data into a pre-constructed large language model to generate a user response; asynchronously monitoring the user response to extract multi-source information of user feedback; generating a training queue according to the multi-source information; and performing knowledge solidification after incremental training of the training queue to realize agent memory management. By introducing an auxiliary small model, the long-term memory is separated from the context window of the large language model, flexible management and persistent storage of long-term memory are realized, new knowledge can be efficiently captured, and the loss of time sequence structure information is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intelligent agent technology, and more specifically, to an intelligent agent memory management method and apparatus based on a decoder memory component. Background Technology

[0002] The memory management of intelligent agents exhibits complex and diverse characteristics, relying not on a single technology but on a systematic architecture supported by a combination of complementary capabilities. Currently, memory management schemes for intelligent agents mainly include several types: sliding window-based schemes, vector database-based schemes, knowledge graph-based schemes, and neural network-based schemes.

[0003] However, the above-mentioned technical solutions all have certain drawbacks. The sliding window mechanism makes it impossible for the agent to backtrack on crucial initial information when dealing with complex tasks that rely on early details or span multiple rounds of conversation, resulting in impaired contextual coherence and severely restricting its ability to maintain logical consistency and perform deep reasoning in long-term interactions. For vector database-based solutions, the fine semantic information such as entity relationships, logical chains, and temporal structures contained in the original dialogue is compressed or even lost, resulting in a lack of necessary contextual association and logical interpretability, making it difficult to support the agent in carrying out multi-step reasoning or generating structurally rigorous and logically coherent responses. Knowledge graph construction is costly and has limited coverage, making it difficult to achieve real-time and lossless structuring of new knowledge, severely limiting its timeliness and ability to capture dynamic knowledge. The main limitation of neural network solutions lies in the computational overhead and inference latency bottleneck introduced by external memory modules. The dynamic read and write operations on external memory in each sequence processing step significantly increase the number of parameters and computational complexity, resulting in inference latency, making it difficult to apply on a large scale in actual deployment scenarios with high real-time requirements or limited computing resources. Summary of the Invention

[0004] The purpose of this application is to provide an intelligent agent memory management method and device based on a decoder memory component. By introducing an auxiliary small model, long-term memory is separated from the context window of the large language model, thereby realizing flexible management and persistent storage of long-term memory. This can efficiently capture new knowledge and avoid the loss of temporal structure information.

[0005] In a first aspect, embodiments of this application provide an intelligent agent memory management method based on a decoder memory component, the method comprising:

[0006] Obtain user input data;

[0007] The user input data is input into a pre-built large language model to generate a user response;

[0008] The user response is monitored asynchronously to extract multi-source information from the user feedback;

[0009] A training queue is generated based on the multi-source information;

[0010] After incremental training of the training queue, knowledge is solidified to realize intelligent agent memory management.

[0011] In the above implementation process, through techniques such as training of a large language model, asynchronous monitoring, and incremental training, and by introducing an auxiliary small model during the training of the large language model, long-term memory is separated from the context window of the large language model, thereby achieving flexible management and persistent storage of long-term memory. This enables efficient capture of new knowledge and avoids the loss of temporal structure information.

[0012] Furthermore, the step of inputting the user input data into a pre-built large language model to generate a user response includes:

[0013] The user input data is fed into a pre-built large language model to determine whether short-term memory is sufficient;

[0014] If so, reason directly and generate a user response;

[0015] If not, the user response is generated after recalling long-term memory according to the memory controller.

[0016] In the above implementation process, long-term memory is separated from the context window of the large language model, realizing persistent storage and independent management of long-term memory, avoiding context breakage, and ensuring that key information is not missed.

[0017] Furthermore, the step of generating a user response after recalling long-term memory according to the memory controller includes:

[0018] A retrieval signal is generated based on the memory controller;

[0019] The lightweight adapter module is subjected to multi-dimensional screening based on the search signal to obtain the relevance score of the lightweight adapter module.

[0020] The target lightweight adaptation module is selected based on the relevance score, and then enhanced inference is performed to generate the user response.

[0021] In the above implementation process, lightweight adaptation modules are screened in multiple dimensions, and lightweight adaptation modules with high scores are selected as target lightweight adaptation modules for enhanced reasoning. This can achieve rapid and efficient capture of knowledge and reduce the cost of acquiring new knowledge.

[0022] Further, the step of selecting a target lightweight adaptation module based on the relevance score, performing enhanced inference, and then generating the user response includes:

[0023] Determine whether the relevance score of the lightweight adapter module exceeds the scoring threshold;

[0024] If not, directly infer and generate the user response;

[0025] If so, a preset number of lightweight adaptation modules are selected as target lightweight adaptation modules and loaded into the decoder memory component to generate prompt text. After the prompt text is securely filtered and compressed, it is fused with the user input data to obtain enhanced input data. Based on the enhanced input data, inference is performed to obtain the user response.

[0026] In the above implementation process, when the relevance score exceeds the score threshold, the target lightweight adaptation module is selected and loaded into the decoder memory component, and the prompt text is subjected to security filtering and compression processing, so that the reasoning process is more logically coherent and the enhanced input data can contain more complex causal chains and temporal dependencies.

[0027] Further, the step of generating the training queue based on the multi-source information includes:

[0028] The multi-source information is fused and analyzed to obtain the key index of each piece of information;

[0029] Determine whether the critical index is below the critical index threshold;

[0030] If so, discard the message;

[0031] If not, perform knowledge classification on the multi-source information to generate the training queue.

[0032] In the above implementation process, knowledge classification of multi-source information that meets the key index can improve the coverage of training sample data, avoid interference from irrelevant knowledge, and improve the accuracy of training results.

[0033] Furthermore, the step of classifying the multi-source information to generate the training queue includes:

[0034] The multi-source information is structured and extracted to obtain the first training sample;

[0035] Add metadata to the first training sample to obtain the second training sample;

[0036] The second training sample is added to the original training queue to generate the training queue.

[0037] In the above implementation process, the structured extraction of multi-source information and the addition of metadata to generate a training queue can achieve efficient training, reduce data redundancy, and reduce the consumption of storage and computing resources during the training process.

[0038] Furthermore, the step of solidifying knowledge after incremental training of the training queue includes:

[0039] Detect whether incremental training has been triggered;

[0040] If so, construct a training model, perform incremental training on the training queue, and obtain a lightweight adaptation module sequence;

[0041] The lightweight adaptation module sequence is solidified with knowledge, and the training queue is cleared to complete the training.

[0042] In the above implementation process, after triggering incremental training, a lightweight adaptation module sequence is obtained, and then knowledge is solidified on the lightweight adaptation module sequence to avoid the knowledge defects and instability of the large language model and achieve comprehensive coverage of knowledge.

[0043] Furthermore, the step of constructing the training model includes:

[0044] Freeze the preceding lightweight adapter module and initialize the new lightweight adapter module;

[0045] The training model is generated by combining the basic decoder memory component with the frozen lightweight adapter module and performing low-rank adaptation on the new lightweight adapter module.

[0046] In the above implementation process, freezing the preceding lightweight adaptation module and initializing the new lightweight adaptation module can improve the stability and robustness of the training process and ensure that historical knowledge is not affected.

[0047] Further, the step of incrementally training the training queue to obtain a lightweight adaptation module sequence includes:

[0048] Incremental training is performed on the training queue, and the loss function is monitored during the training process to determine whether the loss function has converged.

[0049] If so, perform a quality assessment on the validation set. If the quality is not up to standard, retrain; if the quality is up to standard, freeze the new lightweight adapter module and append it to the end of the original lightweight adapter module sequence, build an index and add metadata to generate the lightweight adapter module sequence.

[0050] In the above implementation process, incremental training of the training queue can realize knowledge iteration, retain training capabilities, expand training capabilities, effectively improve training timeliness, and provide a guarantee for rapid knowledge iteration.

[0051] Furthermore, the steps of solidifying knowledge of the lightweight adaptation module sequence and clearing the training queue to complete training include:

[0052] Check whether the length of the lightweight adapter module sequence exceeds the length threshold;

[0053] If so, then compress and merge the lightweight adapter modules with the same semantics in the lightweight adapter module sequence, clear the training queue, and complete the training.

[0054] In the above implementation process, when the sequence length of the lightweight adaptation module is too long, it is compressed and merged to reduce redundancy, improve the effective utilization of storage resources, and improve the training process.

[0055] Secondly, embodiments of this application also provide an intelligent agent memory management device based on a decoder memory component, the device comprising:

[0056] The acquisition module is used to acquire user input data;

[0057] The input module is used to input the user input data into a pre-built large language model to generate a user response;

[0058] The asynchronous monitoring module is used to asynchronously monitor the user response and extract multi-source information from the user feedback;

[0059] The generation module is used to generate a training queue based on the multi-source information;

[0060] The training module is used to perform incremental training on the training queue and then solidify the knowledge to realize the intelligent agent's memory management.

[0061] In the above implementation process, through techniques such as training of a large language model, asynchronous monitoring, and incremental training, and by introducing an auxiliary small model during the training of the large language model, long-term memory is separated from the context window of the large language model, thereby achieving flexible management and persistent storage of long-term memory. This enables efficient capture of new knowledge and avoids the loss of temporal structure information.

[0062] Thirdly, an electronic device provided in this application includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method as described in any of the first aspects.

[0063] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in any of the first aspects.

[0064] Other features and advantages of this disclosure will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.

[0065] It can be implemented in accordance with the contents of the specification. The preferred embodiments of this application are described in detail below with reference to the accompanying drawings. Attached Figure Description

[0066] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation on the range. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0067] Figure 1 A flowchart illustrating an intelligent agent memory management method based on a decoder memory component is provided for embodiments of this application.

[0068] Figure 2 A schematic diagram of the structural composition of an intelligent agent memory management device based on a decoder memory component is provided for embodiments of this application;

[0069] Figure 3 This is a schematic diagram of the structural composition of the electronic device provided in the embodiments of this application. Detailed Implementation

[0070] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0071] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0072] The specific embodiments of this application will be described in further detail below with reference to the accompanying drawings and examples. The following examples are used to illustrate this application, but are not intended to limit the scope of this application.

[0073] The memory management of intelligent agents exhibits complex and diverse characteristics, relying not on a single technology but on a systematic architecture supported by a combination of complementary capabilities. Currently, existing memory management solutions for intelligent agents mainly include several types: sliding window-based methods, vector database-based methods, knowledge graph-based methods, and neural network-based methods, but all of these solutions have certain drawbacks.

[0074] This application proposes an adaptive intelligent agent memory management system based on a decoder memory component, which decouples the reasoning capabilities of a large language model (LLM) from the storage and updating of long-term memory, empowers the LLM with non-intrusive prompt text, and solves the problems of continuity, security and high cost of long-term memory.

[0075] Example 1

[0076] Figure 1 This is a flowchart illustrating an intelligent agent memory management method based on a decoder memory component provided in an embodiment of this application. Figure 1 As shown, the method includes:

[0077] S1, Obtain user input data;

[0078] S2, inputs user input data into a pre-built large language model to generate user response;

[0079] S3 asynchronously monitors user responses and extracts multi-source information from user feedback;

[0080] S4, Generate a training queue based on multi-source information;

[0081] S5 performs incremental training on the training queue and then solidifies the knowledge to achieve intelligent agent memory management.

[0082] In the above implementation process, through techniques such as training of a large language model, asynchronous monitoring, and incremental training, and by introducing an auxiliary small model during the training of the large language model, long-term memory is separated from the context window of the large language model, thereby achieving flexible management and persistent storage of long-term memory. This enables efficient capture of new knowledge and avoids the loss of temporal structure information.

[0083] Furthermore, S2 includes:

[0084] Input user data into a pre-built large language model to determine if short-term memory is sufficient;

[0085] If so, reason directly and generate a user response;

[0086] If not, a user response is generated after recalling long-term memory based on the memory controller.

[0087] In the above implementation process, long-term memory is separated from the context window of the large language model, realizing persistent storage and independent management of long-term memory, avoiding context breakage, and ensuring that key information is not missed.

[0088] Short-term memory retains the history of the most recent K rounds of dialogue (e.g., K=5–10), which is directly placed in the context window of the LLM for immediate and high-frequency interactions. A hierarchical context window strategy is adopted, dividing the window into four layers: system instructions, long-term summaries, recent text, and dynamic information. Each layer has a quota, and when it approaches the limit, it is eliminated based on importance score.

[0089] After user input data enters the Large Language Model (LLM), the system first determines whether short-term memory is sufficient. If it is sufficient, it directly infers and generates the user response; if it is insufficient, it activates the memory controller to recall long-term memory.

[0090] This application adds a section on cleaning, organizing, compressing, and extracting keywords from the content to be memorized, organizing this content into "memory blocks" with a specific structure, which is helpful for future retrieval. When using it, the original text can be output, or external document links can be used to retrieve external "memory banks".

[0091] Furthermore, the steps for generating a user response after the memory controller recalls long-term memory include:

[0092] The retrieval signal is generated based on the memory controller;

[0093] The lightweight adaptation module is screened in multiple dimensions based on the search signal to obtain the relevance score of the lightweight adaptation module.

[0094] Based on the relevance score, a target lightweight adaptation module is selected, and after enhanced inference, a user response is generated.

[0095] In the above implementation process, lightweight adaptation modules are screened in multiple dimensions, and lightweight adaptation modules with high scores are selected as target lightweight adaptation modules for enhanced reasoning. This can achieve rapid and efficient capture of knowledge and reduce the cost of acquiring new knowledge.

[0096] After the memory controller generates the retrieval signal, it performs multi-dimensional filtering on the lightweight adapter module, including three dimensions: time, semantics, and entity, and scores and ranks the lightweight adapter module based on its relevance.

[0097] Transform the current dialogue summary and user query into a retrieval signal (Query Prompt).

[0098] Furthermore, the steps of selecting a target lightweight adaptation module based on the relevance score, performing enhanced inference, and then generating a user response include:

[0099] Determine whether the relevance score of the lightweight adaptation module exceeds the scoring threshold;

[0100] If not, proceed with direct reasoning to generate a user response;

[0101] If so, a preset number of lightweight adapter modules are selected as target lightweight adapter modules and loaded into the decoder memory component to generate prompt text. After the prompt text is securely filtered and compressed, it is fused with the user input data to obtain enhanced input data. Based on the enhanced input data, inference is performed to obtain the user response.

[0102] In the above implementation process, when the relevance score exceeds the score threshold, the target lightweight adaptation module is selected and loaded into the decoder memory component, and the prompt text is subjected to security filtering and compression processing, so that the reasoning process is more logically coherent and the enhanced input data can contain more complex causal chains and temporal dependencies.

[0103] The system determines whether the relevance score exceeds the set threshold. If it does not exceed the threshold, it proceeds with inference. If it exceeds the threshold, it selects the Top-K lightweight adaptation modules as target lightweight adaptation modules and loads them into the DecoderMemory component.

[0104] The decoder memory component generates a prompt text (ContextPrompt) by accumulating the selected target lightweight adaptation module. After security filtering and compression, the prompt is fused with the original input (user input data).

[0105] LLM performs inference based on the fused and enhanced input data, generates a user response, and returns it to the user.

[0106] During the inference phase, the Memory Controller selects a subset S of relevant lightweight adaptation modules from the LoRA sequence based on the current task requirements and query semantics (e.g., lightweight adaptation modules involving user history preferences + domain-specific lightweight adaptation modules). The Decoder Memory generates an effective model that incorporates multi-stage temporal knowledge by accumulating the weights of the activated lightweight adaptation modules. Specifically, the effective model parameters = base model parameters + the sum of the weights of all selected lightweight adaptation modules. This effective model is capable of high-order associative inference in the parameter space, thereby generating logically coherent prompt text containing complex causal chains and temporal dependencies.

[0107] The generation of prompt text effectively compensates for the knowledge fragmentation and semantic fidelity loss caused by vector retrieval.

[0108] The decoder memory component ultimately outputs text-based prompts. These prompts, as refined long-term memory, are securely and non-intrusively incorporated into the LLM input (enhanced input data). This ensures that the core weights and generalization capabilities of the LLM remain unaffected, achieving both security and robustness in knowledge application.

[0109] The Decoder Memory component generates structured cue text based on a combined activation model. This process itself is an efficient compression of long-term memory, avoiding the direct transmission of the original dialogue history into the LLM.

[0110] The selection and compression of long-term memory refers to the efficient screening of long-term memories by the memory controller during the reasoning stage.

[0111] The fusion of prompt text involves concatenating the generated prompt text to the front of the LLM, and the LLM then uses the fused complete context for reasoning and response.

[0112] Furthermore, S4 includes:

[0113] By fusing and analyzing information from multiple sources, a key index for each piece of information is obtained;

[0114] Determine whether the key index is below the key index threshold;

[0115] If so, discard the message;

[0116] If not, perform knowledge classification on the multi-source information and generate a training queue.

[0117] In the above implementation process, knowledge classification of multi-source information that meets the key index can improve the coverage of training sample data, avoid interference from irrelevant knowledge, and improve the accuracy of training results.

[0118] After the user responds and returns the response, asynchronous knowledge monitoring is initiated. It extracts dialogue content, tool call logs, and user feedback information in parallel, and performs fusion analysis on the above multi-source information. The keyness index of each piece of information is calculated through a knowledge value scorer.

[0119] If the criticality index is below 0.7 (criticality index threshold), the information is discarded and the process ends; if it is above 0.7, it proceeds to knowledge classification.

[0120] During each conversation or task execution between the Agent and the user, information that meets specific "key indices" (such as involving new entities, new preferences, or key decisions) is immediately extracted and transformed into structured training samples.

[0121] To ensure the efficiency of LoRA fine-tuning, the decoder memory component employs an hourly or task-level incremental update strategy. For example, a new round of LoRAAdapter creation and fine-tuning is automatically triggered every 500 highly critical samples accumulated or every hour.

[0122] Furthermore, the steps of classifying multi-source information to generate a training queue include:

[0123] The first training sample is obtained by extracting structured information from multiple sources.

[0124] Add metadata to the first training sample to obtain the second training sample;

[0125] The second training sample is added to the original training queue to generate the training queue.

[0126] In the above implementation process, the structured extraction of multi-source information and the addition of metadata to generate a training queue can achieve efficient training, reduce data redundancy, and reduce the consumption of storage and computing resources during the training process.

[0127] The information from multiple sources is extracted in a structured manner, and after adding metadata such as timestamps, tags, and entities, it is added to the training queue and incremental training is performed when subsequent triggering conditions are met.

[0128] Furthermore, S5 includes:

[0129] Detect whether incremental training has been triggered;

[0130] If so, construct a training model, perform incremental training on the training queue, and obtain a lightweight adaptation module sequence;

[0131] The lightweight adaptation module sequence is solidified with knowledge, and the training queue is cleared to complete the training.

[0132] In the above implementation process, after triggering incremental training, a lightweight adaptation module sequence is obtained, and then knowledge is solidified on the lightweight adaptation module sequence to avoid the knowledge defects and instability of the large language model and achieve comprehensive coverage of knowledge.

[0133] The system continuously detects triggering conditions, including sample quantity thresholds and time thresholds. Incremental training is initiated when either condition is met.

[0134] The system preprocesses the samples in the training queue, including deduplication and priority sorting, then freezes all preceding lightweight adapter modules and initializes new lightweight adapter modules.

[0135] Knowledge solidification means that key knowledge, execution experience (tool selection history), and user personalized preferences are treated as independent knowledge increment units. Each increment undergoes an independent Low-Rank Adaptation (LoRA) process, also known as LoRA fine-tuning. Knowledge is solidified into an immutable LoRA Adapter. This does not directly affect LLM; instead, each increment is solidified into an independent, immutable LoRA Adapter through sequential training.

[0136] Furthermore, the steps for building and training the model include:

[0137] Freeze the preceding lightweight adapter module and initialize the new lightweight adapter module;

[0138] The basic decoder memory component is combined with the frozen lightweight adapter module, and the new lightweight adapter module is low-rank adapted to generate a training model.

[0139] In the above implementation process, freezing the preceding lightweight adaptation module and initializing the new lightweight adaptation module can improve the stability and robustness of the training process and ensure that historical knowledge is not affected.

[0140] During training, the new lightweight adaptation module is fine-tuned based on the effective parameters of the current model. Effective parameters refer to the base model parameters plus the accumulated weights of all preceding lightweight adaptation modules, where all preceding lightweight adaptation modules are explicitly frozen (gradients are not backpropagated). This frozen inheritance mechanism ensures at the parameter level that the acquisition of new knowledge will not overwrite or disturb the fixed memories in the old lightweight adaptation modules.

[0141] When building the training model, the basic decoder memory component is combined with the frozen lightweight adaptation module (lightweight adaptation module), and low-rank adaptation (LoRA fine-tuning) is performed only on the new lightweight adaptation module to ensure that historical knowledge is not affected.

[0142] Further, the step of incrementally training the training queue to obtain a lightweight adaptation module sequence includes:

[0143] Incremental training is performed on the training queue, and the loss function is monitored during the training process to determine whether the loss function has converged.

[0144] If so, perform a quality assessment on the validation set. If the quality is not up to standard, retrain; if the quality is up to standard, freeze the new lightweight adapter module and append it to the end of the original lightweight adapter module sequence, build an index and add metadata to generate a lightweight adapter module sequence.

[0145] In the above implementation process, incremental training of the training queue can realize knowledge iteration, retain training capabilities, expand training capabilities, effectively improve training timeliness, and provide a guarantee for rapid knowledge iteration.

[0146] During training, the loss function is monitored in real time to determine if convergence has occurred. Once convergence is achieved, the quality is evaluated on the validation set; if the evaluation fails, the hyperparameters are adjusted and training is retrained.

[0147] Once the quality meets the standards, the new lightweight adapter module is frozen and persistently stored, appended to the end of the original lightweight adapter module sequence, an index is built, and metadata is added.

[0148] Furthermore, the steps of solidifying knowledge of the lightweight adaptation module sequence and clearing the training queue to complete training include:

[0149] Check if the length of the lightweight adapter module sequence exceeds the length threshold;

[0150] If so, then compress and merge the lightweight adapter modules with the same semantics in the lightweight adapter module sequence, clear the training queue, and complete the training.

[0151] In the above implementation process, when the sequence length of the lightweight adaptation module is too long, it is compressed and merged to reduce redundancy, improve the effective utilization of storage resources, and improve the training process.

[0152] Check if the length of the lightweight adaptation module sequence exceeds the length threshold. If it does, compress and merge lightweight adaptation modules that are close in time and semantics. Finally, clear the training queue to complete this round of training.

[0153] The LLM in this embodiment uses GPT-4o, and the decoder memory component uses Qwen-7B, with 28 lightweight adapter modules pre-installed. The system is configured with the MCP toolset, including: vulnerability list query, vendor product correction, vulnerability association query, network search, and result filtering tools.

[0154] For example, if the user input is "What high-risk vulnerabilities exist in Apache Log4j?", the LLM (Local Management Module) determines that short-term memory is sufficient and directly infers the vulnerability. The query is rewritten and semantically enhanced using the RAG (Research and Encode) mechanism to identify the keywords "Apache", "Log4j", and "high-risk vulnerabilities". The task planning phase is broken down into two sub-tasks: Sub-task 1 (vendor product name standardization) takes precedence over Sub-task 2 (vulnerability list query), and a sub-task queue is constructed.

[0155] Subtask 1 requires calling the vendor's product calibration tool to map "Apache Log4j" to a standard name. The first call fails due to an incorrect input format; the failure feedback is obtained and the status is recorded. The second attempt uses fuzzy matching parameters and successfully obtains the standard name "apache_log4j".

[0156] Execute subtask 2 to determine if the vulnerability list query tool needs to be called. Construct parameters: product=apache_log4j, severity=high. Return N high-risk vulnerability records. Confirm that the data is complete, determine that the subtask is complete, and output a completion flag.

[0157] After all subtasks are completed, the results are summarized to generate a final conclusion. Vulnerability information is aggregated, sorted by CVE number, and the data source and confidence level are marked. Finally, the result is returned to the user (user response): "High-risk vulnerabilities related to Apache Log4j were found, including CVE-2021-44228, etc.", along with an explanation of the reasoning path.

[0158] Upon receiving the response, asynchronous monitoring is initiated, synchronously extracting dialogue content, MCP tool call logs, and ReAct execution records. Multi-source information fusion analysis identifies: first-time failure experience with the vendor's product correction tool, a successful strategy involving fuzzy parameter matching, tool call dependencies (vendor correction takes precedence over vulnerability lookup), and the user's focus on the Apache Log4j product. The knowledge value scorer calculates a criticality index of 0.85 (exceeding the criticality index threshold), categorizing it as "tool experience" and "task planning experience." Structured extraction generates training samples, adding metadata (product: Apache Log4j; tool failure strategy; successful retry scheme), which are then added to the training queue.

[0159] When a user asks, "What serious vulnerabilities exist in Nginx?", the memory controller retrieves the most relevant lightweight adapter module (i.e., the target lightweight adapter module) from the lightweight adapter modules and activates it, thus achieving optimal tool selection and decision recommendation.

[0160] This application integrates the LoRA adaptation mechanism with an independent decoder memory component to construct a two-layer architecture that decouples parameterized memory and text. This architecture achieves long-term memory persistence and coherence, high semantic fidelity reasoning, low-cost and high-efficiency knowledge acquisition, secure and controllable knowledge fusion, efficient and lightweight system architecture, excellent engineering feasibility, and superior multi-user scalability, significantly outperforming existing solutions.

[0161] In this application, the decoder memory component stores not only static facts, but also the execution flow of historical tasks of the Agent, tool call sequences, success / failure cases and their decision-making basis.

[0162] During the agent decision-making phase, the knowledge hints generated by the decoder memory component may include experiential instructions.

[0163] Example 2

[0164] To execute the method corresponding to Embodiment 1 above and achieve the corresponding functional and technical effects, an intelligent agent memory management device based on a decoder memory component is provided below, such as... Figure 2 As shown, the device includes:

[0165] Module 1 is used to acquire user input data;

[0166] Input module 2 is used to input user input data into a pre-built large language model to generate user responses;

[0167] Asynchronous monitoring module 3 is used to asynchronously monitor user responses and extract multi-source information from user feedback;

[0168] Generation module 4 is used to generate training queues based on multi-source information;

[0169] Training module 5 is used to solidify knowledge after incremental training of the training queue, thereby realizing the memory management of the intelligent agent.

[0170] In the above implementation process, through techniques such as training of a large language model, asynchronous monitoring, and incremental training, and by introducing an auxiliary small model during the training of the large language model, long-term memory is separated from the context window of the large language model, thereby achieving flexible management and persistent storage of long-term memory. This enables efficient capture of new knowledge and avoids the loss of temporal structure information.

[0171] Furthermore, input module 2 is also used for:

[0172] Input user data into a pre-built large language model to determine if short-term memory is sufficient;

[0173] If so, reason directly and generate a user response;

[0174] If not, a user response is generated after recalling long-term memory based on the memory controller.

[0175] In the above implementation process, long-term memory is separated from the context window of the large language model, realizing persistent storage and independent management of long-term memory, avoiding context breakage, and ensuring that key information is not missed.

[0176] Furthermore, input module 2 is also used for:

[0177] The retrieval signal is generated based on the memory controller;

[0178] The lightweight adaptation module is screened in multiple dimensions based on the search signal to obtain the relevance score of the lightweight adaptation module.

[0179] Based on the relevance score, a target lightweight adaptation module is selected, and after enhanced inference, a user response is generated.

[0180] In the above implementation process, lightweight adaptation modules are screened in multiple dimensions, and lightweight adaptation modules with high scores are selected as target lightweight adaptation modules for enhanced reasoning. This can achieve rapid and efficient capture of knowledge and reduce the cost of acquiring new knowledge.

[0181] Furthermore, input module 2 is also used for:

[0182] Determine whether the relevance score of the lightweight adaptation module exceeds the scoring threshold;

[0183] If not, proceed with direct reasoning to generate a user response;

[0184] If so, a preset number of lightweight adapter modules are selected as target lightweight adapter modules and loaded into the decoder memory component to generate prompt text. After the prompt text is securely filtered and compressed, it is fused with the user input data to obtain enhanced input data. Based on the enhanced input data, inference is performed to obtain the user response.

[0185] In the above implementation process, when the relevance score exceeds the score threshold, the target lightweight adaptation module is selected and loaded into the decoder memory component, and the prompt text is subjected to security filtering and compression processing, so that the reasoning process is more logically coherent and the enhanced input data can contain more complex causal chains and temporal dependencies.

[0186] Furthermore, the generation module 4 is also used for:

[0187] By fusing and analyzing information from multiple sources, a key index for each piece of information is obtained;

[0188] Determine whether the key index is below the key index threshold;

[0189] If so, discard the message;

[0190] If not, perform knowledge classification on the multi-source information and generate a training queue.

[0191] In the above implementation process, knowledge classification of multi-source information that meets the key index can improve the coverage of training sample data, avoid interference from irrelevant knowledge, and improve the accuracy of training results.

[0192] Furthermore, the generation module 4 is also used for:

[0193] The first training sample is obtained by extracting structured information from multiple sources.

[0194] Add metadata to the first training sample to obtain the second training sample;

[0195] The second training sample is added to the original training queue to generate the training queue.

[0196] In the above implementation process, the structured extraction of multi-source information and the addition of metadata to generate a training queue can achieve efficient training, reduce data redundancy, and reduce the consumption of storage and computing resources during the training process.

[0197] Furthermore, training module 5 is also used for:

[0198] Detect whether incremental training has been triggered;

[0199] If so, construct a training model, perform incremental training on the training queue, and obtain a lightweight adaptation module sequence;

[0200] The lightweight adaptation module sequence is solidified with knowledge, and the training queue is cleared to complete the training.

[0201] In the above implementation process, after triggering incremental training, a lightweight adaptation module sequence is obtained, and then knowledge is solidified on the lightweight adaptation module sequence to avoid the knowledge defects and instability of the large language model and achieve comprehensive coverage of knowledge.

[0202] Furthermore, training module 5 is also used for:

[0203] Freeze the preceding lightweight adapter module and initialize the new lightweight adapter module;

[0204] The basic decoder memory component is combined with the frozen lightweight adapter module, and the new lightweight adapter module is low-rank adapted to generate a training model.

[0205] In the above implementation process, freezing the preceding lightweight adaptation module and initializing the new lightweight adaptation module can improve the stability and robustness of the training process and ensure that historical knowledge is not affected.

[0206] Furthermore, training module 5 is also used for:

[0207] Incremental training is performed on the training queue, and the loss function is monitored during the training process to determine whether the loss function has converged.

[0208] If so, perform a quality assessment on the validation set. If the quality is not up to standard, retrain; if the quality is up to standard, freeze the new lightweight adapter module and append it to the end of the original lightweight adapter module sequence, build an index and add metadata to generate a lightweight adapter module sequence.

[0209] In the above implementation process, incremental training of the training queue can realize knowledge iteration, retain training capabilities, expand training capabilities, effectively improve training timeliness, and provide a guarantee for rapid knowledge iteration.

[0210] Furthermore, training module 5 is also used for:

[0211] Check if the length of the lightweight adapter module sequence exceeds the length threshold;

[0212] If so, then compress and merge the lightweight adapter modules with the same semantics in the lightweight adapter module sequence, clear the training queue, and complete the training.

[0213] In the above implementation process, when the sequence length of the lightweight adaptation module is too long, it is compressed and merged to reduce redundancy, improve the effective utilization of storage resources, and improve the training process.

[0214] The intelligent agent memory management device based on the decoder memory component described above can implement the method of Embodiment 1. The options in Embodiment 1 described above are also applicable to this embodiment, and will not be described in detail here.

[0215] The remaining contents of this embodiment can be referred to the contents of Embodiment 1 above, and will not be repeated in this embodiment.

[0216] Example 3

[0217] This application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor runs the computer program to enable the electronic device to execute the intelligent agent memory management method based on the decoder memory component of Embodiment 1.

[0218] Alternatively, the aforementioned electronic device may be a server.

[0219] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating the structural composition of an electronic device provided in an embodiment of this application. The electronic device may include a processor 31, a communication interface 32, a memory 33, and at least one communication bus 34. The communication bus 34 is used to enable direct communication between these components.

[0220] Optionally, the electronic device may also include a storage controller and an input / output unit. The memory 33, storage controller, processor 31, peripheral interface, and input / output unit are electrically connected to each other directly or indirectly to realize data transmission or interaction.

[0221] Input / output units are used to enable users to create tasks and set optional start periods or preset execution times for those tasks, facilitating user-server interaction. Input / output units can be, but are not limited to, a mouse and keyboard.

[0222] Understandable. Figure 3 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 3 The more or fewer components shown, or having the same Figure 3 Different configurations are shown. Additionally, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the intelligent agent memory management method based on a decoder memory component as described in Embodiment 1.

[0223] This application also provides a computer program product that, when run on a computer, causes the computer to perform the method described in the method embodiment.

[0224] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0225] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.

Claims

1. A method for intelligent agent memory management based on a decoder memory component, characterized in that, The method includes: Obtain user input data; The user input data is input into a pre-built large language model to generate a user response; The user response is monitored asynchronously to extract multi-source information from the user feedback; A training queue is generated based on the multi-source information; After incremental training of the training queue, knowledge is solidified to realize intelligent agent memory management; The step of inputting the user input data into a pre-built large language model to generate a user response includes: The user input data is fed into a pre-built large language model to determine whether short-term memory is sufficient; If so, directly infer and generate the user response; If not, the user response is generated after the memory controller recalls long-term memory. The step of generating the user response after recalling long-term memory according to the memory controller includes: A retrieval signal is generated based on the memory controller; The lightweight adapter module is subjected to multi-dimensional screening based on the search signal to obtain the relevance score of the lightweight adapter module. The target lightweight adaptation module is selected based on the relevance score, and then enhanced inference is performed to generate the user response. The step of generating the user response after selecting the target lightweight adaptation module based on the relevance score for enhanced inference includes: Determine whether the relevance score of the lightweight adapter module exceeds the scoring threshold; If not, directly infer and generate the user response; If so, a preset number of lightweight adaptation modules are selected as target lightweight adaptation modules and loaded into the decoder memory component to generate prompt text. After the prompt text is securely filtered and compressed, it is fused with the user input data to obtain enhanced input data. The user response is obtained by reasoning based on the enhanced input data. Specifically, the decoder memory component generates an effective model that integrates multi-stage temporal knowledge by accumulating the selected target lightweight adaptation module. This effective model is capable of high-order relational reasoning in the parameter space, thereby generating prompt text that is logically coherent and contains complex causal chains and temporal dependencies.

2. The intelligent agent memory management method based on the decoder memory component according to claim 1, characterized in that, The step of generating the training queue based on the multi-source information includes: The multi-source information is fused and analyzed to obtain the key index of each piece of information; Determine whether the critical index is below the critical index threshold; If so, discard the message; If not, perform knowledge classification on the multi-source information to generate the training queue.

3. The intelligent agent memory management method based on the decoder memory component according to claim 2, characterized in that, The step of classifying the multi-source information to generate the training queue includes: The multi-source information is structured and extracted to obtain the first training sample; Add metadata to the first training sample to obtain the second training sample; The second training sample is added to the original training queue to generate the training queue.

4. The intelligent agent memory management method based on the decoder memory component according to claim 1, characterized in that, The step of knowledge solidification after incremental training of the training queue includes: Detect whether incremental training has been triggered; If so, construct a training model, perform incremental training on the training queue, and obtain a lightweight adaptation module sequence; The lightweight adaptation module sequence is solidified with knowledge, and the training queue is cleared to complete the training.

5. The intelligent agent memory management method based on the decoder memory component according to claim 4, characterized in that, The steps for constructing the training model include: Freeze the preceding lightweight adapter module and initialize the new lightweight adapter module; The training model is generated by combining the basic decoder memory component with the frozen lightweight adapter module and performing low-rank adaptation on the new lightweight adapter module.

6. The intelligent agent memory management method based on the decoder memory component according to claim 5, characterized in that, The step of incrementally training the training queue to obtain a lightweight adaptation module sequence includes: Incremental training is performed on the training queue, and the loss function is monitored during the training process to determine whether the loss function has converged. If so, perform a quality assessment on the validation set. If the quality is not up to standard, retrain; if the quality is up to standard, freeze the new lightweight adapter module and append it to the end of the original lightweight adapter module sequence, build an index and add metadata to generate the lightweight adapter module sequence.

7. The intelligent agent memory management method based on the decoder memory component according to claim 6, characterized in that, The steps of solidifying knowledge of the lightweight adaptation module sequence and clearing the training queue to complete training include: Check whether the length of the lightweight adapter module sequence exceeds the length threshold; If so, then compress and merge the lightweight adapter modules with the same semantics in the lightweight adapter module sequence, clear the training queue, and complete the training.

8. An intelligent agent memory management device based on a decoder memory component, characterized in that, The device includes: The acquisition module is used to acquire user input data; The input module is used to input the user input data into a pre-built large language model to generate a user response; The asynchronous monitoring module is used to asynchronously monitor the user response and extract multi-source information from the user feedback; The generation module is used to generate a training queue based on the multi-source information; The training module is used to perform incremental training on the training queue and then solidify the knowledge to realize the intelligent agent's memory management. The input module is also used for: The user input data is fed into a pre-built large language model to determine whether short-term memory is sufficient; If so, directly infer and generate the user response; If not, the user response is generated after the memory controller recalls long-term memory. A retrieval signal is generated based on the memory controller; The lightweight adapter module is subjected to multi-dimensional screening based on the search signal to obtain the relevance score of the lightweight adapter module. The target lightweight adaptation module is selected based on the relevance score, and then enhanced inference is performed to generate the user response. Determine whether the relevance score of the lightweight adapter module exceeds the scoring threshold; If not, directly infer and generate the user response; If so, a preset number of lightweight adaptation modules are selected as target lightweight adaptation modules and loaded into the decoder memory component to generate prompt text. After the prompt text is securely filtered and compressed, it is fused with the user input data to obtain enhanced input data. The user response is obtained by reasoning based on the enhanced input data. Specifically, the decoder memory component generates an effective model that integrates multi-stage temporal knowledge by accumulating the selected target lightweight adaptation module. This effective model is capable of high-order relational reasoning in the parameter space, thereby generating prompt text that is logically coherent and contains complex causal chains and temporal dependencies.

9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method as described in any one of claims 1-7.

10. A storage medium, characterized in that, The storage medium stores instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-7.