An agent self-correction method and system based on trajectory comparison and positioning
By performing structured trajectory recording and multimodal divergence calculation on the agent's execution process, combined with causal analysis of the independent teacher model and state snapshot rollback technology, the problem of the agent's difficulty in accurately locating errors in complex tasks is solved, thereby improving task success rate and execution efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HARBIN INST OF TECH AT WEIHAI
- Filing Date
- 2026-05-13
- Publication Date
- 2026-07-31
AI Technical Summary
When performing complex tasks, existing intelligent agents struggle to pinpoint the specific steps where errors occur and lack structured self-correction mechanisms, resulting in low retry efficiency and a lack of online optimization capabilities after task failure.
By recording and monitoring the structured trajectory of the agent's execution process, using dynamic time warping algorithm and multimodal divergence calculation for step-level comparison, introducing an independent teacher model for causal analysis, generating a structured correction strategy, and performing correction operations and real-time verification through state snapshot rollback technology.
It enables intelligent agents to accurately locate erroneous steps in complex tasks, significantly improving task success rate and execution efficiency, reducing the number of repeated errors, and possessing cross-scenario adaptability and interpretability.
Smart Images

Figure CN122173330B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence and general intelligent agent technology, and specifically relates to an intelligent agent self-correction method and system based on trajectory comparison and localization. Background Technology
[0002] With the rapid development of large-scale pre-trained models and general artificial intelligence technologies, intelligent agent systems built on large models are widely used in fields such as automated operation of graphical user interfaces, code generation and debugging, mathematical reasoning, data analysis, and multi-agent collaboration. Unlike traditional single-task models, general agents typically take natural language instructions as input and complete complex multi-step tasks through internal planning, tool invocation, and environmental interaction. These systems have strong generalization capabilities in open environments, but their execution process essentially relies on probability generation and approximate reasoning mechanisms, making it difficult to guarantee stability and accuracy in long-chain tasks. In practical applications, agent task execution typically involves multiple stages such as "task understanding—policy planning—step execution—environmental feedback—result verification." Especially in scenarios such as GUI automation, code execution, or mathematical calculations, tasks often involve ten or even dozens of consecutive operations. Once a critical step deviates, such as clicking the wrong control, generating an incorrect function, misjudging intermediate calculation results, or calling an incompatible tool interface, subsequent steps will be built on the erroneous state, leading to the failure of the entire task. Since errors may originate from early steps and are cumulative, simply making a judgment in the final state and retrying the whole thing is often inefficient and can easily lead to repeating the same error path.
[0003] In existing technologies, the following strategies are mainly adopted to improve the performance of intelligent agents: First, by increasing the scale of model parameters or introducing a larger training corpus to enhance generalization ability; second, by optimizing the inference path through methods such as cue engineering or chain thinking; third, by introducing reinforcement learning or human feedback for offline optimization; and fourth, by limiting the range of model output through external rules or constraint modules. However, the above methods mostly focus on enhancing model capabilities or offline optimization, and lack mechanisms for structured verification and online correction of the execution process of a single task.
[0004] In recent years, some studies have proposed a "self-reflection" or "self-evaluation" framework, which involves calling the model again to verify and correct the results after they are generated. However, such methods usually remain at the result-level or text-level evaluation level, lacking the ability to provide a structured representation of the execution trajectory and step-level analysis. When a task fails, the system often struggles to pinpoint the specific operational node where the error occurred, and it is difficult to distinguish whether the error was due to a strategy planning error, a state understanding error, or a tool invocation error. Furthermore, if the generation and evaluation processes are completed by the same model within the same parameter space, self-confirmation bias may occur, reducing the objectivity and stability of the evaluation. In GUI agent scenarios, although screenshots or interface states can be used to determine whether a task was successful, existing methods typically only utilize the final state signal without step-by-step comparison and verification of the intermediate execution trajectory. In code agent scenarios, although unit tests can be used to determine whether the final output is correct, there is a lack of fine-grained tracking and localization of the intermediate code generation and modification processes. In mathematical or symbolic reasoning agent scenarios, although the answer can be verified by comparing the results, the identification of erroneous steps in the reasoning chain still mainly relies on manual analysis or coarse-grained backtracking. Furthermore, in multi-agent collaborative or complex tool invocation environments, task execution often involves cross-module interaction and state sharing, and error sources have strong context-dependent characteristics. Local judgments by a single module are insufficient to accurately identify root causes, and the lack of a unified trajectory representation and cross-step analysis mechanism makes it difficult for the system to develop stable self-correction capabilities. In summary, existing technologies still have the following shortcomings in terms of the execution stability of general-purpose intelligent agents: First, they lack a structured monitoring and recording mechanism for the complete execution process; second, they lack a precise error localization method based on step-level comparison, making it difficult to quickly identify key error nodes after task failure; third, they lack independent or higher-order analysis modules to perform causal analysis of the error context and generate structured correction suggestions; fourth, they lack a cyclical closed-loop correction and real-time verification mechanism, making it difficult for intelligent agents to continuously self-optimize in online environments.
[0005] Therefore, it is necessary to propose a general self-correction technology solution that can abstract the execution process of different tasks into a unified state monitoring and error diagnosis framework. When the final state fails, the error node can be located by step-level comparison, and the error cause can be analyzed in a structured manner by the analysis module to generate targeted correction suggestions. Then, the agent is driven to perform correction operations and real-time verification to form a stable closed loop. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention proposes a self-correction method and system for intelligent agents based on trajectory comparison and localization. This aims to solve the problems of difficulty in locating errors, low efficiency of repeated retries, and lack of online self-optimization capabilities during agent execution.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, this invention proposes a self-correction method for intelligent agents based on trajectory comparison and localization, comprising the following steps: In response to the intelligent agent executing a task, the state of the interaction between the intelligent agent and the external environment is monitored and recorded according to a preset time strategy to generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps. After the intelligent agent completes its task, the final state is determined. When the task is determined to have failed, the cause of failure is diagnosed and analyzed to generate error diagnosis information. The diagnosis analysis includes: comparing the current failed trajectory with a preset reference trajectory and calculating the divergence of each trajectory; and searching along the time step according to the trajectory divergence to determine the time step in which the divergence value first exceeds the preset divergence threshold as the error step that caused the task to fail. A structured correction strategy is generated based on the error diagnosis information; the agent responds to the structured correction strategy by performing correction operations to restore the correct state; the correction operations include generating compensation actions based on the current state, or rolling back to a historical state and re-executing. After the correction operation is completed, the local state is verified based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks continue to be executed; otherwise, the retry mechanism is triggered.
[0008] Secondly, this invention also proposes an intelligent agent self-correction system based on trajectory comparison and localization, comprising: State monitoring module: used to monitor and record the state of the interaction between the agent and the external environment in response to the agent's task execution, according to a preset time strategy, and generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps; Error diagnosis module: After the intelligent agent completes the task, it determines the final state; when the task is determined to have failed, it performs diagnostic analysis on the cause of failure and generates error diagnosis information; the diagnostic analysis includes: comparing the current failed trajectory with the preset reference trajectory and calculating the divergence of each trajectory; and searching along the time step according to the trajectory divergence, determining the time step in which the divergence value first exceeds the preset divergence threshold as the error step that caused the task to fail. Correction Execution Module: Used to generate a structured correction strategy based on the error diagnosis information; the agent responds to the structured correction strategy and executes correction operations to restore the correct state; the correction operations include generating compensation actions based on the current state, or rolling back to a historical state and re-executing; Verification module: After the correction operation is completed, it verifies the local state based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks continue to be executed; otherwise, a retry mechanism is triggered.
[0009] The effects described in the invention are merely those of the embodiments, and not all the effects of the invention. One of the above technical solutions has the following advantages or beneficial effects: This invention proposes a self-correction method and system for intelligent agents based on trajectory comparison and localization. The method includes the following steps: in response to the intelligent agent executing a task, monitoring and recording the state of the agent's interaction with the external environment according to a preset time strategy, generating execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps; after the intelligent agent's task execution is completed, determining the final state; when the task is determined to have failed, diagnosing and analyzing the cause of failure, generating error diagnosis information; the diagnostic analysis includes: comparing the current failed trajectory with a preset reference trajectory. The system compares the trajectory and calculates the divergence of each trajectory. Based on the trajectory divergence, it searches along time steps, identifying the time step where the divergence value first exceeds a preset divergence threshold as the erroneous step leading to task failure. A structured correction strategy is generated based on the error diagnosis information. The agent responds to the structured correction strategy by executing correction operations to restore the correct state. The correction operations include generating compensation actions based on the current state or rolling back to a historical state and re-executing. After the correction operations are completed, the local state is verified based on the consistency comparison of the state representation. If the verification passes, subsequent tasks continue; otherwise, a retry mechanism is triggered. A corresponding system is also proposed based on this method. This invention, by structuring the agent's execution process into a traceable trajectory, performing step-level comparison and localization upon failure, introducing an independent teacher model for high-order causal analysis and automatically generating structured correction suggestions, combined with local real-time verification and a closed-loop retry mechanism, can significantly reduce repeated errors and improve the success rate and execution efficiency of a single task. This method is applicable to various types of intelligent agents and achieves cross-scenario transfer through modular design and unified trajectory representation. Simultaneously, the system provides detailed error classification and interpretable output, facilitating review, backtracking, and online learning. Compared with existing methods, this invention possesses systematic advantages in error localization accuracy, correction effectiveness, online adaptive capability, and interpretability, enabling reliable deployment and large-scale application of intelligent agents in real-world complex environments.
[0010] This invention records the execution process of the intelligent agent as a structured trajectory and uses a dynamic time warping algorithm and multimodal divergence calculation for step-level comparison, which can accurately locate the specific time step where the error occurs, avoid blind overall retries, and significantly reduce the number of invalid attempts.
[0011] This invention introduces an independent teacher model to perform causal analysis on erroneous steps, avoiding self-confirmation bias caused by the execution agent's own reflection, thus improving the objectivity of error diagnosis and the pertinence of corrective suggestions. It supports state snapshot rollback technology, enabling the system to be restored losslessly to the state before the error occurred for retrying, avoiding the cascading failure risk that may be caused by forward compensation schemes in irreversible operations.
[0012] The technical solution of this invention covers a variety of alternative implementation paths, including static checkpoint assertions and continuous trajectory recording, self-reflection analysis and trajectory comparison analysis, forward compensation and rollback retry, plain text verification and multimodal verification, etc., and has strong adaptability and scalability.
[0013] This invention is applicable to various types of intelligent agents and enables cross-scenario migration through modular design and unified trajectory representation; at the same time, the system provides detailed error classification and interpretable output, which is conducive to review, backtracking and online learning. Attached Figure Description
[0014] Figure 1 This is a flowchart of an intelligent agent self-correction method based on trajectory comparison and localization proposed in Embodiment 1 of the present invention; Figure 2 This is an architecture diagram of an intelligent agent self-correction method based on trajectory comparison and localization proposed in Embodiment 1 of the present invention. Figure 3 This is a flowchart of the steps for comparison and positioning proposed in Embodiment 1 of the present invention; Figure 4 This is a flowchart illustrating the entire closed-loop process of the general intelligent agent proposed in Embodiment 1 of the present invention, from execution verification to teacher-driven error correction. Figure 5 This is a schematic diagram illustrating the precise positioning and configuration deviation based on step-level trajectory comparison proposed in Embodiment 2 of the present invention. Figure 6 This is the causal analysis and attention focus diagram of the teacher model proposed in Embodiment 2 of the present invention; Figure 7 This is a schematic diagram of the closed-loop correction and final task completion status output proposed in Embodiment 2 of the present invention; Figure 8 This is a schematic diagram of an intelligent agent self-correction system based on trajectory comparison and localization proposed in Embodiment 3 of the present invention; Figure 9 This is a schematic diagram of an intelligent agent self-correction device based on trajectory comparison and localization proposed in Embodiment 4 of the present invention. Detailed Implementation
[0015] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and processes are omitted to avoid unnecessarily limiting the invention.
[0016] Example 1 Embodiment 1 of this invention proposes an agent self-correction method based on trajectory comparison and localization, which aims to solve the problem of error cascading and accumulation that is easily caused when agents perform long-link complex tasks. By constructing a structured online verification and local retry mechanism, the robustness of system execution can be effectively improved.
[0017] This invention has high scalability and generalization ability, and is widely applicable to cross-modal intelligent agent application scenarios such as automated operation of graphical user interface (GUI), code generation and debugging testing, and complex mathematical symbol reasoning.
[0018] Figure 1 This is a flowchart of an intelligent agent self-correction method based on trajectory comparison and localization proposed in Embodiment 1 of the present invention; Figure 2 This is an architecture diagram of an intelligent agent self-correction method based on trajectory comparison and localization proposed in Embodiment 1 of the present invention; combined with Figure 1 and Figure 2 The process of implementing Embodiment 1 of the present invention will be described in detail.
[0019] In step S1: In response to the agent performing a task, the state of the agent's interaction with the external environment is monitored and recorded according to a preset time strategy to generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps. In this invention, the self-correction mechanism of the intelligent agent is first based on a structured data foundation established by trajectory recording and final state determination mechanisms. When the intelligent agent receives natural language instructions from a human user and begins to interact with the external environment, the entire multi-step execution process is captured in real time and abstracted using high-dimensional tensors. Figure 2 The core intelligent agent interacts with the external environment through an external environment interface.
[0020] The first prediction time strategy involves recording structured trajectories at continuous time steps. To unify information from different modalities, this invention introduces a cross-modal encoder. This maps text, images, structured code, or the UI DOM tree to a unified latent semantic space. Thus, the complete execution trajectory of a single task is determined. It can be rigorously formalized as a multivariate time series expansion of a Markov decision process (MDP).
[0021] Specifically: at each discrete time step Capture the current environmental state of the agent Actions performed by an agent based on its current state and the observational feedback returned from the environment after the action is performed. ; Environmental status ,action and observation feedback They are grouped into trajectory units according to time sequence. ; The agent executes the task from start time step 1 to end time step 2. All trajectory units are concatenated in time sequence to generate a structured trajectory. : .
[0022] The second prediction time strategy involves state sampling at discrete time points. This is achieved by pre-setting several static checkpoints before or during the agent's task execution. Assertions are only performed when the agent reaches each checkpoint, rather than recording at every consecutive time step. Specifically, the static checkpoints are set based on key operation nodes of the task, fixed time intervals, or milestone nodes in the business logic. When the agent reaches a pre-set checkpoint, the system triggers state acquisition and compares the current state with the expected state. If the assertion verification passes, subsequent tasks continue; if the verification fails, an error is determined to have occurred within the interval where the checkpoint is located, and the corresponding error correction process is triggered. This discrete sampling method effectively reduces the data storage overhead and computational burden of state monitoring, making it suitable for agent applications with high real-time requirements or limited storage resources. It can also serve as a replacement or supplement to the continuous trajectory recording scheme of this invention.
[0023] State sampling at discrete time points is one option among preset time strategies, and it is used in parallel with structured trajectory recording at continuous time steps for protection. In practical applications, the appropriate time strategy can be selected based on the specific scenario requirements. For short-link tasks or resource-constrained scenarios, a discrete time-point state sampling scheme can be adopted to reduce system overhead; For long-link tasks or scenarios requiring high-precision positioning, a continuous trajectory recording scheme can be adopted to achieve precise error correction at the step level. For mixed scenarios, an adaptive strategy can be adopted: use continuous recording in critical stages and discrete sampling in non-critical stages to balance accuracy and efficiency.
[0024] In step S2: After the agent's task is completed, the final state is determined; The sequence execution reaches the final step. At that time, for the final state The final output of the environment or project is evaluated. Specifically: When determining the final state, the final state determination function is used. For the final state Conduct an assessment: In the standard implementation of binary success rate determination, its output follows a binomial distribution: ; Or use a continuous reward function The partial completion rate of the task is quantified; when the reward function value is lower than a preset threshold, the task is deemed to have failed.
[0025] In embodiments requiring fine-grained evaluation, the final state determination function can be extended to a continuous reward function. This quantifies the partial completion rate of a task. The judgment mechanism is architecturally deeply decoupled from the specific task type. For example, in code generation tasks, It can be the overall pass rate calculation result of preset unit test cases; in GUI operation tasks, It can be the feature matching degree of the target interface DOM tree or the alignment degree of the perceptual hash; in mathematical reasoning, it can be the degree of conformity between the final derivation expression and the rules of the theorem library.
[0026] In step S3, when a task is determined to have failed, a diagnostic analysis of the cause of failure is performed to generate error diagnostic information. The diagnostic analysis includes: comparing the current failed trajectory with a preset reference trajectory and calculating the divergence of each trajectory; and searching along the time step according to the trajectory divergence, and determining the time step in which the divergence value first exceeds the preset divergence threshold as the error step that caused the task to fail. In this step: the preset reference trajectory is a pre-stored successful execution trajectory, an ideal trajectory generated based on task specifications, or a dynamic reference trajectory retrieved and aggregated from historical successful experiences.
[0027] Figure 3 This is a flowchart of the steps for comparison and positioning proposed in Embodiment 1 of the present invention; when the final state determination result determines that the task has failed (i.e. or When the value falls below a preset threshold, the system automatically intercepts the regular global retry command and proceeds to the core step-level trajectory comparison and error localization stage. In this stage, the system extracts pre-built prior knowledge of the "correct trajectory" from an external high-dimensional vector database, or generates a dynamic reference trajectory by retrieving and aggregating historical high-score success experiences. The system will record the currently failed execution path. Compared with reference trajectory A multi-dimensional alignment comparison based on time steps is performed. Considering that the number of execution steps for failed trajectories and reference trajectories often differs in actual interactions, this embodiment of the invention introduces an adaptive dynamic time warping algorithm to flexibly align the trajectory sequences. The time steps of two trajectory sequences are defined as follows: and The cumulative distance matrix element at is Its state transition equation is expressed as: ; To overcome the limitations of a single mode and accurately calculate the local divergence cost in the above formula. This invention employs a multimodal distance metric method to comprehensively evaluate the degree of deviation at each step.
[0028] Define time step Trajectory Divergence at (after alignment) for: ; in, The semantic distance representing the observation results, i.e., the cosine distance of the environmental observation results in the latent semantic space, is calculated using the following formula: ; express Observation and feedback of failure trajectories at any given moment; express Observation feedback based on preset reference trajectories at all times; This represents the deviation distance of an action sequence, such as the parameter combination of an API call or the two-dimensional screen coordinates of a mouse click. Edit distance or Euclidean space deviation; express Actions that consistently fail to capture the trajectory of the failure; express Actions that are constantly preset with reference trajectories; A measure of difference in environmental state, that is, a measure of difference in the interface or environmental state topology. express The environmental state of the failure trajectory at any given moment; express The environmental conditions for constantly preset reference trajectories; Indicates the first weighting coefficient; This represents the second weighting coefficient; Indicates the third weighting coefficient; It can be dynamically adjusted based on the specific task scenario, and ; By calculating the divergence sequence of the entire trajectory, the system can accurately identify the watershed where errors begin to accumulate. Candidate error nodes. The positioning is transformed into an optimization process, namely, finding the trajectory divergence that first exceeds the preset dynamic fault tolerance threshold. Earliest time step: Based on the trajectory divergence, the time step in which the divergence value earliest exceeds a preset divergence threshold is identified as the erroneous step that caused the task to fail. ; in, Indicates a candidate error node; This indicates the preset dynamic fault tolerance threshold.
[0029] This high-precision error localization mechanism based on multimodal divergence fundamentally avoids the agent blindly retrying the whole process in long-link tasks, effectively cutting off the butterfly effect of error states cascading and accumulating in subsequent steps.
[0030] In step S4, a structured correction strategy is generated based on the error diagnosis information; the agent responds to the structured correction strategy and performs a correction operation to restore the correct state; the correction operation includes generating a compensation action based on the current state, or rolling back to a historical state and re-executing; The first implementation of generating a structured correction strategy based on the error diagnosis information is as follows: the teacher model is invoked to perform causal analysis on the located error steps and their context information to generate a structured correction strategy; the teacher model outputs error type labels during the generation process, and the error types include strategy planning errors, state understanding errors, or tool invocation errors.
[0031] Accurately locate the exact error node Subsequently, the system triggers a teacher-reflection-driven mechanism for generating higher-order analysis and corrective suggestions. This invention introduces an independent higher-order teacher model with a larger parameter scale or higher inference authority. This drives in-depth causal analysis. Compared to reflection by the original intelligent agent performing the task, which is prone to self-confirmation bias and illusion traps in existing technologies, the teacher model operates in a heterogeneous parameter space and is given omniscient access to system logs.
[0032] First, focus on the identified error nodes. Extract a dynamic size A bidirectional context window is used to extract a high-information-density error context feature matrix. Subsequently, the teacher model The system receives this context information matrix and combines it with the environment replay snapshot or the differential logs at the system's underlying layer when the error occurred to infer the root cause of the error. For example, the teacher model can distinguish whether the error stems from "logical shortsightedness in long-term strategic planning," "a biased visual understanding of the current environmental state," or "misuse of parameter format when calling external tool APIs."
[0033] After performing multi-head self-attention calculations, the teacher model generates targeted step-by-step structured correction suggestions or cue word optimization strategies. The generation process can be rigorously modeled as an autoregressive conditional generation probability maximization problem given context, historical memory, and prior teacher model conditions: ; in, Representing the teacher model; Indicates the sequence length of the generated correction strategy; For the policy sequence Each word element.
[0034] The generated structured correction strategy The optimal correction strategy not only includes specific corrective instructions for erroneous actions, such as "the 'Confirm' button should not be clicked here, but the 'Advanced Settings' drop-down menu should be expanded first," but also includes intervention instructions for the short-term working memory of the underlying agent, ensuring that the system deeply understands "why the error occurred here" and "how to avoid traps with similar features when retrying."
[0035] The first implementation of generating a structured correction strategy based on the aforementioned error diagnosis information is to replace the "independent teacher model causal analysis" with "single agent internal self-reflection (Self-Refine)".
[0036] The self-reflection approach within a single agent can save computational overhead from dual-model calls or circumvent this architecture by using only the native agent executing the task (Student Agent) for self-correction. That is, after a task failure, the error log is input again into the same large language model, requiring it to analyze the cause of failure and generate a prompt for the next attempt. However, this approach is highly susceptible to self-confirmation bias and logical illusion when dealing with complex e-commerce backend GUI interaction logic. If it fails to identify a hidden audience targeting control in the initial stage, it often overlooks that control during reflection.
[0037] This invention prioritizes the first method for causal analysis. The independent teacher model has a global "omniscient perspective," effectively isolating the contamination of the execution context, and has an overwhelming advantage in the objectivity and accuracy of root cause analysis (RCA).
[0038] In step S5: After the correction operation is completed, the local state is verified based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks are executed; otherwise, the retry mechanism is triggered.
[0039] Consistency comparison based on state representation can be implemented in two ways: The first way is to verify the consistency based on a consistency metric of multimodal feature fusion. The second way is to verify the consistency based on a consistency metric of pure text DOM tree comparison. The detailed process of the first method is as follows: Obtaining high-quality correction strategies from the teacher model output. Subsequently, the system enters a closed-loop retry and real-time verification system, transforming theoretical reflections into actual physical or virtual actions in the environment. Since agent tasks are often irreversible, this embodiment of the invention introduces a state snapshot rollback technique. First, the environmental context and the agent's internal hidden states are rolled back to their original states without loss of data. Next, Soft prompts or explicit instructions are injected into the agent's decision context to force the agent to explore new action trajectories at this fork point.
[0040] To verify the authenticity and effectiveness of the correction actions and prevent the system from getting stuck in oscillations or infinite loops at local error nodes, this invention introduces a fine-grained, low-latency real-time verification function at the retry node. Therefore, the process of real-time verification of local states includes: After the agent performs the correction action, the current local state is captured. ; Through real-time verification function The local state is scored, and the verification function is based on a consistency measure between the expected result and the actual result; When the verification score is higher than the preset threshold If the verification score is below the threshold, the verification is considered successful; if the verification score is below the threshold, the verification is considered unsuccessful, and the local retry counter for the current step is incremented. ,when Exceeding the preset maximum local tolerance number of times If all upgrade strategies fail to pass the verification, the current task is determined to be unable to be automatically corrected, the task is terminated, and a failure report and error diagnosis information are output.
[0041] During this process, all divergence change gradients before and after correction, policy generation logs, and final validation scores will be packaged into a structured experience pool to support subsequent online reinforcement learning and updates to the automated error prevention strategy library of the system's underlying model.
[0042] If the underlying environment snapshot capture and rollback capabilities are lacking, a forward compensation action generation method can be used as an alternative to the lossless rollback technology of environment snapshots. This involves the agent generating a series of "undo" or "remedy" actions based on the current error state (e.g., if the wrong audience is selected in a live stream, the agent finds and clicks the "delete" button, then adds it back). However, the forward compensation action generation method relies on the reversibility of the environment, but in many real-world business scenarios (e.g., products have been confirmed for listing, marketing SMS messages have been sent, funds have been deducted), the operation is irreversible. Continuing forward compensation after an error often leads to more serious cascading failures. Embodiment 1 of this invention preferably uses an underlying state snapshot rollback mechanism to directly rewind the system state to a safe node just before the error occurred. By attempting to rebranch, the security of automated execution is greatly enhanced.
[0043] The second method reduces the latency of processing images in multimodal large models by verifying the correctness of the steps through plain text comparison of the DOM tree source code of the front-end page and the back-end API logs. However, this second method often fails when dealing with modern, highly dynamic web pages (especially e-commerce back-ends rendered using Canvas or complex front-end frameworks). Many visually obscured, collapsed, or grayed-out buttons still exist in the DOM tree and have normal attributes. The verification method based on consistency metrics of multimodal feature fusion emphasizes "multimodal trajectory verification." "By integrating visual screenshots and text information, it can accurately identify visual interaction layer obstacles that cannot be detected by relying solely on the DOM tree, resulting in significantly higher robustness."
[0044] In step S6, an error classification and recording step is performed: after locating the erroneous step, the error is classified into observation comprehension error, action execution error, or state prediction error according to the modal distribution characteristics of the trajectory divergence; the classification result, the context information of the erroneous step, and the correction strategy generated by the teacher model are associated and stored in the experience pool for subsequent online learning or strategy library updates.
[0045] Embodiment 1 of this invention provides a self-correction method for intelligent agents based on trajectory comparison and localization, employing a full-link closed-loop error correction approach. This is to fully demonstrate the closed-loop error correction process of this invention. Figure 4 This is a flowchart illustrating the entire closed-loop process of the general intelligent agent proposed in Embodiment 1 of the present invention, from execution verification to teacher-driven error correction. The complete self-correction closed-loop process is as follows: After the task begins, the intelligent agent executes the task and records the structured trajectory in real time. .
[0046] After the task is completed, the system performs a final state determination: if the task is determined to be successful, the process ends and the task is completed; if the task is determined to be unsuccessful, the error correction process begins.
[0047] The error correction process first extracts the reference trajectory and aligns it with the current failed trajectory, then calculates the step-level divergence (including semantic divergence). Action divergence State divergence If the divergence does not exceed the preset threshold, the detection continues to the next time step; if the divergence exceeds the threshold for the first time, the time step is identified as the first erroneous step.
[0048] Subsequently, the teacher model performs causal reflection analysis on the erroneous steps and generates a structured correction strategy. The system performs an environment snapshot rollback, restoring the state to before the erroneous step, and then re-executes the action according to the correction strategy. After execution, real-time verification is performed: if verification passes, it returns to continue executing subsequent tasks; if verification fails, it enters a retry loop (as shown in the B→A loop in the figure), incrementing the retry counter and re-executing the correction operation until verification passes or the upgrade strategy is triggered.
[0049] This flowchart fully illustrates the closed-loop mechanism of this invention, from task execution, state monitoring, final state determination, trajectory comparison and localization, teacher reflection and analysis, strategy generation, rollback and retry to real-time verification, demonstrating the systematic and complete nature of this invention in agent self-correction. Table 1 below shows the complete algorithm implemented by this invention.
[0050] Table 1: An agent self-correction algorithm based on trajectory comparison and localization
[0051] The self-correction method for intelligent agents based on trajectory comparison and localization proposed in Embodiment 1 of this invention achieves precise localization and safe closed-loop correction of execution errors by intelligent agents through structured trajectory recording, step-level divergence comparison localization, teacher model causal analysis, and state snapshot rollback retry. This significantly improves the execution success rate and error correction efficiency of long-link tasks. Table 2 below shows the performance comparison of different error correction schemes in various scenarios.
[0052] Table 2: Performance Comparison of Different Error Correction Schemes in Various Scenarios
[0053] Experimental results show that in GUI automation scenarios, the success rate of the proposed solution is 86.40%, an improvement of 28.2 percentage points compared to Solution B's 58.20%, with the average number of attempts decreasing from 3.1 to 1.8, a reduction of 41.9%. In code generation scenarios, the success rate is 81.20%, an improvement of 28.6 percentage points compared to Solution B's 52.60%, with the average number of attempts decreasing from 3.8 to 2.1, a reduction of 44.7%. In mathematical reasoning scenarios, the success rate is 92.70%, an improvement of 27.3 percentage points compared to Solution B's 65.40%, with the average number of attempts decreasing from 2.5 to 1.4, a reduction of 44.0%. The average success rate across the three scenarios reaches 86.77%, with an average of only 1.77 attempts, fully demonstrating the significant technical effect and cross-scenario versatility of the proposed solution in intelligent agent self-correction.
[0054] Example 2 To fully illustrate the implementation process of Embodiment 1 of the present invention, Embodiment 2 of the present invention presents a closed-loop self-correction process for an intelligent agent for automated operation of e-commerce live streaming. A trajectory recording and final state determination mechanism is used to capture the continuous operations of the intelligent agent when configuring the live streaming room in the e-commerce platform backend. Step-level trajectory comparison is used to accurately locate configuration deviations. Correction strategies are generated based on teacher reflection, and key parameters such as live streaming audience targeting are corrected in real time through closed-loop retries. Finally, efficient deployment is achieved through a general architecture.
[0055] Figure 5 This is a schematic diagram illustrating the precise positioning and configuration deviation using step-level trajectory comparison as proposed in Embodiment 2 of the present invention; the diagram includes two parts: a trajectory divergence distribution curve and a step comparison table. The upper left side represents the strategy divergence. The graph shows the changes over time, with the horizontal axis representing the time step and the vertical axis representing the divergence value. Two curves are plotted: one representing the reference divergence distribution and the other representing the divergence distribution of the current agent's execution trajectory. The trend shows that in the preceding steps, the two curves largely overlap, with low divergence values. As execution progresses, the divergence value begins to increase at a certain intermediate step, and the agent's divergence curve clearly separates from the reference divergence curve. This high divergence value persists in subsequent steps, forming a significant divergence peak region, indicating that this location is the starting point of the error.
[0056] The upper right side shows a bar chart of the reference divergence distribution at each step, with the horizontal axis representing the step and the vertical axis representing the divergence value. This further visually demonstrates the difference between the reference divergence and the actual divergence of the agent at each time step, with the divergence peak value highlighted at the step.
[0057] The table below provides a step-by-step comparison between the reference trajectory (left side, numbers 1-11) and the agent's actual execution trajectory (right side, numbers 1'-11'). Specific steps include: This figure fully illustrates the process by which the present invention achieves precise positioning from the overall trend to specific steps by calculating trajectory divergence step by step, drawing divergence distribution curves, and combining them with step-level comparison tables.
[0058] Step 1 (Login to the system): There is no difference between the reference trajectory and the actual execution trajectory of the agent; Step 1' (Login to the system): There is no difference between the reference trajectory and the actual execution trajectory of the agent; Step 2 (Product Management): The reference path is the newly added product "Smartwatch Strap"; Step 2' (Product Management): The actual execution trajectory of the intelligent agent is the addition of the product "Smartwatch Strap"; Step 3 (Add Product): The reference track is the addition of the product "Smartwatch Strap"; Step 3' (Add Product): The actual execution trajectory of the intelligent agent is the addition of the product "Smartwatch Strap"; Step 4 (Setting the price): The reference price for the trajectory is 30 to 50 yuan; Step 4' (Setting the price): The actual execution trajectory of the intelligent agent is set to a price of 30 to 50 yuan; Step 5 (Setting the price): The reference price for the trajectory is 30 to 50 yuan; Step 5' (Setting the price): The actual execution trajectory of the intelligent agent is set to a price of 30 to 50 yuan; Step 6 (Upload Completed): The reference track is now uploaded. Step 6' (Upload Completed): The actual execution trajectory of the agent has been uploaded. Step 7 (Live Stream Management): Refer to the start time of the live stream and click the "Start Stream" button; Step 7′ (Live Stream Management): The actual execution trajectory of the intelligent agent is to start the live stream by clicking the "Start Stream" button; Step 8 (Audience Size): The reference trajectory is the number of audience members; Step 8′ (Number of Audience Members): The actual execution trajectory of the agent is the number of audience members; Step 9 (Select Audience): Refer to the expanded menu and select women aged 17 to 30; Step 9′ (Selecting the audience): The agent's actual execution trajectory deviated in this step, failing to correctly expand the menu and select the target audience; Step 10 (Confirm Settings): The reference track is set to confirm the settings; Step 10′ (Confirm Settings): The actual execution trajectory of the agent is as confirmed. Step 11 (Live Stream in Progress): The reference trajectory is during the live stream. Step 11′ (Live Streaming in Progress): The actual execution trajectory of the agent is currently in live streaming.
[0059] The comparison shows that the reference trajectory (steps 1 to 11) and the actual execution trajectory (steps 1′ to 11′) are consistent except for steps 9 and 9′. The main difference occurs at steps 9 and 9′. In the reference trajectory, step 9 is "expand the menu and select women aged 17 to 30," while step 9′ in the agent's actual execution trajectory deviates from this operation, causing a significant increase in the divergence value at this step. Combined with the divergence curve above showing that the divergence at step 9 first exceeds the preset threshold, the system identifies this step as an erroneous step that leads to task failure.
[0060] Figure 5 This invention fully demonstrates how it achieves precise positioning from the overall trend to specific steps by calculating trajectory divergence step by step, drawing divergence distribution curves, and combining them with step-level comparison tables.
[0061] Figure 6 This is the causal analysis and attention focus map of the teacher model proposed in Embodiment 2 of the present invention; based on the information output above, an independent teacher model is introduced to perform causal analysis on the located erroneous steps (i.e., the target audience setting steps) and their context.
[0062] The top of the graph shows the curve of trajectory divergence as a function of time step, with the horizontal axis representing the time step. The vertical axis represents the divergence value. The figure shows the divergence values in the steps described. A sudden change occurs at [location], and the curve [is in this position]. A clear divergence peak appears at the location. The time step axis is sequentially labeled as step 1, step 2, ..., step... ,step ,……,step This clearly shows the specific location where the divergence mutation occurs. The lower left side of the image shows a snapshot of the e-commerce backend audience settings interface, along with the system-generated step-by-step correction strategies. These strategies include: "Default Full Audience" and "Expand the dropdown menu for a specific DOM path and select 'Women aged 17-30'. Note the collapsed state." The image also marks the correction path, indicating the direction of action from the incorrect state to the correct operation.
[0063] The right side of the diagram below shows the teacher's reflection and causal analysis module. The teacher model performs causal analysis and determines the error type as "cognitive bias," specifically "UI update cognitive error." Root cause analysis indicates that the platform UI update collapsed the audience targeting controls into a dropdown menu, and the agent failed to correctly expand the panel, mistakenly clicking the external default full button. Based on this, the teacher model generates a correction prompt, requiring the teacher to suppress attention to surrounding visual distractions and focus on the correct hidden controls.
[0064] The bottom of the diagram also displays three key status labels: on the left is "Agent Misoperation: Default 'All Audience' Button," in the middle is "Teacher Attention Focus Menu Control," and on the right is "Collapsed Target Audience Menu Control." These three labels fully present the causal analysis chain from the agent's erroneous operation, the teacher model's attention redirection, to the target control.
[0065] This figure fully illustrates the entire process of how the present invention uses a teacher model to reflect on the causal analysis of erroneous steps, determine the error type, identify the root cause, and generate step-level correction strategies. It demonstrates the advantages of the independent teacher model over the agent's self-reflection in terms of objectivity and accuracy in error analysis.
[0066] Figure 7 This is a schematic diagram of the closed-loop correction and final task completion status output proposed in Embodiment 2 of the present invention; The top of the diagram shows the output of the teacher model. Teacher model output correction strategy. Specifically, this includes expanding the DOM control, selecting the "17-30 year old women" audience tag, and ensuring that partial validation passes.
[0067] The left side of the diagram shows the state storage and rollback module. This module performs environment snapshot rollback to the preceding secure node. The system will be restored to its state without loss to the moment before the erroneous step occurred, in preparation for the corrective action.
[0068] The image shows the product settings interface in the center. This interface displays three key elements: the "Listing Now" status, the audience targeting area, and "Visual Distractions." The audience targeting area lists three options: "Women aged 17-30," "Women aged 17-30" (a duplicate), and "Men aged 17-30." Following the correction strategy output by the teacher model, the agent correctly selects the "Women aged 17-30" label in the audience targeting area.
[0069] The right side of the image shows the audience targeting results. The system displays "Setting successful" and notes "Target audience: Women aged 17-30," while also providing a "Verification passed" confirmation message, indicating that the local real-time verification has passed and the correction operation is effective.
[0070] The lower part of the diagram shows the final state determination and task completion section. The final state determination module confirms the following task completion statuses: live stream is normal; decorative smartwatch straps have been successfully listed; live stream pre-heating has begun. Specific items for completed long-command tasks include: the watch straps are listed, priced between 30-50 yuan, marked as "complete"; the target audience is precisely targeted to women aged 17-30, marked as "complete". The final state determination result is "successful", and the final state determination function... =1.
[0071] This diagram fully illustrates the closed-loop correction process from the teacher model outputting correction strategies to the final successful completion of the task.
[0072] This invention, through a unified trajectory representation and interface interaction, can be quickly migrated and reused to other scenarios such as automatic distribution of short videos or automatic after-sales response as a plug-in-type decision-maker, significantly reducing the engineering implementation cost between different tasks.
[0073] Example 3 Based on the trajectory comparison and localization-based intelligent agent self-correction method proposed in Embodiment 1 of this invention, Embodiment 3 of this invention also proposes an intelligent agent self-correction system based on trajectory comparison and localization. Figure 8 This is a schematic diagram of an intelligent agent self-correction system based on trajectory comparison and localization proposed in Embodiment 3 of the present invention; the system includes: State monitoring module: used to monitor and record the state of the interaction between the agent and the external environment in response to the agent's task execution, according to a preset time strategy, and generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps; Error diagnosis module: After the intelligent agent completes the task, it determines the final state; when the task is determined to have failed, it performs diagnostic analysis on the cause of failure and generates error diagnosis information; the diagnostic analysis includes: comparing the current failed trajectory with the preset reference trajectory and calculating the divergence of each trajectory; and searching along the time step according to the trajectory divergence, determining the time step in which the divergence value first exceeds the preset divergence threshold as the error step that caused the task to fail. Correction Execution Module: Used to generate a structured correction strategy based on the error diagnosis information; the agent responds to the structured correction strategy and executes correction operations to restore the correct state; the correction operations include generating compensation actions based on the current state, or rolling back to a historical state and re-executing; Verification module: After the correction operation is completed, it verifies the local state based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks continue to be executed; otherwise, a retry mechanism is triggered.
[0074] The intelligent agent self-correction system proposed in Embodiment 3 of this invention achieves accurate location and safe closed-loop correction of execution errors of the intelligent agent through structured trajectory recording, step-level divergence comparison and localization, teacher model causal analysis, and state snapshot rollback and retry, which significantly improves the execution success rate and error correction efficiency of long-link tasks.
[0075] This application provides a self-correction system for intelligent agents based on trajectory comparison and localization, which modularizes the process implemented in embodiment 1 of this invention. For the description of the relevant parts in embodiment 3 of this application, please refer to the detailed description of the corresponding parts in the self-correction system for intelligent agents based on trajectory comparison and localization provided in embodiment 1 of this application, which will not be repeated here.
[0076] Example 4 Based on the trajectory comparison and localization-based intelligent agent self-correction method proposed in Embodiment 1 of the present invention, Embodiment 4 of the present invention also proposes an intelligent agent self-correction device based on trajectory comparison and localization. Figure 9 This is a schematic diagram of a self-correcting intelligent agent device based on trajectory comparison and localization, as proposed in Embodiment 4 of the present invention. At the hardware level, the electronic device 900 includes: a processor 910, optionally including an internal bus 920, a network interface 930, and a memory. The processor 910 is connected to the memory; the memory may include RAM, such as high-speed random-access memory (RAM), and may also include non-volatile memory, such as at least one disk storage device. Of course, this electronic device may also include other hardware required for other services.
[0077] The processor 910, network interface 930, and memory can be interconnected via an internal bus 920. This internal bus 920 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be categorized as an address bus, data bus, control bus, etc. For ease of illustration, only a single bidirectional arrow is used in this diagram, but this does not imply that there is only one bus or one type of bus. The memory is used to store programs. Specifically, the program can include program code, which includes computer operation instructions. The memory can include main memory 940 and non-volatile memory 950, and provides instructions and data to the processor 910.
[0078] The processor 910 reads the corresponding computer program from the non-volatile memory 950 into the main memory 940 and then runs it, forming a device for locating the target user at the logical level. The processor 910 executes the program stored in the memory and specifically performs the following: In step S1: In response to the agent performing a task, the state of the agent's interaction with the external environment is monitored and recorded according to a preset time strategy to generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps. In step S2: After the agent's task is completed, the final state is determined; In step S3, when a task is determined to have failed, a diagnostic analysis of the cause of failure is performed to generate error diagnostic information. The diagnostic analysis includes: comparing the current failed trajectory with a preset reference trajectory and calculating the divergence of each trajectory; and searching along the time step according to the trajectory divergence, and determining the time step in which the divergence value first exceeds the preset divergence threshold as the error step that caused the task to fail. In step S4, a structured correction strategy is generated based on the error diagnosis information; the agent responds to the structured correction strategy and performs a correction operation to restore the correct state; the correction operation includes generating a compensation action based on the current state, or rolling back to a historical state and re-executing; In step S5: After the correction operation is completed, the local state is verified based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks are executed; otherwise, the retry mechanism is triggered.
[0079] In step S6, an error classification and recording step is performed: after locating the erroneous step, the error is classified into observation comprehension error, action execution error, or state prediction error according to the modal distribution characteristics of the trajectory divergence; the classification result, the context information of the erroneous step, and the correction strategy generated by the teacher model are associated and stored in the experience pool for subsequent online learning or strategy library updates.
[0080] Figure 1 It can be applied to processor 910, or implemented by processor 910. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the processor or by instructions in the form of software. The processor mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0081] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0082] The description of the relevant part of the intelligent agent self-correction device based on trajectory comparison and localization provided in Embodiment 4 of this application can be found in the detailed description of the corresponding part of the intelligent agent self-correction method based on trajectory comparison and localization provided in Embodiment 1 of this application, and will not be repeated here.
[0083] It should be noted that, in this document, relational terms such as "first" and "second" are used merely 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 the elements inherent in a process, method, article, or apparatus that includes a list of elements are included. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Additionally, portions of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.
[0084] While specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art can make other modifications or variations based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
[0085] It should be noted that, in this document, relational terms such as "first" and "second" are used merely 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 the elements inherent in a process, method, article, or apparatus that includes a list of elements are included. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Additionally, portions of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.
[0086] While specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art can make other modifications or variations based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A self-correction method for intelligent agents based on trajectory comparison and localization, applied to closed-loop self-correction of intelligent agents for automated operation of e-commerce live streaming, characterized in that, Includes the following steps: In response to the intelligent agent executing e-commerce live streaming tasks, the state of the intelligent agent and the interaction is monitored and recorded according to a preset time strategy to generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps. After the agent finishes executing its task, the final state is determined. When a task is determined to have failed, the cause of failure is diagnosed and analyzed, and error diagnosis information is generated. The diagnostic analysis includes: comparing the current failed trajectory with a preset reference trajectory, calculating the divergence of each trajectory; and searching along the time steps based on the trajectory divergence, identifying the time step in which the divergence value first exceeds a preset divergence threshold as the erroneous step that caused the task to fail. When a task is determined to have failed, the current failed trajectory is compared with a preset reference trajectory, and the divergence of each trajectory is calculated. Then, based on the trajectory divergence, a search is performed along the time steps, and the time step in which the divergence value first exceeds a preset divergence threshold is identified as the erroneous step that caused the task failure. Specifically: The current failed trajectory is compared with a preset reference trajectory. A dynamic time warping algorithm is used to flexibly align the current failed trajectory with the reference trajectory, and a multimodal distance metric method is used to calculate the divergence of the aligned trajectory. : in, The semantic distance representing the observation results; express Observation and feedback of failure trajectories at any given moment; express Observation feedback based on preset reference trajectories at all times; Indicates the deviation distance of the action sequence; express Actions that consistently fail to capture the trajectory of the failure; express Actions that are constantly preset with reference trajectories; A measure of difference in environmental conditions; express The environmental state of the failure trajectory at any given moment; express The environmental conditions for constantly preset reference trajectories; Indicates the first weighting coefficient; This represents the second weighting coefficient; This represents the third weighting coefficient; and ; Based on the trajectory divergence, a search is performed along the time steps, and the time step in which the divergence value first exceeds a preset divergence threshold is identified as the erroneous step that leads to task failure, where candidate erroneous nodes are identified. for: ; in, This indicates the preset dynamic fault tolerance threshold; A structured correction strategy is generated based on the error diagnosis information; the agent responds to the structured correction strategy by performing correction operations to restore the correct state; the correction operations include generating compensation actions based on the current state, or rolling back to a historical state and re-executing. After the correction operation is completed, the local state is verified based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks continue to be executed; otherwise, the retry mechanism is triggered. The system employs a trajectory recording and final state determination mechanism to capture the continuous operations of the agent when configuring the live broadcast room in the e-commerce platform backend. It uses step-level trajectory comparison to accurately locate configuration deviations, generates correction strategies based on teacher reflection, and corrects key parameters of live broadcast audience targeting in real time through closed-loop retry. Finally, it achieves efficient deployment through a general architecture.
2. The self-correction method for intelligent agents based on trajectory comparison and localization according to claim 1, characterized in that, Structured trajectory recording is performed at continuous time steps, specifically as follows: At each discrete time step Capture the current environmental state of the agent Actions performed by an agent based on its current state and the observational feedback returned from the environment after the action is performed. ; Environmental status ,action and observation feedback They are grouped into trajectory units according to time sequence. ; The agent executes the task from start time step 1 to end time step 2. All trajectory units are concatenated in time sequence to generate a structured trajectory. : 。 3. The agent self-correction method based on trajectory comparison and localization according to claim 1, characterized in that, When determining the final state, the final state determination function is used. For the final state Conduct an assessment: Or use a continuous reward function The partial completion rate of the task is quantified; when the reward function value is lower than a preset threshold, the task is deemed to have failed.
4. The self-correction method for intelligent agents based on trajectory comparison and localization according to claim 1, characterized in that, Based on the error diagnosis information, a structured correction strategy is generated. Specifically, the teacher model is invoked to perform causal analysis on the located error steps and their context information to generate a structured correction strategy. During the generation process, the teacher model simultaneously outputs error type labels, which include strategy planning errors, state understanding errors, or tool invocation errors.
5. The agent self-correction method based on trajectory comparison and localization according to claim 4, characterized in that, The teacher model is invoked to perform causal analysis on the located erroneous steps and their contextual information, generating a structured correction strategy, specifically: The teacher model receives a context window captured around the error step. And generate a structured correction strategy through an autoregressive generation method. : ; in, Representing the teacher model; Indicates the sequence length of the generated correction strategy; For the policy sequence Each word element; Indicates the first policy sequence All lexical units preceding the given lexical unit.
6. The self-correction method for intelligent agents based on trajectory comparison and localization according to claim 1, characterized in that, After rolling back to the previous state, the process is repeated as follows: The structured correction strategy is injected into the decision context of the agent by means of soft hints or explicit instructions; The agent uses state snapshot rollback technology to restore the environment state and the agent's internal hidden state to the moment before the erroneous step without loss. ; The agent starts from the recovered state and re-executes the erroneous steps and subsequent operations according to the injected correction strategy.
7. The agent self-correction method based on trajectory comparison and localization according to claim 1, characterized in that, The consistency comparison based on state representation specifically includes: verification based on consistency metrics of pure text DOM tree comparison; or verification based on consistency metrics of multimodal feature fusion.
8. The self-correction method for intelligent agents based on trajectory comparison and localization according to claim 1, characterized in that, The retry mechanism includes: The retry counter is incremented, and the operation of rolling back to the historical state and then re-executing and verifying the local state is re-executed. When the number of retries exceeds the preset maximum tolerance number, an escalation strategy is triggered. The escalation strategy includes expanding the context window of the teacher model, adjusting the divergence threshold, or calling for manual intervention.
9. A self-correction system for intelligent agents based on trajectory comparison and localization, applied to closed-loop self-correction of intelligent agents for automated operation of e-commerce live streaming, characterized in that, include: State monitoring module: used to respond to the intelligent agent executing e-commerce live streaming tasks, monitor and record the state of the intelligent agent's interaction with the external environment according to a preset time strategy, and generate execution state data; the preset time strategy includes state sampling at discrete time points or structured trajectory recording on continuous time steps; Error diagnosis module: Determines the final state after the agent's task is completed; When a task is determined to have failed, the cause of failure is diagnosed and analyzed, and error diagnosis information is generated. The diagnostic analysis includes: comparing the current failed trajectory with a preset reference trajectory and calculating the divergence of each trajectory; and searching along time steps based on the trajectory divergence, identifying the time step in which the divergence value first exceeds a preset divergence threshold as the erroneous step leading to task failure; when task failure is determined, comparing the current failed trajectory with a preset reference trajectory and calculating the divergence of each trajectory; and searching along time steps based on the trajectory divergence, identifying the time step in which the divergence value first exceeds a preset divergence threshold as the erroneous step leading to task failure, specifically: The current failed trajectory is compared with a preset reference trajectory. A dynamic time warping algorithm is used to flexibly align the current failed trajectory with the reference trajectory, and a multimodal distance metric method is used to calculate the divergence of the aligned trajectory. : in, The semantic distance representing the observation results; express Observation and feedback of failure trajectories at any given moment; express Observation feedback based on preset reference trajectories at all times; Indicates the deviation distance of the action sequence; express Actions that consistently fail to capture the trajectory of the failure; express Actions that are constantly preset with reference trajectories; A measure of difference in environmental conditions; express The environmental state of the failure trajectory at any given moment; express The environmental conditions for constantly preset reference trajectories; Indicates the first weighting coefficient; This represents the second weighting coefficient; This represents the third weighting coefficient; and ; Based on the trajectory divergence, a search is performed along the time steps, and the time step in which the divergence value first exceeds a preset divergence threshold is identified as the erroneous step that leads to task failure, where candidate erroneous nodes are identified. for: ; in, This indicates the preset dynamic fault tolerance threshold; Correction Execution Module: Used to generate a structured correction strategy based on the error diagnosis information; the agent responds to the structured correction strategy and executes correction operations to restore the correct state; the correction operations include generating compensation actions based on the current state, or rolling back to a historical state and re-executing; Verification module: After the correction operation is completed, it verifies the local state based on the consistency comparison of the state representation. If the verification is successful, the subsequent tasks are executed; otherwise, a retry mechanism is triggered. The system employs a trajectory recording and final state determination mechanism to capture the continuous operations of the agent when configuring the live broadcast room in the e-commerce platform backend. It uses step-level trajectory comparison to accurately locate configuration deviations, generates correction strategies based on teacher reflection, and corrects key parameters of live broadcast audience targeting in real time through closed-loop retry. Finally, it achieves efficient deployment through a general architecture.