Large language model agent system, method and related equipment
By constructing an adaptive optimization closed loop for a large language model intelligent agent system, accurate identification and self-optimization of task failures are achieved, solving the problem of insufficient self-diagnosis in existing technologies and improving the stability and adaptability of the system.
Patent Information
- Application Number
- CN202511266863.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-05
- Publication Date
- 2025-11-28
AI Technical Summary
Existing large language model intelligent agent systems lack self-diagnosis and strategic flexibility when facing complex scenarios. They are unable to adaptively optimize, resulting in the inability to accurately identify the cause of failure after task failure. They also lack reflection and learning mechanisms, their strategies are not reconfigurable, they lack cognitive closed-loop design, and their prompt calls are not structured, which affects the stability and adaptability of the system.
The input parser module performs semantic understanding and task decomposition to generate a structured strategy plan. The execution controller module records the execution trajectory. The task result evaluation module judges failures. The reflection module generates a structured reflection report. The strategy rewriting module optimizes the strategy plan and builds an adaptive optimization closed loop to achieve self-diagnosis and optimization.
It improved task completion rate, execution stability and scenario adaptability, enhanced robustness and error tolerance in complex multi-step tasks, and filled the key gap in self-reflection and self-optimization.
Smart Images

Figure CN121029949A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, more specifically, to a large language model agent system, method and related equipment. BACKGROUND
[0002] In recent years, large language models have rapidly developed in the field of natural language processing and have been widely applied to static tasks such as search and question answering, content generation, etc., and have shown excellent capabilities. However, when facing dynamic changing scenarios, multi-step connected processes, and goal-oriented tasks that need to be pushed forward for a long time, the execution capability of a single large language model is obviously limited. It cannot autonomously disassemble complex tasks and plan execution paths, nor can it respond to unexpected problems during execution, resulting in a significant reduction in application value in complex business scenarios. To break through this limitation, academic and industrial circles have proposed language model agent frameworks such as AutoGPT, AgentGPT, etc.
[0003] However, the defects of existing language model agent systems have become a key bottleneck restricting their penetration into complex scenarios, which can be summarized in five aspects: first, there is a lack of diagnostic capability after task failure. When the system is interrupted during execution, it can only mechanically repeat the original steps or directly stop running, and it cannot locate the core reasons for failure, such as tool invocation parameter errors, sub-task disassembly logic deviations, etc., which cannot be effectively identified; second, there is no effective reflection and learning mechanism. The system cannot optimize its behavior patterns based on historical execution data and intermediate feedback information, nor can it adjust the priority ordering of task plans or optimize the prompt expression structure to improve model response accuracy; third, there is a serious lack of strategy flexibility. Most systems rely on static prompt templates or pre-set planning rules, and once the execution chain fails due to external environmental changes or internal logic contradictions, the strategy cannot be reconstructed, such as being unable to adjust the invocation order according to tool interface updates; fourth, there is a lack of complete cognitive closed-loop design. Existing processes mostly stay at the planning, execution, and simple feedback level, resulting in poor adaptability of the system in uncertain environments; fifth, there is a lack of structured prompt invocation. In long-term continuous task execution, the prompt expression style and information dimension differ greatly at different stages, which easily leads to prompt drift, directly affecting model understanding consistency and reducing overall system stability.
[0004] These defects directly lead to the obvious shortcomings of existing language model agent systems in complex scenarios: they cannot self-repair when faults occur, nor can they effectively generalize between different task types.
[0005] Based on this, it is an urgent need to propose technical solutions that can solve the above-mentioned defects and improve the autonomy and adaptability of the system, which is the core necessity of the present application. SUMMARY
[0006] The present application provides a large language model agent system, method and related equipment, which significantly improves the task completion rate, execution stability and scene adaptability, especially enhances the robustness and error tolerance in multi-step complex tasks, and fills the key gap of existing language model agent systems in self-reflection and self-optimization.
[0007] A large language model agent system, comprising:
[0008] An input parser module for semantic understanding and task decomposition of user input natural language tasks, outputting a sub-task list and an initial prompt template;
[0009] A strategy generation module for generating a structured strategy plan containing tool selection and calling sequence according to the sub-task list and the initial prompt template;
[0010] An execution controller module for calling a large language model interface and external tools to execute the structured strategy plan, and recording execution trajectory and state information;
[0011] A task result evaluation module for judging whether the task has failed according to the difference between the execution result and the preset target;
[0012] A reflection module for analyzing the execution trajectory and model response when the task fails, and generating a structured reflection report containing failure causes and improvement suggestions;
[0013] A strategy rewriting module for rewriting the structured strategy plan according to the structured reflection report, and feeding back to the execution controller module for re-execution;
[0014] Wherein, the system constitutes an adaptive optimization closed loop of task execution through the reflection module and the strategy rewriting module.
[0015] Optionally, the reflection module comprises:
[0016] An execution trajectory analyzer for analyzing the tool calling sequence and API return status code in the execution trajectory and state information, and identifying the first abnormal calling node;
[0017] A model response analyzer for calculating the semantic similarity between the text output by the large language model and the expected output keywords, and determining that the output deviates if the semantic similarity is below a threshold;
[0018] A causal attribution analyzer for determining the root cause of failure based on the abnormal calling node and the output deviation result through a pre-defined error type mapping table;
[0019] A natural language reflection generator is configured to combine the failure root cause, abnormal node information, and pre-stored improvement strategy templates to generate the structured reflection report in JSON format.
[0020] Optionally, the strategy rewriting module comprises:
[0021] A prompt rewriter is configured to extract keywords from the structured reflection report and replace or supplement the constraint conditions in the initial prompt template based on the keywords.
[0022] A module replacer is configured to update the structured strategy plan by selecting a functionally equivalent alternative tool from a pre-registered tool library when the root cause is a tool call failure.
[0023] A flow rearranger is configured to insert a data verification or condition judgment node in the tool call sequence when the root cause is a logical omission.
[0024] A version controller is configured to generate a new version identifier for the rewritten strategy plan and archive the old version strategy to a history database.
[0025] Optionally, the task result evaluation module determines the failure mode of the task, comprising:
[0026] A call semantic similarity calculation service is used to compare the task final output with the target description input by the user, and if the similarity score is lower than a first threshold, it is determined as a failure.
[0027] The number of abnormal status codes in the execution track is counted, and if the number of abnormalities in a continuous preset number of sub-tasks exceeds a second threshold, it is determined as a failure.
[0028] Optionally, the structured strategy plan is stored in JSON format and includes at least three logical components: tool call sequence, prompt template structure, and expected output specification. The strategy rewriting module rewrites the strategy by parsing and modifying the logical components.
[0029] Optionally, when the system is deployed as a cloud service, the input parser module, the strategy generation module, and the execution controller module are deployed in a serverless computing engine, and the reflection module and the strategy rewriting module are deployed in independent adaptive optimization microservices and communicate through a message queue.
[0030] A large language model agent method, comprising:
[0031] A natural language task input by a user is received, semantic understanding and task decomposition are performed by an input parser, and a sub-task list and an initial prompt template are generated.
[0032] constructing a structured policy plan containing a tool call sequence through a policy generation module;
[0033] calling a large language model and an external tool to execute the structured policy plan through an execution controller module, and recording an execution log;
[0034] judging whether the execution result meets the standard through a task result evaluation module, and triggering a reflection module if the execution result does not meet the standard;
[0035] generating a structured reflection report through the reflection module by analyzing the execution log;
[0036] rewriting the structured policy plan according to the structured reflection report through a policy rewriting module, and re-submitting the structured policy plan to the execution controller module for execution.
[0037] A large language model agent device, comprising a memory and a processor;
[0038] The memory is configured to store a program.
[0039] The processor is configured to execute the program to implement each step of the large language model agent method.
[0040] A readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement each step of the large language model agent method.
[0041] A computer program product comprising a computer program, wherein the computer program is executed by a processor to implement each step of the large language model agent method.
[0042] As can be seen from the above technical solutions, the large language model agent system, method and related device provided by the embodiments of the present application contain an input parser module, a policy generation module, an execution controller module, a task result evaluation module, a reflection module and a policy rewriting module, and form a self-adaptive optimization closed loop for task execution through the reflection module and the policy rewriting module, which can solve the defects of the prior art and achieve the following specific effects:
[0043] For the defect of no diagnosis after task failure, the task result evaluation module of the system can judge whether the task has failed, and the reflection module can analyze the execution track and model response when the task fails to generate a structured reflection report containing the failure reason, realizing the accurate identification and tracking of the failure reason and avoiding the problem of only repeating attempts or stopping running. For the lack of reflection and learning mechanism, the structured reflection report of the reflection module provides key feedback for task execution, and the strategy rewriting module optimizes the task plan and prompt structure based on the report, so that the system has the ability of self-learning and optimization, breaking the limitation of being unable to adjust according to feedback. For the defect that the strategy cannot be reconstructed, the strategy rewriting module can reconstruct the structured strategy plan, adjust the tool calling sequence or replace the strategy module, replace the static prompt and preset planning mode, and improve the flexibility of the system. For the defect of lacking cognitive closed loop design, the adaptive optimization closed loop formed by the reflection module and the strategy rewriting module forms a complete process of task execution, result evaluation, reflection and attribution, strategy rewriting and re-execution, filling the gap of cognitive closed loop. In addition, the initial prompt template output by the input parser module realizes the unified management of the prompt structure, effectively solves the problem of unstructured and easy drifting of prompt calling, and guarantees the stability of the system. Overall, the system significantly improves the task completion rate, execution stability and scene adaptability, especially enhances the robustness and error tolerance in multi-step complex tasks, and fills the key gap of existing language model agent systems in self-reflection and self-optimization. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and those skilled in the art can obtain other drawings according to the provided drawings without creative labor.
[0045] Figure 1 A schematic diagram of a large language model agent system disclosed by an embodiment of the present application;
[0046] Figure 2 Another schematic diagram of a large language model agent system disclosed by an embodiment of the present application;
[0047] Figure 3 A flowchart of a large language model agent method disclosed by an embodiment of the present application;
[0048] Figure 4 A hardware structure block diagram of a large language model agent device disclosed by an embodiment of the present application. DETAILED DESCRIPTION
[0049] With reference to the drawings and embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present application.
[0050] The present application can be used in many general or special-purpose computing device environments or configurations. For example: personal computers, server computers, handheld or laptop devices, tablet devices, multiprocessor systems, distributed computing environments that include any of the above systems or devices, and the like.
[0051] Next, the technical solutions of the present application will be introduced. The present application proposes the following technical solutions, which are described below.
[0052] Figure 1 A schematic diagram of a large language model agent system disclosed in an embodiment of the present application.
[0053] Figure 2 Another schematic diagram of a large language model agent system disclosed in an embodiment of the present application.
[0054] As shown in Figure 1 and Figure 2 , the system can include:
[0055] The input parser module 110 is configured to perform semantic understanding and task decomposition on the natural language task input by the user, and output a subtask list and an initial prompt template;
[0056] The strategy generation module 120 is configured to generate a structured strategy plan containing tool selection and calling sequence according to the subtask list and the initial prompt template;
[0057] The execution controller module 130 is configured to call a large language model interface and an external tool to execute the structured strategy plan, and record execution trajectory and state information;
[0058] The task result evaluation module 140 is configured to judge whether the task fails according to the difference between the execution result and the preset target;
[0059] The reflection module 150 is configured to analyze the execution trajectory and model response when the task fails, and generate a structured reflection report containing failure causes and improvement suggestions;
[0060] The strategy rewriting module 160 is configured to rewrite the structured strategy plan according to the structured reflection report, and feed back to the execution controller module for re-execution;
[0061] The system forms an adaptive optimization closed loop for task execution through the reflection module and the strategy rewriting module.
[0062] Specifically, the input parser module 110 serves as the core entry for system-user interaction, and is mainly responsible for receiving and processing natural language tasks input by the user. Through an embedded natural language understanding model, the module performs deep semantic parsing on the core intent, key entity, and operation target in the natural language task, accurately identifies the multi-level requirements implied in the task, and then decomposes the complex original task into a set of subtasks that are logically clear and can be independently executed. During the decomposition process, the module will label each subtask with a clear operation target description, and recommend an adapted tool type (such as simulation scheduling API, causal reasoning engine, etc.) based on the task type, ensuring that the subsequent modules can accurately match the execution resources. Finally, the module outputs a structured result containing a subtask list and an initial prompt template, where the initial prompt template standardizes the basic structure of task expression, providing uniform semantic support and information format standards for the subsequent strategy generation module 120, and avoiding execution deviations caused by ambiguous task expression in subsequent processes.
[0063] The strategy generation module 120 takes the subtask list and initial prompt template output by the input parser module 110 as the core basis, and is responsible for constructing a structured strategy plan. The module first completes the association matching of subtasks, execution intent, and recommended tools, and then generates a strategy plan containing complete execution logic based on task complexity and tool characteristics. The strategy plan is stored in JSON format, which facilitates dynamic reading and updating by subsequent modules. Its content covers three core elements: first, prompt style (such as formatted prompt, chained thinking prompt, ReAct style prompt, etc.), to ensure that large language models can accurately understand task requirements; second, tool selection and calling sequence, to clearly define the tool calling order and parameter configuration corresponding to each subtask; third, expected output format and evaluation criteria, to provide a basis for the subsequent task result evaluation module 140. Through the processing of this module, dispersed subtasks are integrated into an ordered and executable strategy chain, laying the foundation for efficient scheduling by the execution controller module 130.
[0064] The execution controller module 130 is the core scheduling unit of system task execution, mainly responsible for coordinating the collaborative operation of large language model interface and external tools according to the structured strategy plan output by the strategy generation module 120. During the execution process, this module will trigger the inference calculation of the large language model and the function call of the external tool according to the tool call sequence in the strategy plan, and record the key information in real time, including: the output content of the large language model, the return value of the external tool call, the execution timestamp of each step, the execution status code, the exception flag, and the similarity or matching score of the current execution result and the expected result. These recorded information will form a complete execution trajectory data, providing detailed process data support for the failure judgment of the subsequent task result evaluation module 140 and the root cause analysis of the reflection module 150.
[0065] The task result evaluation module 140 is mainly responsible for quantitatively evaluating the task execution result output by the execution controller module 130 to determine whether the task has achieved the preset goal. This module realizes accurate judgment by setting a soft and hard combined evaluation index system: in the hard index level, including whether the number of tool call failures exceeds the preset fault tolerance range, whether the execution status code is an abnormal value, etc.; in the soft index level, including whether the similarity of the text output result and the target keyword reaches the threshold, whether the output format meets the standard specified in the strategy plan, etc., while supporting receiving user direct feedback as evaluation basis. After evaluation, this module outputs the evaluation result in the form of a Boolean variable and a score list, where the Boolean variable is used to explicitly identify task success or failure, and the score list quantitatively presents the specific scores of each evaluation index. This result will be directly transmitted to the reflection module 150 as the core basis for triggering the reflection process.
[0066] The reflection module 150 is the core module for the system to realize self-diagnosis capability, which is started only when the task result evaluation module 140 determines that the task has failed. This module first aggregates multi-source failure-related data, including prompt content, tool call chain information, large language model intermediate response, error log and status code record during task execution, to ensure the completeness of analysis dimensions. Then, the module analyzes the aggregated data in depth through the built-in large language model template, extracts the key features of task failure, and classifies the failure causes into specific types such as understanding error, improper API selection, tool function failure, output format anomaly, and thought chain breakage. Finally, the module generates a structured reflection report in JSON format, which not only clearly marks the hierarchical relationship of failure causes (such as root cause, auxiliary factor and chain effect), but also contains targeted improvement suggestions (such as completing task parameters, optimizing prompt expression) and candidate alternative strategies, providing clear optimization direction for the subsequent strategy rewriting module 160.
[0067] The strategy rewriting module 160 is the execution module for adaptive strategy optimization in the system. Its core function is to rewrite the original structured strategy plan based on the structured reflection report output by the reflection module 150. Specific optimization operations include three dimensions: first, prompt-level optimization, such as replacing vaguely worded key terms in the original prompt, supplementing missing task parameters, and enhancing the prompt's guidance for the large language model; second, tool call-level adjustments, such as reordering tool call sequences or replacing ineffective tools with more adaptable alternatives; and third, execution logic refinement, such as inserting new logical judgment nodes to guide the large language model in chain-like reasoning. After rewriting, the module updates the new strategy, generates a new structured strategy plan that meets execution requirements, and feeds it back to the execution controller module 130, triggering the re-execution of the task.
[0068] The system constructs an adaptive optimization closed loop for task execution, which includes failure diagnosis, strategy optimization, and re-execution, through the collaborative work of the reflection module 150 and the strategy rewriting module 160. The reflection module 150 provides accurate problem location and direction for optimization, while the strategy rewriting module 160 transforms the optimization direction into a new executable strategy. The closed loop mechanism formed by the two enables the system to autonomously adjust itself after task failure, avoids ineffective repeated execution, and significantly improves the robustness and success rate of complex task execution.
[0069] Furthermore, the structured strategy plan is stored in JSON format and includes at least three logical components: tool call sequence, prompt template structure, and expected output specification. The strategy rewriting module rewrites the strategy by parsing and modifying these logical components.
[0070] Furthermore, when the system is deployed as a cloud service, the input parser module, the policy generation module, and the execution controller module are deployed in a serverless computing engine, and the reflection module and the policy rewriting module are deployed in independent adaptive optimization microservices and communicate with each other through message queues.
[0071] Specifically, when the system is deployed as a cloud service, a layered deployment architecture is adopted based on considerations of functional decoupling, resource optimization, and efficiency improvement. The specific module allocation and communication mechanism are as follows:
[0072] Serverless computing engine deployment module: The input parser module, policy generation module, and execution controller module are deployed within the serverless computing engine. This deployment method allows for dynamic and elastic scaling of resources based on user task request volume. During peak task request periods, computing resources are automatically increased to ensure low-latency response, while redundant resources are released during idle periods to reduce costs. Simultaneously, these three modules handle the core processes of initial task parsing, policy construction, and execution scheduling. Deploying them within the serverless computing engine fully leverages its high-concurrency processing capabilities, ensuring rapid response to user input and efficient task execution.
[0073] Independent Adaptive Optimization Microservice Deployment Module: The reflection module and the strategy rewriting module are deployed in an independent adaptive optimization microservice. This microservice focuses on diagnosis and strategy optimization after task failure. Independent deployment avoids resource competition between the optimization process and the task execution process, and facilitates separate iterative upgrades of the reflection logic and rewriting algorithm. Furthermore, this microservice communicates with modules in the serverless computing engine via a message queue: when the execution controller module detects a task failure, it sends execution trajectory logs, the original JSON-formatted structured strategy plan, and other data to the adaptive optimization microservice via the message queue; after the reflection module generates a structured reflection report, the strategy rewriting module completes the strategy rewriting and then feeds back the modified JSON-formatted structured strategy plan to the execution controller module via the message queue, triggering task re-execution. This communication method ensures the reliability and asynchronous processing capability of cross-module data transmission, further strengthens the decoupling of various functional layers of the system, and improves the stability and scalability of the entire cloud service architecture.
[0074] As can be seen from the above technical solutions, the large language model intelligent agent system, method, and related devices provided in this application include an input parser module, a policy generation module, an execution controller module, a task result evaluation module, a reflection module, and a policy rewriting module. The reflection module and the policy rewriting module form an adaptive optimization closed loop for task execution, which can specifically solve the defects of the prior art. The specific effects are as follows:
[0075] To address the lack of diagnostic capabilities after task failure, the system's task result evaluation module can determine whether a task has failed. The reflection module analyzes the execution trajectory and model response upon failure, generating a structured reflection report containing the reasons for failure. This enables precise identification and tracking of the causes of failure, avoiding the problem of simply repeating attempts or stopping execution. To address the lack of reflection and learning mechanisms, the structured reflection report from the reflection module provides key feedback on task execution. The strategy rewriting module optimizes the task plan and prompt structure based on this report, enabling the system to have self-learning and optimization capabilities, overcoming the limitation of not being able to adjust based on feedback. To address the lack of reconfigurable strategies, the strategy rewriting module can reconstruct structured strategy plans, adjust tool call order, or replace strategy modules, replacing static prompts and preset planning patterns, improving system flexibility. To address the lack of a cognitive closed-loop design, the adaptive optimization closed loop constructed by the reflection and strategy rewriting modules forms a complete process of task execution, result evaluation, reflection and attribution, strategy rewriting, and re-execution, filling the gap in cognitive closed-loop design. Furthermore, the initial prompt template output by the input parser module enables unified management of the prompt structure, effectively solving the problems of unstructured and drifting prompt calls, ensuring system stability. Overall, the system significantly improves task completion rate, execution stability, and scenario adaptability, especially enhancing robustness and error tolerance in complex multi-step tasks, filling a key gap in the self-reflection and self-optimization capabilities of existing language model agent systems.
[0076] The reflection module, strategy rewriting module, and task result evaluation module will be further introduced below, specifically including:
[0077] The reflection module includes:
[0078] An execution trajectory analyzer is used to parse the tool call sequence and API return status code in the execution trajectory and status information, and identify the first abnormal call node;
[0079] The model response analyzer is used to calculate the semantic similarity between the text output by the large language model and the expected output keywords. If the similarity is lower than the threshold, it is determined to be an output deviation.
[0080] A causal attribution analyzer is used to determine the root cause of failure based on the abnormal call nodes and output deviation results, using a predefined error type mapping table.
[0081] A natural language reflection generator is used to combine the root causes of failure, abnormal node information, and pre-stored improvement strategy templates to generate the structured reflection report in JSON format.
[0082] Specifically, the reflection module is a functional module that realizes task failure diagnosis and attribution. Through the collaborative work of four sub-components—execution trajectory analyzer, model response analyzer, causal attribution analyzer, and natural language reflection generator—it completes the entire process from parsing multi-source execution data to generating a standardized and structured reflection report. The specific functions are as follows:
[0083] The execution trajectory analyzer is used to locate initial abnormal nodes in the task execution process. Its input data comes from the execution trajectory and status information recorded by the execution controller module. This sub-component first performs structured parsing of the tool call sequence and API return status codes in the execution trajectory, establishing a correspondence between tool call steps and status codes. Then, it traverses all execution steps in the chronological order of tool calls, verifying whether the API return status codes of each step conform to the preset normal range. When the first tool call operation with a status code exceeding the normal range is detected, the step corresponding to this operation is determined as the first abnormal call node, and the tool identifier, call parameters, abnormal status code, and subtask number of the node are recorded simultaneously, forming structured abnormal node information, providing initial abnormal location basis for subsequent causal attribution analysis.
[0084] The model response analyzer is used to determine whether the output of the large language model deviates from the expected goal of the task. Its input includes the output text of the large language model recorded by the execution controller module, and the expected output keywords defined by the policy generation module in the structured policy plan. This sub-component calculates the semantic similarity between the output text of the large language model and the expected output keyword set by calling a semantic similarity calculation algorithm. At the same time, the system presets a semantic similarity threshold. If the calculated semantic similarity score is lower than the threshold, it is directly determined that the output of the large language model has deviated, and the specific manifestation of the deviation is recorded as a supplementary judgment basis for subsequent causal attribution analysis.
[0085] The causal attribution analyzer is a core sub-component for locating the root cause of failures. Its input consists of abnormal call node information output by the execution trajectory analyzer and output deviation results output by the model response analyzer. This sub-component has a built-in predefined error type mapping table, which stores the correspondence between abnormal status codes, output deviation types, and root causes of failure. By matching the input abnormal information with the error type mapping table, secondary influencing factors such as network fluctuations are eliminated, the root cause of task failure is identified, and a corresponding root cause classification label is generated, providing precise guidance for subsequent strategy rewriting.
[0086] The Natural Language Reflection Generator is responsible for integrating the analysis results of various sub-components to generate a standardized, structured reflection report. This sub-component first reads the root causes of failure and root cause classification labels output by the causal attribution analyzer, and the abnormal node information output by the execution trajectory analyzer. Then, it calls the system's pre-stored improvement strategy template. Subsequently, it combines the root causes of failure, abnormal node details, improvement suggestions, and root cause classification labels in a preset JSON format to generate a structured reflection report in JSON format. This report is directly passed to the strategy rewriting module, providing a clear direction and basis for strategy optimization.
[0087] The strategy rewriting module includes:
[0088] A prompt rewriter is used to extract keywords from the structured reflection report and replace or supplement the constraints in the initial prompt template based on these keywords.
[0089] A module replacer is used to update the structured strategy plan by selecting a functionally equivalent alternative tool from a pre-registered tool library when the root cause is a tool call failure.
[0090] A process reorderer is used to insert data validation or condition judgment nodes into the tool call sequence when the root cause is a logical missing.
[0091] The version controller is used to generate new version identifiers for rewritten policy plans and archive old version policies to the history database.
[0092] Specifically, the strategy rewriting module, based on the structured reflection report output by the reflection module, uses targeted operations from four sub-components—prompt rewriter, module replacer, process reorderer, and version controller—to precisely optimize the original structured strategy plan, ensuring that the optimized strategy can adapt to task execution requirements. The specific functionalities are as follows:
[0093] The core function of the prompt rewriter is to optimize the prompt template structure in the structured strategy plan. Its input includes the root causes of failure and improvement suggestions from the structured reflection report, as well as the initial prompt template from the original structured strategy plan. This sub-component first extracts keywords related to prompt template optimization from the structured reflection report; then, based on these keywords, it modifies the initial prompt template: if the root cause of failure is insufficient prompt template guidance, it adds constraints; if the root cause of failure is missing keywords, it replaces vague expressions in the template; after modification, it synchronously updates the prompt template structure in the structured strategy plan to ensure that the new template accurately guides the reasoning direction of the large language model.
[0094] The module replacement is suitable for scenarios where the root cause of failure is tool call failure. Its core function is to update the tool call sequence in the structured strategy plan. This sub-component first reads the abnormal call node information from the structured reflection report; then it accesses the system's pre-registered tool library, which stores the functional descriptions, parameter requirements, compatibility information, and equivalent alternative tool lists for each tool; based on the functional requirements of the failed tool, it selects functionally equivalent and currently available alternative tools from the pre-registered tool library, replaces the corresponding information of the failed tool in the original structured strategy plan with its tool identifier and call parameters, and simultaneously adjusts the execution order of the tool call sequence (if the alternative tool has prerequisite dependencies, the call order is adjusted accordingly) to ensure the availability and rationality of the tool call process.
[0095] The process rescheduler is suitable for scenarios where the root cause of failure is a lack of logic. Its core function is to optimize the tool call sequence in the structured strategy plan. This sub-component first inserts corresponding logical nodes into the tool call sequence based on the improvement suggestions in the structured reflection report: if data validation is needed, a data validation node is inserted; if condition judgment is needed, a condition judgment node is inserted. After inserting logical nodes, the execution order of the tool call sequence is adjusted synchronously to ensure that the newly added nodes are logically consistent with the original execution steps, avoiding task failure due to missing logic.
[0096] The version controller is used to manage the versions of structured strategy plans, ensuring that the strategy optimization process is traceable and rollbackable. After the strategy is rewritten, this sub-component automatically assigns a new version identifier to the newly generated structured strategy plan and records the version update log. At the same time, it archives the old version of the structured strategy plan before rewriting to the historical database. The historical database supports querying old version strategies by version identifier, task type, and update time, which facilitates subsequent analysis of the strategy optimization effect or rollback to the old version in case of abnormal execution of the new strategy, ensuring the security and traceability of strategy management.
[0097] The task result evaluation module determines task failure in the following ways:
[0098] Call the semantic similarity calculation service to compare the final output of the task with the target description input by the user. If the similarity score is lower than the first threshold, it is judged as a failure.
[0099] The number of abnormal status codes in the execution trajectory is counted. If the number of abnormalities exceeds the second threshold in a consecutive preset number of subtasks, it is judged as a failure.
[0100] Specifically, the task result evaluation module uses two independent and complementary judgment methods to accurately identify the success or failure of task execution. The two judgment methods are executed in parallel, and if either method determines failure, the entire task is judged as a failure. The specific judgment methods are implemented as follows:
[0101] The first method is failure determination based on semantic similarity.
[0102] This judgment method uses the semantic matching degree between the final task output and the user's goal as the core criterion. The specific execution process is as follows: The task result evaluation module first calls the semantic similarity calculation service integrated into the system to obtain two types of core input data, including the final output text of the task passed by the execution controller module (i.e., the final execution result generated by the large language model or external tools) and the target description of the user input recorded by the input parser module (i.e., the core needs in the user's original natural language task). Subsequently, the semantic similarity calculation service performs word segmentation and semantic encoding processing on the above two types of text and calculates the semantic similarity score between them. The system presets a first threshold. If the calculated semantic similarity score is lower than the first threshold, it is determined that the task has not achieved the user's goal, the overall task execution has failed, and the semantic similarity score and missing target keywords are recorded simultaneously to provide a basis for the root cause analysis of the subsequent reflection module.
[0103] The second method is failure determination based on exception status code statistics.
[0104] This judgment method uses the stability of tool calls during execution as the core criterion. The specific execution process is as follows: The task result evaluation module first extracts the API return status codes of all subtasks from the execution trajectory recorded by the execution controller module and filters out the abnormal status codes. Then, according to the execution order of the subtasks, the number of abnormal status codes in a consecutive preset number of subtasks is counted. The system presets a second threshold. If the number of abnormal status codes exceeds the second threshold in any consecutive preset number of subtasks, it is determined that there is a persistent fault in the task execution process, the overall task execution fails, and the type, number of occurrences, and corresponding subtask number of the abnormal status code are recorded simultaneously to provide a fault distribution basis for the root cause analysis of the subsequent reflection module.
[0105] The following describes a large language model intelligent agent method provided by an embodiment of this application. The large language model intelligent agent method described below can be referred to in correspondence with the large language model intelligent agent system described above.
[0106] See Figure 3 , Figure 3 This is a schematic diagram of a large language model intelligent agent method disclosed in an embodiment of this application.
[0107] like Figure 3 As shown, the large language model intelligent agent method may include:
[0108] Step S1: Receive the natural language task input by the user, perform semantic understanding and task decomposition through the input parser, and generate a subtask list and initial prompt template;
[0109] Step S2: Construct a structured policy plan containing tool call sequences using the policy generation module;
[0110] Step S3: Execute the structured strategy plan by calling the large language model and external tools through the execution controller module, and record the execution log;
[0111] Step S4: Determine whether the execution result meets the standard through the task result evaluation module. If it does not meet the standard, trigger the reflection module.
[0112] Step S5: Analyze the execution log through the reflection module to generate a structured reflection report;
[0113] Step S6: Rewrite the structured strategy plan according to the structured reflection report through the strategy rewriting module, and resubmit it to the execution controller module for execution.
[0114] As can be seen from the above technical solutions, the large language model intelligent agent system, method, and related devices provided in this application include an input parser module, a policy generation module, an execution controller module, a task result evaluation module, a reflection module, and a policy rewriting module. The reflection module and the policy rewriting module form an adaptive optimization closed loop for task execution, which can specifically solve the defects of the prior art. The specific effects are as follows:
[0115] To address the lack of diagnostic capabilities after task failure, the system's task result evaluation module can determine whether a task has failed. The reflection module analyzes the execution trajectory and model response upon failure, generating a structured reflection report containing the reasons for failure. This enables precise identification and tracking of the causes of failure, avoiding the problem of simply repeating attempts or stopping execution. To address the lack of reflection and learning mechanisms, the structured reflection report from the reflection module provides key feedback on task execution. The strategy rewriting module optimizes the task plan and prompt structure based on this report, enabling the system to have self-learning and optimization capabilities, overcoming the limitation of not being able to adjust based on feedback. To address the lack of reconfigurable strategies, the strategy rewriting module can reconstruct structured strategy plans, adjust tool call order, or replace strategy modules, replacing static prompts and preset planning patterns, improving system flexibility. To address the lack of a cognitive closed-loop design, the adaptive optimization closed loop constructed by the reflection and strategy rewriting modules forms a complete process of task execution, result evaluation, reflection and attribution, strategy rewriting, and re-execution, filling the gap in cognitive closed-loop design. Furthermore, the initial prompt template output by the input parser module enables unified management of the prompt structure, effectively solving the problems of unstructured and drifting prompt calls, ensuring system stability. Overall, the system significantly improves task completion rate, execution stability, and scenario adaptability, especially enhancing robustness and error tolerance in complex multi-step tasks, filling a key gap in the self-reflection and self-optimization capabilities of existing language model agent systems.
[0116] The large language model intelligent agent device provided in this application embodiment can be applied to large language model intelligent agent devices. Figure 4 The hardware structure block diagram of the large language model intelligent agent device is shown below. Figure 4 The hardware structure of a large language model intelligent agent device may include: at least one processor 1, at least one communication interface 2, at least one memory 3, and at least one communication bus 4.
[0117] In this embodiment of the application, the number of processor 1, communication interface 2, memory 3, and communication bus 4 is at least one, and processor 1, communication interface 2, and memory 3 communicate with each other through communication bus 4;
[0118] Processor 1 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
[0119] Memory 3 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device;
[0120] The memory stores a program, which the processor can call. The program is used for:
[0121] The system receives natural language tasks from user input, performs semantic understanding and task decomposition through an input parser, and generates a list of subtasks and an initial prompt template.
[0122] The strategy generation module constructs a structured strategy plan containing tool call sequences;
[0123] The structured strategy plan is executed by calling the large language model and external tools through the execution controller module, and the execution log is recorded.
[0124] The task result evaluation module determines whether the execution result meets the standard; if it does not, the reflection module is triggered.
[0125] The reflection module analyzes the execution logs to generate a structured reflection report.
[0126] The strategy rewriting module rewrites the structured strategy plan based on the structured reflection report and resubmits it to the execution controller module for execution.
[0127] Optionally, the refined and extended functions of the program can be referred to the above description.
[0128] This application embodiment also provides a readable storage medium that can store a program suitable for execution by a processor, the program being used for:
[0129] The system receives natural language tasks from user input, performs semantic understanding and task decomposition through an input parser, and generates a list of subtasks and an initial prompt template.
[0130] The strategy generation module constructs a structured strategy plan containing tool call sequences;
[0131] The structured strategy plan is executed by calling the large language model and external tools through the execution controller module, and the execution log is recorded.
[0132] The task result evaluation module determines whether the execution result meets the standard; if it does not, the reflection module is triggered.
[0133] The reflection module analyzes the execution logs to generate a structured reflection report.
[0134] The strategy rewriting module rewrites the structured strategy plan based on the structured reflection report and resubmits it to the execution controller module for execution.
[0135] Optionally, the refined and extended functions of the program can be referred to the above description.
[0136] This application also provides a computer program product, including a computer program, wherein the computer program is executed by a processor using the following method:
[0137] The system receives natural language tasks from user input, performs semantic understanding and task decomposition through an input parser, and generates a list of subtasks and an initial prompt template.
[0138] The strategy generation module constructs a structured strategy plan containing tool call sequences;
[0139] The structured strategy plan is executed by calling the large language model and external tools through the execution controller module, and the execution log is recorded.
[0140] The task result evaluation module determines whether the execution result meets the standard; if it does not, the reflection module is triggered.
[0141] The reflection module analyzes the execution logs to generate a structured reflection report.
[0142] The strategy rewriting module rewrites the structured strategy plan based on the structured reflection report and resubmits it to the execution controller module for execution.
[0143] Optionally, the refined and extended functions of the program can be referred to the above description.
[0144] Finally, 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 a process, method, article, or apparatus. 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.
[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0146] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A large language model intelligent agent system, characterized in that, include: The input parser module is used to perform semantic understanding and task decomposition on the natural language task input by the user, and output a list of subtasks and an initial prompt template. The strategy generation module is used to generate a structured strategy plan containing tool selection and invocation sequence based on the subtask list and the initial prompt template; The execution controller module is used to call the large language model interface and external tools to execute the structured strategy plan, and record the execution trajectory and status information; The task result evaluation module is used to determine whether a task has failed based on the difference between the execution result and the preset target. The reflection module is used to analyze the execution trajectory and model response when a task fails, and generate a structured reflection report containing the reasons for failure and improvement suggestions. The strategy rewriting module is used to rewrite the structured strategy plan based on the structured reflection report and feed it back to the execution controller module for re-execution; The system forms an adaptive optimization closed loop for task execution through the reflection module and the strategy rewriting module.
2. The system according to claim 1, characterized in that, The reflection module includes: An execution trajectory analyzer is used to parse the tool call sequence and API return status code in the execution trajectory and status information, and identify the first abnormal call node; The model response analyzer is used to calculate the semantic similarity between the text output by the large language model and the expected output keywords. If the similarity is lower than the threshold, it is determined to be an output deviation. A causal attribution analyzer is used to determine the root cause of failure based on the abnormal call nodes and output deviation results, using a predefined error type mapping table. A natural language reflection generator is used to combine the root causes of failure, abnormal node information, and pre-stored improvement strategy templates to generate the structured reflection report in JSON format.
3. The system according to claim 2, characterized in that, The strategy rewriting module includes: A prompt rewriter is used to extract keywords from the structured reflection report and replace or supplement the constraints in the initial prompt template based on these keywords. A module replacer is used to update the structured strategy plan by selecting a functionally equivalent alternative tool from a pre-registered tool library when the root cause of the failure is a tool call failure. A process reorderer is used to insert data validation or condition judgment nodes into the tool call sequence when the root cause of the failure is a logical missing node. The version controller is used to generate new version identifiers for rewritten policy plans and archive old version policies to the history database.
4. The system according to claim 3, characterized in that, The task result evaluation module determines task failure in the following ways: Call the semantic similarity calculation service to compare the final output of the task with the target description input by the user. If the similarity score is lower than the first threshold, it is judged as a failure. The number of abnormal status codes in the execution trajectory is counted. If the number of abnormalities exceeds the second threshold in a consecutive preset number of subtasks, it is judged as a failure.
5. The system according to claim 1, characterized in that, The structured strategy plan is stored in JSON format and includes at least three logical components: tool call sequence, prompt template structure, and expected output specification. The strategy rewriting module rewrites the strategy by parsing and modifying the logical components.
6. The system according to claim 1, characterized in that, When the system is deployed as a cloud service, the input parser module, the policy generation module, and the execution controller module are deployed in a serverless computing engine, and the reflection module and the policy rewriting module are deployed in an independent adaptive optimization microservice and communicate with each other through a message queue.
7. A method for intelligent agents based on large language models, characterized in that, include: The system receives natural language tasks from user input, performs semantic understanding and task decomposition through an input parser, and generates a list of subtasks and an initial prompt template. The strategy generation module constructs a structured strategy plan containing tool call sequences; The structured strategy plan is executed by calling the large language model and external tools through the execution controller module, and the execution log is recorded. The task result evaluation module determines whether the execution result meets the standard; if it does not, the reflection module is triggered. The reflection module analyzes the execution logs to generate a structured reflection report. The strategy rewriting module rewrites the structured strategy plan based on the structured reflection report and resubmits it to the execution controller module for execution.
8. A large language model intelligent agent device, characterized in that, Including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement the various steps of the large language model intelligent agent method as described in claim 7.
9. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the various steps of the large language model intelligent agent method as described in claim 7.
10. A computer program product, comprising a computer program, characterized in that, The computer program is executed by the processor to perform the various steps of the large language model intelligent agent method as described in claim 7.
Citation Information
Cited By
Task execution method and device based on model scheduling and storage medium
CN121579178A