Search

CN-121745148-B - Context dynamic clipping method for multi-agent dialogue

CN121745148BCN 121745148 BCN121745148 BCN 121745148BCN-121745148-B

Abstract

The invention discloses a context dynamic clipping method for multi-agent dialogue. The method comprises the steps of S1, standardizing an input collection and context text segment object, standardizing multi-source heterogeneous data into a context text segment object with a state mark and storing the context text segment object, S2, performing context storage and cutting triggering judgment, monitoring the state of a storage area to trigger dynamic cutting, S3, compressing a completed historical context into a structured abstract, S4, performing context assessment and dynamic cutting, acquiring active and abstract contexts from the storage area to form a candidate set when cutting triggering, and executing dynamic cutting processing of a core, S5, performing task routing, and then routing the task to sub-agents based on a capacity matrix and weights, S6, performing and result aggregation by the sub-agents, and generating a final result after outputting the aggregated agents. The invention solves the problem of unbalanced efficiency and precision in long context management, and realizes intelligent reservation and accurate routing of key information.

Inventors

  • WANG ZIYU
  • SHI PEIDONG
  • WANG ZIYI
  • HUANG XIAOWEI

Assignees

  • 杭州数鸢科技有限公司

Dates

Publication Date
20260505
Application Date
20260225

Claims (10)

  1. 1. A method for dynamically clipping a context of a multi-agent-oriented dialogue is characterized by comprising the following steps: S1, input collection and standardization of an upper text segment object and a lower text segment object; receiving heterogeneous data from a multi-agent dialogue scene, and unifying and standardizing the heterogeneous data into a context segment object; The heterogeneous data at least comprises user input, tool calling results, historical dialogue records, external knowledge base hit results and intermediate conclusions of all sub-agents; The context segment object at least comprises text content, a state mark, a risk mark and a vector representation, wherein the state mark at least comprises incomplete, completed, compressed and representative abstracts, and the state marks of the newly generated context segment object are initialized to be incomplete; S2, context storage and clipping trigger judgment; Storing the standardized context segment objects in an original text buffer area, monitoring state data of the original text buffer area, and starting a dynamic cutting flow when a preset trigger condition is met; s3, context compression; Monitoring state marks of the context segment objects, merging the context segment objects meeting the conditions when the number of the context segment objects with the completed state marks meets the trigger compression trigger condition, generating a structured task abstract, taking the task abstract as a new context segment object with the state marks representing the abstract, and storing the task abstract into a representing abstract area; S4, context evaluation and dynamic clipping: When the dynamic clipping flow is started, acquiring all context segment objects with status marked as incomplete or representing abstract from the original text buffer area and representing abstract area to form a candidate context set; performing dynamic clipping on the candidate context set, calculating a gated attention score for each of the context field objects within the candidate context set ; According to the gated attention score Screening the context segment objects from the candidate context set and forming a core context set For the core context set The context segment objects in the context segment objects are subjected to weight normalization processing to obtain final weights ; S5, task routing; According to a predetermined multi-agent capability matrix R and the core context set Final weight of the object in (b) Computing a set The route scores between the inner context segment object and each sub-agent; inputting the corresponding context segment object by the current user and weighting according to the final weight Ordered core context set Packaging to form a context package, and routing the context package to one or more target sub-agents based on the routing score; s6, sub-agent execution and result aggregation; The target sub-agent executes the received context package, analyzes and executes an reasoning task, and outputs a structured intermediate result; And carrying out aggregation and consistency check on the intermediate results output by all the sub-agents to generate final output.
  2. 2. The method for dynamically tailoring a context for a multi-agent conversation according to claim 1, wherein in step S2, the status data comprises at least an amount of data in the original text buffer, a total number of tokens, and a last processing time; presetting a first threshold for the triggering condition A second threshold value Third threshold value The triggering condition is any one of the following conditions: The number of the context field objects in the original text buffer zone reaches a first threshold Or the estimated total number of tokens of all the context field objects in the original text buffer reaches a second threshold Or the time interval from the last cutting operation reaches a third threshold value 。
  3. 3. The method for dynamically clipping a context for a multi-agent conversation according to claim 1, wherein in step S3, the specific steps of context compression are as follows: s301, compressing a triggering condition; A compression threshold value theta is preset for representing the number of the context segment objects to be processed, when the number of the context segment objects with the state marked as completed reaches the compression threshold value theta, a compression operation is executed to acquire the objects to form a compression input context set If the number of the text segment objects does not reach the compression threshold value theta, not compressing the text segment objects, and waiting for more text segment objects until the number of the text segment objects reaches the compression threshold value theta; S302, merging contents; Integrating the compressed input context The text content of all the upper and lower text segment objects is spliced, and is processed by using a large language model or a structured summarizer to generate a structured summary text at least comprising points, entities and conclusions; S303, vectorizing the representation; vectorizing the structured abstract text, creating a new state mark, updating the new state mark into a context segment object representing the abstract, storing the context segment object into a region representing the abstract, and recording a system time stamp; S304, updating the state; Integrating the compressed input context The state marks of all the original context segment objects are updated to be compressed, and a backtracking association is established with the newly created context segment objects.
  4. 4. The method for dynamic clipping of a multi-agent conversation-oriented context of claim 1 wherein in step S4, the specific step of gating attention score computation comprises: s401, mask filtering; Screening the context segment objects in the candidate context set by calculating the Boolean mask thereof, and screening the context segment objects with the states marked as incomplete or representing abstract and the risks marked as 0; s402, calculating the theme matching degree; Projecting the context segment objects screened out from the candidate context set to a subject space through a projection matrix W t to obtain a projected matrix Calculating a post-projection matrix The matching degree score matrix S with the preset theme base matrix T is calculated according to the following formula: ; And calculating the topic distribution P (i, k) of each candidate through a softmax function, wherein the calculation formula is as follows: Wherein P (i, k) is the topic distribution, S i,k is the matching degree score matrix, i represents the i-th text segment object screened out from the candidate context set, and k represents the k-th topic; and defining a topic matching degree based on the topic distribution P (i, k) The calculation formula is as follows: s403, basic attention weight; For each context field object in the candidate context set, calculating its base attention weight The calculation formula is as follows: Wherein, the method comprises the steps of, For semantic significance of the context field object, can be calculated by the intersection ratio of the key entity contained in the context and the domain key entity list, As a coefficient of the decay in time, And The current timestamp and the object timestamp are respectively; S404, attention calculation; For each context field object in the candidate context set, calculating its gating attention score ; S405, calculating candidate weights; For each context field object in the candidate context set, gating it to an attention score By Sigmoid function Conversion to soft gating values And based on the base attention weight Calculating the candidate weight of the context segment object The calculation formula is as follows: 。
  5. 5. The method for dynamic clipping of a multi-agent conversation-oriented context of claim 4 wherein in step S404 the gated attention score The calculation formula of (2) is as follows: Wherein, the 、 、 Respectively preset weighting coefficients; Maximum matching degree between the context segment object and the theme prototype library; Maximum cosine similarity between the context segment object and other context segment objects in the candidate context set; The risk estimation for the object compliance is based on risk analysis of the text content of the context segment object, and ; The risk analysis method at least comprises one mode of a pre-trained lightweight neural network model, a predefined risk keyword library and an agent-based historical risk record.
  6. 6. The method for dynamic clipping of multi-agent conversation-oriented context of claim 4 wherein in step S405, the soft gate value The specific calculation formula of (2) is as follows: Wherein, the Is a soft-gate value that is set to be, To gate the attention score.
  7. 7. The method for dynamic clipping of multi-agent conversation-oriented context of claim 4 wherein in step S4, attention scores are gated based on Sorting and selecting K context segment objects to form the core context set If the number of the context segment objects is smaller than K, all the context segment objects are selected, wherein K is a preset clipping number threshold value, and after the core context set is obtained, the core context set is subjected to the processing of the core context set The weight normalization processing is carried out on the context segment objects, and the specific steps are as follows: For the core context set Candidate weights for each of the context field objects Normalizing to obtain the final weight The specific calculation formula is as follows: Wherein, the 、 To represent the core context set Candidate weights of context field objects, i and j are the core context set The index of the upper and lower field object, epsilon, is a very small positive number to prevent zero removal errors.
  8. 8. The method for dynamically clipping a context for a multi-agent dialogue according to claim 1, wherein in step S5, the multi-agent capability matrix R [ agent, topic ] ∈ [0,1] represents capability matching degree of a certain agent with a certain Topic, and the calculation formula of the routing score is as follows: Wherein, the For the multi-agent capability matrix; The best matching theme of the context segment object i; the final weight of the context segment object i; a soft risk value for context segment object i, the specific value of which is based on the risk estimate Determining that the value is a continuous risk intensity value, an More than or equal to 0, the higher the value is, the higher the compliance risk of the context segment object is, and the lower the priority of the context segment object is selected in the routing process is; alpha, beta and lambda are respectively preset weighting coefficients, and influence of the capability matching degree, the final weight of the context object and the soft risk value is respectively controlled.
  9. 9. The method for dynamically tailoring context for multi-agent conversation according to claim 1, wherein in step S6, the structured intermediate result at least comprises content of reasoning result, evidence list referenced, confidence of result, number of token consumed by reasoning process and reasoning delay time, and the specific steps of aggregating and consistency checking the intermediate results of all sub-agents are: S601, weighting aggregation; Based on the confidence of the intermediate result and the final weight of the consumed context segment object The sum is used for carrying out weighted fusion on the output contents of all the agents to form a preliminary aggregation result; S602, conflict resolution; if the conflict exists, the conflict is resolved through a voting mechanism or a predefined business rule, and a final output of consistency is formed; s603, compliance verification; And if the compliance risk is found, automatically rewriting or desensitizing the output content.
  10. 10. The method for dynamically tailoring context for multi-agent conversation according to claim 1, wherein after step S6, further supporting memory updating and online learning comprises the following steps: precipitating the high-value final output or intermediate result into a new context segment object with a state marked as a representative abstract, and storing the new context segment object into a representative abstract area; according to the contribution of each agent in the task execution at this time on different topics, updating the capability matching degree in the multi-agent capability matrix R on line, wherein, for the contribution of sub-agents, the confidence degree of the reasoning result according to the intermediate result output by the sub-agents, the task success rate or the final weight of the consumed context segment object One or more of (a) to perform quantization.

Description

Context dynamic clipping method for multi-agent dialogue Technical Field The invention relates to the technical field of artificial intelligence and man-machine interaction, in particular to a context dynamic clipping method for multi-agent dialogue. Background In the scenario where a Multi-Agent system cooperates with a Large Language Model (LLM) to accomplish complex tasks, how to efficiently manage the growing Multi-turn dialog context is a key challenge. The context information is the core basis of user intention recognition and task distribution, and the management quality directly determines the response accuracy and the processing efficiency of the system. At present, many researches on context management exist at home and abroad, but the researches mainly focus on interaction scenes between users and single LLM, and the prior art is not disclosed and described in detail for complex interaction scenes among users, multi-agent systems and LLM. Thus, there are still a number of limitations to the prior art: 1. Most of the prior art schemes focus on security and strategies, lack of semantic refining, rarely relate to only cutting and compressing semantic contents of an upper text body and a lower text body, and most of the prior art schemes only adopt cutting strategies with single dimensions such as time window cutting or pure similarity scoring, and cannot use topic information and business constraint to perform joint optimization, so that key evidence is easily lost or redundant information is easily reserved. 2. The processing mode is simple, information redundancy is difficult to deal with, and some technical schemes construct the context by constructing the historical message chain, so that the processing mode is simpler. This approach tends to accumulate a large amount of redundant information in long conversations and does not actively identify and remove duplicate or secondary content. At the same time, it lacks state management for context lifecycles, resulting in difficulty in achieving structured congealing and efficient multiplexing of critical information in long-term conversations. 3. The existing complex strategy is high in cost, difficult to maintain in parameters and does not deeply cooperate with the dynamic routing capability of multiple agents. Disclosure of Invention The invention aims to solve the problems and provides a context dynamic clipping method for multi-agent dialogue. In order to achieve the above purpose, the following technical scheme is adopted: The method for dynamically cutting the context of the multi-agent-oriented dialogue comprises the following steps: S1, input collection and standardization of an upper text segment object and a lower text segment object; And receiving heterogeneous data from the multi-agent dialogue scene, and unifying and standardizing the heterogeneous data into the context field objects. The heterogeneous data at least comprises user input, tool calling results, historical dialogue records, external knowledge base hit results and intermediate conclusions of all sub-agents. The context field object at least comprises text content, a state mark, a risk mark and a vector representation, wherein the state mark at least comprises incomplete, completed, compressed and representative abstracts, and the state marks of the newly generated context field object are initialized to be incomplete. S2, context storage and clipping trigger judgment; and storing the standardized context segment objects in an original text buffer area, monitoring state data of the original text buffer area, and starting a dynamic cutting flow when a preset trigger condition is met. Specifically, the status data at least includes the data amount in the original text buffer, the total token number and the last processing time. Specifically, a first threshold value is preset for the triggering conditionA second threshold valueThird threshold valueWhen any one of the following conditions is triggered, a dynamic clipping flow is started: The number of the context field objects in the original text buffer zone reaches a first threshold Or the estimated total number of tokens of all the context field objects in the original text buffer reaches a second thresholdOr the time interval from the last cutting operation reaches a third threshold value。 S3, context compression; And monitoring state marks of the context segment objects, merging the context segment objects meeting the conditions when the number of the context segment objects, of which the state marks are completed, meets the trigger compression trigger conditions, generating a structured task abstract, taking the task abstract as a new context segment object of which the state marks are representative abstracts, and storing the task abstract into a representative abstract area. Specifically, step S3 includes the following sub-steps: s301, compressing a triggering condition; A compression threshold value theta is preset for r