Method and device for memory management of agent of dynamic routing, equipment, storage medium and computer program product
By implementing structured preprocessing and dynamic routing management for the agent memory system, the problem of insufficient accuracy in retrieval results in multi-turn dialogues and long-term tasks is solved, achieving more efficient memory management and more accurate retrieval results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN EMDOOR DIGITAL TECH
- Filing Date
- 2026-03-17
- Publication Date
- 2026-06-30
AI Technical Summary
Existing intelligent agent memory systems lack classification management and retrieval scope control for different types of memory in multi-turn dialogues and long-term tasks, resulting in poor accuracy of retrieval results. Furthermore, the lack of a decision-making mechanism in the writing stage can easily lead to the accumulation of redundant, conflicting, and expired information. In the retrieval stage, single-path recall is prone to missed recalls or insufficient matching.
By acquiring the content to be written and performing structured preprocessing, a candidate memory set is retrieved within the user scope based on feature information. The target storage category and writing action are determined by the write decision module, forming a consistent set of memory entries. On the retrieval side, the retrieval scope is limited by the context information and permission information of the user query, and vector and keyword recall is performed. The candidate set is deduplicated and reordered through mapping relationships.
It improves the accuracy of retrieval results in the intelligent agent's memory system, reduces redundancy and conflicts, ensures that the memory content is more relevant and less redundant, and improves the relevance and usability of the intelligent agent's generated output.
Smart Images

Figure CN122309721A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent agent memory and knowledge management technology, and in particular to a dynamic routing intelligent agent memory management method, device, equipment, storage medium and computer program product. Background Technology
[0002] As large-scale model-driven agents are increasingly used in customer service, office assistant, and knowledge-based question-answering scenarios, these agents typically need to continuously accumulate user-related information during multi-turn dialogues and long-term tasks to enable personalized understanding and behavioral decisions in subsequent interactions. Existing technologies commonly store dialogue fragments, user preferences, and task records in text format, further employing vectorization to construct a memory bank. When the memory is needed, a query vector is generated based on the user query, a similarity search is performed in the memory bank to return candidate content, and this candidate content is then concatenated with prompts or context to drive the model's output generation. However, in practical applications, the above solutions still have shortcomings: On the one hand, the sources of memory content are diverse and their nature varies greatly. If there is a lack of classification management and retrieval scope control for different types of memory, a large number of irrelevant candidates are easily generated in the full dataset during retrieval. On the other hand, the writing stage often adopts direct addition or simple overwriting, lacking a mechanism to make decisions based on existing memory within the user scope. It is difficult to determine whether to add, update, delete, or retain, which can easily lead to redundancy, conflicts, and the accumulation of expired information. In addition, the retrieval stage usually only uses single-path vector recall. When faced with short queries, semantic ambiguity, or significant keywords, it is easy to miss or insufficiently match. At the same time, short-term context and permission constraints are not uniformly incorporated into retrieval routing and filtering conditions, making it difficult to determine the memory categories to be accessed and the constraint rules to be satisfied before retrieval, resulting in poor accuracy of retrieval results. Therefore, how to improve the accuracy of retrieval results of intelligent agent memory systems has become an urgent technical problem to be solved. Summary of the Invention
[0003] The main objective of this application is to provide a dynamic routing intelligent agent memory management method, device, equipment, storage medium, and computer program product, aiming to solve the technical problem of how to improve the accuracy of retrieval results of intelligent agent memory systems.
[0004] To achieve the above objectives, this application provides a dynamic routing agent memory management method, the method comprising the following steps: Obtain the content to be written and perform structured preprocessing on the content to be written to obtain the feature information to be written; Within the user range corresponding to the content to be written, a candidate memory set is retrieved based on the feature information to be written, and the feature information to be written and the candidate memory set are input into the write decision module to output the target storage category and the target write action; Based on the target storage category and the target write action, the memory data is written or optimized and updated to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, multiple corresponding sub-representations are generated, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed based on the sub-representations. Obtain user query and corresponding short-term context information and permission information; perform semantic representation on user query to obtain query representation; and determine the target storage category set to be retrieved and retrieval constraint information based on query representation, short-term context information and permission information. Within the target storage category set, vector recall is performed based on the query representation and the retrieval constraint information, and keyword recall is performed based on the query representation to obtain a multi-way candidate set. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. The agent is then driven to generate output results based on the fused memory set.
[0005] In one embodiment, the step of obtaining the content to be written and performing structured preprocessing on the content to be written to obtain the feature information to be written includes: Obtain the content to be written, and parse the content to be written based on the preset content type rules to obtain the content type identifier and the original field set corresponding to the content type identifier; Based on the content type identifier, the original field set is normalized to obtain a normalized field set, wherein the normalization process includes one or more of the following: field extraction, format unification, noise field removal, and sensitive field marking. Based on the standardized field set, a structured representation is constructed to obtain the feature information to be written.
[0006] In one embodiment, the step of retrieving a candidate memory set based on the write-to-write feature information within the user range corresponding to the content to be written, and inputting the write-to-write feature information and the candidate memory set into a write decision module to output the target storage category and the target write action, includes: Within the user range corresponding to the content to be written, a retrieval range constraint is determined based on the feature information to be written, and a subset of memories to be retrieved is obtained from the memory data based on the retrieval range constraint; Based on the feature information to be written, a similarity retrieval process is performed on the subset of memories to be retrieved to obtain a set of candidate memories that match the feature information to be written. The feature information to be written and the candidate memory set are input into the write decision module. Based on the correlation between the candidate memory set and the feature information to be written, a decision result is generated to output the target storage category and the target write action.
[0007] In one embodiment, the step of performing write processing or optimization update processing on memory data based on the target storage category and the target write action to form a set of memory entries, generating corresponding multiple sub-representations based on at least a portion of the memory entries in the set of memory entries, and constructing a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations includes: The memory data is classified and written according to the target storage category, and a writing strategy is determined according to the target writing action. When the target writing action is to add, the data corresponding to the content to be written is written as new memory data to the target storage category. When the target writing action is to update or delete, the target memory data corresponding to the content to be written in the candidate memory set is located and replaced, updated or deleted. When the target writing action is to keep, the storage state of the target memory data is maintained. Based on the writing strategy, the memory data after writing or optimization and update processing is organized into entries to obtain a set of memory entries. At least some memory entries are selected from the set of memory entries as parent memory entries, and multiple sub-representations are generated for the parent memory entries based on preset representation generation rules. The various sub-representations are vectorized to construct a set of sub-vectors, and an association mapping is established between each sub-vector in the set and its corresponding parent memory entry to obtain the mapping relationship from the sub-vector to the parent memory entry.
[0008] In one embodiment, the steps of obtaining a user query and corresponding short-term context information and permission information, performing semantic representation on the user query to obtain a query representation, and determining the target storage category set to be retrieved and retrieval constraint information based on the query representation, the short-term context information, and the permission information include: Obtain a user query, and obtain short-term context information and permission information corresponding to the user query, wherein the short-term context information is used to characterize the session context to which the user query belongs, and the permission information is used to characterize the access control conditions corresponding to the user query; The user query is semantically represented based on a preset semantic encoding strategy to obtain a query representation for retrieval and matching. Based on the query representation, the short-term context information, and the permission information, a retrieval route determination process is performed to determine the target storage category set to be retrieved and the retrieval constraint information.
[0009] In one embodiment, the steps of performing vector recall based on the query representation and the retrieval constraint information within the target storage category set, and performing keyword recall based on the query representation to obtain a multi-path candidate set, performing parent memory backtracking, deduplication, and reordering fusion processing on the multi-path candidate set based on the mapping relationship to output a fused memory set, and driving the agent to generate output results based on the fused memory set, include: Within the target storage category set, vector similarity retrieval processing is performed on the memory entry set and / or the sub-vector set based on the query representation and the retrieval constraint information to obtain a vector candidate set. The vector candidate set is then filtered based on the retrieval constraint information to obtain a first candidate set that satisfies the constraints. Based on the query representation, keyword matching retrieval processing is performed on the set of memory entries within the target storage category set to obtain a keyword candidate set. The keyword candidate set is then filtered to obtain a second candidate set that meets the constraints. The first candidate set and the second candidate set are then merged to obtain a multi-path candidate set. Based on the mapping relationship, the parent memory entries corresponding to the hit sub-vectors in the multi-path candidate set are backtracked and retrieved. The backtracked candidate results are deduplicated, reordered, and fused to output a fused memory set. The fused memory set is organized into an agent input context, and the agent is driven to generate output results based on the agent input context.
[0010] Furthermore, to achieve the above objectives, this application also proposes a dynamic routing agent memory management device, which includes: The write-to-be-written module is used to acquire the content to be written and perform structured preprocessing on the content to be written to obtain the write-to-be-written feature information; The storage output module is used to retrieve a candidate memory set based on the write-to-write feature information within the user range corresponding to the content to be written, and input the write-to-write feature information and the candidate memory set into the write decision module to output the target storage category and the target write action. The mapping module is used to perform write processing or optimization update processing on memory data based on the target storage category and the target write action to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, it generates a variety of corresponding sub-representations and constructs a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations. The query representation module is used to obtain user queries and short-term context information and permission information corresponding to the user queries, perform semantic representation on the user queries to obtain query representation, and determine the target storage category set to be retrieved and retrieval constraint information based on the query representation, the short-term context information and the permission information; The target module is used to perform vector recall based on the query representation and the retrieval constraint information within the target storage category set, and to perform keyword recall based on the query representation to obtain a multi-way candidate set. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. The fused memory set is then used to drive the agent to generate output results.
[0011] Furthermore, to achieve the above objectives, this application also proposes a dynamic routing agent memory management device, the device comprising: a memory, a processor, and a dynamic routing agent memory management program stored in the memory and executable on the processor, the dynamic routing agent memory management program being configured to implement the steps of the dynamic routing agent memory management method as described in any of the above embodiments.
[0012] In addition, to achieve the above objectives, this application also proposes a storage medium storing a dynamic routing agent memory management program, which, when executed by a processor, implements the steps of the dynamic routing agent memory management method described above.
[0013] In addition, to achieve the above objectives, this application also proposes a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the intelligent agent memory management method for dynamic routing as described above.
[0014] This application obtains the content to be written and performs structured preprocessing on it to obtain the feature information to be written. Within the user scope corresponding to the content to be written, a candidate memory set is retrieved based on the feature information to be written. The feature information to be written and the candidate memory set are input into a write decision module to output the target storage category and the target write action. Based on the target storage category and the target write action, the memory data is processed for writing or optimization and updating to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, multiple corresponding sub-representations are generated, and a set of sub-vectors and the sub-vectors to the parent memory entries are constructed based on the sub-representations. The process involves: mapping the target relationship; obtaining user queries and corresponding short-term context and permission information; semantically representing the user queries to obtain query representations; determining the target storage category set and retrieval constraints based on the query representation, short-term context, and permission information; performing vector recall based on the query representation and retrieval constraints within the target storage category set; performing keyword recall based on the query representation to obtain a multi-path candidate set; performing parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship on the multi-path candidate set to output a fused memory set; and driving the agent to generate output results based on the fused memory set. This application first performs structured preprocessing on the content to be written on the writing side to form the feature information to be written. Then, based on the feature information to be written, a candidate memory set is retrieved within the corresponding user range, and the write decision module determines the target storage category and the target write action. This allows the memory data to form a more consistent set of memory entries through write processing or optimization updates. At the same time, multiple sub-representations are generated for at least some memory entries, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed, so that subsequent retrieval can hit the sub-representations and backtrack to the parent memory entries. On the retrieval side, the query representation is obtained by combining the short-term context information and permission information of the user query, and the target storage category set and retrieval constraint information are determined. The recall is limited to the target range and subject to constraint filtering. Then, a multi-way candidate set is formed through vector recall and keyword recall. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. This makes the memory content entering the agent generation stage more relevant and less redundant, thereby improving the accuracy of the retrieval results from a mechanism perspective. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating the first embodiment of the intelligent agent memory management method for dynamic routing in this application. Figure 2 This is a schematic diagram of a sub-process in the second embodiment of the intelligent agent memory management method for dynamic routing in this application; Figure 3 This is a schematic diagram of a sub-process in the third embodiment of the intelligent agent memory management method for dynamic routing in this application; Figure 4 This is a schematic diagram of the overall architecture of a noise-suppressed, multi-path recall dynamic routing agent memory system in one embodiment of the dynamic routing agent memory management method of this application; Figure 5 This is a flowchart illustrating the overall dynamic route retrieval process in one embodiment of the intelligent agent memory management method for dynamic routing in this application. Figure 6 This is a schematic diagram of a multi-source memory bank hierarchical storage structure in one embodiment of the intelligent agent memory management method for dynamic routing in this application; Figure 7 This is a schematic diagram of the module structure of the intelligent agent memory management device for dynamic routing according to an embodiment of this application; Figure 8 This is a schematic diagram of the device structure of the hardware operating environment involved in the intelligent agent memory management method for dynamic routing in the embodiments of this application.
[0016] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0017] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of this application.
[0018] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0019] It's important to note that as large-model-driven agents become increasingly prevalent in scenarios such as customer service, office assistants, and knowledge-based question answering, these agents typically need to continuously accumulate user-related information during multi-turn dialogues and long-term tasks to enable personalized understanding and behavioral decisions in subsequent interactions. In existing technologies, a common approach is to store dialogue fragments, user preferences, task records, etc., in text format and further construct a memory using vectorized representation. When the memory needs to be accessed, a query vector is generated based on the user query, a similarity search is performed in the memory to return candidate content, and this candidate content is then concatenated with prompts or context to drive the model's output generation. However, in practical applications, the above solutions still have shortcomings: On the one hand, the sources of memory content are diverse and their nature varies greatly. If there is a lack of classification management and retrieval scope control for different types of memory, a large number of irrelevant candidates are easily generated in the full dataset during retrieval. On the other hand, the writing stage often adopts direct addition or simple overwriting, lacking a mechanism to make decisions based on existing memory within the user scope. It is difficult to determine whether to add, update, delete, or retain, which can easily lead to redundancy, conflicts, and the accumulation of expired information. In addition, the retrieval stage usually only uses single-path vector recall. When faced with short queries, semantic ambiguity, or significant keywords, it is easy to miss or insufficiently match. At the same time, short-term context and permission constraints are not uniformly incorporated into retrieval routing and filtering conditions, making it difficult to determine the memory categories to be accessed and the constraint rules to be satisfied before retrieval, resulting in poor accuracy of retrieval results. Therefore, how to improve the accuracy of retrieval results of intelligent agent memory systems has become an urgent technical problem to be solved.
[0020] The main solution of this application is as follows: First, acquire the content to be written and perform structured preprocessing on it to obtain the feature information to be written. Second, within the user scope corresponding to the content to be written, retrieve a candidate memory set based on the feature information to be written, and input the feature information to be written and the candidate memory set into a write decision module to output the target storage category and the target write action. Third, based on the target storage category and the target write action, perform write processing or optimization update processing on the memory data to form a memory entry set. Fourth, based on at least some memory entries in the memory entry set, generate corresponding multiple sub-representations, and construct a sub-vector set and sub-vector mapping based on the sub-representations. The mapping relationship of parent memory entries is established; user queries and corresponding short-term context information and permission information are obtained; semantic representation of user queries is performed to obtain query representation; and the target storage category set to be retrieved and retrieval constraint information are determined based on the query representation, short-term context information and permission information; within the target storage category set, vector recall is performed based on the query representation and retrieval constraint information, and keyword recall is performed based on the query representation to obtain a multi-way candidate set; the multi-way candidate set is subjected to parent memory backtracking, deduplication and reordering fusion processing based on the mapping relationship to output a fused memory set, and the agent is driven to generate output results based on the fused memory set.
[0021] This application first performs structured preprocessing on the content to be written on the writing side to form the feature information to be written. Then, based on the feature information to be written, a candidate memory set is retrieved within the corresponding user range, and the write decision module determines the target storage category and the target write action. This allows the memory data to form a more consistent set of memory entries through write processing or optimization updates. At the same time, multiple sub-representations are generated for at least some memory entries, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed, so that subsequent retrieval can hit the sub-representations and backtrack to the parent memory entries. On the retrieval side, the query representation is obtained by combining the short-term context information and permission information of the user query, and the target storage category set and retrieval constraint information are determined. The recall is limited to the target range and subject to constraint filtering. Then, a multi-way candidate set is formed through vector recall and keyword recall. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. This makes the memory content entering the agent generation stage more relevant and less redundant, thereby improving the accuracy of the retrieval results from a mechanism perspective.
[0022] It should be noted that the executing entity of the method in this embodiment can be a computing service device with data processing, network communication, and program execution functions, or it can be the aforementioned intelligent agent memory management device for dynamic routing with the same or similar functions. This embodiment and the following embodiments will be described using an intelligent agent memory management device for dynamic routing as an example.
[0023] Based on this, a first embodiment of the intelligent agent memory management method for dynamic routing in this application is proposed. Please refer to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the intelligent agent memory management method for dynamic routing in this application.
[0024] In this embodiment, the agent memory management method for dynamic routing includes the following steps: S1: Obtain the content to be written and perform structured preprocessing on the content to be written to obtain the feature information to be written; S2: Within the user range corresponding to the content to be written, a candidate memory set is retrieved based on the feature information to be written, and the feature information to be written and the candidate memory set are input into the write decision module to output the target storage category and the target write action; It should be noted that the content to be written is the new information carrier intended to enter the memory management system. Structured preprocessing involves parsing and standardizing the content to be written, transforming it into a structured representation that can be used for subsequent retrieval, matching, and writing decisions. The candidate memory set is the set of existing memories related to the content to be written, retrieved within the user scope based on the feature information to be written. The writing decision module is the decision-making unit that receives "feature information to be written + candidate memory set". The target storage category is the memory category determined by the writing decision module. The target writing action is the writing operation type determined by the writing decision module.
[0025] Specifically, after obtaining the content to be written, the content is preprocessed in a structured manner: for example, the content is first parsed to identify its basic components (such as text fragments, key entities / topic clues, source identifiers, and contextual clues), and the parsed information is standardized and structured to give it a unified representation that can be directly consumed by the subsequent retrieval and decision-making modules; in this structuring process, the writing feature information is output to characterize the content to be written, so that the writing feature information can serve as a consistent input basis for the subsequent "candidate retrieval" and "writing decision".
[0026] Furthermore, after obtaining the feature information to be written, a candidate search is performed within the user range corresponding to the content to be written: that is, using the feature information to be written as the search basis, a candidate memory set is retrieved from the existing memory data within the user range; subsequently, the feature information to be written and the candidate memory set are input into the write decision module, which makes a write decision based on the correlation between the feature information to be written and the candidate memory set, and outputs the target storage category and the target write action, wherein the target storage category is used to indicate the memory category to be written, and the target write action is used to indicate the write processing method such as adding, updating, deleting or keeping the content to be written.
[0027] Because these two steps first transform the content to be written into writing feature information that can be used for matching and judgment through structured preprocessing, and then retrieve a set of candidate memories based on the writing feature information within the user range corresponding to the content to be written, and input the writing feature information and the candidate memory set together into the writing decision module to output the target storage category and target writing action, the writing side can determine the classification position and processing method of the memory based on the association between "content to be written - existing candidate memory" under the premise of limiting the user range. This avoids the content to be written being written indiscriminately when there is no alignment object, or being repeatedly added when there is a related memory. Furthermore, by outputting the target storage category, differentiated storage of different categories of memories is achieved, making the subsequent retrieval more controllable in the category dimension. This comprehensively reduces the probability of irrelevant and duplicate memories entering the database and participating in subsequent retrieval matching, thereby providing the writing side with basic support for improving the relevance and accuracy of the intelligent agent memory system's retrieval results.
[0028] S3: Based on the target storage category and the target write action, perform write processing or optimization update processing on the memory data to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, generate corresponding multiple sub-representations, and construct a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations. It should be noted that write processing refers to performing new writes in the memory corresponding to the target storage class. Optimization and update processing involves maintenance processes such as merging, replacing, deleting, or maintaining existing memories. Memory data refers to the memory content to be maintained / written and its storage medium. The memory entry set is the set of searchable memory entries formed under the target storage class after write or optimization and update processing. A parent memory entry is a memory entry that serves as a complete memory medium, such as an "original dialogue segment / event segment." Sub-representations are representations of multiple simplified / restated perspectives constructed for each parent memory entry. The mapping relationship from sub-vectors to parent memory entries is the association used to trace back the matched sub-vectors to their corresponding parent memory entries.
[0029] Specifically, after obtaining the target storage category and the target write action, the target storage category is used as the basis for storage, and the memory data to be processed is routed to the corresponding memory domain. The target write action is used as the maintenance instruction to select whether to perform write processing or optimization update processing on the memory data: when the target write action is to add, a new memory entry is generated under the target storage category; when the target write action is to update, the new content is merged into the corresponding parent memory entry or its structured fragment as an incremental supplement to the existing memory; when the target write action is to delete, the memory entry that is determined to be removed is deleted or marked as unsearchable; when the target write action is to remain unchanged, the storage state of the existing entries is maintained, thereby forming a set of managed memory entries under the target storage category.
[0030] Furthermore, after forming a set of memory entries, at least some memory entries are selected from the set as parent memory entries, and multiple sub-representations are generated around the same parent memory entry. The sub-representations may include summary descriptions, keyword descriptions, related question descriptions, or entity phrase descriptions of the parent memory entry, so as to provide a multi-perspective expression of the same memory. Subsequently, each sub-representation is vectorized to obtain a set of sub-vectors, and a mapping relationship is established between each sub-vector and its source parent memory entry, so that when any sub-vector is hit in a subsequent retrieval, the corresponding parent memory entry can be back located through the mapping relationship.
[0031] Because this step determines the storage domain of memory entries based on the target storage category and drives the writing or optimization update of memory data with the target write action, the memory entry set undergoes a governance process of addition, update, deletion, or retention during the formation stage, avoiding the indiscriminate accumulation of memory data that introduces redundancy and conflicts. At the same time, by generating multiple sub-representations for at least some parent memory entries and constructing a set of sub-vectors and their mapping relationship to parent memory entries, the same parent memory entry obtains multiple searchable entry points. Even if a subsequent search hits a more easily matching sub-representation, it can still use the mapping relationship to trace back to the parent memory entry and return the complete content. Therefore, this step improves the organizational consistency and searchability of entries in the database through "classification storage + action governance" on the writing side, and improves the hit and traceability capabilities in scenarios with large differences from the query expression through "multiple sub-representations + sub-vector backtracking to parent memory". Both mechanisms jointly support the improvement of the relevance and accuracy of subsequent search results.
[0032] S4: Obtain the user query and the short-term context information and permission information corresponding to the user query, perform semantic representation on the user query to obtain the query representation, and determine the target storage category set to be retrieved and the retrieval constraint information based on the query representation, the short-term context information and the permission information; It should be noted that a user query is the retrieval request text submitted by the user in the current interaction. Short-term context information is the session context information corresponding to the user query. Permission information is information used to characterize the access control conditions corresponding to the user query. Semantic representation is the process of converting the user query into a semantic expression that can be used for subsequent matching and routing determination. Query representation is the query semantic expression result obtained from the semantic representation process and used for retrieval and routing determination. Retrieval constraint information is the retrieval constraint condition generated by routing determination. Routing determination is a determination process that first determines "which type of memory is most likely to be relied upon" before retrieval, and generates the retrieval scope and constraints accordingly.
[0033] Specifically, the process first obtains the user query and simultaneously obtains the short-term context information and permission information corresponding to the user query. The short-term context information is used to provide clues about the current conversation context, and the permission information is used to indicate the access control boundary. Based on this, semantic representation processing is performed on the user query to convert the user query into a query representation, so that the query representation can serve as a unified input representation for subsequent routing determination and retrieval matching.
[0034] Furthermore, after obtaining the query representation, the query representation, short-term context information, and permission information are used together for routing determination: on the one hand, the dependent memory type of the current problem is determined based on the query representation and short-term context information to determine the target storage category set to be retrieved; on the other hand, the permission information is used as the basis for constraint generation to form retrieval constraint information that matches the target storage category set, which is used to limit the memory range and filtering conditions that can be accessed in the subsequent retrieval process; wherein, the routing determination can be implemented by using rules, lightweight classifiers, or LLM tool calls, so as to complete the input preparation of "routing first, then retrieving" before retrieval.
[0035] Because this step incorporates user query, short-term context information, and permission information simultaneously before retrieval, and first performs semantic representation of the user query to obtain a query representation, and then completes routing determination based on the query representation, short-term context information, and permission information to output the target storage category set and retrieval constraint information, subsequent retrieval can be performed within the retrieval domain defined by the target storage category set, rather than performing an indiscriminate search on the entire memory; at the same time, the retrieval constraint information pre-fixes the access boundaries related to permissions into the input of the retrieval stage, so that memories that do not meet the constraints are restricted before entering the recall and candidate stages, thereby reducing the probability of irrelevant category memories and memories that should not be accessed entering the candidate set, and making subsequent recall and fusion more focused on memory content that is consistent with the current context and meets the access conditions, thus providing a pre-screening and range convergence basis for improving the relevance and accuracy of memory retrieval results.
[0036] S5: Within the target storage category set, perform vector recall based on the query representation and the retrieval constraint information, and perform keyword recall based on the query representation to obtain a multi-way candidate set. Perform parent memory backtracking, deduplication and reordering fusion processing on the multi-way candidate set based on the mapping relationship to output a fused memory set, and drive the agent to generate output results based on the fused memory set.
[0037] It should be noted that vector recall is a recall process performed within a selected library set based on the similarity between the query representation and the memory vector. Keyword recall is a recall process performed on a candidate text set (which can be the parent memory text or the child representation set) based on explicit term clues in the query representation. The multi-path candidate set is a candidate set obtained by aggregating different recall paths (vector recall, keyword recall, and recalls that may come from different libraries). Parent memory backtracking is the process of backtracking to obtain the corresponding parent memory set through mapping relationships when a child vector is matched in the multi-path candidate set, and returning the original parent memory text or structured fragment as a candidate.
[0038] Specifically, after obtaining the target storage category set, a recall is performed within the memory scope defined by the target storage category set: First, vector recall is performed based on query representation and retrieval constraint information, that is, vector similarity retrieval is performed in each selected memory using the query representation as the retrieval entry point, and the accessible range or candidate items are filtered according to the retrieval constraint information to obtain candidate results for the vector recall path; Second, keyword recall is performed based on query representation, that is, keyword matching recall is performed on the candidate text set using term clues in the query representation. The candidate text set can come from the parent memory text set or the sub-representation set corresponding to the parent memory to obtain candidate results for the keyword hitting path; Subsequently, the candidate results obtained from the vector recall path and the keyword recall path are aggregated to form a multi-path candidate set.
[0039] Furthermore, after obtaining the multi-path candidate set, a fusion process is performed on the multi-path candidate set: First, for the candidates in the multi-path candidate set that are hit by the sub-vector, parent memory backtracking is performed based on the mapping relationship to obtain the corresponding parent memory set, and the original text or structured fragment of the parent memory is included in the candidate range; Second, deduplication processing is performed on the candidate set including the parent memory backtracking results to avoid the same memory being repeatedly retained by multiple paths; Third, reordering fusion processing is performed on the deduplicated candidate set, that is, the candidate memories are scored and reordered, and the candidate sequences are uniformly fused by comprehensively considering the relevant factors of retrieval constraints, and a fused memory set is output; Finally, the fused memory set and the context are organized into an agent input prompt, and the agent is driven to generate the output result based on the fused memory set.
[0040] Because this step limits the retrieval to the target storage category set and introduces retrieval constraint information during vector recall, the recall scope and candidate items are first subject to dual constraints of category and constraint. At the same time, keyword recall is introduced as a supplementary channel based on query representation, so that the candidate set comes not only from semantically similar paths but also from explicit term matching paths, thus forming a multi-path candidate set with complementary coverage. On this basis, the sub-vector hit results are backtracked to the original text or structured fragments of the parent memory through parent memory backtracking based on mapping relationship, so that the final candidate and the memory carrier are consistent. Then, duplicate candidates from multiple paths are eliminated by deduplication, and candidates from different paths are uniformly scored and sorted by reordering and fusion, and a fused memory set is output, so that the memory content input into the agent is more concentrated and the sequence is more stable, thereby improving the relevance and availability of the memory on which the agent generates output.
[0041] This embodiment first performs structured preprocessing on the content to be written on the writing side to form the feature information to be written. Then, based on the feature information to be written, a candidate memory set is retrieved within the corresponding user range, and the write decision module determines the target storage category and the target write action. This allows the memory data to form a more consistent set of memory entries through write processing or optimization updates. At the same time, multiple sub-representations are generated for at least some memory entries, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed, so that subsequent retrieval can hit the sub-representations and backtrack to the parent memory entries. On the retrieval side, the query representation is obtained by combining the short-term context information and permission information of the user query, and the target storage category set and retrieval constraint information are determined. The recall is limited to the target range and subject to constraint filtering. Then, a multi-way candidate set is formed through vector recall and keyword recall. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. This makes the memory content entering the agent generation stage more relevant and less redundant, thereby improving the accuracy of the retrieval results from a mechanism perspective.
[0042] Based on the first embodiment described above, a second embodiment of the intelligent agent memory management method for dynamic routing of this application is proposed. Please refer to... Figure 2 , Figure 2 This is a schematic diagram of a sub-process in the second embodiment of the intelligent agent memory management method for dynamic routing in this application.
[0043] like Figure 2 As shown, in this embodiment, step S1 includes: S11: Obtain the content to be written, and parse the content to be written based on the preset content type rules to obtain the content type identifier and the original field set corresponding to the content type identifier; S12: Based on the content type identifier, the original field set is normalized to obtain a normalized field set, wherein the normalization process includes one or more of the following: field extraction, format unification, noise field removal, and sensitive field marking. S13: Based on the standardized field set, construct a structured representation to obtain the feature information to be written.
[0044] It should be noted that the preset content type rules are a pre-defined set of rules used for type identification and parsing of the content to be written. The content type identifier is a type label obtained by parsing the content to be written according to the preset content type rules. The original field set is a set of fields parsed from the content to be written based on the content type identifier. Sensitive field markers are used to mark fields that may involve access control or compliance requirements, so that subsequent write decisions and retrieval constraints can reference permission-related information.
[0045] Specifically, upon acquiring the content to be written, the system first parses the content according to preset content type rules. This parsing identifies the organizational structure of the content and outputs a content type identifier. After obtaining the content type identifier, the system extracts the original field set from the content according to the field template corresponding to the content type identifier, thus breaking down content from different sources and in different forms into processable field units. Subsequently, the system performs normalization processing on the original field set based on the content type identifier: on the one hand, it extracts and unifies the format of fields to ensure consistency in field names, field formats, and field value ranges; on the other hand, it removes noisy fields to eliminate fields irrelevant to memory maintenance or with low information density; simultaneously, it marks sensitive fields related to permissions or privacy, providing referable field-level clues for subsequent writing decisions and retrieval constraints.
[0046] Furthermore, after the normalization process is completed, a structured representation is constructed based on the normalized field set. The fields and their relationships are organized into a unified data structure, which can be directly used to retrieve candidate memory sets within the user scope and input into the write decision module to determine the target storage category and target write action. Based on this structured representation, the feature information to be written is generated, so that the feature information to be written can consistently represent the key elements, context clues and sensitive markers of the content to be written.
[0047] This step first parses the content to be written into a content type identifier and a set of original fields using preset content type rules. Then, based on the content type identifier, it performs normalization processing on the original field set, such as field extraction, format unification, noise field removal, and sensitive field marking. This transforms heterogeneous input content with different granularities into a consistent set of normalized fields. Furthermore, it constructs a structured representation based on this set of normalized fields and generates the feature information to be written. This allows the subsequent "candidate memory retrieval within the user range" and "determination of target storage category and target writing action by the write decision module" to be matched and decided in a unified feature space. Therefore, it can reduce candidate retrieval bias caused by inconsistent input expressions, reduce the probability of irrelevant information entering the subsequent processing chain by removing noise fields, and provide basic clues for subsequent permission-related constraints by marking sensitive fields. This provides a more stable feature input for accurate alignment and controllable data storage in the write closed loop.
[0048] Based on the first embodiment described above, in this embodiment, step S2 includes: S21: Within the user range corresponding to the content to be written, determine the retrieval range constraint based on the feature information to be written, and filter out the memory subset to be retrieved from the memory data based on the retrieval range constraint; S22: Based on the feature information to be written, perform similarity retrieval processing on the subset of memories to be retrieved to obtain a set of candidate memories that match the feature information to be written; S23: Input the feature information to be written and the candidate memory set into the write decision module, generate a decision result based on the correlation between the candidate memory set and the feature information to be written, and output the target storage category and the target write action.
[0049] It should be noted that the subset of memories to be retrieved is a subset selected from the memory data under the constraint of the retrieval scope, serving as a candidate retrieval domain for similarity retrieval. Similarity retrieval processing uses the feature information to be written as the query basis, performing similarity matching within the subset of memories to be retrieved to return relevant memory entries. The association relationship is the matching / correspondence between the candidate memory set and the feature information to be written.
[0050] Specifically, within the user scope corresponding to the content to be written, the system reads the memory data and its metadata within that user scope, and determines the retrieval scope constraints based on the feature information to be written, thus limiting the candidate retrieval to the memory scope related to the context of the content to be written. These retrieval scope constraints can be manifested as limitations on scope conditions such as user identifier, session identifier, time clues, and access level. Subsequently, the system filters the memory data to obtain a subset of memories to be retrieved based on the retrieval scope constraints, so that subsequent similarity searches do not need to be performed on the entire memory, but rather on the subset after the scope constraints have converged.
[0051] Furthermore, after obtaining the subset of memories to be retrieved, a similarity search is performed on the subset of memories to be retrieved based on the feature information to be written, resulting in a candidate memory set that matches the feature information to be written. The candidate memory set is used to represent existing memory entries that may duplicate, be merged, or need to be replaced with the content to be written. Subsequently, the feature information to be written and the candidate memory set are input into the write decision module. The write decision module generates a decision result based on the correlation between the candidate memory set and the feature information to be written, and then outputs the target storage category and the target write action, providing clear instructions for subsequent write processing or optimization update processing.
[0052] This step first determines the retrieval range constraints and filters the memory subset to be retrieved based on the feature information to be written within the user scope. This limits the matching objects of the similarity retrieval to the memory range related to the content to be written, thereby reducing the probability of irrelevant memories entering the candidate set. Furthermore, by performing similarity retrieval on the memory subset to be retrieved to obtain a candidate memory set, the content to be written obtains an existing memory reference that can be aligned before writing. The feature information to be written and the candidate memory set are then input into the writing decision module, and the target storage category and target writing action are output based on their correlation. This allows the writing action to form a decision result around "whether the existing candidate matches and how to handle it". This mechanism avoids the content to be written from being repeatedly added or having inconsistent writing positions when there is a lack of alignment judgment, thus providing a foundation for the orderly maintenance and controllable storage of subsequent memory entries.
[0053] This embodiment first performs structured preprocessing on the content to be written on the writing side to form the feature information to be written. Then, based on the feature information to be written, a candidate memory set is retrieved within the corresponding user range, and the write decision module determines the target storage category and the target write action. This allows the memory data to form a more consistent set of memory entries through write processing or optimization updates. At the same time, multiple sub-representations are generated for at least some memory entries, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed, so that subsequent retrieval can hit the sub-representations and backtrack to the parent memory entries. On the retrieval side, the query representation is obtained by combining the short-term context information and permission information of the user query, and the target storage category set and retrieval constraint information are determined. The recall is limited to the target range and subject to constraint filtering. Then, a multi-way candidate set is formed through vector recall and keyword recall. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. This makes the memory content entering the agent generation stage more relevant and less redundant, thereby improving the accuracy of the retrieval results from a mechanism perspective.
[0054] Based on the second embodiment described above, a third embodiment of the intelligent agent memory management method for dynamic routing in this application is proposed. Please refer to... Figure 3 , Figure 3 This is a schematic diagram of a sub-process in the third embodiment of the intelligent agent memory management method for dynamic routing in this application.
[0055] In this embodiment, step S3 includes: S31: Perform a classification writing process on the memory data based on the target storage category, and determine a writing strategy based on the target writing action. When the target writing action is to add, the data corresponding to the content to be written is written as new memory data into the target storage category. When the target writing action is to update or delete, locate the target memory data corresponding to the content to be written in the candidate memory set and perform replacement, update or delete processing. When the target writing action is to keep, maintain the storage state of the target memory data. S32: Based on the writing strategy, the memory data after the writing process or optimization update process is organized into entries to obtain a set of memory entries, and at least some memory entries are selected from the set of memory entries as parent memory entries, and multiple sub-representations are generated for the parent memory entries based on preset representation generation rules; S33: The various sub-representations are vectorized to construct a set of sub-vectors, and an association mapping is established between each sub-vector in the set of sub-vectors and its corresponding parent memory entry to obtain the mapping relationship from sub-vectors to parent memory entries.
[0056] It should be noted that the categorized write process is the process of routing memory data to the corresponding memory bank and performing write / maintenance based on the target storage category. The write strategy is the specific processing strategy determined based on the target write action. Itemized organization is the process of organizing and maintaining memory data after write processing or optimization update processing by item unit. Preset representation generation rules are a set of pre-defined rules used to generate multiple sub-representations from parent memory entries.
[0057] Specifically, after receiving the target storage category and the target write action, the system first performs a categorized write process on the memory data according to the target storage category, routing the data to be processed to the memory domain corresponding to the target storage category. Then, based on the target write action, a write strategy is determined and corresponding processing is executed: when the target write action is an add operation, the data corresponding to the content to be written is written as new memory data to the target storage category; when the target write action is an update or delete operation, the target memory data corresponding to the content to be written is first located in the candidate memory set, and then replacement / update or deletion processing is performed on the target memory data; when the target write action is a hold operation, the storage state of the target memory data remains unchanged. Through the execution of the above write strategies, the memory data completes the write processing or optimized update processing while maintaining a consistent storage structure with the target storage category.
[0058] Furthermore, after completing the write processing or optimization update processing, the memory data is organized into entries based on the write strategy to obtain a set of memory entries. At least a portion of the memory entries are selected as parent memory entries, and multiple sub-representations are generated for each parent memory entry according to preset representation generation rules, so that the same parent memory entry has multiple perspectives for expression. Subsequently, the sub-representations are vectorized to construct a set of sub-vectors, and an association mapping is established between each sub-vector and its source parent memory entry, thus obtaining the mapping relationship from sub-vectors to parent memory entries. This allows subsequent retrieval of a sub-vector to trace back to the corresponding parent memory entry.
[0059] This step first performs a classification and writing process on the memory data according to the target storage category and determines the writing strategy based on the target writing action. This ensures that processes such as adding, updating, deleting, and maintaining are all performed on the target memory data located in the candidate memory set. As a result, orderly governance and consistent storage of memory data are achieved during the writing stage, reducing the probability of duplicate, conflicting, or invalid memories accumulating in the database. At the same time, by generating multiple sub-representations for at least some of the parent memory entries after itemization and vectorizing them to construct sub-vector sets, and then establishing a mapping relationship between sub-vectors and parent memory entries, the same parent memory entry has multiple retrieval entry points that can be hit. After hitting a sub-vector, it is possible to backtrack to the parent memory entry to return the complete memory carrier. On the one hand, this improves the organizational consistency and maintainability of the memory entry set, and on the other hand, it improves the hit rate and backtracking consistency in the subsequent retrieval stage, providing a basic support for the relevance and stability of the final fused memory set.
[0060] Based on the second embodiment described above, in this embodiment, step S4 includes: S41: Obtain a user query, and obtain short-term context information and permission information corresponding to the user query, wherein the short-term context information is used to characterize the session context to which the user query belongs, and the permission information is used to characterize the access control conditions corresponding to the user query. S42: Perform semantic representation processing on the user query based on a preset semantic encoding strategy to obtain a query representation for retrieval and matching; S43: Based on the query representation, the short-term context information, and the permission information, perform retrieval route determination processing to determine the target storage category set to be retrieved and retrieval constraint information.
[0061] It should be noted that the preset semantic encoding strategy is an encoding strategy for semantically representing user queries. Semantic representation processing is the semantic encoding process performed on user queries based on the preset semantic encoding strategy. The retrieval routing determination process is the process of determining the scope of memory categories to be retrieved and generating retrieval constraints based on the query representation and context / permission information before performing retrieval.
[0062] Specifically, the system first obtains the user query and simultaneously acquires the short-term context information and permission information corresponding to the user query. The short-term context information is used to represent the contextual clues of the session to which the user query belongs, and the permission information is used to represent the access control conditions corresponding to the query. Based on this, a preset semantic encoding strategy is invoked to perform semantic representation processing on the user query, converting the user query into a query representation for retrieval matching, so that subsequent retrieval routing determination and recall matching can be based on a unified query semantic expression.
[0063] Furthermore, after obtaining the query representation, the query representation and short-term context information are used together to determine which type of memory content the current query relies on more, so as to determine the retrieval route and output the target storage category set to be retrieved. At the same time, the permission information is used as the basis for constraint generation, and is linked with the target storage category set to generate retrieval constraint information, so that subsequent recall and candidate screening are carried out under the dual constraints of category range and access control conditions, thereby completing the determination of the target storage category set and retrieval constraint information.
[0064] Because this step simultaneously acquires user query, short-term context information, and permission information before retrieval, and converts the user query into a query representation for retrieval matching based on a preset semantic encoding strategy, subsequent judgment and matching are based on a unified semantic expression. Furthermore, based on the query representation, short-term context information, and permission information, retrieval routing judgment processing is performed, outputting the target storage category set and retrieval constraint information. This allows subsequent retrieval to be conducted within the retrieval domain defined by the target storage category set, and candidate content is filtered under the access control conditions defined by the retrieval constraint information. Therefore, range convergence and constraint pre-positioning can be completed before recall, reducing the probability of irrelevant category memories and memories that do not meet access control conditions entering the candidate set, thereby providing a higher purity and more controllable candidate basis for subsequent vector / keyword recall and fusion processing.
[0065] Based on the second embodiment described above, in this embodiment, step S5 includes: S51: Within the target storage category set, based on the query representation and the retrieval constraint information, perform vector similarity retrieval processing on the memory entry set and / or the sub-vector set to obtain a vector candidate set, and filter the vector candidate set based on the retrieval constraint information to obtain a first candidate set that satisfies the constraints. S52: Based on the query representation, perform keyword matching retrieval processing on the set of memory entries in the target storage category set to obtain a keyword candidate set, and filter the keyword candidate set to obtain a second candidate set that meets the constraints. Then, merge the first candidate set and the second candidate set to obtain a multi-path candidate set. S53: Based on the mapping relationship, backtracking is performed on the parent memory entries corresponding to the hit sub-vectors in the multi-path candidate set, and the backtracked candidate results are deduplicated, reordered and fused to output a fused memory set. The fused memory set is organized into an agent input context, and the agent is driven to generate output results based on the agent input context.
[0066] It should be noted that vector similarity retrieval is a recall process based on the similarity between the query representation and the memory vectors (from the memory entry set and / or sub-vector set). The first candidate set is a set of candidates that meet the constraints after filtering the vector candidate set based on retrieval constraint information. The second candidate set is a set of candidates that meet the constraints after filtering the keyword candidate set. The backtracking retrieval process is the process of locating and retrieving the corresponding parent memory entry based on the mapping relationship when a sub-vector is matched among the candidates.
[0067] Specifically, within the memory domain defined by the target storage category set, vector similarity retrieval is first performed on the memory item set and / or sub-vector set based on the query representation and retrieval constraint information to obtain a vector candidate set. Then, the vector candidate set is filtered according to the retrieval constraint information to obtain a first candidate set that meets the constraints, thus ensuring that the vector recall results satisfy access control and scope conditions before entering the fusion stage. Simultaneously, keyword matching retrieval is performed on the memory item set within the target storage category set based on the query representation to obtain a keyword candidate set, which is further filtered to obtain a second candidate set that meets the constraints. After obtaining the first and second candidate sets, they are merged to form a multi-path candidate set covering semantic similarity paths and term matching paths.
[0068] Furthermore, after obtaining the multi-path candidate set, the hit sub-vectors in the multi-path candidate set are identified based on the mapping relationship, and the parent memory entries corresponding to the hit sub-vectors are backtracked to retrieve the candidate results from "sub-vector hit" back to the memory content carried by the "parent memory entry". Subsequently, the candidate set including the backtracking results is deduplicated to eliminate duplicate candidates in multiple paths. Then, the deduplicated candidate results are reordered and fused to form a unified candidate sequence, and the fused memory set is output. Finally, the fused memory set is organized into the agent's input context, and the agent is driven to generate the output results based on the agent's input context.
[0069] Because this step limits the retrieval to the target storage category set and simultaneously applies retrieval constraint information during the vector similarity retrieval stage, the vector candidate set forms a first candidate set that satisfies the constraints after filtering. At the same time, based on the query representation, keyword matching retrieval is performed within the same target category range to obtain a second candidate set, thus enabling the candidate sources to have complementary coverage in terms of semantic similarity and term matching. The integrity of candidate coverage is improved by merging multiple candidate sets. On this basis, the parent memory backtracking process is performed on the hit sub-vectors based on the mapping relationship, so that the candidate content returns to the complete memory carrier carried by the parent memory entry. Subsequently, after deduplication to reduce interference from duplicate items in multiple paths, and after reordering and fusion to form a more stable unified candidate sequence, a fused memory set is output. Finally, the fused memory set is organized into the intelligent agent input context to drive generation. Thus, under the combined effect of mechanisms such as scope and constraint pre-positioning, complementary recall paths, backtracking consistency, and fusion sorting, the relevance and usability of the memory content entering the generation stage are improved.
[0070] This embodiment first performs structured preprocessing on the content to be written on the writing side to form the feature information to be written. Then, based on the feature information to be written, a candidate memory set is retrieved within the corresponding user range, and the write decision module determines the target storage category and the target write action. This allows the memory data to form a more consistent set of memory entries through write processing or optimization updates. At the same time, multiple sub-representations are generated for at least some memory entries, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed, so that subsequent retrieval can hit the sub-representations and backtrack to the parent memory entries. On the retrieval side, the query representation is obtained by combining the short-term context information and permission information of the user query, and the target storage category set and retrieval constraint information are determined. The recall is limited to the target range and subject to constraint filtering. Then, a multi-way candidate set is formed through vector recall and keyword recall. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. This makes the memory content entering the agent generation stage more relevant and less redundant, thereby improving the accuracy of the retrieval results from a mechanism perspective.
[0071] Please see Figures 4-6 , Figure 4 This is a schematic diagram of the overall architecture of a noise-suppressed, multi-path recall dynamic routing agent memory system in one embodiment of the dynamic routing agent memory management method of this application; Figure 5 This is a flowchart illustrating the overall dynamic route retrieval process in one embodiment of the intelligent agent memory management method for dynamic routing in this application. Figure 6This is a schematic diagram of a multi-source memory bank hierarchical storage structure in one embodiment of the dynamic routing agent memory management method of this application. In one embodiment, a noise-suppressed multi-path recall dynamic routing agent memory system is proposed. Based on "multi-source memory bank hierarchical storage," it enables differentiated management of memories of different properties at both the physical and policy levels, thereby reducing noise recall, improving retrieval efficiency, and providing a controllable memory carrier for subsequent dynamic routing and enhanced recall. In this embodiment, the vector memory bank set is defined as:
[0072] The functions and access strategies of each dedicated library are as follows: Core memory stores users' long-term stable attributes and preferences (such as occupation, long-term interests, key relationships, long-term goals, communication style, etc.). This type of information is characterized by "high stability and high frequency of reuse" and is usually used as a high-priority candidate or filtering condition during retrieval (e.g., personalized constraints, preference priors).
[0073] Contextual memory bank: Stores time-sensitive events, dialogue fragments, phased plans, task execution trajectories, interaction summaries, etc. This type of information is characterized by "strong temporal correlation and strong context dependency," and retrieval is often associated with timestamps, event types, session_id, or task IDs.
[0074] Semantic memory stores conceptual facts, domain knowledge, general experiences, definitions and rules, emphasizing "conceptual structuring and transferability," and is used to provide background support for reasoning and answering.
[0075] Sensitive memory database: Stores private information (such as contact information, account credentials, precise addresses, and identity verification information). This database employs strict access control: retrieval and return are only permitted when permissions and authorization conditions are met, and it supports anonymization / minimum disclosure strategies.
[0076] For any memory text By embedding model Obtain the vector:
[0077] Each memory must contain not only a vector, but also metadata. (Including user_id, timestamp, session_id, permission level, etc.), to support permission, time sequence, source, confidence, and lifecycle management, constituting .
[0078] In one embodiment, the focus is not only on "how to retrieve", but also on providing a closed-loop mechanism for "how to write and how to optimize updates", so that the memory maintains low noise, low redundancy and high consistency during long-term operation.
[0079] When new content Upon arrival (which may come from user messages, conversation summaries, tool execution results, or external knowledge), the system first performs structured preprocessing, which is then written to the decision maker. Based on content characteristics and context, map it to One or more. Then retrieve the candidate relevant memory set within the user's relevant range:
[0080] Then, the input is written to the decision agent, and two key decisions are output: (1) Target library selection: (2) Action selection: These correspond to addition, update, deletion, and unchanged, respectively. This can be formally represented as:
[0081] The meanings of the actions are as follows: Update: When new content provides an "incremental supplement" to existing memories (more complete information, updated time, and changed parameters but not contradictory), the new information is merged into the parent memory summary or a new sub-fragment is added, and the confidence / freshness fields are improved.
[0082] Add: When the new content does not have a clear intersection with the existing memory, and no related content is found in the library, the add operation is performed to add a new memory.
[0083] Delete: When a retrieved memory is determined to be expired (TTL expired), obviously erroneous, redundant (highly similar and without incremental changes), or violates the policy (such as sensitive content that should not be stored for a long time), delete it or mark it as unretrievalable.
[0084] Keep: When new content does not constitute effective memory (noise / chicken talk), completely duplicates existing memory, or lacks sufficient confidence, it is not written to or is only written to the short-term cache and does not enter the long-term library.
[0085] The aforementioned four-option decision is implemented by the LLM Agent and is constrained by permission and audit policies. Deletion or leaving it unchanged is jointly determined by explicit intent, permission rules, noise discriminators, or compliance policies. Through this mechanism, the present invention enables the memory to possess the ability of "continuous optimization rather than disordered accumulation," significantly reducing the noise ratio and redundancy rate during long-term operation.
[0086] In one embodiment, instead of a full-database brute-force search during the retrieval phase, a pipeline of "routing first, then retrieval, multi-path recall, and fusion sorting" is executed. This makes the retrieval action directional and interpretable, significantly reduces the proportion of irrelevant memory recall, and maintains more stable latency and throughput as the data scale increases. The retrieval process no longer involves a full-database brute-force search, but instead executes a "routing first, then retrieval, multi-path recall, and fusion sorting" process.
[0087] Define the input as: user query Short-term context User profile and permission information μ. Output: fused memory set. With the final answer The overall process can be summarized as follows: (1) Semantically represent the query; (2) The routing agent predicts the most relevant set of memory databases and generates retrieval constraints; (3) Perform vector recall and (optional) keyword recall in the selected library; (4) Perform parent-child vector backtracking, denoising, deduplication, and reordering on the recall results; (5) Final memory With context The organization provides input prompts, driving the agent to generate responses. .
[0088] In one embodiment, dynamic routing decision-making includes: a dynamic routing agent denoted as... Its output is the set of libraries to be retrieved:
[0089] Routing strategies can be implemented using rules, lightweight classifiers, or LLM tools. The core idea is to determine "which type of memory is most likely to be relied upon for this problem" before retrieval, thereby reducing invalid database searches and noisy recall.
[0090] In one embodiment, a parent-child vector structure is further introduced on the basis of "multi-database retrieval + dynamic routing" to solve the problem of missed recall in abstract, fuzzy, and short text query scenarios, and to achieve an enhanced recall effect of "hitting child representation - backtracking parent memory - returning complete fragment".
[0091] Traditional vector recall: In the selected library set Then, for each library Perform vector retrieval. The query vector is:
[0092] database The recall result is defined as:
[0093] The final multi-database candidate set is obtained as follows:
[0094] This mechanism can quickly recall relevant memories when semantic similarity is high, but it may still miss key content when the user query is more abstract, the keywords are sparser, or the expression is significantly different from the original dialogue.
[0095] Parent-child vector augmented recall: To improve recall capabilities in ambiguous semantic scenarios, this invention provides each parent memory with... Construct multiple sub-representations (e.g., summary, keyword phrase, association question, entity phrase, etc.), denoted as
[0096] Generate sub-vectors respectively:
[0097] And establish a mapping relationship:
[0098] During the retrieval phase, the system can retrieve data from both the parent memory and the child vector database. Search:
[0099] Once a subvector is hit, the system obtains the parent memory set through mapping backtracking:
[0100] The original parent memory or structured fragment is then returned as the final candidate. The key advantage of this mechanism is that even if the user only provides vague keywords or abstract descriptions, it can first hit the "sub-representation that is easier to express and match", thereby reliably recalling the parent memory containing complete details.
[0101] Keyword recall: To further enhance scenarios with "low semantic similarity but high keyword hit rate," this embodiment can add a keyword recall channel (e.g., BM25). For queries... With candidate text set implement:
[0102] in Selectable from The text set, or the sub-representation set from the "parent memory summary / keyword library". Keyword recall, as a supplementary channel to the noise reduction system, can be enabled as needed by the routing agent: enabled when the query contains proper names, numbers, short words, colloquial fragments or strong keyword clues, to reduce missed recalls that may be caused by pure vector recall.
[0103] Rearrangement, deduplication, and fusion of multi-way recalls: Multi-path recall yields multiple candidate sets from different paths.
[0104] The system performs deduplication and fusion on the candidate set to prevent the same memory from being returned by multiple paths simultaneously. Deduplication is performed using the memory ID:
[0105] The candidate memories are then scored and reordered to balance factors such as semantic similarity, library priority, temporal relevance, and access constraints. The comprehensive score is defined as follows:
[0106] in This indicates the library priority weight (e.g., core first, episode second), while wt represents the time weight, which is mainly effective for episodic memory, with newer memories having higher priority. This represents a noise penalty (templatement, repetition, low information density, etc.). Final output:
[0107] Through the above fusion mechanism, a closed-loop retrieval strategy of "first layered noise suppression, then multi-path supplementation, and finally unified sorting" is realized, which can maintain a high recall rate and a low noise rate even in complex query and long-term interaction scenarios.
[0108] This application also provides a dynamic routing intelligent agent memory management device, please refer to... Figure 7 , Figure 7 This is a schematic diagram of the module structure of the intelligent agent memory management device for dynamic routing according to an embodiment of this application. The intelligent agent memory management device for dynamic routing includes: The write-to-be-written module 701 is used to acquire the content to be written and perform structured preprocessing on the content to be written to obtain the write-to-be-written feature information; The storage output module 702 is used to retrieve a candidate memory set based on the write-to-write feature information within the user range corresponding to the content to be written, and input the write-to-write feature information and the candidate memory set into the write decision module to output the target storage category and the target write action. The mapping module 703 is used to perform write processing or optimization update processing on memory data based on the target storage category and the target write action to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, it generates a variety of corresponding sub-representations and constructs a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations. The query representation module 704 is used to obtain a user query and short-term context information and permission information corresponding to the user query, perform semantic representation on the user query to obtain a query representation, and determine the target storage category set to be retrieved and retrieval constraint information based on the query representation, the short-term context information and the permission information. The target module 705 is used to perform vector recall based on the query representation and the retrieval constraint information within the target storage category set, and to perform keyword recall based on the query representation to obtain a multi-way candidate set. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. The fused memory set is then used to drive the agent to generate output results.
[0109] The dynamic routing agent memory management device provided in this application, employing the dynamic routing agent memory management method described in the above embodiments, can solve the technical problem of how to improve the accuracy of retrieval results of the agent memory system. Compared with the prior art, the beneficial effects of the dynamic routing agent memory management device provided in this application are the same as those of the dynamic routing agent memory management method provided in the above embodiments, and other technical features in the dynamic routing agent memory management device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0110] This application provides a dynamic routing intelligent agent memory management device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the dynamic routing intelligent agent memory management method in the above embodiments.
[0111] The following is for reference. Figure 8 , Figure 8 This is a schematic diagram of the hardware operating environment involved in the intelligent agent memory management method for dynamic routing in the embodiments of this application. It shows a schematic diagram of the structure of an intelligent agent memory management device suitable for implementing the dynamic routing in the embodiments of this application. Figure 8 The illustrated intelligent agent memory management device for dynamic routing is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0112] like Figure 8 As shown, the dynamically routed agent memory management device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the dynamically routed agent memory management device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the dynamically routed intelligent agent memory management device to communicate wirelessly or wiredly with other devices to exchange data. Although a dynamically routed intelligent agent memory management device with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented or possessed alternatively.
[0113] In particular, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. When the computer program is executed by the processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0114] The dynamic routing agent memory management device provided in this application, employing the dynamic routing agent memory management method described in the above embodiments, can solve the technical problem of how to improve the accuracy of retrieval results of the agent memory system. Compared with the prior art, the beneficial effects of the dynamic routing agent memory management device provided in this application are the same as those of the dynamic routing agent memory management method provided in the above embodiments, and other technical features in this dynamic routing agent memory management device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0115] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0116] 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 the claims.
[0117] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the intelligent agent memory management method for dynamic routing in the above embodiments.
[0118] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a dynamically routed intelligent agent memory management device, the dynamically routed intelligent agent memory management device: acquires content to be written and performs structured preprocessing on the content to be written to obtain feature information to be written; within the user scope corresponding to the content to be written, it retrieves a candidate memory set based on the feature information to be written, and inputs the feature information to be written and the candidate memory set into a write decision module to output a target storage category and a target write action; based on the target storage category and the target write action, it performs write processing or optimization update processing on the memory data to form a memory entry set; and based on at least some of the memory entries in the memory entry set, it generates... The system generates multiple corresponding sub-representations and constructs a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on these sub-representations. It obtains user queries and corresponding short-term context and permission information, performs semantic representation on the user queries to obtain query representations, and determines the target storage category set and retrieval constraints based on the query representation, short-term context, and permission information. Within the target storage category set, it performs vector recall based on the query representation and retrieval constraints, and keyword recall based on the query representation to obtain a multi-path candidate set. The multi-path candidate set undergoes parent memory backtracking, deduplication, and reordering fusion processing based on mapping relationships to output a fused memory set. The system then drives the agent to generate output results based on the fused memory set. Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0119] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0120] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0121] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described dynamic routing agent memory management method, thereby solving the technical problem of how to improve the accuracy of retrieval results of the agent memory system. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the dynamic routing agent memory management method provided in the above embodiments, and will not be repeated here.
[0122] This application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described dynamic routing intelligent agent memory management method.
[0123] The computer program product provided in this application can solve the technical problem of how to improve the accuracy of retrieval results of an intelligent agent memory system. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiments of this application are the same as the beneficial effects of the dynamic routing intelligent agent memory management method provided in the above embodiments, and will not be repeated here.
[0124] The above are merely preferred embodiments of this application and do not limit the scope of protection of this application. Any equivalent structural or procedural transformations made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of this application.
Claims
1. A method for managing the memory of a dynamic routing agent, characterized in that, The method includes: Obtain the content to be written and perform structured preprocessing on the content to be written to obtain the feature information to be written; Within the user range corresponding to the content to be written, a candidate memory set is retrieved based on the feature information to be written, and the feature information to be written and the candidate memory set are input into the write decision module to output the target storage category and the target write action; Based on the target storage category and the target write action, the memory data is written or optimized and updated to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, multiple corresponding sub-representations are generated, and a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries are constructed based on the sub-representations. Obtain user query and corresponding short-term context information and permission information; perform semantic representation on user query to obtain query representation; and determine the target storage category set to be retrieved and retrieval constraint information based on query representation, short-term context information and permission information. Within the target storage category set, vector recall is performed based on the query representation and the retrieval constraint information, and keyword recall is performed based on the query representation to obtain a multi-way candidate set. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. The agent is then driven to generate output results based on the fused memory set.
2. The method as described in claim 1, characterized in that, The steps of obtaining the content to be written and performing structured preprocessing on the content to be written to obtain the feature information to be written include: Obtain the content to be written, and parse the content to be written based on the preset content type rules to obtain the content type identifier and the original field set corresponding to the content type identifier; Based on the content type identifier, the original field set is normalized to obtain a normalized field set, wherein the normalization process includes one or more of the following: field extraction, format unification, noise field removal, and sensitive field marking. Based on the standardized field set, a structured representation is constructed to obtain the feature information to be written.
3. The method as described in claim 1, characterized in that, The step of retrieving a candidate memory set based on the write-to-write feature information within the user range corresponding to the content to be written, and inputting the write-to-write feature information and the candidate memory set into the write decision module to output the target storage category and the target write action includes: Within the user range corresponding to the content to be written, a retrieval range constraint is determined based on the feature information to be written, and a subset of memories to be retrieved is obtained from the memory data based on the retrieval range constraint; Based on the feature information to be written, a similarity retrieval process is performed on the subset of memories to be retrieved to obtain a set of candidate memories that match the feature information to be written. The feature information to be written and the candidate memory set are input into the write decision module. Based on the correlation between the candidate memory set and the feature information to be written, a decision result is generated to output the target storage category and the target write action.
4. The method as described in claim 1, characterized in that, The steps of performing write processing or optimization update processing on memory data based on the target storage category and the target write action to form a set of memory entries, generating corresponding multiple sub-representations based on at least a portion of the memory entries in the set of memory entries, and constructing a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations include: The memory data is classified and written according to the target storage category, and a writing strategy is determined according to the target writing action. When the target writing action is to add, the data corresponding to the content to be written is written as new memory data to the target storage category. When the target writing action is to update or delete, the target memory data corresponding to the content to be written in the candidate memory set is located and replaced, updated or deleted. When the target writing action is to keep, the storage state of the target memory data is maintained. Based on the writing strategy, the memory data after writing or optimization and update processing is organized into entries to obtain a set of memory entries. At least some memory entries are selected from the set of memory entries as parent memory entries, and multiple sub-representations are generated for the parent memory entries based on preset representation generation rules. The various sub-representations are vectorized to construct a set of sub-vectors, and an association mapping is established between each sub-vector in the set and its corresponding parent memory entry to obtain the mapping relationship from the sub-vector to the parent memory entry.
5. The method as described in claim 1, characterized in that, The steps of obtaining a user query and corresponding short-term context information and permission information, performing semantic representation on the user query to obtain a query representation, and determining the target storage category set to be retrieved and retrieval constraint information based on the query representation, the short-term context information, and the permission information include: Obtain a user query, and obtain short-term context information and permission information corresponding to the user query, wherein the short-term context information is used to characterize the session context to which the user query belongs, and the permission information is used to characterize the access control conditions corresponding to the user query; The user query is semantically represented based on a preset semantic encoding strategy to obtain a query representation for retrieval and matching. Based on the query representation, the short-term context information, and the permission information, a retrieval route determination process is performed to determine the target storage category set to be retrieved and the retrieval constraint information.
6. The method as described in claim 1, characterized in that, The steps of performing vector recall based on the query representation and the retrieval constraint information within the target storage category set, and keyword recall based on the query representation to obtain a multi-path candidate set, performing parent memory backtracking, deduplication, and reordering fusion processing on the multi-path candidate set based on the mapping relationship to output a fused memory set, and driving the agent to generate output results based on the fused memory set, include: Within the target storage category set, vector similarity retrieval processing is performed on the memory entry set and / or the sub-vector set based on the query representation and the retrieval constraint information to obtain a vector candidate set. The vector candidate set is then filtered based on the retrieval constraint information to obtain a first candidate set that satisfies the constraints. Based on the query representation, keyword matching retrieval processing is performed on the set of memory entries within the target storage category set to obtain a keyword candidate set. The keyword candidate set is then filtered to obtain a second candidate set that meets the constraints. The first candidate set and the second candidate set are then merged to obtain a multi-path candidate set. Based on the mapping relationship, the parent memory entries corresponding to the hit sub-vectors in the multi-path candidate set are backtracked and retrieved. The backtracked candidate results are deduplicated, reordered, and fused to output a fused memory set. The fused memory set is organized into an agent input context, and the agent is driven to generate output results based on the agent input context.
7. A dynamic routing intelligent agent memory management device, characterized in that, The device includes: The write-to-be-written module is used to acquire the content to be written and perform structured preprocessing on the content to be written to obtain the write-to-be-written feature information; The storage output module is used to retrieve a candidate memory set based on the write-to-write feature information within the user range corresponding to the content to be written, and input the write-to-write feature information and the candidate memory set into the write decision module to output the target storage category and the target write action. The mapping module is used to perform write processing or optimization update processing on memory data based on the target storage category and the target write action to form a set of memory entries. Based on at least some of the memory entries in the set of memory entries, it generates a variety of corresponding sub-representations and constructs a set of sub-vectors and a mapping relationship from sub-vectors to parent memory entries based on the sub-representations. The query representation module is used to obtain user queries and short-term context information and permission information corresponding to the user queries, perform semantic representation on the user queries to obtain query representation, and determine the target storage category set to be retrieved and retrieval constraint information based on the query representation, the short-term context information and the permission information; The target module is used to perform vector recall based on the query representation and the retrieval constraint information within the target storage category set, and to perform keyword recall based on the query representation to obtain a multi-way candidate set. The multi-way candidate set is then subjected to parent memory backtracking, deduplication, and reordering fusion processing based on the mapping relationship to output a fused memory set. The fused memory set is then used to drive the agent to generate output results.
8. A dynamic routing intelligent agent memory management device, characterized in that, The device includes: a memory, a processor, and a dynamic routing agent memory management program stored in the memory and executable on the processor, the dynamic routing agent memory management program being configured to implement the steps of the dynamic routing agent memory management method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium stores a dynamic routing agent memory management program, which, when executed by a processor, implements the steps of the dynamic routing agent memory management method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the agent memory management method for dynamic routing as described in any one of claims 1 to 6.