AI agent processing method based on hierarchical memory architecture and near real-time experience update

By constructing an L0-L4 hierarchical memory architecture and a near real-time experience update method, the problems of repeated errors and slow response caused by improper information management in multi-agent systems are solved, and the stable hit rate of key instructions and the improvement of response speed are achieved.

CN122489703APending Publication Date: 2026-07-31BEIJING XIAOHAISHI TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING XIAOHAISHI TECHNOLOGY CO LTD
Filing Date
2026-05-07
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies in multi-agent systems lack hierarchical priority management of user hard constraints, recent task facts, and previous error correction experience, which leads to high-priority information being squeezed out or truncated by low-priority content, resulting in failure modes such as repeated invocation of incorrect tools and repeated generation of inconsistent steps.

Method used

A method based on hierarchical memory architecture and near real-time experience update is adopted. By collecting and processing data throughout the agent collaborative processing process, an L0-L4 hierarchical memory architecture is constructed. Time axis relocation, content denoising, role completion and normalization are performed, the hierarchical belonging degree of candidate memory units is evaluated, experience update tags are generated, role delivery status is identified, and role-level context assembly reports are generated.

Benefits of technology

It significantly improves the assembly priority and hit stability of key instructions in long dialogue collaborative processing, reduces noise interference, lowers response latency, and enhances the observability and robustness of multi-agent systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489703A_ABST
    Figure CN122489703A_ABST
Patent Text Reader

Abstract

This invention discloses an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates, belonging to the field of machine learning technology. The method includes the following steps: S1, acquiring agent interaction observation data and performing timeline relocation and normalization processing; S2, constructing a hierarchical memory writing queue and evaluating the hierarchical affiliation of candidate memory units; S3, constructing an experience update input sequence and evaluating the effectiveness of current experience candidates; S4, evaluating the role context adaptation degree and generating a role-level context assembly report. This invention effectively improves the efficiency of context management and decision consistency in multi-agent long dialogue collaborative processing, solving the problems of lack of hierarchical management of key user instructions, recent facts, and new experiences, and the lack of real-time updates and role filtering in long dialogue collaborative processing, leading to repeated errors and slow response times.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine learning technology, specifically to an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates. Background Technology

[0002] With the development of large-scale language model-driven multi-agent systems, existing technologies typically concatenate user instructions, dialogue facts, and error correction conclusions into a unified historical cache or vectorize them into a unified retrieval pool during long-dialogue collaborative processing. The Plan agent and Worker agents then deliver the context based on the same retrieval results. However, in collaborative execution processes with limited tokens and numerous dialogue rounds, existing systems lack hierarchical priority management and real-time write-back updates for user hard constraints, recent task facts, and previous error correction experience. High-priority constraints may be truncated or overwhelmed by low-priority content, causing previously confirmed error correction conclusions to fail to consistently hit in the next round, resulting in failure modes such as repeatedly calling incorrect tools and generating inconsistent steps.

[0003] For example, the invention patent with announcement number CN112465148B discloses a method, apparatus, and terminal device for updating network parameters of a multi-agent system. The method includes: determining the overall internal reward through the novelty parameters of the entire agent system; determining the local internal reward of each agent based on their contribution level; and combining this with external rewards to determine the network update parameters for each agent. This approach determines the internal reward from a global perspective, making the multi-agent system's search of the global state space more comprehensive. Furthermore, by determining the internal reward of each agent based on their contribution to the overall novelty parameters, it fully considers the different exploration capabilities of different agents, reduces redundant and repetitive exploration, accelerates training speed, and improves task completion efficiency.

[0004] For example, invention patent CN116362345B discloses an edge caching method and system based on multi-agent reinforcement learning and federated learning, including: constructing a MADRL framework comprising state, action, reward, and policy; employing federated deep learning to predict popular content within the coverage area of ​​the SBS; and based on the MADRL framework, the SBS adjusts the popular content cached locally by the SBS according to its local state and the states of neighboring SBSs. This invention allows the SBS to predict the popularity of content within its coverage area and effectively adjust the popular content cached locally by SBSs, thereby achieving effective utilization of distributed edge caching.

[0005] In existing technologies, current systems, when faced with collaborative execution scenarios involving limited token resources and frequent dialogue rounds, lack a hierarchical priority management mechanism based on hard constraints on users, recent task facts, and previous error correction experience. Furthermore, they cannot achieve real-time information write-back and updates, leading to high-priority constraints being easily squeezed out or truncated by low-priority content. This makes it difficult for confirmed error correction conclusions from the previous round to be consistently applied in subsequent rounds, resulting in typical failure scenarios such as repeated calls to incorrect tools and repeated generation of inconsistent steps. Ultimately, this manifests as increased retrieval noise, a significant increase in decision latency with each round, and quantifiable performance degradation.

[0006] Therefore, in order to address the above problems, there is an urgent need for an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates. Summary of the Invention

[0007] Technical problems to be solved To address the shortcomings of existing technologies, this invention provides an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates. This method solves the problems in long-dialogue collaborative processing where key user instructions, recent facts, and new experiences are not managed hierarchically, and there is a lack of real-time updates and role filtering, leading to repeated errors and slow response times.

[0008] Technical solution To achieve the above objectives, the present invention provides the following technical solution: an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates, comprising: S1, collecting data throughout the agent's collaborative processing process, acquiring agent interaction observation data, and performing timeline relocation, content denoising, role completion, and normalization processing; S2, based on the agent interaction observation data, extracting candidate memory units, constructing a hierarchical memory writing queue, evaluating the hierarchical affiliation of candidate memory units, and constructing a hierarchical memory dataset; S3, based on the hierarchical memory dataset, constructing an experience update input sequence, evaluating the effectiveness of the current experience candidates, and generating experience update labels; S4, extracting the current task request and candidate context fragments, evaluating the role context adaptation, identifying the role delivery status, and generating a role-level context assembly report.

[0009] Furthermore, the specific steps for collecting data on the entire process of agent collaborative processing, acquiring agent interaction observation data, and performing timeline relocation, content denoising, role completion, and normalization are as follows: The entire process of agent collaborative processing is collected to acquire agent interaction observation data, which includes user text commands, user-added preferences, task identifiers, session rounds, Plan planning data, Worker execution data, tool call status data, retrieval hit fragment data, error correction conclusions, role identifiers, message generation time, module reception time, and write time. A message reordering method based on timestamp alignment is used to relocate the agent interaction observation data on the timeline. A text denoising method based on role and task label constraints is used to denoise the agent interaction observation data. A role completion method based on task parent-child relationship mapping is used to complete data items with missing role identifiers, missing task source identifiers, and missing round identifiers. A normalization method based on field categories is used to perform interval scaling, encoding mapping, and length unification processing on the agent interaction observation data.

[0010] Furthermore, based on agent interaction observation data, the specific steps for extracting candidate memory units and constructing a hierarchical memory writing queue are as follows: Based on agent interaction observation data, constraint sentence recognition based on keyword dictionary and regular expression template is performed on user text commands and user new preferences to generate user explicit command items and user preference items; Plan planning data, Worker execution data, tool call status, retrieval hit fragments, and error correction conclusions within consecutive session rounds under the same task identifier are sequentially concatenated to generate recent task fact items; Message generation time, module reception time, and writing time are written as individual messages to generate original session log items; For error correction conclusions that are confirmed and marked as successful by the user, the corresponding task identifier, Plan planning data, Worker execution data, and Worker preference items are extracted. The kernel executes data and tool call status to generate experience candidates; it reads system rules, role permission rules, and tool call constraints from the system rule file to generate system rule items; the aforementioned user explicit command items, user preference items, recent task fact items, original session log items, experience candidates, and system rule items constitute all candidate memory units; it generates hierarchical labels, source labels, role labels, task labels, and validity period labels for each candidate memory unit; the system rule items correspond to the L0 system rule layer, the user explicit command items and user preference items correspond to the L1 user profile layer, the recent task fact items correspond to the L2 short-term fact layer, the experience candidates correspond to the L3 medium-term experience layer, and the original session log items correspond to the L4 session log layer; and it constructs a hierarchical memory write queue based on the hierarchical write rules.

[0011] Furthermore, the specific steps for evaluating the hierarchical affiliation of candidate memory units are as follows: Priority strength is obtained by statistically analyzing the hit rate of explicit user instructions and user preferences within the candidate memory units; cross-round stability is obtained by statistically analyzing the number of times a candidate memory unit is repeatedly retrieved within a round window; cross-task reusability is obtained by statistically analyzing the recurrence of task types, error types, and correction actions corresponding to the candidate memory units; and conflict is determined item by item between the candidate memory units and existing records in the L1 user profile layer, L2 short-term fact layer, and L3 medium-term experience layer. The comparison yields the conflict degree; the redundancy density is obtained by statistically analyzing the proportion of duplicate content between candidate memory units and hierarchical memory writing queues; the product of priority strength and stability adjustment coefficients multiplied by cross-round stability and the product of reuse adjustment coefficients multiplied by cross-task reuse are summed and divided by the sum of conflict degree plus one and anti-zero term to obtain the main discriminant input; the main discriminant input is subjected to arctangent transformation to obtain the main discriminant value; the redundancy density is divided by the sum of redundancy density plus one and anti-zero term to obtain the redundancy penalty value; the redundancy penalty value is subtracted from the main discriminant value to obtain the memory hierarchy attribution evaluation value.

[0012] Further, the specific steps for constructing the hierarchical memory dataset are as follows: Real-time comparison of memory level attribution evaluation values ​​and hierarchical writing threshold groups, including first-level thresholds, second-level thresholds, and third-level thresholds; when the memory level attribution evaluation value of a candidate memory unit is greater than or equal to the first-level threshold, it is written to the L1 user profile layer; when the memory level attribution evaluation value of a candidate memory unit is less than the first-level threshold but greater than or equal to the second-level threshold, it is written to the L2 short-term fact layer; when the memory level attribution evaluation value of a candidate memory unit is less than the second-level threshold but greater than or equal to the third-level threshold, it is written to the L3 intermediate experience layer; when the memory level attribution evaluation value of a candidate memory unit is less than the third-level threshold, it is written to the L4 session pipeline layer; fixed loading processing is performed on the L0 system rules layer, which does not participate in the hierarchical comparison, thus constructing the hierarchical memory dataset.

[0013] Furthermore, based on the hierarchical memory dataset, the specific steps for constructing the experience update input sequence are as follows: Based on the hierarchical memory dataset, read the L2 short-term fact layer records within N rounds of the current session and the L4 session pipeline layer records corresponding to the same session round, perform sliding window splicing, repetitive compression, and sequential reorganization to obtain key fact items, immediate correction items, and stage status items, and construct a sliding window fact candidate sequence; when it is detected that there are no new user messages and no tool calls within T consecutive seconds of the session, jointly read the corresponding records in the L2 short-term fact layer and the L4 session pipeline layer, and use stability screening based on cross-round co-occurrence statistics and archiving summary methods based on rule template merging to summarize, extract user new preferences, cross-task reusable experience, and decision logic, and construct an archived experience candidate sequence.

[0014] Furthermore, the specific steps for evaluating the effectiveness of the current experience candidates are as follows: Based on the sliding window fact candidate sequence and the archived experience candidate sequence, evaluate the effectiveness of the current experience candidates: retain the recursive value of the experience effectiveness at the previous moment as a historical state item; calculate the ratio of the number of key fact items in the sliding window fact candidate sequence to the total number of key fact items, immediate correction items, and stage state items in the sliding window fact candidate sequence to obtain the fact conciseness item; calculate the ratio of the number of immediate correction items confirmed by the user in the sliding window fact candidate sequence to the number of sliding window fact candidates. The error correction confirmation term is obtained by calculating the ratio of the total number of immediate correction terms in the selected sequence; the conflict jitter is obtained by calculating the normalized data of the number of conflict terms between the archived experience candidate sequence and the existing L1-L3; the fact conciseness term and the error correction confirmation term are multiplied, divided by the sum of the conflict jitter and the zero-prevention term, and then subjected to hyperbolic tangent transformation to obtain the current evidence term; the historical state term is multiplied by the recursive inertia factor to obtain the historical correlation term; the current evidence term is multiplied by the difference between 1 and the recursive inertia factor to obtain the evidence correlation term; the historical correlation term and the evidence correlation term are added to obtain the experience effectiveness recursive value.

[0015] Further, the specific steps for generating experience update tags are as follows: Real-time comparison of the experience effectiveness recursive value with the experience migration threshold group, which includes a first experience migration threshold and a second experience migration threshold; when an experience candidate contains a new user preference and the experience effectiveness recursive value is greater than or equal to the first experience migration threshold, it is written to the L1 user profile layer; when the same correction action of an experience candidate occurs more than K times in different task types and the experience effectiveness recursive value is greater than or equal to the second experience migration threshold, it is written to the L3 mid-term experience layer; when the experience effectiveness recursive value is lower than the second experience migration threshold, the corresponding experience candidate is retained in the L2 short-term fact layer and the L4 session pipeline layer for reconfirmation; and the identified migration status is structurally bound to the current session identifier, round information, experience source range, role source information, and task identifier to generate experience update tags.

[0016] Further, the specific steps for extracting the current task request and candidate context fragments and evaluating the role context adaptability are as follows: Based on the user text command, task identifier, role identifier, Plan planning data corresponding to the current task identifier, and tool call status in the current round, a role request vector is constructed based on the field mapping method; from the L0-L3 layers and the retrieved fragments, candidate context fragments are extracted using a task identifier-based filtering method, and source level identifiers are attached to each fragment. Corresponding tags are generated according to the fragment source, and the corresponding tags are encoded to construct a context feature vector; Tokenizer segmentation is performed on the candidate context fragments to obtain the context consumption; the remaining budget of the agent is obtained by subtracting the cumulative token consumption of the already assembled context content from the current role agent's token budget; according to the role type, a permission matrix is ​​used... The matrix generation method constructs a role permission matrix; it evaluates the context fit between the current candidate context fragment and the target role: it calculates the matrix product of the transpose of the context feature vector, the role permission matrix, and the role request vector to obtain the matching term; it calculates the matrix product of the transpose of the context feature vector, the role permission matrix, and the context feature vector to obtain the feature term; it calculates the square root of the sum of the feature term and the zero-prevention term to obtain the baseline feature term, and the square root of the sum of the matching term and the zero-prevention term to obtain the matching penalty term; it multiplies the baseline feature term and the matching penalty term to obtain the constraint term; it divides the matching term by the constraint term to obtain the matrix constraint value; it extracts the maximum value of the difference between the context consumption and the agent's remaining budget and the constant term zero, divides it by the sum of the agent's remaining budget and the zero-prevention term, and performs an exponential operation to obtain the penalty term; it multiplies the matrix constraint value by the penalty term to obtain the role context fit value.

[0017] Further, the specific steps for identifying the role delivery status and generating a role-level context assembly report are as follows: When the current role is a Plan agent and the role context adaptation value is greater than or equal to the role delivery threshold, the corresponding candidate context fragments of the L0 system rule layer, L1 user profile layer, L2 short-term fact layer, and L3 mid-term experience layer are retained to form a global context assembly report for the Plan agent; when the current role is a Worker agent and the role context adaptation value is greater than or equal to the role delivery threshold, only the fact fragments of the L2 short-term fact layer, the constraint fragments of the L1 user profile layer, and the execution instructions generated by the Plan agent related to the current subtask are retained; when the role context adaptation value is lower than the role delivery threshold, the corresponding fragments are filtered; the identified role delivery status is structurally bound with the current role number, task identifier, session round, context source level, and sampling time information to generate a role-level context assembly report and mark the corresponding delivery anomaly status.

[0018] Beneficial effects The present invention has the following beneficial effects: (1) This invention constructs an L0-L4 hierarchical memory architecture, namely L0 system rules layer, L1 user profile layer, L2 short-term facts layer, L3 medium-term experience layer and L4 conversation pipeline layer, which hierarchically isolates and stores user hard constraints, recent facts, reusable experience and original pipeline, avoiding high-priority information being truncated or submerged by low-priority content, and significantly improving the assembly priority and hit stability of key instructions in long dialogue collaborative processing.

[0019] (2) In this invention, the role-level context trimming and distribution of Plan agent and Worker agent are performed by using the role permission matrix and context adaptation evaluation formula, so that the Worker only receives fragments related to the current subtask, reducing noise interference from irrelevant planning links, other subtask content and historical chat content, improving the effective hit rate of cross-role delivery and reducing end-to-end response latency.

[0020] (3) This invention ensures the causal consistency and structural integrity of asynchronous interaction data of multiple agents by repositioning the time axis, completing roles, unifying identifiers, and denoising content. It provides a high-quality data foundation for hierarchical memory construction and experience updating, and fixes the problems of round misalignment and causal order reversal caused by asynchronous message arrival, tool return delay and concurrent execution of multiple agents.

[0021] (4) This invention identifies roles that deliver inefficiently or over budgeted tasks and sets re-inspection flags by generating role-level context assembly reports and collaborative processing statistical reports. This enables quantitative labeling and feedback of abnormal delivery status, providing quantifiable decision-making basis for system optimization, fault diagnosis and resource scheduling, and further improving the observability and robustness of multi-agent systems.

[0022] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0023] Figure 1 This is a flowchart of the AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to the present invention. Figure 2 This is a graph showing the hierarchical classification evaluation data of candidate memory units in this invention. Figure 3 This is a graph showing the change in the empirically effective recursive values ​​of this invention. Figure 4 This is a comparison chart of the role context adaptation values ​​of the present invention on different source fragments; Figure 5 This is a comparison chart of the repetition error rate and response latency under different session rounds in this invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0025] Please see Figures 1-5 This invention provides a technical solution: an AI agent processing method based on a hierarchical memory architecture and near real-time experience updates, comprising: S1 collects data on the entire process of intelligent agent collaborative processing, obtains intelligent agent interaction observation data, and performs time axis relocation, content denoising, role completion and normalization processing. S2, based on the intelligent agent interaction observation data, extract candidate memory units, construct a hierarchical memory writing queue, evaluate the degree of hierarchical affiliation of candidate memory units, and construct a hierarchical memory dataset; S3, based on the hierarchical memory dataset, constructs an experience update input sequence, evaluates the effectiveness of the current experience candidates, and generates experience update labels; S4: Extract the current task request and candidate context fragments, evaluate the role context adaptation, identify the role delivery status, and generate a role-level context assembly report.

[0026] Specifically, the steps for collecting data on the entire process of agent collaboration, acquiring agent interaction observation data, and performing timeline relocation, content denoising, role completion, and normalization are as follows: The entire process of intelligent agent collaborative processing is monitored, including user input behavior, user preference change behavior, task goal issuance behavior, Plan agent task planning behavior, Worker agent subtask execution behavior, tool call feedback behavior, knowledge retrieval hit behavior, error correction behavior, experience writing back behavior, and context delivery difference behavior. This process collects intelligent agent interaction observation data, which includes user text commands, newly added user preferences, task identifiers, session rounds, Plan planning data, Worker execution data, tool call status data, retrieval hit fragment data, error correction conclusions, role identifiers, message generation time, module reception time, and writing time.

[0027] A message reordering method based on timestamp alignment is used to reposition the timeline of agent interaction observation data, correcting round misalignment and causal order reversal caused by asynchronous message arrival, tool return delays, and concurrent execution of multiple agents. A text denoising method based on role and task label constraints is used to denoise the agent interaction observation data, filtering out irrelevant chatter, irrelevant historical planning fragments, and duplicate tool return content. A role completion method based on task parent-child relationship mapping is used to complete data items with missing role identifiers, missing task source identifiers, and missing round identifiers. A unified identifier processing method is used to bind application identifiers, user identifiers, session identifiers, round sequence numbers, role identifiers, and task identifiers to unify the identifiers of agent interaction observation data. A normalization processing method based on field categories is used to perform range scaling, encoding mapping, and length unification processing on numerical fields, categorical fields, and text fields in the agent interaction observation data, respectively.

[0028] This implementation scheme achieves correct causal temporal repair and semantic noise filtering of multi-agent collaborative interaction data, ensuring round alignment and complete role identification; through unified field encoding and normalization processing, it significantly reduces data heterogeneity and improves the input quality and stability of memory hierarchies, context assembly, and experience transfer; it provides a highly reliable and low-redundancy observation data foundation for sliding window fact construction, archived experience generation, and role adaptation evaluation, thereby enhancing the continuous learning ability and self-healing ability of complex task flows and abnormal states.

[0029] Specifically, the steps for extracting candidate memory units and constructing a hierarchical memory writing queue based on agent interaction observation data are as follows: Based on intelligent agent interaction observation data, constraint sentence recognition based on keyword dictionary and regular expression templates is performed on user text commands and newly added user preferences. The keyword dictionary is constructed by manually annotating and extracting high-frequency modal verbs, negation words, and preference keywords from historical dialogues, such as "remember," "prioritize," "don't," "use only," and "always," with boundaries limited to parts of speech that are modal verbs or adverbs and strongly related to the verb's semantics. The regular expression template has preset matching patterns, such as "remember.", "prioritize (.)," "don't (.)," "use only (.)," and "always (.*)," with a matching length not exceeding 20 characters and not spanning sentences. Text fragments containing the tags "remember," "prioritize," "don't," "use only," and "always" are extracted, and the key-value pairs in the newly added user preference field are directly expanded to generate explicit user command items and user preference items. When executing Plan planning, a unique subtask identifier is assigned to each decomposed subtask, and its association with the parent task identifier is recorded to form a task tree structure. The boundary is the direct decomposition level under the same root task, and the parent-child relationship does not cross levels.

[0030] For consecutive session rounds under the same task identifier, Plan planning data, Worker execution data, tool call status, retrieval hit fragments, and error correction conclusions are concatenated sequentially to generate recent task fact items. User text commands, Plan planning data, Worker execution data, tool call status, retrieval hit fragments, error correction conclusions, and corresponding message generation time, module reception time, and write time are written as individual messages to generate original session log items. For error correction conclusions that have been confirmed and marked as successful by the user, the corresponding task identifier, Plan planning data, Worker execution data, and tool call status are extracted and assembled according to a fixed field structure of task type, error type, correction action, and execution status to generate experience candidates. System rules, role permission rules, and tool call constraints are read from the system rule file to generate system rule items. The above-mentioned user explicit command items, user preference items, recent task fact items, original session log items, experience candidates, and system rule items constitute all candidate memory units. The system rule file is a predefined JSON or YAML configuration file. Its content includes system-level behavioral constraints, role and permission rules, tool invocation whitelists, and parameter validation templates. The file path is specified by system startup parameters, and it is read-only and cannot be modified at runtime. After parsing the system rule file, each rule is instantiated as an immutable memory unit, appended with a version number and an effective timestamp. The boundary is that it only contains atomic rules directly mapped from the system rule file, excluding derived or combined rules. System rules, role and permission rules, and tool invocation constraints are read from the system rule file to generate system rule items.

[0031] Each candidate memory unit is assigned a hierarchical label, source label, role label, task label, and validity period label. System rule items correspond to the L0 system rule layer, user explicit command items and user preference items correspond to the L1 user profile layer, recent task fact items correspond to the L2 short-term fact layer, experience candidates correspond to the L3 mid-term experience layer, and original session pipeline items correspond to the L4 session pipeline layer. A hierarchical memory write queue is constructed based on the hierarchical write rules. The L1 user profile layer and L2 short-term fact layer candidates are written to Markdown or JSON hot storage files after generating file paths according to user identifier, session date, and hierarchical type. The L3 mid-term experience layer candidates are written to an SQLite table after generating structured records according to task type, error type, correction action, and execution status, and vector indexes are generated synchronously. The L4 session pipeline layer candidates are generated into append-only pipeline files according to session identifier and round sequence number. The L0 system rule items are written to a fixed rule file and loaded directly when the session starts.

[0032] This implementation scheme achieves structured decomposition and hierarchical abstraction of multi-source heterogeneous interactive data, transforming raw observation data into L0 to L4 hierarchical memory units with clear semantic boundaries and lifecycle labels. Through constraint recognition combining keyword dictionaries and regular templates, task tree mapping, error correction experience assembly, and atomic instantiation of system rules, the accuracy, integrity, and traceability of the memory content are ensured. Based on hierarchical labels and hierarchical writing rules, hot storage, vector indexing, and append-only pipelined files are combined to balance high-frequency read / write performance with long-term storage stability, significantly improving the computational efficiency and retrieval accuracy of memory retrieval, context assembly, and experience transfer.

[0033] Specifically, the steps for evaluating the hierarchical affiliation of candidate memory units are as follows: Priority strength is obtained by statistically analyzing the hit rate of explicit user commands and user preferences in candidate memory units; the hit count is divided by the total number of user interactions within the round window of the candidate memory unit, and the result is normalized to the range of 0 to 1. Cross-round stability is obtained by statistically analyzing the number of times a candidate memory unit is repeatedly retrieved within the round window; the number of repeated retrievals is divided by the maximum possible retrieval count within the round window, and the result is normalized to the range of 0 to 1. Cross-task reusability is obtained by statistically analyzing the recurrence of task types, error types, and correction actions corresponding to candidate memory units; the number of recurrences of the same combination is divided by the total number of different task types involved in the candidate memory unit, and the result is normalized to the range of 0 to 1. Conflict degree is obtained by comparing candidate memory units with existing L1 user profile layer, L2 short-term fact layer, and L3 medium-term experience layer records item by item; the number of conflicting comparisons is divided by the total number of comparisons, and the result is normalized to the range of 0 to 1. Redundancy density is obtained by statistically analyzing the proportion of duplicate content between candidate memory units and hierarchical memory writing queues. The length of the overlap between the candidate memory cell and the existing record in the write queue is divided by the total length of the candidate memory cell, and the result is normalized to the interval between 0 and 1.

[0034] The product of priority intensity and stability adjustment coefficient multiplied by cross-wheel stability and the product of reuse adjustment coefficient multiplied by cross-task reuse are summed and divided by the sum of conflict degree plus one and anti-zero term to obtain the main discriminant input. The main discriminant input is then subjected to arctangent transformation to obtain the main discriminant value. The redundancy density is divided by the sum of redundancy density plus one and anti-zero term to obtain the redundancy penalty value. The redundancy penalty value is then subtracted from the main discriminant value to obtain the memory level attribution evaluation value.

[0035] The specific formula for calculating the memory hierarchy attribution evaluation value is as follows: ; In the formula, This represents the memory hierarchy assessment value of the i-th candidate memory unit, which is used as the basis for determining hierarchical writing. It indicates the priority intensity, used to characterize the degree to which the current candidate memory unit is preferentially retained in the hierarchical memory system; This represents the stability across rounds, used to characterize the degree of continued stability of the current candidate memory unit in adjacent session rounds; This indicates cross-task reusability, used to characterize the reusability of the current candidate memory unit in different tasks; The conflict level is used to characterize the degree of inconsistency between the current candidate memory unit and existing memory content; Redundancy density represents the proportion of duplicate content in the current candidate memory unit. This represents the stability adjustment coefficient, which is obtained by parameter calibration of the cross-wheel stability term on the validation sample set during the development phase. The value range is (0,2], and it is used to adjust the influence of cross-wheel stability in the memory level attribution evaluation value. This represents the reuse adjustment coefficient, which is obtained by parameter calibration of the cross-task reuse item on the validation sample set during the development phase. The value range is (0,2], and it is used to adjust the influence of cross-task reuse in the memory hierarchy attribution evaluation value. The sequence number of the candidate memory unit is obtained by numbering the current set of candidate memory units to be evaluated in the order of generation or traversal. It is used to distinguish different candidate memory units and identify the objects currently participating in the calculation. This indicates a zero-preservation term, which is obtained by setting a very small positive constant and is used to avoid zero values ​​in the denominator and maintain the stability of the formula calculation process.

[0036] In this implementation scheme, by performing multi-dimensional quantitative calculations on priority strength, cross-round stability, cross-task reusability, conflict degree, and redundancy density, the importance and reuse value of candidate memory units are accurately distinguished. By utilizing arctangent transform and redundancy penalty mechanism, the interference of noisy memory and duplicate content on hierarchical determination is effectively suppressed, improving the robustness and rationality of evaluation results. By combining monotonically decreasing threshold groups and fixed loading strategy, the writing logic of each level from L0 to L4 is ensured to be clear and consistent, avoiding hierarchical overlap or decision ambiguity. Finally, a hierarchical memory dataset with a clear structure and high access efficiency is formed, providing a reliable data foundation for context assembly, experience transfer, and agent collaborative decision-making.

[0037] Specifically, the steps for constructing a hierarchical memory dataset are as follows: The system compares the memory hierarchy's assessment value with the hierarchical write threshold group in real time. The hierarchical write threshold group includes a first-level threshold, a second-level threshold, and a third-level threshold. The thresholds follow a monotonically decreasing relationship: first-level threshold > second-level threshold > third-level threshold, and each threshold is between 0 and 1, with zero-prevention items being non-zero constants. The recommended default values ​​are: first-level threshold = 0.85, second-level threshold = 0.65, and third-level threshold = 0.40. The values ​​are determined as follows: the first-level threshold is higher to filter the highest-priority explicit user instructions, ensuring only high-confidence constraints are written to the L1 user profile layer; the second-level threshold is moderate, corresponding to short-term task facts, and is written to the L2 short-term fact layer; the third-level threshold is lower to filter low-confidence items, writing them to the L3 mid-term experience layer or the L4 session pipeline layer; items below the third-level threshold are uniformly written to the L4 session pipeline layer. The L0 system rule layer does not participate in the hierarchy comparison and is always loaded at a fixed rate. The above default values ​​can be optimized online based on the memory hit rate and the proportion of interference items during actual operation. For example, when there is too much noise written to the L1 user profile layer, the threshold of the first level can be increased, and when the L2 short-term fact layer misses important facts, the threshold of the second level can be appropriately reduced.

[0038] When the memory level attribution evaluation value of a candidate memory unit is greater than or equal to the first-level threshold, it is written to the L1 user profile layer; when the memory level attribution evaluation value of a candidate memory unit is less than the first-level threshold but greater than or equal to the second-level threshold, it is written to the L2 short-term fact layer; when the memory level attribution evaluation value of a candidate memory unit is less than the second-level threshold but greater than or equal to the third-level threshold, it is written to the L3 intermediate experience layer; when the memory level attribution evaluation value of a candidate memory unit is less than the third-level threshold, it is written to the L4 session pipeline layer; fixed loading is performed on the L0 system rules layer, which does not participate in the level comparison, and a hierarchical memory dataset is constructed.

[0039] like Figure 2The candidate memory unit hierarchical classification evaluation data chart illustrates the distribution of different candidate memory units in terms of memory hierarchical classification evaluation values ​​and the corresponding hierarchical writing data. The horizontal axis represents the candidate memory unit number, and the vertical axis represents the memory hierarchical classification evaluation value. The scatter points of different colors in the chart correspond to the L1 user profile layer, L2 short-term fact layer, L3 mid-term experience layer, L4 conversation pipeline layer, and L0 system rules layer, respectively. The dashed lines represent the hierarchical writing thresholds for each layer. As can be seen from the chart, candidate memory units M001, M005, and M007 have relatively high memory hierarchical classification evaluation values, which are near or above the higher thresholds, corresponding to writing to the high-priority layer; candidate memory units M002 and M006 are in the middle range, corresponding to writing to the L2 short-term fact layer; candidate memory unit M003 is close to the threshold boundary of the L3 mid-term experience layer, indicating that it belongs to the candidate content that can enter the low to medium levels; candidate memory unit M004 has the lowest evaluation value, corresponding to writing to the L4 conversation pipeline layer. This diagram visually illustrates how this scheme calculates the memory hierarchy assessment value of candidate memory units based on priority strength, cross-cycle stability, cross-task reusability, conflict degree, and redundancy density, and completes the writing determination process for the L1 user profile layer, L2 short-term fact layer, L3 medium-term experience layer, and L4 session pipeline layer based on the comparison data between the assessment value and the hierarchical threshold.

[0040] In this implementation scheme, real-time comparison of monotonically decreasing threshold groups with memory level attribution evaluation values ​​enables automated and unambiguous write determination from the L1 user profile layer to the L4 session pipeline layer; a fixed loading strategy is adopted for the L0 system rule layer to ensure the stable effectiveness of system-level constraints; combined with Figure 2 The data distribution shown intuitively verifies the rationality of the hierarchical structure where high-evaluation-value memories are written into high-priority layers and low-evaluation-value memories are pushed down to low-priority layers. This forms a hierarchical memory dataset with clear levels, configurable thresholds, and clear writing rules, providing structured memory support for context retrieval, experience transfer, and collaborative decision-making in multi-agent systems.

[0041] Specifically, the steps for constructing the experience-updated input sequence based on the hierarchical memory dataset are as follows: Based on the hierarchical memory dataset, the L2 short-term fact layer records and the L4 session pipeline records corresponding to the same session round are read from the N rounds of the current session. The records are then spliced ​​together using a sliding window according to the session round order. For user input, task status, tool call data, error correction conclusions, and execution data within the N rounds, a method combining slot extraction based on field template constraints and summary compression based on inter-sentence dependencies is used for extraction. First, structured fragments are extracted according to a fixed field template of "task identifier - role identifier - tool name - tool call status - error correction conclusion - execution data". Then, text fragments with semantic repetition and unchanged status in consecutive rounds are merged and compressed. The retained fragments are reorganized according to the message generation time order to obtain key fact items, immediate correction items, and stage status items, and a sliding window fact candidate sequence is constructed. Here, N is the sliding window size, representing the number of consecutive session rounds participating in splicing and extraction, which is a system-preset configurable parameter with a default value of 3.

[0042] When no new user messages and no tool calls are detected within T consecutive seconds of a session, the corresponding records in the L2 short-term fact layer and the L4 session pipeline layer are jointly read. For content that is recurring, stable across rounds, or confirmed by the user, a stability screening method based on cross-round co-occurrence statistics and an archiving summary method based on rule template merging are used for summarization. First, the number of times candidate content recurs in consecutive rounds, whether it is confirmed by the user, and whether it corresponds to successful execution data are counted to filter out candidate fragments that meet the preset stability conditions. Then, the filtered candidate fragments are classified and merged according to the preset archiving templates of "user preference type, long-term constraint type, experience type, and decision logic type". For content that is consistent between user text commands and user new preferences and has not been corrected, it is extracted as user new preferences. For content that repeatedly appears with error correction conclusions and corresponding successful execution data under different task identifiers, it is extracted as cross-task reusable experience. For content that maintains a correspondence between Plan planning data, Worker execution data, and tool call status, it is extracted as decision logic, and an archived experience candidate sequence is constructed.

[0043] In this implementation plan, through cross-cycle co-occurrence statistics and rule template merging archived summaries, content that is stable across cycles, confirmed by users, or has reusable value is effectively screened out. This content is then extracted as new user preferences, reusable experiences across tasks, and decision-making logic, constructing a well-structured candidate sequence of archived experiences. This provides a high-quality, low-noise input foundation for subsequent evaluation of experience effectiveness, comparison of experience migration thresholds, and generation of experience update tags.

[0044] Specifically, the steps for evaluating the effectiveness of the current empirical candidates are as follows: Based on the sliding window fact candidate sequence and the archived experience candidate sequence, the effectiveness of the current experience candidate is evaluated: the recursive value of the experience effectiveness at the previous moment is retained as a historical state item; the ratio of the number of key fact items in the sliding window fact candidate sequence to the total number of key fact items, immediate correction items, and stage state items in the sliding window fact candidate sequence is calculated to obtain the fact conciseness item, which takes the value of 0 when the denominator is zero; the ratio of the number of immediate correction items confirmed by the user in the sliding window fact candidate sequence to the total number of immediate correction items in the sliding window fact candidate sequence is calculated to obtain the error correction confirmation item, which takes the value of 0 when the denominator is zero; The number of conflict terms between the archived experience candidate sequence and the existing L1-L3 is calculated using normalized data to obtain the conflict jitter. This is then divided by the larger of the archived experience candidate sequence length and the maximum number of conflicts in the historical window to obtain the normalized conflict jitter. The conflict jitter is set to 0 when the denominator is zero. The factual conciseness term and the error correction confirmation term are multiplied, then divided by the sum of the conflict jitter and the zero-prevention term, and then subjected to a hyperbolic tangent transformation to obtain the current evidence term. The historical state term is multiplied by the recursive inertia factor to obtain the historical correlation term. The current evidence term is multiplied by the difference between 1 and the recursive inertia factor to obtain the evidence correlation term. The historical correlation term and the evidence correlation term are added together to obtain the empirical effectiveness recursive value.

[0045] The specific formula for calculating the empirical recursive value is as follows: ; In the formula, This represents the current moment's effective recursive value, which is used as the basis for determining whether experience migration should be written. This represents the recursive value of the experience effect from the previous moment, used to characterize the experience effect state that has been formed in the previous moment; This represents the recursive inertia factor, calculated using the sliding window trigger state and the archive trigger state at the current moment. Its value range is (0,1], and it is used to adjust the degree of retention of the empirical state at the previous moment in the calculation at the current moment. This indicates the degree of factual conciseness, used to characterize the effective retention of task facts within the current window after extraction and compression. Indicates the error correction confirmation degree, which characterizes the extent to which error correction information within the current window has been confirmed; This represents the amount of conflict jitter, used to characterize the degree of inconsistency between the current experiential candidate and existing hierarchical memory; This indicates a zero-preservation term, which is obtained by setting a very small positive constant and is used to avoid zero values ​​in the denominator and maintain the stability of the formula calculation process.

[0046] As shown in Table 1, the evaluation data of the recursive cognitive iteration process was quantified using multi-dimensional indicators for each of the seven rounds of cognitive iteration: Round 1: Factual conciseness 0.42, Error correction confirmation 0.3, Conflict jitter 0.15, Recursive inertia factor 0.7, Experience effective recursive value 0.28; Round 2: Factual conciseness 0.55, Error correction confirmation 0.45, Conflict jitter 0.2, Recursive inertia factor 0.65, Experience effective recursive value 0.41; Round 3: Factual conciseness 0.68, Error correction confirmation 0.7, Conflict jitter 0.12, Recursive inertia factor 0.6, Experience effective recursive value 0.62; Round 4: Factual conciseness 0.7 2. The error correction confirmation rate is 0.85, the conflict jitter is 0.08, the recursive inertia factor is 0.55, and the experience-effective recursive value is 0.79. The factual refinement rate in the 5th round is 0.78, the error correction confirmation rate is 0.92, the conflict jitter is 0.05, the recursive inertia factor is 0.5, and the experience-effective recursive value is 0.89. The factual refinement rate in the 6th round is 0.8, the error correction confirmation rate is 0.95, the conflict jitter is 0.03, the recursive inertia factor is 0.45, and the experience-effective recursive value is 0.94. The factual refinement rate in the 7th round is 0.82, the error correction confirmation rate is 0.98, the conflict jitter is 0.02, the recursive inertia factor is 0.4, and the experience-effective recursive value is 0.97. Overall data shows that as the iteration rounds progress, the factual refinement, error correction confirmation, and the recursive value of effective experience continue to improve steadily, while the amount of conflict jitter and the recursive inertia factor gradually decrease. This indicates that the cognitive model is continuously optimized during the iteration process, the fact extraction is more accurate, the error correction capability is continuously enhanced, the cognitive conflict is gradually resolved, the recursive inertia is effectively weakened, and the effectiveness of experience continues to improve, ultimately achieving an iterative upgrade in cognitive quality.

[0047] Table 1. Data Table of Iterative Cognitive Evaluation

[0048] like Figure 3The graph showing the change in the recursive value of experience effectiveness illustrates the changing trend of the effectiveness of this scheme and different comparison schemes as the number of consecutive session rounds increases. The horizontal axis represents the number of session rounds, the vertical axis represents the recursive value of experience effectiveness, and the dashed line represents the experience migration threshold of 0.85. As can be seen from the graph, the recursive value of experience effectiveness continuously increases with the number of rounds, and exceeds the experience migration threshold in the 5th round. This indicates that the key facts, immediate corrections, and archived experiences extracted in the current round can quickly transition from the candidate state to the effective state. In contrast, the comparison schemes that only perform archiving without using the sliding window mechanism, and those that only perform sliding window updates without archiving write-back, have a slower rate of increase in the recursive value of experience effectiveness. They do not reach the experience migration threshold within the same number of rounds, indicating that a single update mechanism is insufficient to complete the solidification and migration of experience in a timely manner. This graph is used to visually demonstrate the process characteristics of this scheme, which achieves near real-time effectiveness and accelerated migration of experience through the linkage of sliding window updates and session archiving.

[0049] In this implementation scheme, by integrating the hyperbolic tangent transformation of historical state items and current evidence items, a smooth iterative update of the recursive value of experience effectiveness is achieved, effectively suppressing the drastic disturbance of single-round noise to the evaluation results; the product of factual condensation degree and error correction confirmation degree is used to synergistically characterize the information quality within the current window, and combined with the normalization penalty mechanism of conflict jitter, the experience candidates inconsistent with the existing memory system are accurately identified, avoiding the premature migration of low-quality experience.

[0050] Specifically, the steps for generating experience update tags are as follows: The system compares the effective recursive value of the experience with the experience migration threshold group in real time. The experience migration threshold group includes a first experience migration threshold and a second experience migration threshold, and the first experience migration threshold is less than the second experience migration threshold. Both the first and second experience migration thresholds are derived from the experience migration control parameters read from the configuration file during initialization. The first experience migration threshold has a default value of 0.6, and the second experience migration threshold has a default value of 0.85, with a value range of 0 to 1. The repetition number threshold K has a default value of 3. The threshold values ​​are determined as follows: The first experience transfer threshold is relatively low, used to determine whether newly added user preferences meet the stability requirements for being written into the L1 user profile layer. A value of 0.6 indicates that when the recursive value of the experience effectiveness exceeds 60%, the preference is considered to have long-term retention value, avoiding excessively delayed learning. The second experience transfer threshold is relatively high, used to screen whether repeatedly occurring correction actions across tasks are promoted to the L3 mid-stage experience layer. A value of 0.85 requires the recursive value of the experience effectiveness to reach more than 85%, to prevent accidentally successful single corrections from being mistakenly promoted to general experience. The repetition threshold K=3 means that the same correction action must occur repeatedly in at least three different task types and the effective recursive value must meet the second threshold before migration to the L3 mid-stage experience layer is triggered. The value is set based on statistical experience; too small a value can easily lead to overfitting, while too large a value will result in slow convergence. The above default values ​​can be dynamically adjusted based on online performance.

[0051] When an experience candidate includes a new user preference and the experience effectiveness recursion value is greater than or equal to the first experience migration threshold, it is written to the L1 user profile layer. When the same correction action of an experience candidate appears more than K times in different task types and the experience effectiveness recursion value is greater than or equal to the second experience migration threshold, it is written to the L3 mid-term experience layer. K is the repetition threshold, with a default value of 3. When the experience effectiveness recursion value is lower than the second experience migration threshold, the corresponding experience candidate will continue to be retained in the L2 short-term fact layer and the L4 session pipeline layer for reconfirmation. Waiting for reconfirmation means retaining the original candidate without migration and re-participating in the effectiveness evaluation in the round. The identified migration status is then structurally bound with the current session identifier, round information, experience source range, role source information, and task identifier to generate an experience update tag.

[0052] In this implementation scheme, by setting a first experience migration threshold and a second experience migration threshold and maintaining a monotonically increasing relationship, differentiated migration control of new user preferences and reusable cross-task experiences is achieved, avoiding the premature writing of low-confidence experiences into the L1 user profile layer or the L3 intermediate experience layer; the use of the recurrence frequency threshold K to filter cross-task reusable experiences effectively suppresses the pollution of the intermediate experience layer by accidental correction actions.

[0053] Specifically, the steps for extracting the current task request and candidate context fragments, and evaluating the role context fit are as follows: Based on the user text commands, task identifiers, role identifiers, Plan planning data corresponding to the current task identifier, and tool call status for the current round, a role request vector is constructed using a field mapping method. Keyword matching and position extraction are performed on action words, object words, and restriction words in the user text commands to obtain task target fragments and constraint condition fragments. The Plan planning data corresponding to the current task identifier is parsed according to step number to extract the execution phase fragment corresponding to the current subtask. Field mapping is performed on the tool name and call data fields in the tool call status to extract the tool requirement fragment. Then, the task target fragment, execution phase fragment, tool requirement fragment, constraint condition fragment, and role identifier are encoded according to a preset field order to construct the role request vector. The dimension of the role request vector is equal to the total number of semantic slots. The encoding method is as follows: the task target fragment, execution phase fragment, tool requirement fragment, constraint condition fragment, and role identifier are each one-hot encoded or embedded encoded separately, and then concatenated into a fixed-length vector according to the field order. The tag encoding caliber is one continuous sub-vector interval corresponding to each field, and the interval boundary is determined by the field dictionary size.

[0054] The system retrieves system rule records and tool call constraint records corresponding to the current role identifier from the L0 system rule layer; retrieves explicit user commands and user preferences corresponding to the current user identifier from the L1 user profile layer; retrieves recent task facts corresponding to the current task identifier and located within the round window from the L2 short-term fact layer; retrieves experience candidates matching the current task type, error type, or correction action from the L3 mid-term experience layer; and retrieves hit records corresponding to the current task identifier from the retrieved hit fragments. A context filtering method based on task identifier filtering, user identifier filtering, role identifier filtering, and time window filtering is used to extract candidate context fragments. Source level identifiers, task identifiers, and role identifiers are then attached to each fragment, and corresponding tags are generated based on the fragment's source. Among these, fragments from the L0 system rule layer are considered as source level identifiers, task identifiers, and role identifiers. The process involves generating constraint labels from candidate context fragments at each layer: L1 user profile layer, L2 short-term fact layer, L3 mid-term experience layer, and retrieval hit fragments. Each candidate context fragment is also labeled with a task label and a source layer label. A vectorized construction method based on label number mapping and field concatenation is then used to encode the corresponding labels, constructing a context feature vector. Tokenizer segmentation is performed on the candidate context fragments to obtain the context consumption. The remaining budget of the agent is obtained by subtracting the cumulative token consumption of the already configured context content from the agent's current token budget. The dimension of the context feature vector equals the total number of label types multiplied by the maximum number of values ​​for each label, with a default dimension of 128. The encoding method involves mapping each label to an integer number, converting it into a dense vector through an embedding layer, and finally concatenating them into a single vector. The label encoding caliber is a bijective mapping table from label values ​​to non-negative integers, generated from the entire label set during system initialization.

[0055] Based on the role type, a role permission matrix is ​​constructed using a permission matrix generation method. The number of rows in the role permission matrix is ​​equal to the dimension of the context feature vector, and the number of columns is equal to the dimension of the role request vector. The matrix cell takes the value 0 or 1, where 1 indicates that the context feature of the corresponding dimension is allowed to pass through the corresponding dimension of the role request vector, and 0 indicates that it is prohibited. The encoding method is to generate a sparse matrix from a predefined permission rule table based on the role type. The label encoding caliber is that the matrix row index is aligned with the label encoding of the context feature vector, and the column index is aligned with the slot encoding of the role request vector.

[0056] The system reads role permission rules and tool call constraints from the system rule file. It sets global planning read permissions, cross-task experience read permissions, and task distribution read permissions for the Plan agent. It sets current subtask fact read permissions, necessary constraint read permissions, and execution instruction read permissions for the Worker agent. It also sets suppression permissions for irrelevant planning links, other subtask content, and historical chat content. The system fills the matrix cells with the permission rules according to the correspondence between tag type, source level, and role type to generate a role permission matrix.

[0057] Evaluate the context fit between the current candidate context fragment and the target role: Calculate the matrix product of the transpose of the context feature vector, the role permission matrix, and the role request vector to obtain the matching term; calculate the matrix product of the transpose of the context feature vector, the role permission matrix, and the context feature vector to obtain the feature term; calculate the square root of the sum of the feature term and the zero-prevention term to obtain the baseline feature term, and the square root of the sum of the matching term and the zero-prevention term to obtain the matching penalty term; multiply the baseline feature term and the matching penalty term to obtain the constraint term; divide the matching term by the constraint term to obtain the matrix constraint value; extract the maximum value of the difference between the context consumption and the agent's remaining budget and the constant term zero, divide it by the sum of the agent's remaining budget and the zero-prevention term, and perform an exponential operation to obtain the penalty term; multiply the matrix constraint value by the penalty term to obtain the role context fit value.

[0058] The specific formula for calculating the role context adaptation value is as follows: ; In the formula, Indicates the first Role-based intelligent agents for the first The role context adaptation value of each candidate context fragment is used to characterize the degree of adaptation of the current candidate context fragment to the corresponding role agent context; The category identifier of the role agent is obtained by reading the role identifier field of the current agent and according to the role type mapping relationship. The value range is positive integer. It is used to distinguish different categories of role agents and identify the role object currently participating in the adaptation calculation. k represents the sequence number identifier of the candidate context fragment. It is obtained by numbering the candidate context fragments to be assembled in the current set according to the extraction order or traversal order. The value range is positive integer. It is used to distinguish different candidate context fragments and identify the context object currently participating in the adaptation calculation. Indicates the first The context feature vector of each candidate context fragment is used to characterize the content attribute, source attribute, and task association attribute of the current candidate context fragment. Indicates the first The role permission matrix for role-based intelligent agents is used to represent the readable range and constraint relationships of the current role-based intelligent agent for different types of context fragments; Indicates the first The role request vector of a role-based intelligent agent is used to represent the request characteristics of the current role-based intelligent agent in the current task; Indicates the first The context consumption is used to characterize the token resources used by the current candidate context fragment when it is assembled into the context; Indicates the first The remaining budget of the agent is used to represent the amount of tokens that the current agent can continue to allocate during this round of context assembly. This indicates a zero-preservation term, which is obtained by setting a very small positive constant and is used to avoid zero values ​​in the denominator and maintain the stability of the formula calculation process.

[0059] like Figure 4 The comparison chart showing the role context adaptation values ​​across different source fragments illustrates the differences in adaptation between candidate context fragments from different sources for different role agents during the role-based context assembly process. The horizontal axis represents the source type of candidate context fragments, including system rules, user hard constraints, recent facts, cross-task experience, other subtask planning, historical chatter, and retrieval hits. The vertical axis represents the role context adaptation value, and the dashed line represents the delivery threshold of 0.7. As can be seen from the chart, the Plan agent has a generally high adaptation value for system rules, user hard constraints, recent facts, and cross-task experience, and most of these values ​​are higher than the delivery threshold. This indicates that when performing global planning and task distribution, the Plan agent needs to prioritize receiving global information such as rule constraints, user preferences, current task status, and historical experience. The Worker agent also has a high adaptation value for recent facts and cross-task experience, but its adaptation value for system rules, other subtask planning, and historical chatter is significantly lower. This indicates that the Worker agent is more suitable for receiving fact fragments and necessary constraint fragments directly related to the current subtask, and should not receive too many irrelevant planning links and low-relevance historical content. This diagram visually illustrates the assembly logic of this solution, which uses role-based permission constraints and context adaptation evaluation to achieve differentiated context delivery between the Plan agent and the Worker agent.

[0060] This implementation achieves precise context delivery for Plan and Worker agents: the Plan agent's adaptation value to system rules, user hard constraints, and cross-task experience is significantly higher than the delivery threshold, ensuring the integrity of global planning and task distribution; the Worker agent focuses on recent facts and necessary constraints, significantly reducing its adaptation value to irrelevant planning links and historical chatter, effectively suppressing context interference. Combined with the penalty term of the Token budget constraint, highly adaptable fragments are prioritized within limited resources, improving context utilization efficiency and the accuracy of multi-agent collaborative decision-making.

[0061] Specifically, the steps for identifying the role delivery status and generating a role-level context assembly report are as follows: When the current role is a Plan agent and the role context adaptation value is greater than or equal to the role delivery threshold, the corresponding candidate context fragments of the L0 system rule layer, L1 user profile layer, L2 short-term fact layer, and L3 mid-term experience layer are retained to form a global context assembly report for the Plan agent. When the current role is a Worker agent and the role context adaptation value is greater than or equal to the role delivery threshold, only the fact fragments of the L2 short-term fact layer, the constraint fragments of the L1 user profile layer, and the execution instructions generated by the Plan agent related to the current subtask are retained. When the role context adaptation value is lower than the role delivery threshold, the corresponding fragments are filtered. The identified role delivery status is compared with the current role number, task identifier, and meeting... The conversation turn, context source level, and sampling time information are structurally bound to generate a role-level context assembly report. Simultaneously, roles identified as having inefficient or over-budget delivery are flagged for review, and their corresponding delivery anomaly states are marked. The anomaly types for these states include: inefficient delivery, over-budget delivery, insufficient permissions delivery, and missing fragment delivery. Inefficient delivery is triggered when the role's context fit value is below the role's delivery threshold but above 0.5 times the threshold. Over-budget delivery is triggered when context consumption exceeds the agent's remaining budget. Insufficient permissions delivery is triggered when the corresponding matrix element in the role's permission matrix contains a zero-value prohibited item. Missing fragment delivery is triggered when the necessary candidate context fragment is empty. After all roles have completed context assembly and task execution, all role-level context assembly reports are summarized to generate a collaborative processing statistics report.

[0062] like Figure 5 The graph comparing the duplication error rate and response latency across different session rounds illustrates the changes in duplication error control and response efficiency maintenance of the proposed solution as the number of session rounds increases. The horizontal axis represents the session round range, the left vertical axis represents the duplication error rate, and the right vertical axis represents the response latency. As the graph shows, as the number of session rounds increases from 1-5 to 31-35, the duplication error rate of the existing solution continuously rises, and the response latency increases synchronously. This indicates that the existing solution is prone to problems such as historical redundancy accumulation, repeated error triggering, and increased context assembly burden in long dialogues and multi-round collaborative processing. In contrast, the duplication error rate of the proposed solution maintains a downward trend overall, and the response latency remains within a low and relatively stable range. This demonstrates that through hierarchical memory construction, near real-time experience updates, and role-based context filtering, the proposed solution can continuously suppress the propagation of duplication errors and reduce the processing overhead caused by invalid context assembly during round growth. This graph visually demonstrates the proposed solution's ability to jointly optimize both duplication error rate and response latency in long-session collaborative scenarios.

[0063] In this implementation plan, highly compatible segments are retained for roles that reach the delivery threshold, and a structured assembly report is generated. Abnormal deliveries, such as inefficient deliveries, those exceeding budget limits, those with insufficient permissions, or those with missing segments, are automatically flagged for re-inspection and the anomaly type is labeled, effectively preventing interference from invalid context on the agent. By summarizing multi-role assembly reports, a collaborative processing statistical report is generated, providing traceable assembly data for global task execution. Figure 5 As shown, the proposed solution continuously reduces the repetitive error rate and maintains stable response latency in long-session scenarios, verifying the joint optimization capability of the abnormal delivery handling and re-inspection mechanism for system robustness and efficiency.

[0064] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0065] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims

1. An AI agent processing method based on hierarchical memory architecture and near real-time experience updates, characterized in that: Includes the following steps: S1 collects data on the entire process of intelligent agent collaborative processing, obtains intelligent agent interaction observation data, and performs time axis relocation, content denoising, role completion and normalization processing. S2, based on the intelligent agent interaction observation data, extract candidate memory units, construct a hierarchical memory writing queue, evaluate the degree of hierarchical affiliation of candidate memory units, and construct a hierarchical memory dataset; S3, based on the hierarchical memory dataset, constructs an experience update input sequence, evaluates the effectiveness of the current experience candidates, and generates experience update labels; S4: Extract the current task request and candidate context fragments, evaluate the role context adaptation, identify the role delivery status, and generate a role-level context assembly report.

2. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 1, characterized in that: The specific steps for collecting data on the entire process of agent collaboration, acquiring agent interaction observation data, and performing timeline relocation, content denoising, role completion, and normalization are as follows: The entire process of intelligent agent collaborative processing is collected to obtain intelligent agent interaction observation data, which includes user text commands, user new preferences, task identifiers, session rounds, plan planning data, worker execution data, tool call status data, retrieval hit fragment data, error correction conclusions, role identifiers, message generation time, module reception time and writing time. A message reordering method based on timestamp alignment is used to relocate the timeline of agent interaction observation data; a text denoising method based on role label and task label constraints is used to denoise the content of agent interaction observation data. The role completion method based on task parent-child relationship mapping is used to complete the roles of data items with missing role identifiers, missing task source identifiers, and missing round identifiers; the normalization method based on field categories is used to perform interval scaling, encoding mapping, and length unification processing on the agent interaction observation data.

3. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update as described in claim 2, characterized in that: The specific steps for extracting candidate memory units and constructing a hierarchical memory writing queue based on intelligent agent interaction observation data are as follows: Based on the intelligent agent interaction observation data, the system performs constraint sentence recognition based on keyword dictionary and regular expression template for user text commands and user new preferences, generating explicit user command items and user preference items; and sequentially splices together Plan planning data, Worker execution data, tool call status, retrieval hit fragments and error correction conclusions within consecutive session rounds under the same task identifier to generate recent task fact items. Write the message generation time, module reception time, and writing time as a single message to generate the original session log item; For error correction conclusions that have been confirmed and marked as successful by the user, extract the corresponding task identifier, plan planning data, worker execution data and tool call status, and generate experience candidates; The system rules, role and permission rules, and tool call constraints are read from the system rule file to generate system rule items; the above-mentioned user explicit command items, user preference items, recent task facts items, original session log items, experience candidate items, and system rule items are all candidate memory units; For each candidate memory unit, generate hierarchical labels, source labels, role labels, task labels, and validity period labels; system rule items correspond to the L0 system rule layer, user explicit instruction items and user preference items correspond to the L1 user profile layer, recent task fact items correspond to the L2 short-term fact layer, experience candidate items correspond to the L3 mid-term experience layer, and original session pipeline items correspond to the L4 session pipeline layer; and construct a hierarchical memory write queue based on hierarchical write rules.

4. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 3, characterized in that: The specific steps for evaluating the hierarchical affiliation of candidate memory units are as follows: Priority strength is obtained by statistically analyzing the hit rate of user explicit instructions and user preferences in candidate memory units; cross-round stability is obtained by statistically analyzing the number of times candidate memory units are repeatedly retrieved within a session round window; cross-task reusability is obtained by statistically analyzing the recurrence of task types, error types, and correction actions corresponding to candidate memory units; conflict degree is obtained by comparing candidate memory units with existing L1 user profile layer, L2 short-term fact layer, and L3 medium-term experience layer records item by item; and redundancy density is obtained by statistically analyzing the proportion of duplicate content between candidate memory units and hierarchical memory write queues. The product of priority intensity and stability adjustment coefficient multiplied by cross-wheel stability and the product of reuse adjustment coefficient multiplied by cross-task reuse are summed and divided by the sum of conflict degree plus one and anti-zero term to obtain the main discriminant input. The main discriminant input is then subjected to arctangent transformation to obtain the main discriminant value. The redundancy density is divided by the sum of redundancy density plus one and anti-zero term to obtain the redundancy penalty value. The redundancy penalty value is then subtracted from the main discriminant value to obtain the memory level attribution evaluation value.

5. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 4, characterized in that: The specific steps for constructing the hierarchical memory dataset are as follows: The system compares the memory level attribution evaluation value and the hierarchical writing threshold group in real time. The hierarchical writing threshold group includes the first-level threshold, the second-level threshold, and the third-level threshold. When the memory level attribution evaluation value of a candidate memory unit is greater than or equal to the first-level threshold, it is written to the L1 user profile layer. When the memory level attribution evaluation value of a candidate memory unit is less than the first-level threshold but greater than or equal to the second-level threshold, it is written to the L2 short-term fact layer. When the memory level attribution evaluation value of a candidate memory unit is less than the second-level threshold but greater than or equal to the third-level threshold, it is written to the L3 intermediate experience layer. When the memory level attribution evaluation value of a candidate memory unit is less than the third-level threshold, it is written to the L4 session pipeline layer. The L0 system rules layer is subjected to fixed loading processing and does not participate in the hierarchical comparison, thus constructing a hierarchical memory dataset.

6. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 5, characterized in that: The specific steps for constructing the experience-updated input sequence based on the hierarchical memory dataset are as follows: Based on the hierarchical memory dataset, the L2 short-term fact layer records and the L4 session pipeline records corresponding to the same session round are read within N rounds of the current session. Sliding window splicing, repetition compression, and sequential reorganization are performed to obtain key fact items, immediate correction items, and stage status items, and a sliding window fact candidate sequence is constructed. When no new user messages and no tool calls are detected within T consecutive seconds of the session, the corresponding records in the L2 short-term fact layer and the L4 session pipeline are read together. Stability screening based on cross-round co-occurrence statistics and archiving summary methods based on rule template merging are used to summarize and extract user new preferences, reusable experiences across tasks, and decision logic, and an archive experience candidate sequence is constructed.

7. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 6, characterized in that: The specific steps for evaluating the effectiveness of the current empirical candidates are as follows: Based on the sliding window fact candidate sequence and the archived experience candidate sequence, the effectiveness of the current experience candidate is evaluated: the previous time-lapse experience effectiveness recursion value is retained as a historical state item; The fact conciseness item is obtained by calculating the ratio of the number of key fact items in the sliding window fact candidate sequence to the total number of key fact items, immediate correction items, and stage status items in the sliding window fact candidate sequence. The error correction confirmation term is obtained by calculating the ratio of the number of immediate correction items confirmed by the user in the sliding window fact candidate sequence to the total number of immediate correction items in the sliding window fact candidate sequence. The number of conflict terms between the archived experience candidate sequence and the existing L1-L3 is calculated using normalized data to obtain the conflict jitter. The factual condensation term and the error correction confirmation term are multiplied, divided by the sum of the conflict jitter and the zero-prevention term, and then subjected to hyperbolic tangent transformation to obtain the current evidence term. The historical state term is multiplied by the recursive inertia factor to obtain the historical correlation term. The current evidence term is multiplied by the difference between 1 and the recursive inertia factor to obtain the evidence correlation term. The historical correlation term and the evidence correlation term are added together to obtain the experience effectiveness recursive value.

8. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 7, characterized in that: The specific steps for generating experience update tags are as follows: The system compares the recursive value of the effective experience with the experience migration threshold group in real time. The experience migration threshold group includes the first experience migration threshold and the second experience migration threshold. When an experience candidate contains a new user preference and the recursive value of the effective experience is greater than or equal to the first experience migration threshold, it is written to the L1 user profile layer. When the same correction action of an experience candidate occurs more than K times in different task types and the recursive value of the effective experience is greater than or equal to the second experience migration threshold, it is written to the L3 mid-term experience layer. When the experience effective recursion value is lower than the second experience migration threshold, the corresponding experience candidate will continue to be retained in the L2 short-term fact layer and the L4 session pipeline layer for reconfirmation. The identified migration status is then structurally bound to the current session identifier, round information, experience source range, role source information, and task identifier to generate experience update tags.

9. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 8, characterized in that: The specific steps for extracting the current task request and candidate context fragments, and evaluating the role context adaptation are as follows: Based on the user text commands, task identifiers, role identifiers, Plan planning data corresponding to the current task identifier, and tool call status of the current round, a role request vector is constructed based on the field mapping method. From the L0-L3 layers and the retrieved fragments, a candidate context fragment is extracted using a task identifier filtering method, and a source level identifier is attached to each fragment. A corresponding label is generated according to the fragment source, and the corresponding label is encoded to construct a context feature vector. Perform tokenizer segmentation and statistical analysis on the candidate context fragments to obtain the context consumption; subtract the cumulative token consumption of the assembled context content from the current agent's token budget to obtain the agent's remaining budget; Based on the role type, a role permission matrix is ​​constructed using a permission matrix generation method; Evaluate the context fit between the current candidate context fragment and the target role: calculate the matrix product of the transpose of the context feature vector, the role permission matrix, and the role request vector to obtain the matching item; The feature terms are obtained by calculating the transpose of the context feature vector, the matrix product of the role and permission matrix and the context feature vector; The baseline feature term is obtained by taking the square root of the sum of the feature term and the zero-prevention term. The matching penalty term is obtained by taking the square root of the sum of the matching term and the zero-prevention term. The constraint term is obtained by multiplying the baseline feature term and the matching penalty term. The matrix constraint value is obtained by dividing the matching term by the constraint term. The maximum value of the difference between the context consumption and the agent's remaining budget and the constant term zero is extracted, divided by the sum of the agent's remaining budget and the zero-prevention term, and exponentially calculated to obtain the penalty term. The role context adaptation value is obtained by multiplying the matrix constraint value by the penalty term.

10. The AI ​​agent processing method based on hierarchical memory architecture and near real-time experience update according to claim 3, characterized in that: The specific steps for identifying the role delivery status and generating a role-level context assembly report are as follows: When the current role is the Plan agent and the role context adaptation value is greater than or equal to the role delivery threshold, the corresponding candidate context fragments of the L0 system rule layer, L1 user profile layer, L2 short-term fact layer and L3 medium-term experience layer are retained to form a global context assembly report for the Plan agent. When the current role is a Worker agent and the role context adaptation value is greater than or equal to the role delivery threshold, only the fact fragments of the L2 short-term fact layer, the constraint fragments of the L1 user profile layer, and the execution instructions generated by the Plan agent are retained for the current subtask. When the role context adaptation value is lower than the role delivery threshold, the corresponding fragments are filtered out. The identified role delivery status is structurally bound with the current role number, task identifier, session round, context source level, and sampling time information to generate a role-level context assembly report and mark the corresponding delivery anomaly status.