Task processing method and device, electronic equipment and storage medium

By using the task stack and the results of the previous round of tool call in task planning for dynamic adjustment, the problem of difficult task planning in complex task environments is solved, and efficient and accurate task execution and system robustness are achieved.

CN119537541APending Publication Date: 2025-02-28TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Application Number
CN202411603831.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

When the prior art faces complex problems, it is difficult to efficiently and accurately carry out task planning and execution, especially when task requirements change dynamically.

Method used

A task processing method is adopted to manage planned tasks through the task stack, and dynamically adjust decision actions according to the results of the previous round of tool call in each round of task planning to ensure the accuracy and flexibility of task planning.

Benefits of technology

It realizes efficient and accurate task planning and execution in complex task environments, reduces the need for frequent calls to large language models (LLMs), and improves task planning efficiency and system robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537541A_ABST
    Figure CN119537541A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to the technical field of artificial intelligence, and provides a task processing method and device, electronic equipment and a storage medium which are used for efficiently and accurately performing task planning and execution. The method comprises the following steps: executing at least one round of task processing according to a question input by an object until a preset end condition is met, and outputting reply information corresponding to the question; the nth round of task processing comprises the following steps: planning an nth round of decision action according to a problem and a tool calling result corresponding to an (n-1) th round of target task so as to indicate task planning details of the nth round; extracting the nth round of target task from the task stack according to the nth round of decision action; generating tool calling information for the nth round of target task according to the nth round of target task and the background information corresponding to the problem; and calling a tool according to the tool calling information to execute the nth round of target task to obtain a tool calling result corresponding to the nth round of target task.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Task planning is one of the important core capabilities of Large Language Model (LLM) agent systems to solve complex problems. In related technologies, LLM agent systems for task planning are divided into two categories: single-agent systems and multi-agent systems.

[0003] For a single-agent system, its underlying LLM is responsible for both task planning and tool calling (i.e., task execution), which places high demands on LLM capabilities. When encountering complex tasks, it faces challenges such as large state space, uncertainty processing, and real-time multi-task execution.

[0004] For multi-agent systems, task planning technology based on task lists is generally used. In the initial stage, global task planning is carried out, and task lists are formulated to execute tasks according to them. However, since the task list is formulated before the task starts, it has poor flexibility and is difficult to cope with dynamically changing task requirements, such as the need to dynamically select subsequent tasks after data completeness checks.

[0005] In summary, when faced with complex problems, how to plan and execute tasks efficiently and accurately is an urgent issue to be solved. Summary of the invention

[0006] The embodiments of the present application provide a task processing method, device, electronic device and storage medium for efficiently and accurately planning and executing tasks.

[0007] An embodiment of the present application provides a task processing method, including:

[0008] Perform at least one round of task processing according to the question input by the object, and output the reply information corresponding to the question after reaching the preset end condition; wherein the nth round of task processing includes the following steps:

[0009] According to the problem and the tool call result corresponding to the target task of the n-1th round, plan the decision action of the nth round; the decision action of the nth round is used to indicate the task planning details of the nth round, where n is a positive integer;

[0010] According to the nth round decision action, taking out the nth round target task from the task stack; the task stack includes the currently planned tasks related to the problem;

[0011] Generating tool call information for the n-th round target task according to the background information corresponding to the n-th round target task and the problem; the background information is determined according to the execution status of the problem and related tasks;

[0012] A tool is called according to the tool calling information to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

[0013] An embodiment of the present application provides a task processing device, including:

[0014] The task processing unit is used to perform at least one round of task processing according to the question input by the object, and output the reply information corresponding to the question after the preset end condition is reached; wherein the task processing unit includes a task planning subunit and a tool calling subunit, and the nth round of task processing includes the following steps:

[0015] The task planning subunit is used to plan the nth round of decision actions according to the problem and the tool call results corresponding to the target task of the n-1th round; the nth round of decision actions are used to indicate the task planning details of the nth round, where n is a positive integer;

[0016] According to the nth round decision action, taking out the nth round target task from the task stack; the task stack includes the currently planned tasks related to the problem;

[0017] The tool calling subunit is used to generate tool calling information for the target task of the nth round according to the background information corresponding to the target task of the nth round and the problem; the background information is determined according to the execution status of the problem and related tasks;

[0018] A tool is called according to the tool calling information to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

[0019] Optionally, the task planning subunit is specifically used for:

[0020] Generate a new task set according to the nth round of decision actions;

[0021] Updating the task stack according to the new task set;

[0022] The top task taken out from the updated task stack is used as the target task of the nth round.

[0023] Optionally, the task planning subunit is further configured to, before the tool calling subunit generates tool calling information for the n-round target task according to the n-round target task and the background information corresponding to the problem:

[0024] The background information is updated according to the problem, the task stack, and the tool call result corresponding to the target task of the n-1th round.

[0025] Optionally, the task processing unit is specifically used for:

[0026] Generate response information corresponding to the question by summarizing the question, the task stack, the tool call result corresponding to the target task of the n-1th round, and the background information, and output the response information;

[0027] The reply information is the answer to the question, or the reply information indicates the current processing result of the question and the problems existing in the task processing process.

[0028] Optionally, the task planning subunit is specifically used for:

[0029] Analyze whether the target task of the n-1th round is empty;

[0030] If the target task of the n-1th round is empty, the decision action of the nth round indicates: based on the problem, generate at least one main task, and set the execution times of the main task to the initial value;

[0031] If the target task of the n-1th round is not empty, the decision action of the nth round is planned according to the task type of the target task of the n-1th round and the tool calling result.

[0032] Optionally, the task planning subunit is specifically used for:

[0033] Analyze whether the target task of the n-1th round is successfully executed according to the tool call result corresponding to the target task of the n-1th round;

[0034] If the execution of the target task of the n-1th round fails, planning the decision action of the nth round according to whether there is a branch task of the target task of the n-1th round;

[0035] If the target task of the n-1th round is successfully executed, the decision action of the nth round is planned according to whether the target task of the n-1th round is a main task.

[0036] Optionally, the task planning subunit is specifically used for:

[0037] If the target task of the n-1th round has a branch task, the decision action of the nth round indicates: generating a corresponding branch task, and setting the execution times of the branch task to an initial value;

[0038] If there is no branch task in the target task of the n-1th round, and the number of executions of the target task of the n-1th round has not reached the upper limit, then the decision action of the nth round indicates: re-planning tasks according to the target task of the n-1th round;

[0039] If there is no branch task for the target task of the n-1th round, and the execution times of the target task of the n-1th round reaches the upper limit, the decision action of the nth round indicates that the task processing fails.

[0040] Optionally, the task planning subunit is specifically used for:

[0041] If the target task of the n-1th round is a main task and the task stack is empty, then the decision action of the nth round is planned according to whether the question has been answered;

[0042] Otherwise, the nth round decision action indicates: no new task is generated.

[0043] Optionally, the task planning subunit is specifically used for:

[0044] If the question has been answered, the nth round of decision-making action means that the task processing has been completed;

[0045] If the question has not been answered, the nth round decision action indicates: based on the question, the background information and the tool call result corresponding to the target task of the n-1th round, at least one main task is generated, and the number of executions of the main task is set to the initial value.

[0046] Optionally, the task planning subunit is specifically used for:

[0047] If the n-th round decision action is not a designated decision action, taking out the n-th round target task from the task stack according to the n-th round decision action; wherein the designated decision action includes: task processing completed, task processing failed;

[0048] The task planning subunit is also used for:

[0049] If the n-th round decision action is a designated decision action, it is determined that the preset end condition is met.

[0050] Optionally, if the n-th round target task has one, correspondingly, each n-th round target task corresponds to one tool calling information, then the tool calling subunit is specifically used for:

[0051] For multiple target tasks of the nth round, the following process is performed in parallel:

[0052] A tool is called according to tool calling information corresponding to an n-th round target task to execute the n-th round target task and obtain a tool calling result corresponding to the n-th round target task.

[0053] An electronic device provided by an embodiment of the present application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above-mentioned task processing methods.

[0054] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is executed on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the above-mentioned task processing methods.

[0055] An embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any one of the above-mentioned task processing methods.

[0056] The beneficial effects of this application are as follows:

[0057] The embodiment of the present application provides a task processing method, device, electronic device and storage medium. For task planning, the present application performs task planning once per round, and during task planning, the decision-making actions of each round are planned according to the tool call results (initial empty) of the task executed in the previous round and the problem, and this task planning method makes reference to the execution of the previous task in each round of task planning process, and can dynamically adjust the downstream tasks according to the execution of the upstream tasks in a targeted manner, so as to ensure that the decision-making actions of each round are planned in consideration of task dependency, and the planning results are more accurate.

[0058] On this basis, a series of related tasks can be determined in advance through the task stack, which can reduce the need to frequently call LLM for re-planning. In addition, these planned tasks are saved in the stack in an orderly manner to ensure that the tasks are executed in a certain order. This helps to clarify the priority of tasks, avoid inefficiency caused by mutual interference between tasks, effectively reduce the number of re-planning times, and improve task planning efficiency.

[0059] In summary, in this application, the task stack is used to store the planned tasks in the form of a stack, and the task planning is performed in combination with the results of the previous round of tool calls. This planning strategy can guide the large model to conduct scientific process analysis on the results of the executed tasks to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning, taking into account planning efficiency while considering task dependencies and improving system robustness.

[0060] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0062] Figure 1 An optional schematic diagram of an application scenario in an embodiment of the present application;

[0063] Figure 2 A schematic diagram of a large language model task planning system in an embodiment of the present application;

[0064] Figure 3 A flowchart of a task processing method provided in an embodiment of the present application;

[0065] Figure 4 A schematic diagram of a front-end operation interface of LLMAPP in an embodiment of the present application;

[0066] Figure 5 A schematic diagram of a task stack storage process in an embodiment of the present application;

[0067] Figure 6 A logical diagram of task processing based on a multi-agent framework in an embodiment of the present application;

[0068] Figure 7 A logical schematic diagram of task planning based on a task planning agent in an embodiment of the present application;

[0069] Figure 8 This is a logical diagram of the first planning of decision-making actions in this round in the embodiment of the present application;

[0070] Fig. 9 This is a logical diagram of the second planning of decision-making actions in this round in the embodiment of the present application;

[0071] Fig.10 This is a logic diagram of the third planning of decision-making actions in this round in the embodiment of the present application;

[0072] Fig.11 A flowchart of a task processing method in an embodiment of the present application;

[0073] Fig.12A flowchart of a task planning method in an embodiment of the present application;

[0074] Fig.13 A logic diagram of interaction between a terminal device and a server in an embodiment of the present application;

[0075] Fig.14 is a structural schematic diagram of a task processing device in an embodiment of the present application;

[0076] Fig.15 A schematic diagram of a hardware structure of an electronic device to which an embodiment of the present application is applied;

[0077] Fig.16 The present invention is a schematic diagram of the hardware structure of another electronic device to which the embodiments of the present application are applied. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.

[0079] The following is an introduction to some concepts involved in the embodiments of the present application.

[0080] 1. LLM: refers to a deep learning model trained with a large amount of text data, which can perform various natural language processing (NLP) tasks, such as generating natural language text or understanding the meaning of language text. Large language models generally use multiple transformer models and are trained with massive data sets, so they are very large in scale, which is also a strong foundation for them to recognize, translate, predict or generate text or other content. The task processing method in this application can be applied to LLM, specifically to the LLM Agent system.

[0081] 2. Agent: An intelligent operating system based on LLM that has certain thinking, memory, tool use and action capabilities. The agent can perceive the environment, make decisions, and perform corresponding actions to influence the environment under given goals. Specifically, a single-agent system contains an independent agent, while a multi-agent system consists of multiple agents that collaborate or compete with each other to jointly solve problems or complete tasks.

[0082] 3. Task planning: refers to the process of converting the intentions of the object (such as the user) into a series of specific tasks after understanding them based on LLM. Each task usually includes a tool call, which aims to use external tools or services to obtain the required information or perform specific operations. The Agent system will execute in the order of this series of planned tasks, update its status after each task is completed, and determine the subsequent tasks based on the results until all tasks are completed or the predetermined goals are achieved, thus forming a final answer or solution.

[0083] 4. Decision action: It is a specific step in the task planning process. A decision action can contain one or more task-type operations, such as querying a database, searching for network information, etc., aiming to promote the achievement of task goals. At the same time, a decision action may not contain any specific tasks, but directly generate the final answer or take the default action by LLM. This design allows the agent to respond quickly when necessary, avoiding unnecessary delays or waste of resources.

[0084] 5. Function Call: This means that when processing an object request, the object intent understood by LLM is converted into a structured instruction format to trigger the call to an external application programming interface (API) or tool. For example, a series of external tools such as calculators, search engines, code compilers, etc. can be called. This method allows LLM to utilize the functions of external services, such as performing mathematical operations, searching for network information, writing and running code snippets, etc., to enhance its own capabilities and provide more accurate and rich responses. Among them, tool calls are implemented through standardized interfaces to ensure the consistency and reliability of interactions, so that LLM can seamlessly integrate multiple external functions to meet the diverse needs of objects. In the task execution phase of this application, tool calls are required.

[0085] 6. Stack: It is an abstract data structure that follows the First In First Out (FIFO) or Last In First Out (LIFO) principle. The FIFO principle means that the element first added to the stack will be removed first, and the LIFO principle means that the element last added to the stack will be removed first. For a stack, push and pop operations are limited to the top of the stack. Adding a new element to the top of the stack is called pushing, and taking an element from the top of a stack is called popping.

[0086] Task Stack: is a specific application for task management and scheduling. In the task stack, tasks are arranged in a certain order, usually according to the FIFO or LIFO principle. When a new task is added to the task stack, it will be placed at the top of the stack and become the next task to be executed. When the task is executed, it is removed from the top of the stack, and the next task becomes the current task to be executed. Through push and pop operations, the task stack provides an efficient and concise way to manage and process tasks, help manage the execution order of tasks in the system, ensure that tasks are executed on demand, and can backtrack or restore task status when necessary. In the multi-agent system proposed in this application, the task stack can be used to manage the task allocation and execution process between different agents.

[0087] 7. Planned tasks and target tasks: Planned tasks refer to specific tasks that have been determined and recorded during the task planning process. Planned tasks are usually stored in a task stack or other data structure, waiting to be executed as planned. They are intermediate results in the task management process and provide a basis for subsequent task scheduling and execution. Target tasks refer to specific tasks that need to be actually completed during the task execution process. These tasks are selected from the planned tasks and are ready to be executed. As in this article, the task stack stores the current planned tasks related to the problem in a certain order, and the task stack can be continuously updated, and the target tasks are taken out from the task stack for execution.

[0088] 8. Synchronous task: It means that the execution of a task must wait for the previous operation to be completed before continuing to the next operation. In synchronous mode, the control flow of the program is linear, that is, the start of the next task depends on the completion of the previous task. This mode usually leads to blocking during execution, because the subsequent tasks cannot start to execute when the previous task is not completed.

[0089] Asynchronous task: refers to a task that can be executed without waiting for the previous task to complete. In asynchronous mode, the program can execute subsequent operations immediately after issuing instructions without waiting for the previous task to complete. Once the previous task is completed, the program will notify the main program through callback functions, events, signals, etc.

[0090] Parallel execution: refers to executing multiple tasks at the same time. This can be achieved through multi-threading, multi-processing, or by taking advantage of the concurrency capabilities provided by modern computer hardware (such as the number of CPU cores). Parallel execution can significantly improve the execution efficiency of programs, especially when dealing with input / output (I / O) intensive tasks (such as network requests, disk reading and writing, etc.).

[0091] The following is a brief introduction to the design concept of the embodiment of the present application:

[0092] Building an LLM Agent system and allowing it to think independently and call tools to solve professional problems is one of the important means to expand the capabilities of LLM. In the face of complex problems, planned thinking and tool calling are the key to LLM completing tasks. To this end, a series of studies are dedicated to developing the task planning capabilities of the LLM Agent system.

[0093] In the related art, the LLM Agent system used for task planning is divided into two categories: single-agent system and multi-agent system.

[0094] Among them, for single-agent systems, there are great challenges when facing complex tasks.

[0095] For multi-agent systems, task planning technology based on Task List is generally used. In addition to global task planning in the initial stage, some of these algorithms will also update TaskList when each subsequent task is completed. However, these algorithms require that the problem to be solved has a relatively fixed task planning route. For some problems, the subsequent task type needs to be dynamically selected based on the existing tasks. However, because these algorithms lack task dependency considerations, it is difficult to dynamically select the next task type based on the existing task execution results.

[0096] For example, when calculating the year-on-year value of a certain indicator on a certain day in the data, it is necessary to first check the data completeness. If the data is available, it is calculated directly. If the data is missing, it is necessary to predict first and then calculate or end the task directly. For this situation, the task planning technology based on Task List has poor flexibility because the Task List is formulated before the task starts, so it is difficult to solve such problems in principle.

[0097] In view of this, the present application proposes a task processing method, device, electronic device and storage medium. For task planning, the present application performs task planning once per round, and during task planning, the decision-making actions of each round are planned based on the problem and the tool call results of the tasks executed in the previous round. This task planning method makes reference to the execution of the previous tasks in each round of task planning, and can dynamically adjust the downstream tasks according to the execution of the upstream tasks in a targeted manner, ensuring that the decision-making actions of each round are planned in consideration of task dependencies, and the planning results are more accurate.

[0098] On this basis, a series of related tasks can be determined in advance through the task stack, which can reduce the need to frequently call LLM for re-planning. In addition, these planned tasks are saved in the stack in an orderly manner to ensure that the tasks are executed in a certain order. This helps to clarify the priority of tasks, avoid inefficiency caused by mutual interference between tasks, effectively reduce the number of re-planning times, and improve task planning efficiency.

[0099] In summary, in this application, the task stack is used to store the planned tasks in the form of a stack, and the task planning is performed in combination with the results of the previous round of tool calls. This planning strategy can guide the large model to conduct scientific process analysis on the results of the executed tasks to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning, taking into account planning efficiency while considering task dependencies and improving system robustness.

[0100] In addition, after each task is executed, there may be a situation where the task fails or the result does not meet expectations. In such cases, the task needs to be replanned. However, these algorithms in the related art lack a targeted design for task replanning when the task fails, and only treat it as a general task execution result, which is not conducive to the LLMAgent system to diagnose errors and adjust tasks in a timely manner, making the LLM Agent system lack robustness in solving practical problems.

[0101] In order to overcome the above problems, the present application has carried out targeted design for task re-planning during task planning. For example, in the case where the task execution does not achieve the expected results, the present application divides the tasks into two categories: main line tasks and branch line tasks. In the case of failure of the main line task execution, the task planning strategy in the present application will guide the LLM to determine whether to re-execute the task, or to retain the main line task while adding a new branch line task, thereby enhancing the robustness of the LLM Agent system in the case of task failure.

[0102] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0103] like Figure 1 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes a terminal device 110 and a server 120.

[0104] In the embodiments of the present application, the terminal device 110 includes but is not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals and other devices; a client related to task processing may be installed on the terminal device, which may be software (such as a browser, conversational artificial intelligence (AI) software, etc.), or a web page, a small program, etc. The server 120 is a background server corresponding to the software or web page, small program, etc., or a server specifically used for task processing, which is not specifically limited in the present application. The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0105] It should be noted that the task processing method in each embodiment of the present application can be executed by an electronic device, which can be a terminal device 110 or a server 120, that is, the method can be executed by the terminal device 110 or the server 120 alone, or by the terminal device 110 and the server 120 together. For example, when executed by the server 120, the server 120 will obtain the question input by the object on the terminal device 110 side, and then perform at least one round of task processing according to the question, until the preset end condition is reached, and then output the reply information corresponding to the question; wherein, the nth round of task processing includes two parts: task planning and task execution. Taking the nth round as an example, it specifically includes the following steps:

[0106] Task planning part: according to the tool call results corresponding to the problem and the target task of the n-1th round, plan the decision action of the nth round, and the decision action of the nth round is used to indicate the task planning details of the nth round; according to the decision action of the nth round, take out the target task of the nth round from the task stack; wherein the task stack contains the currently planned tasks related to the problem, specifically the currently planned tasks in the task stack that have not yet been executed;

[0107] Task execution part: Generate tool call information for the nth round target task based on the background information corresponding to the nth round target task and the problem; the background information is determined based on the execution status of the problem and related tasks; call the tool according to the tool call information to execute the nth round target task and obtain the tool call result corresponding to the nth round target task.

[0108] Optionally, the above method can be applied to the LLM Agent system, which refers to an intelligent agent system built using LLM as the core component, that is, the large language model task planning system in this article, referred to as the task planning system. Such systems can perform a variety of tasks, from simple information query and text generation to more complex dialogue management, content creation, and even decision support in specific fields.

[0109] In an embodiment of the present application, the LLM Agent system is responsible for processing object requests, generating tasks, calling tools, and summarizing information. Specifically, the LLM Agent system can run on the server side or in a cloud environment (such as a cloud server). The server is responsible for storing the code, tool pool, database and other resources of the LLM Agent system, and providing the necessary computing power to perform tasks. It is also responsible for processing requests from terminal devices and communicating with terminal devices through the network. The terminal device, as a front-end device for the interaction between the object and the LLM Agent system, can be installed with the client listed above, such as conversational AI software, which is responsible for receiving the input of the object (such as questions or instructions) and sending these requests to the LLM Agent system. At the same time, the terminal device will also display the answer or execution result returned by the LLM Agent system.

[0110] In practical applications, task planning capability is one of the important core capabilities of the LLM Agent system to solve complex problems. The LLM Agent system proposed in this application is a multi-agent system, which can be obtained by adding the task planning agent in this application on the basis of the traditional single agent. For example, the LLM Agent system developer can add the task planning function proposed in this application to the traditional single agent system by linking the task planning agent in the tool pool and the tool calling agent backend on the LLMAPP platform (LLMAPP is a front-end application of the LLM Agent system in this article).

[0111] like Figure 2 As shown, it is a schematic diagram of a large language model task planning system in an embodiment of the present application. The large language model task planning system proposed in the present application includes three components: a tool calling agent (Function CallAgent), a tool pool, and a task planning agent (Plan Agent).

[0112] Among them, the tool pool is a collection of multiple tools or functional modules that are centrally managed to provide a flexible and extensible framework that enables tool-calling agents to dynamically load and use the required tools to perform specific tasks. The tools in the tool pool can be scripts, API interfaces, command-line tools, library functions, or containerized services, which are uniformly managed and shared to improve resource utilization efficiency. In addition, the tool pool in the embodiment of the present application also supports dynamic addition or removal of tools to facilitate system maintenance and expansion, which will not be repeated here.

[0113] The tool calling agent can be a component specially designed to interact with external services. It can understand tool calling information and perform corresponding operations. It is responsible for executing specific tasks. Its main responsibilities include: generating tool calling information, executing tool calling, and feedback results. Specifically, the tool calling agent is used to generate calling instructions for the specified tool according to the task requirements, including the tool category name and necessary tool input parameters, etc., and then execute the tool calling information generated above to call the tools in the tool pool to complete the specific task. In addition, the tool calling agent can also report the results of the tool calling (such as success or failure) to the task planning agent to facilitate the decision-making of subsequent tasks.

[0114] The task planning agent is the brain of the entire process. It is responsible for overall task management and coordination. Its main functions include task scheduling, that is, deciding which subtask should be executed next based on the current status and resource conditions. In addition, the task planning agent is also used to evaluate the performance of the current task based on the results returned by the tool calling agent, and adjust the subsequent task plan accordingly.

[0115] In practical applications, the work of these two agents is interdependent. The task planning agent provides high-level policy guidance, while the tool calling agent is responsible for low-level operation execution. The interaction between them ensures that the task can be completed efficiently and flexibly according to the established goals. For example, in the case of a tool call failure, the task planning agent can re-plan subsequent tasks based on the failure information provided by the tool calling agent, select alternative solutions, or try other tools to achieve the final goal.

[0116] In an optional implementation, the terminal device 110 and the server 120 may communicate with each other via a communication network.

[0117] In an optional implementation, the communication network is a wired network or a wireless network.

[0118] It should be noted that Figure 1 The figure is only an example. In fact, the number of terminal devices and servers is not limited and is not specifically limited in the embodiments of the present application.

[0119] In an embodiment of the present application, when there are multiple servers, the multiple servers can form a blockchain, and the servers are nodes on the blockchain; as in the task processing method disclosed in the embodiment of the present application, the task-related data involved can be saved on the blockchain, for example, questions, task stacks, tool call results, decision actions, background information, reply information, etc.

[0120] In addition, the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios.

[0121] With the continuous advancement of technology, LLM-driven agent systems are rapidly changing the way people process information, solve problems, and create value. For example:

[0122] In the field of customer service, LLM Agent systems can not only automatically answer common customer inquiries and improve service efficiency, but also deeply analyze customer behavior patterns, predict customer needs, and provide more accurate service solutions, thereby enhancing customer satisfaction and loyalty. For example, they can recommend personalized products or services based on historical interaction records to make the customer experience more intimate.

[0123] In terms of educational assistance, the LLM Agent system uses its powerful data processing capabilities to analyze students' learning habits and progress, and then provides tailored learning suggestions and resources to help students overcome learning obstacles and promote efficient knowledge absorption. In addition, these systems can also act as virtual teachers to answer questions in real time, making the distribution of educational resources more balanced and promoting educational equity.

[0124] In the field of medical health, the LLM Agent system, with its ability to understand a large amount of medical literature and clinical data, can not only provide preliminary health consultation services to the subjects, but also assist doctors in disease analysis and provide diagnostic support. More importantly, such systems can play an important role in patient management and follow-up, and can warn of potential risks by monitoring changes in health indicators, thereby achieving early intervention.

[0125] In the field of content creation, the LLM Agent system has demonstrated its ability to generate high-quality original texts, whether news reports, professional articles or literary works, which can be quickly produced according to specific subject and style requirements. This not only greatly enriches the content market, but also provides a source of inspiration for creators, and promotes the innovation and development of cross-media content production. In addition, such systems can also be used for automated editing and proofreading, improving the efficiency and accuracy of the publishing process.

[0126] It should be noted that the application scenarios of the above-mentioned LLM Agent system are just simple examples, and this article does not make specific restrictions on them. The LLM Agent system can show broad application prospects in various fields due to its flexibility and adaptability.

[0127] In addition, it should be emphasized that in the specific implementation of this application, the relevant data of the object is involved, such as the problems listed above. When the above embodiments of this application are applied to specific products or technologies, the permission or consent of the object needs to be obtained, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.

[0128] The following describes the task processing method provided by the exemplary embodiment of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation methods of the present application are not limited in this regard.

[0129] See also Figure 3 As shown, it is an implementation flow chart of a task processing method provided in an embodiment of the present application. Taking the execution subject as a server as an example, the specific implementation process of the method is as follows S31-S32:

[0130] S31: Problem of obtaining object input.

[0131] In the embodiment of the present application, the object can ask questions, and the server can obtain the questions input by the object on the terminal device side. The object can be any object, such as a conversational AI software installed on the terminal device side, and the object that inputs questions through the software can be regarded as an object in S31.

[0132] Among them, questions include but are not limited to text, voice, pictures, videos, URLs, etc., and this article does not make specific restrictions on this.

[0133] There are many ways to input questions, such as typing, voice input, or selecting from preset questions. The following is a brief description of these input methods:

[0134] Input method 1: typing input.

[0135] This method is suitable for describing complex problems or instructions in detail, allowing objects to be modified and edited during input, and is suitable for situations where precise expression is required.

[0136] Input method 2: Voice input.

[0137] This method does not require manual input and is quick and convenient. It is particularly suitable for use in mobile environments or situations that require two-handed operation. It is suitable for sending messages while driving, smart home control, or asking questions when manual typing is not possible, such as while cooking.

[0138] Input method three: Select from preset questions.

[0139] This method simplifies the input process and avoids misunderstandings due to spelling errors or unclear expressions. It is suitable for customer service interfaces, online questionnaires, or any situation that requires standardized answers.

[0140] In addition to the above-mentioned input methods, some more intelligent ways can be used to input questions, such as gesture recognition input, which is to convey instructions by capturing the movements of the object through the camera, which is suitable for barrier-free access or augmented reality applications; touch screen input, which is to directly click or slide on the screen to input information, which is suitable for mobile devices and tablets; another example is graphical interface input, such as using dragging elements, icon selection, etc. to construct questions, which is suitable for non-verbal communicators or children.

[0141] The forms of questions and input methods listed above are just simple examples. These diverse methods enable the LLM Agent system to adapt to the needs of different target groups, improve the system's usability and inclusiveness, and by combining multiple input methods, the LLM Agent system can provide a more flexible and user-friendly interactive experience.

[0142] Still with the above Figure 2 Take the LLM Agent system listed as an example. After the system is built, the subject can ask questions in a dialogue. After asking questions, the LLM Agent system will independently plan tasks, call tools, and ultimately solve the problem. During this process, the subject does not need manual intervention and can see the specific task planning and execution process, or only focus on the final summary of the answer by the LLM Agent system.

[0143] like Figure 4 As shown, it is a schematic diagram of a front-end operation interface of an LLMAPP in an embodiment of the present application, wherein the interface is an object-oriented interactive interface, and an object can open a chat window with the LLMAPP through S41 "Create a new conversation" in the conversation list part of the interface, such as Figure 4 In the interface shown on the right, LLM will first introduce itself to the object, such as Figure 4 S42 in “Hello, this is LLMAPP. You can debug your LLM application here” allows the target to quickly understand the LLMAPP.

[0144] For example, an object can be Figure 4Input your own questions in the chat box S43 and ask questions to the LLM Agent system. After asking the questions, the LLM Agent system can answer the object's questions by planning and executing tasks based on the task processing method in the embodiment of the present application, and directly present the reply information to the object in the interface.

[0145] In the embodiment of the present application, for the problem of object input, if the problem is relatively simple, it may be completed by executing only one task. If the problem is relatively complex, it may be necessary to execute multiple tasks in sequence. In summary, at least one round of task processing is required. The specific implementation method is as follows:

[0146] S32: Perform at least one round of task processing according to the question input by the object until the preset end condition is reached, and output the reply information corresponding to the question; wherein the nth round of task processing includes the following steps S321 to S324:

[0147] S321: Plan the decision action for the nth round according to the problem and the tool call result corresponding to the target task for the n-1th round.

[0148] The nth round decision action is used to indicate the task planning details of the nth round. In this application, n is a positive integer.

[0149] As mentioned above, each round of task processing includes two parts: task planning and task execution. S321~S322 are the task planning part, which can be implemented by the task planning agent, and S323~S324 are the task execution part, which can be implemented by the tool calling agent.

[0150] Among them, the tool call result corresponding to the target task of the n-1th round (hereinafter referred to as the tool call result of the n-1th round, and the same applies to other information) refers to the result obtained after calling the tool in the execution of the previous round of tasks of the nth round during the cycle. When n=1, n-1=0, and the result is empty at this time. Correspondingly, the result obtained after calling the tool in the execution of the nth round of tasks is the tool call result corresponding to the target task of the nth round (hereinafter referred to as the tool call result of the nth round). The decision action of the nth round refers to the specific decision generated in the task planning process of the nth round. Correspondingly, the decision action of the n-1th round refers to the specific decision generated in the task planning process of the n-1th round. The specific decision indicates the task planning details in the corresponding round. The task planning details include but are not limited to: whether new tasks need to be planned in this round, the type of tasks to be planned, the current number of executions, etc. When n=1, n-1=0, and the decision action is also empty at this time, and the same applies to other subsequent information.

[0151] Specifically, in each round of task planning, the task planning agent will plan a decision action based on the pre-configured task planning strategy and by analyzing the execution of the last task. For example, the nth round is recorded as the nth round decision action. In an embodiment of the present application, a decision action may include operations of one or more task types. Of course, a decision action may not include any specific tasks. For example, the tasks in the task stack may be directly executed, and the final answer may be directly generated by LLM or the default behavior may be adopted. In actual applications, different decision actions will be generated if the execution of the last task is different. This will be described in detail below and will not be repeated here.

[0152] S322: According to the n-th round decision action, the n-th round target task is taken out from the task stack.

[0153] The task stack contains the currently planned tasks related to the problem.

[0154] Among them, the target task of round n refers to the task to be executed in round n when several rounds of task processing are carried out in a cycle; when round n is regarded as the current round, the target task of round n-1 refers to the task executed in the previous round of the current round in the cycle, and the execution result of this task is the tool call result corresponding to the target task of round n-1. The target task of round n-1 can be recorded as t n-1 , the corresponding tool call result can be recorded as o n-1 , the target task of round n can be recorded as t n , the corresponding tool call result can be recorded as o n .

[0155] In multi-agent systems, task planning is a key link, especially when it involves complex task sequences and coordination between multiple agents. In addition to the above-mentioned task planning methods based on Task List, multi-agent systems can also use task planning technology based on sequential decision-making, which only performs one step of task planning at a time and dynamically determines the next task type after the task is completed. However, since this type of algorithm needs to re-call LLM for task planning after each step, it consumes a lot of resources and time, and the planning efficiency is insufficient.

[0156] To overcome this problem, the present application introduces a task stack, which can store multiple planned tasks in an orderly manner to ensure that tasks are executed in a certain order, which helps to clarify the priority of tasks and avoid inefficiency caused by mutual interference between tasks; in addition, through the task stack, multiple small-scale LLM calls can be merged into a smaller number of large-scale calls, reducing the cost of each call. For example, you can get planning suggestions for multiple tasks at one time instead of calling them one by one, reducing the number of calls required for each task planning, thereby reducing overall resource consumption and time overhead.

[0157] like Figure 5 As shown, it is a schematic diagram of a task stack storage process in an embodiment of the present application. Taking the principle of last in first out as an example, Figure 5 This example lists the process of executing a push operation in an empty stack and gradually pushing in tasks, such as pushing task a first, then task b, then task c, and finally task d, where top represents the top of the stack.

[0158] According to the last-in-first-out principle, when a pop operation is performed in the task stack and tasks are gradually taken out, task d is taken out first, then task c, then task b, and finally task a.

[0159] Optionally, this application uses a multi-agent framework to build a task planning agent and a tool calling agent, such as Figure 6 As shown, it is a logical schematic diagram of task processing based on a multi-agent framework in an embodiment of the present application.

[0160] Specifically, each round of task processing is mainly implemented by the interaction between the task planning agent (Plan Agent) and the tool calling agent (Function Call Agent). The steps required to be executed in each round of task processing can be divided into two parts: task planning and task execution.

[0161] Among them, task planning refers to generating a series of ordered task sequences (which may be empty) according to the goals and current status before the task is executed, while task execution refers to executing the planned tasks.

[0162] In the embodiment of the present application, the task planning agent mainly performs task planning, such as receiving questions, and dynamically planning the target task of this round by receiving the tool calling result of the previous round of target tasks fed back by the tool calling agent, combined with the background information corresponding to the current round, to guide the tool calling agent to call tools. The tool calling agent, on the other hand, considers what tool to call according to the target task of this round planned by the task planning agent, generates tool calling information, such as the tool category name and tool input parameters of the tool to be called, calls the corresponding tool in the tool pool through these tool calling information, executes the target task of this round, obtains the tool calling result corresponding to the target task of this round, and sends it to the task planning agent again.

[0163] For example Figure 6 As shown in the figure, the tool pool stores calculation tools such as calculator (used to perform mathematical operations and formula calculations), retriever (used to retrieve information and data), python sandbox (used to execute Python code snippets), and data analyzer (used to analyze data sets). Assuming that the task planning agent plans to perform the task of calculating the area of ​​a circle in this round, the calculation tool needs to be called; the task planning agent plans to perform the task of finding the population of city X in this round, the retrieval tool needs to be called; when the task planning agent plans to write a simple Python function to calculate the sum of two numbers in this round, the code execution tool needs to be called; when the task planning agent plans to perform the task of analyzing a set of sales data and finding the month with the highest sales in this round, the data analysis tool needs to be called, and so on.

[0164] Specifically, Figure 6 The framework process shown is divided into three steps as follows:

[0165] Step 1: The task planning agent takes into account the problem input by the object and plans the task based on the strategy π ToT Think about the decision action generated in this round, update the task stack, and then take the top task taken from the task stack as the target task of this round, which corresponds to the relevant description of S321 to S322 in this article. In addition, the task planning agent will summarize new background information based on the current task stack, the tool call result corresponding to the target task of the previous round (initially empty), the problem and historical background information. The specific implementation method will be described in detail below and will not be repeated here.

[0166] Among them, the task planning agent plans the logic of the current decision action, see below for details Figure 7 The relevant description will not be repeated here.

[0167] Step 2: The tool calling agent reflects and acts (ReAct) based on the problem, the target task of this round and the current background information (here refers to the new background information summarized in step 1), and generates the tool calling information of the tool currently needed to be called, such as the tool category name and tool input parameters, which corresponds to the relevant description in part S323 of this article. For the specific implementation method, please see below.

[0168] Step 3: In the tool pool, call the tool according to the tool category name and tool input parameters, and return the tool call result of this round of target tasks, which corresponds to the relevant description of part S324 in this article. For specific implementation methods, see below.

[0169] Among them, ReAct is a framework for building intelligent agents, which divides the behavior of the tool-calling intelligent agent in this application into two steps: reasoning and acting. In the reasoning stage, the tool-calling intelligent agent will infer the best action plan based on current information and past experience, and generate the tool call information of the tool currently required to call; in the action stage, it will perform specific actions, such as calling external tools or services based on the previous action plan to perform the target task of the nth round. By repeatedly executing these two steps, the goal is gradually approached until the task is completed.

[0170] The task planning system in this application will repeat steps one, two, and three until the task planning agent believes that the process can be ended and the question can be finally answered.

[0171] In the above method, when the task planning agent plans the nth round of task execution, the tool calling agent will call the corresponding tool according to the specific requirements of the task, which not only improves the efficiency of task execution, but also ensures that the task can be completed correctly.

[0172] The following is a brief description of the design concept of the task planning agent in the embodiment of the present application:

[0173] In this application, the Markov decision process (MDP) is used to model the task planning process, and a task stack and task planning strategy π are designed. ToT The task planning agent is used as a task executor, and the tool calling agent is used as the task executor, thus building a highly flexible and robust task planning system. This system can significantly improve the ability of the LLM Agent system to solve complex task problems.

[0174] MDP is a mathematical model for sequential decision problems. In MDP, the change of system state follows the Markov property, that is, the current state depends only on the previous state and the action taken, but not on the earlier historical state. In this process, the agent will take actions according to the current state with a certain strategy, and after executing the action, it will enter a new state and observe feedback. The goal of MDP is usually to find a strategy (such as the task planning strategy π in this article) ToT ), so that the cumulative reward obtained by the agent in the long term is maximized.

[0175] In the design of the task planning agent, this application mainly designs the following two aspects: one is the closed-loop task planning system model based on MDP, and the other is based on the task stack and task planning strategy π ToT mission planning technology.

[0176] First, the former models the task planning system based on MDP, realizes the task planning and execution framework of sequential decision-making, and can dynamically adjust the downstream task type according to the execution status of the upstream tasks, effectively solving the problem of task dependency.

[0177] It should be noted that, in addition to MDP, in practical applications, the task planning system can also be modeled based on other sequential decision-making methods. For example, the Hierarchical Task Network (HTN) is a hierarchical task planning method that supports decomposing complex tasks into a series of subtasks and defining the execution order and conditions of the subtasks. It is suitable for scenarios where tasks need to be gradually refined. For another example, Reactive Planning can respond to object inputs and environmental changes in real time, dynamically generate new task sequences, and is suitable for scenarios that require rapid response to changes. For another example, the Partial Order Causal Link (POCL) method allows for partial sequential relationships between tasks rather than a strict linear order, and is suitable for scenarios where the order of tasks needs to be flexibly adjusted. Of course, other methods not listed are also applicable to the embodiments of the present application, and will not be described one by one here.

[0178] Secondly, the latter stores the planned tasks in the form of a stack through the task stack and uses the task planning strategy π ToT Guide the big model to conduct scientific process analysis on the results of executed tasks to generate new decision actions, produce one or more task types, and store them in the task stack, so as to overcome the problem of low efficiency of sequential decision-making task planning.

[0179] It should be noted that in addition to the task stack, in actual applications, planned tasks can also be stored based on other similar methods to overcome the problem of low efficiency of sequential decision-making task planning, such as the priority queue. The priority queue can sort tasks according to their priorities. In the dynamic task planning process, the priority of the task can be dynamically adjusted according to the urgency and importance of the task. It is suitable for scenarios where the order of tasks needs to be dynamically adjusted according to the priority of the task. By inserting and deleting tasks, high-priority tasks can be executed first.

[0180] Another example is a double-ended queue (Deque). A double-ended queue can insert and delete elements from both ends. During dynamic task planning, tasks can be inserted or removed at any time to adjust the execution order of tasks. It is suitable for scenarios that require flexible control of the insertion and deletion positions of tasks.

[0181] Another example is the Task Tree, where tasks are organized in a tree structure. Each node can have multiple subtasks. This is suitable for scenarios where tasks have a hierarchical relationship and the subtasks of tasks need to be managed. Subtasks can be added or deleted dynamically, and the execution order of tasks can be adjusted.

[0182] Another example is the Task List, where tasks are stored in a list format and can be executed in order or by priority. This is suitable for scenarios where tasks need to be executed in order or by priority. In the dynamic task planning process, tasks can be flexibly inserted and deleted to adjust the execution order of tasks.

[0183] The mechanisms listed above each have their own advantages in dynamic task planning. The choice of which mechanism to use depends on specific needs and scenarios. By choosing an appropriate mechanism, dynamic task planning can be managed and executed more effectively, improving the flexibility and robustness of the system.

[0184] Of course, other methods not listed are also applicable to the embodiments of the present application and will not be described in detail here.

[0185] The methods listed above also support the process of determining the decision actions of the current round of planning based on the tool call results of the previous round of target tasks in each round of task planning, so as to effectively handle complex tasks and provide timely and accurate responses, such as using task planning strategy π ToT and task list, which will not be repeated here.

[0186] Combine the following Figure 7 , a brief description is given of the process of task planning based on the task planning agent in the embodiment of the present application:

[0187] See also Figure 7As shown, it is a logical diagram of task planning based on a task planning agent in an embodiment of the present application. The present application divides tasks into two categories: main line tasks and branch line tasks, such as Figure 7 The main tasks in the listed task stack are: main task 1, main task 2, ..., main task N, and the side tasks are side task 1 and side task 2.

[0188] in, Figure 7 The task planning logic shown is simply the task planning strategy π mentioned above. ToT Guide the big model to conduct scientific process analysis on the results of executed tasks in order to generate new decision-making actions.

[0189] Optionally, when planning the current decision action, such as Figure 7 As shown, it is necessary to comprehensively consider the task type (such as main line or branch line) and tool call result (such as success or failure) of the previous task. Different combinations correspond to different decision actions. In short, there are four specific situations:

[0190] If the target task of the previous round is the main task and is executed successfully, the decision action of this round means: plan a new main task or execute according to the task stack. The specific decision action to be adopted needs to consider whether the current task stack is empty.

[0191] If the target task of the previous round is the main task and the execution fails, the decision action of this round means: plan a new branch task or re-plan the main task or retry N times or end directly after reaching the retry limit. The specific decision action to be adopted needs to consider whether there is a branch task for the target task of the previous round and whether the number of repeated executions of the branch task has reached the upper limit.

[0192] If the target task in the previous round is a side task and is successfully executed, the decision action in this round means: return to the main task in the task stack.

[0193] If the target task in the previous round is a side task and its execution fails, the decision action in this round means: plan a new side task or re-plan the main task or retry N times or end directly after reaching the retry limit. The specific decision action to be adopted needs to consider whether the number of repeated executions of the side task in the previous round has reached the upper limit.

[0194] The task planning agent is based on the task planning strategy π ToTAfter thinking about the decision actions for this round, some new tasks (which may be empty) can be generated and pushed into the task stack to update the task stack, and then the top task of the stack is taken out (pop) as the target task for this round. In addition, the task planning agent will also summarize new background information based on the current task stack situation, the tool call results corresponding to the target task of the previous round (referred to as the tool call results of the previous round), the problems input by the object, and the historical background information. The specific implementation method will be described in detail below and will not be repeated here.

[0195] The task planning process in S321 is described in detail below:

[0196] For a task planning problem, this application proposes to model the decision-making process with MDP. In MDP, the change of system state follows the Markov property, that is, the current state only depends on the previous state and the action taken, but not on the earlier historical state. The task planning intelligent body will take action according to a certain strategy based on the current state.

[0197] Accordingly, in the embodiments of the present application, an optional implementation is:

[0198] Update the system status according to the problem input by the object, the current background information, the tool call results of the previous round (such as the n-1th round), the decision actions of the previous round, the target tasks of the previous round and the current task stack; plan the decision actions of this round (such as the nth round) according to the updated system status.

[0199] Among them, the questions raised by the object can ensure that the decision is always centered around the core needs of the object. The current background information can provide the context of the current task execution, which helps to understand the latest progress of the task. The results of the previous round of tool calls can reflect the actual effect of the previous operation and help the system evaluate the current state. The previous round of decision actions records the decisions of the previous step, which is easy to trace and adjust. The previous round of target tasks clarifies the task goals of the previous step, which can ensure the consistency of the planned tasks. The current task stack provides the execution order and dependencies of the tasks to ensure the orderly execution of the tasks.

[0200] When the application performs several rounds of task processing in a cycle, each round needs to obtain the system state s, decision action a and tool call result o. Specifically, the problem input by the object is represented by Q, and in the nth round of task processing, the system state is represented by s n Indicates that n Include known background information n-1 , tool call result o in round n-1 n-1 、Decision action a in round n-1 n-1 , the target task t executed in the n-1th round n-1 , the task stack before update in round n is T n-1(Updated to T n ),Right now:

[0201] s n =(Q,c n-1 ,o n-1 ,a n-1 ,t n-1 ,T n-1 ).

[0202] In the initial case, the background information is empty, the tool call result is empty, the target task is empty, the decision action is empty, and the task stack is also empty.

[0203] Of course, in addition to this, you can also refer to some other information from the previous round to determine the system status, such as reference object feedback. The real-time feedback of the object can provide important information to help the system adjust task planning and improve object satisfaction. For another example, refer to historical task records. Historical task records can provide references to help the system identify common problems and solutions and improve the efficiency of task processing. For another example, refer to task dependencies and understand the dependencies between tasks to ensure that the order and dependencies of tasks are handled correctly and avoid task conflicts. For another example, you can also refer to resource status. The currently available resource status (such as computing resources, network bandwidth, etc.) affects the execution of tasks and ensures the effective use of resources.

[0204] By comprehensively considering these factors, the system can more comprehensively understand the context and status of the task, thereby making more reasonable and efficient decisions.

[0205] Optionally, when determining the system status, the task content of the target task mentioned here specifically includes but is not limited to: the guideline for executing the task (such as calling a tool to execute the task and how to input the tool), the task category type (main line or branch line) and the number of times the task is repeatedly called times (i.e., the current execution number, such as times = 1, 2, ...), that is:

[0206] t={guideline,type,times}.

[0207] Of course, in addition to this, the task content of the target task can also include: the importance and urgency of the task; the current status of the task, such as not started, in progress, paused, completed, failed, etc.; the dependency of the task on other tasks; the time limit within which the task needs to be completed within a specific time; the expected output results after the task is completed; the environmental information of the task execution, such as network status, computing resources, etc.; the historical execution record of the task, including previous execution results and feedback; the specific reasons for the failure of the task; and so on. By comprehensively considering these task contents, the system can have a more comprehensive understanding of the background and status of the task, so as to make more reasonable and efficient decisions. This information helps to improve the flexibility, adaptability and robustness of task planning.

[0208] In the embodiment of the present application, based on s n , the task planning agent in the task planning system will use the task planning strategy π ToT Plan, make decisions and take action n (i.e., the decision action of round n), namely:

[0209] π(a|s n )→a n .

[0210] Then, we can make action a according to the decision in round n. n , update the task stack by T n-1 To T n , take out the current task to call the tool, and then repeat this process until the preset end condition is reached. The specific task planning system execution process will be described below.

[0211] In the embodiment of the present application, the current background information, the results of the previous round of tool calls, the previous round of decision actions, the previous round of target tasks and the current task stack accurately reflect the previous state and the actions taken. Based on this information, the system state is updated in combination with the questions raised by the object to determine the current state, so as to efficiently and accurately plan decision actions according to the current state. By fully utilizing this information to plan this round of decision actions, the flexibility, adaptability, robustness and efficiency of task planning can be significantly improved, while enhancing the transparency and traceability of the system. In particular, when the task execution fails or the result does not meet expectations, the system can re-plan according to the current state to ensure the smooth progress of the task.

[0212] The specific design of the task planning in this application is described below:

[0213] In the design of the task planning agent, this application designs a task planning strategy π ToT , the task planning agent in the task planning system will use the task planning strategy π ToT Planning, task planning strategy π ToTGuide the big model to conduct scientific process analysis on the results of executed tasks to generate new decision actions, produce one or more task types, and store them in the task stack, so as to overcome the problem of low efficiency of sequential decision-making task planning.

[0214] Among them, the Tree of Thoughts (ToT) has the following main features: (1) Hierarchical structure: The Tree of Thoughts decomposes the task into multiple levels, each level contains several nodes, and each node represents a subtask or decision point; (2) Logical path: Each node is connected by a logical relationship to form one or more logical paths, guiding LLM to reason and generate according to the predetermined ideas; (3) Dynamic adjustment: According to the progress of task execution and intermediate results, the Tree of Thoughts can dynamically adjust the path to ensure that the generated content always meets the expected goals.

[0215] In the embodiment of the present application, the task planning strategy π ToT The goal of answering the questions raised by the object is broken down into multiple small tasks and organized into a hierarchy to help LLM reason and generate more systematically. Task planning strategy π ToT The generation path can also be dynamically adjusted according to task progress and intermediate results to improve flexibility.

[0216] The task planning strategy in the embodiment of the present application is as follows ToT To explain in detail:

[0217] In the embodiment of the present application, tasks are divided into two categories: main tasks (which may be referred to as main tasks) and branch tasks.

[0218] Among them, the main task is the task that must be completed to achieve the main goal when using LLM to answer questions. It is used to directly solve the main questions or needs raised by the object. It is usually the most important part of the whole process and directly affects the realization of the final goal. It requires LLM to accurately understand the core of the problem and provide clear, accurate and direct answers to ensure the correctness and practicality of the information to meet the primary needs of the object.

[0219] Side quests are auxiliary tasks that can be completed selectively while completing the main quest. They are used to solve non-core needs or potential problems related to the main quest while processing the subject's main request, such as providing additional background information, suggestions or extended knowledge to enhance the subject's overall understanding and experience. Although this information is not necessary, it can increase the richness and value of the answer.

[0220] On this basis, the task processing flow in the present application can be designed as an orderly process, in which each step determines the next step according to the result of the previous step. Of course, in the first round of task processing flow, there is no previous step. Therefore, in S321, an optional implementation is as follows:

[0221] First, based on the current system status, analyze whether the target task in round n-1 is empty.

[0222] If the target task of round n-1 is empty, it means that round n is actually the first round of task processing, and the previous task stack is empty. Correspondingly, the target task of round n-1 is also empty. That is to say, the task to be processed in the current round is the first task. Since the task stack is empty, some main line tasks need to be generated first to execute.

[0223] In the first round of task processing, considering that other information is generally empty, such as background information, tool call results corresponding to the target task in the n-1th round, etc., it is only necessary to generate tasks based on the questions.

[0224] Optionally, if the target task of the n-1th round is empty, the decision action of the nth round indicates: based on the problem, at least one main task is generated, and the execution times of the newly generated main task are set to the initial value, which helps to observe the progress of the task and possible repeated execution.

[0225] The initial value may be any value and may be flexibly set according to actual needs in practical applications. This article does not make any specific restrictions and generally sets the initial value to 0, indicating that a task has not been executed before.

[0226] On this basis, each subsequent execution of the task will also update the corresponding execution count, and the update method is: the latest execution count = the current execution count + the preset step length. Among them, the preset step length can also be any value, which can be flexibly set according to actual needs in practical applications. This article does not make specific restrictions, and it can generally be set to 1, indicating that each time the task is executed before, the execution count + 1.

[0227] In the first round of task processing (n=1) for a certain problem, the decision action a is planned n (i.e. the nth round of decision-making action): Generate a series of main tasks based on Q (type: main, times: 1).

[0228] Specifically, by analyzing the questions or instructions provided by the subject, extracting key information, and understanding their core needs, based on this information or needs, generate at least one clear, specific, and executable main task to directly respond to the subject's request, ensuring that the answer is accurate and targeted.

[0229] In the embodiment of the present application, these newly generated mainline tasks should be the core part that can directly solve the problem, so as to ensure that an effective workflow is established from scratch in the absence of historical task data, and to manage the life cycle of the task by counting the number of executions.

[0230] Here are a few examples of generating main tasks based on problems:

[0231] Example 1: Suppose the question is: "I want to learn how to make pizza at home." Based on this, a main task can be generated, which is: provide a simple recipe for making pizza at home, including a list of required materials and step-by-step instructions.

[0232] Example 2: Assume the question is: "Please help me find the nearest library and tell me how to apply for a library card." Based on this, two main tasks can be generated. Main task 1 is to find the location of the library near the object, and main task 2 is to list the steps and documents required to apply for a library card in each library found. Among them, main task 2 depends on main task 1.

[0233] Example 3: Assume the problem is: "The Word document on my computer cannot be opened and it says the format is wrong. What should I do?" Based on this, a main task can be generated. The main task is: guide the subject to repair the damaged Word document, including trying to use recovery tools or convert the document format.

[0234] The main tasks listed above directly target the needs of the target and provide specific and effective solutions.

[0235] In the embodiment of the present application, the specific number of main line tasks generated is not limited herein, and it can be one, two, or even more.

[0236] On the contrary, if the target task of round n-1 is not empty, it means that round n is not the first round of task processing, and there are previous tasks and their results. In this case, planning is required based on the tool call results corresponding to the target task of round n-1.

[0237] In the task processing flow of subsequent rounds, considering the nature of the target task in the n-1 round and the results of its tool call can better connect the previous and subsequent tasks, ensure the consistency and coherence of decision-making, and thus more effectively plan the action plan for the nth round. Therefore, when making decisions, in addition to referring to the tool call results corresponding to the target task in the n-1 round, you can also refer to the task type of the target task in the n-1 round. Of course, in addition to this, you can also refer to some other information of the n-1 round, such as feedback from the reference object, historical task records, task dependencies, resource status, etc.

[0238] Optionally, if the target task of the n-1th round is not empty, the decision action of the nth round is planned according to the task type of the target task of the n-1th round and the tool calling result.

[0239] Specifically, evaluating the results of the tools or methods used in the target tasks of round n-1 can help determine whether the target tasks of round n-1 have been successfully completed or whether the strategy needs to be adjusted. And according to the type of target tasks of round n-1, deciding what type of action should be taken next can determine the strategy that needs to be continued in round n or the method that needs to be changed to ensure the coherence of the overall process and the consistency of goals.

[0240] In the embodiment of the present application, the next decision action formulated based on the above analysis includes but is not limited to: continuing to execute the existing main task, adjusting the direction of the task, or starting a new branch or main task, etc. Of course, if it is determined that the question has been answered or cannot be answered further, the next decision action formulated based on the above analysis also includes but is not limited to: completion, failure, etc.

[0241] The planning logic listed above can ensure that each task processing is optimized and adjusted based on the feedback from previous work, thereby improving the efficiency and accuracy of problem solving. In this way, it can dynamically adapt to new situations or unexpected problems that arise in the process.

[0242] It should be noted that the above is a brief description of the planning process of decision-making work based on whether the current round is the first round. Generally speaking, in the first round, the main tasks can be planned according to the problems, while in other rounds, some detailed information related to the target tasks of the n-1th round is required, such as task type, tool call results, etc. The decision actions planned in different situations are also different.

[0243] See also Figure 8 As shown, it is a logical diagram of the first planning of the nth round of decision-making actions in an embodiment of the present application. Figure 8 It means that firstly, according to the current system status, the target task t of the n-1th round is determined. n-1 Is it empty? If so, determine the decision action of round n: Based on the problem, generate a series of main tasks, and set the execution times of these newly generated main tasks to 1, that is, a n : Generate a series of mainline tasks based on Q (type: main, times: 1); otherwise, use LLM plan(i.e., the task planning agent) determines whether the target task of the n-1th round is executed successfully or failed, and discusses the different situations according to the judgment results. For example, execution failure is divided into the following execution failure situation 1, execution failure situation 2, and execution failure situation 3; execution success is divided into the following execution success situation 1 and execution success situation 2. Please refer to the relevant specific introduction below, which will not be repeated here.

[0244] The following is an explanation of the planning process of decision actions in rounds other than the first round:

[0245] It can be seen from the above content that in other rounds, it is necessary to plan the decision-making actions of the nth round according to the task type and tool call results of the target task of the n-1th round. This application takes into account that the success or failure of the task directly affects the direction of subsequent decisions. If the target task of the n-1th round fails, it is necessary to solve the remaining problems or try different strategies first; if successful, you can decide whether to continue the main process or open a new branch line based on the task type (main line or branch line). This ensures that each decision is based on the latest and valid information, improves the efficiency and success rate of the overall process, so you can first analyze whether the target task of the n-1th round is successful based on the tool call results, and then make different decisions with reference to the task type.

[0246] Therefore, when planning the decision action for the nth round according to the task type and tool call result of the target task for the n-1th round, an optional implementation method is:

[0247] According to the tool call results corresponding to the target task in round n-1, analyze whether the target task in round n-1 is successfully executed; there are two specific cases:

[0248] (i) If the target task of round n-1 fails to be executed, the decision action of round n is planned according to whether there are branch tasks of the target task of round n-1.

[0249] That is, t n-1 If the execution fails, then according to t n-1 Whether there is a side quest, determine a n .

[0250] Specifically, if the execution of the target task in round n-1 fails, check whether there are branch tasks in round n-1: if there are branch tasks, it may be necessary to prioritize these branch tasks to support or correct the execution of the main task. For example, the branch tasks may provide necessary resources or conditions to overcome obstacles in the main task. If there are no branch tasks, the main task can be replanned.

[0251] That is to say, in case the task execution fails to achieve the expected results, this application divides the tasks into two categories: main line tasks and branch line tasks. In case the main line task fails to execute, the task planning strategy πToT The LLM will be guided to determine whether to re-execute the task, or to retain the main task while adding a new branch task, thereby enhancing the robustness of the Agent system in the event of task failure.

[0252] Assume that each task has a preset maximum number of retries, denoted as N repeat , which indicates the maximum number of times each task can be tried when answering a question. The maximum number of retries for different tasks can be the same or different. When different maximum number of retries are set for different tasks, the system can flexibly adjust the retry strategy according to the characteristics and importance of the task.

[0253] An optional implementation method is to divide the planning of the decision action of the nth round into the following cases according to whether there is a branch task in the target task of the n-1th round:

[0254] (1) Execution failure scenario 1:

[0255] If there is a branch task for the target task in round n-1, the decision action in round n means: generate the corresponding branch task, and set the execution times of the branch task to the initial value;

[0256] Specifically, when there are branch tasks in the target task of round n-1, it means that the main task may depend on the completion of some auxiliary tasks. At this time, the decision action of round n is to generate new branch tasks and set the execution times of the branch tasks to the initial value, such as 1 in the above text, which means that the system will give priority to these branch tasks to support the completion of the main task.

[0257] That is, t n-1 The execution fails, and t n-1 When there is a side quest, a n To generate corresponding branch tasks (type: branch, times: 1).

[0258] When generating the corresponding branch tasks, in order to provide necessary support for the main tasks and ensure the realization of the ultimate goal, the number of tasks required to be generated can be determined based on the complexity of the tasks, resource availability, and time constraints. By analyzing the tool call results and core requirements of the n-1th round of target tasks, the necessary number of auxiliary tasks can be generated to support the completion of the main tasks.

[0259] Suppose the main task is to "help the subject book a flight ticket", but when trying to book, it is found that the subject does not have enough points. At this time, the generated side tasks may include: query and obtain points: help the subject find a way to get more points; point redemption rule confirmation: confirm whether the points can be used directly for flight ticket booking, or whether there are other redemption rules; alternative solution exploration: if the points are insufficient and it is impossible to obtain enough points in the short term, explore other payment methods or other related companies. These side tasks are all to support the successful completion of the main task and ensure that the subject can successfully book a flight ticket.

[0260] In this way, the system can handle complex task chains in a more organized manner and improve the efficiency and success rate of task completion.

[0261] (2) Execution failure scenario 2:

[0262] If there is no branch task in the target task of round n-1, and the number of executions of the target task of round n-1 has not reached the upper limit, the decision action of round n means: re-plan the task according to the target task of round n-1;

[0263] Specifically, if the target task of the n-1th round has no branch tasks, but the number of executions of the task itself has not reached the preset maximum number of retries, then the decision action of the current round is to re-plan the tasks of the previous round and achieve the task goals by adjusting the strategies or methods.

[0264] Specifically, replanning the task means replanning the current task. When the target task for the nth round has not been determined, the current task is the target task for the n-1th round, that is, replanning the target task for the n-1th round, which specifically means: continuing to execute the target task for the n-1th round, the task type remains unchanged, and the number of executions increases by a preset step, such as +1.

[0265] That is, t n-1 Execution failed, t n-1 There are no side quests, and t n-1 .times <N repeat When n To re-plan the current task (type: n-1 .type,times:t n-1 .times+1).

[0266] Assume that the main task is to "find and provide the nearest library address" and the maximum number of retries is N. repeat Set to 3 times:

[0267] For example, n-1 To resolve the object's location information and search for nearby libraries, the search failed because the object's location information was unclear. n-1The number of executions is 1, which is less than the maximum number of retries of 3, and there is no branch task. In this way, according to t n-1 In the case of failure, the decision action of round n is to re-plan the current task. The task type is still the main task "find the nearest library address", and the number of executions is increased from 1 to 2, so that the object can be asked for more specific location information in the future. After obtaining more information, try to search for the nearest library again.

[0268] In general, each time t n-1 When a task fails but the number of executions does not reach the maximum number of retries, the task planning agent will re-plan the current task and obtain more detailed information to increase the possibility of task success. This can gradually refine the object requirements and ultimately achieve the goal of solving the problem.

[0269] In this way, each time a task fails but the maximum number of retries has not been reached, the system will reschedule and try to execute the same task again until the task succeeds or the maximum number of retries is reached.

[0270] (3) Execution failure situation three:

[0271] If there is no branch task for the target task in round n-1, and the execution times of the target task in round n-1 reaches the upper limit, the decision action in round n indicates that the task processing has failed.

[0272] Specifically, if the target task in round n-1 has no side tasks, and the number of executions of the task has reached the preset upper limit, then the decision action for the current round is to mark the task as "failed". This indicates that the system has tried many times but failed to achieve the goal, so it is determined that this task cannot be completed by current means.

[0273] That is, t n-1 Execution failed, t n-1 There are no side quests, and t n-1 .times≥N repeat When n Failed (i.e. task processing failed).

[0274] The main task is still to "find and provide the nearest library address", and the maximum number of retries is N repeat Set it to 3 times as an example:

[0275] Assuming that after multiple attempts, the search still fails, and the number of attempts reaches the maximum number of retries of 3, this task can be marked as failed. In this case, the subsequent task planning agent can continue to analyze whether the failure of this task affects the execution of other subsequent tasks. If the failure of the task affects the execution of other subsequent tasks, it means that the question cannot be answered this time, which means that not only this task failed, but also the entire processing process failed. On the contrary, if the failure of the task does not affect the execution of subsequent tasks, the planning of subsequent tasks can continue.

[0276] In the embodiment of the present application, by setting the maximum number of retries, the system can avoid infinite loop attempts on an unsolvable problem, thereby wasting resources. When a task reaches the maximum number of retries, the system can clearly determine that the task has failed and take corresponding measures, such as notifying the object, recording the error, etc. In addition, by limiting the number of retries, the resource usage of the system can be effectively managed to ensure that too many resources are not consumed on a task that is unlikely to succeed.

[0277] The above logic of planning the current round of decision-making actions based on the previous round of task status helps the system to dynamically adjust strategies based on whether there are auxiliary tasks and the number of attempts when encountering task failures, ensuring that the problem is solved as efficiently as possible within the limited number of attempts. When there are branch lines available, they are processed first; when the main task has been attempted many times but failed, the ineffective efforts are stopped in time to avoid meaningless repetitive operations. This method improves the flexibility and efficiency of task management.

[0278] See also Fig. 9 As shown, it is a logical diagram of the second planning of the nth round of decision actions in an embodiment of the present application. Fig. 9 Introduced in the n-1 round target task t n-1 Not empty, and using LLM plan When the task planning agent determines that the target task of round n-1 fails to execute, it plans three situations of the decision action of round n, which correspond to the above-mentioned execution failure situation 1, execution failure situation 2 and execution failure situation 3. In short, that is:

[0279] Execution failure case 1: If there are branch tasks in the target task of round n-1, determine the decision action of round n: generate corresponding branch tasks, and set the execution times of these newly generated branch tasks to 1, that is, a n : Generate branch quest (type: branch, times: 1);

[0280] Execution failure case 2: If there is no branch task for the target task of round n-1, and the number of executions of the target task of round n-1 has not reached the maximum number of retries, then the decision action of round n is determined: re-plan the current task according to the target task of round n-1, that is, an :Re-plan the current task (type:t n-1 .type,times:t n-1 .times+1);

[0281] Execution failure case 3: If there is no branch task for the target task in round n-1, and the number of executions of the target task in round n-1 reaches the maximum number of retries, the decision action in round n is determined to indicate that the task processing has failed, i.e., a n :fail.

[0282] The specific implementation method is shown in the above embodiment, which will not be repeated here.

[0283] The above specifically explains several situations in which the target task in the n-1th round fails to execute. In general, considering that the previous task failed, it may be necessary to give priority to the branch task, so a new branch task can be planned. If there is no branch task, the main task can be re-planned and can be ended directly after retrying N times (referring to the maximum planned rounds) or reaching the retry limit (referring to the maximum number of retries).

[0284] In the implementation mode of the present application, through dynamic analysis and planning of decision-making actions, the system can flexibly respond to changes in tasks and ensure the coherence and consistency of task processing. In addition, the system can timely feedback the task processing status and provide some feasible solutions, reducing the waiting time and frustration of the subject, and improving the satisfaction and trust of the subject users.

[0285] Next, the following describes several situations in which the target task of round n-1 is successfully executed:

[0286] (ii) If the target task of the n-1th round is successfully executed, the decision action of the nth round is planned according to whether the target task of the n-1th round is the main task.

[0287] That is, t n-1 If the execution is successful, according to t n-1 Is it the main task? Determine a n .

[0288] Specifically, if the target task of round n-1 is successfully executed, it is necessary to further determine whether the target task of round n-1 is the main task. If the main task is successful, it usually means that the next major action can be continued according to the original plan. If the branch task is successful, there is no need to generate a new task, and the next action can be determined according to the status of the main task.

[0289] For example, if all side quests have been completed, you can focus on the main quest. This analysis method can help the system make reasonable decisions in a complex and changing task environment and ensure the effectiveness and consistency of the task process.

[0290] The following is based on t n-1 Is it the main task? Determine a n Several situations are described in detail:

[0291] When planning the decision-making actions for the nth round, based on whether the target task for the n-1th round is the main task, there are two situations:

[0292] (1) Successful execution scenario 1:

[0293] If the target task of the n-1th round is the main task and the task stack is empty, the decision action of the nth round is planned according to whether the question has been answered.

[0294] Specifically, if the target task of round n-1 is the main task and the current task stack is empty, it is necessary to check whether the object's question has been completely answered or solved. An optional implementation method is as follows:

[0295] Successful execution sub-case 1: If the question has been answered, it means that the question raised by the object has been completely answered or solved, and the decision action of the current round is "Completed", which means that the system has determined that sufficient information or solutions have been provided to meet the needs of the object, and there is no need to generate new tasks or take further actions. "Completed" in this case can include closing tasks, ending conversations, clearing related context information, etc., to ensure that the system is ready for the next request or conversation.

[0296] That is, t n-1 Execution successful, T n-1 is empty, and the question is answered, a n To complete.

[0297] Sub-case 2 of successful execution: If the question is not answered, it means that the question raised by the object has not been completely solved. In this case, it may be necessary to generate a new task to continue processing the remaining part that has not been completely solved. Optionally, the decision action of the nth round indicates: based on the question, background information and the tool call result corresponding to the target task of the n-1th round, at least one main task is generated, and the execution number of the main task is set to the initial value, such as 1, which helps to manage and observe the independent progress of each task and avoid confusion between the status of different tasks.

[0298] That is, t n-1 Execution successful, T n-1 When it is empty and the question is not answered, an Based on Q,c n-1 ,o n-1 Generate a series of mainline tasks (type: main, times: 1).

[0299] In this case, the newly generated mainline tasks will target the unresolved parts of the problem, aiming to supplement the missing information or provide further help, and the number of mainline tasks to be generated needs to be determined based on the actual situation, and this article does not make a specific limitation.

[0300] In the embodiment of the present application, by analyzing the problem and the background information of the n-1th round, it can be ensured that the generated new tasks can cover the unresolved parts of the problem; using the results of the tool call corresponding to the target task of the n-1th round, it is possible to better understand the status of the current problem and formulate the next action plan based on this. Generating new mainline tasks based on this existing information can ensure that they are consistent with the previous tasks, forming an orderly task flow, thereby improving the efficiency of problem solving.

[0301] In summary, t n-1 Execution successful, t n-1 .type is primary, and T n-1 When it is empty, use LLM plan Determine whether the question has been answered:

[0302] If the answer is complete, then a n is completed (i.e., the task processing has been completed);

[0303] If the answer is not complete, then a n Based on Q,c n-1 ,o n-1 Generate a series of mainline tasks (type: main, times: 1).

[0304] Suppose the question is: "Please help me find the nearest library and tell me whether book A is available there.":

[0305] For example, the target task (main task) of the n-1th round is to find the nearest library, and the task is successfully executed. At this time, analyze whether the current task stack is empty. Assuming that the task stack is empty, the task planning agent can be used to check whether the question "Please help me find the nearest library and tell me if there is book A there." has been answered.

[0306] Obviously, although the nearest library has been found, the inventory of book A has not been confirmed. The question has not been fully answered. In this case, a new main task is generated based on the question (confirming the inventory of books), the background information of the n-1th round (the nearest library is public library B), and the tool call result corresponding to the target task of the n-1th round (the nearest library has been found). The type of the new task is "main", and the number of executions is set to the initial value 1. For example, the following two specific tasks are generated:

[0307] Task 1: Query the book inventory of public library B. Type: Main, Execution times: 1, Objective: Confirm whether book A is in stock.

[0308] Task 2: If book A is in stock, help the subject reserve the book. Type: Main, Execution times: 1, Goal: Ensure that the subject can reserve the book.

[0309] It should be noted that the above-mentioned situations are just simple examples. Of course, when generating new main tasks, in addition to generating new main tasks based on the problem, background information, and tool call results corresponding to the target task in the n-1th round, you can also refer to the following information to generate main tasks:

[0310] For example, considering the preferences and historical behaviors of the subject, such as the subject's past request patterns, commonly used service channels, etc., can help generate tasks that are more in line with the subject's expectations. For another example, considering the context in which the subject is currently located, such as time, location, and other external factors. This information can help the system better understand the actual needs of the subject and generate more accurate tasks. For another example, using the information in the knowledge base and database, key data points that may be missed in the target task of the n-1 round can be supplemented to generate more comprehensive tasks. In addition, the ultimate purpose of the object's request can be clarified to ensure that the generated tasks can directly point to the ultimate goal and avoid deviation from the core needs. In some cases, if the subject provides additional feedback or instructions in the target task of the n-1 round, this information can also be taken into account to generate tasks that are closer to the actual needs of the subject.

[0311] It should be noted that the reference information listed above can also be used in combination, for example, the object's preferences and historical behaviors as well as the object's current context can be combined to generate a more accurate main task, etc. This article does not make specific limitations on this.

[0312] Still taking the above problem as "Please help me find the nearest library and tell me if there is book A there." as an example:

[0313] A new main task can be generated based on the problem, the background information of the n-1th round, and the tool call results corresponding to the target task of the n-1th round. The type of the new task is "main", and the number of executions is set to the initial value 1.

[0314] Of course, additional information can also be referenced, such as subject preferences: the subject often went to the library on weekends in the past and liked to reserve books. Context: The current time is Friday afternoon, and the subject may plan to go to the library on the weekend. Knowledge base information: the opening hours and reservation process of Public Library B. Subject feedback: The subject mentioned that he has a library membership card, but is not sure whether it has expired, etc., generating the following specific tasks:

[0315] Task 1: Query the book inventory of public library B. Type: Main, Execution times: 1, Objective: Confirm whether book A is in stock.

[0316] Task 2: Help the subject reserve the book. Type: Main, Execution times: 1, Goal: Ensure that the subject can reserve the book.

[0317] Task 3: Confirm the subject's membership card status. Type: Main, Execution times: 1, Objective: Ensure that the membership card is valid so that the subject can borrow books smoothly.

[0318] In the above implementation, after the main task is completed, it is checked whether the questions raised by the object have been answered. The system can ensure that the task processing flow ends when the previous round of target tasks is successful and the questions are completely answered, ensuring the integrity of the task closed loop and preventing omissions or unresolved issues. It can also ensure that when the previous round of target tasks is successful but the questions have not been completely answered, a new main task is generated to continue to solve the problem, thereby ensuring that the object's question can be fully answered. At the same time, referring to the above information to generate a new main task, the generated main task not only solves the current part of the problem, but also prepares for the subsequent steps, which can ensure the consistency and effectiveness of task management and problem solving, generate a more comprehensive main task that fits the actual needs of the object, and ensure that the questions raised by the object can be thoroughly solved later.

[0319] (2) Successful execution scenario 2:

[0320] Otherwise, the decision action of the nth round indicates: no new task is generated.

[0321] Specifically, there are two sub-situations where no new tasks are generated:

[0322] Sub-case three of successful execution: The target task of the n-1th round is the main task, but the task stack is not empty, then the decision action of the nth round indicates: do not generate a new task.

[0323] That is, at tn-1 Execution successful, t n-1 .type is primary, but T n-1 If it is not empty, a n Do not generate new tasks.

[0324] Specifically, in T n-1 If it is not empty, it indicates that there are unfinished tasks in the current task stack, so there is no need to generate new tasks. You only need to take tasks out of the task stack and execute them.

[0325] Still taking the above problem as "Please help me find the nearest library and tell me if there is book A there." as an example:

[0326] For example, the target task (main task) of the n-1th round is to find the nearest library, and it is executed successfully. At this time, there is still one main task in the current task stack, which is: help confirm the inventory status of book A.

[0327] In this case, there is no need to generate a new main task. After the target task in the n-1th round is successfully executed, the tasks in the current task stack are executed in sequence until the problem is completely solved.

[0328] In the above implementation, by checking whether the task stack is empty to decide whether to generate a new task, it is possible to avoid repeated creation of unnecessary tasks when there are already tasks to be processed, ensure that existing resources are reasonably allocated and used, and ensure that the task stack does not become cluttered due to repeated tasks, which helps to maintain the orderliness of task management, ensure the efficient operation of the task planning system, and ensure that problems can be handled in a timely and complete manner.

[0329] Sub-case 4 of successful execution: If the target task of the n-1th round is not a main task (but a side task), the decision action of the nth round indicates: do not generate a new task.

[0330] That is, at t n-1 The execution was successful, but t n-1 .type is branch, a n Do not generate new tasks.

[0331] In actual applications, side quests usually provide necessary prerequisites or auxiliary information for the main quest. Therefore, the completion of a side quest means that a part of the current task chain has been resolved. At this time, the main quest can continue without worrying about the missing of this part of the task. Moreover, if the side quest has been successfully executed, the main quest already has the required auxiliary information or resources. Generating a new task may cause duplication of work and waste of resources.

[0332] Therefore, in the above t n-1If it is not a main task but a side task, there is no need to generate new tasks considering task dependency, completeness and avoiding redundancy.

[0333] Still taking the above problem as "Please help me find the nearest library and tell me if there is book A there." as an example:

[0334] For example, the target task (side task) of the n-1th round is to obtain the current location information of the object. After successful execution, the main task can be continued with reference to this result, such as finding the nearest library to a certain location and confirming the book inventory, and finally completing the answer to the question.

[0335] In the above implementation, the completion of these side tasks provides the necessary prerequisites for the main task, so there is no need to generate new tasks. The main task can smoothly complete the subsequent process based on the information provided by the completed side tasks, avoiding task redundancy, improving the efficiency and consistency of task execution, and ensuring the effective use of resources.

[0336] See also Fig.10 As shown, it is a logical diagram of the third planning of the nth round of decision actions in an embodiment of the present application. Fig.10 Introduced in the n-1 round target task t n-1 Not empty, and using LLM plan When (i.e., the task planning agent) determines that the target task of the n-1th round is executed successfully, it plans two situations of the decision action of the nth round, which correspond to the above-mentioned successful execution situation one (including successful execution sub-situation one and sub-situation two) and successful execution situation two (including successful execution sub-situation three and sub-situation four).

[0337] In actual application, when the target task in round n-1 is successfully executed, the following logic can be used to plan the decision action:

[0338] Determine whether the target task of round n-1 is the main task;

[0339] If the target task of round n-1 is the main task, it is necessary to further analyze whether the task stack is empty, which can be divided into four cases:

[0340] If the task stack is empty, plan the nth round of decision actions based on whether the question has been answered:

[0341] Corresponding to the above successful execution sub-case 1: If the answer is complete, then the nth round of decision action indicates that the task processing has been completed, that is, a n :Finish;

[0342] Corresponding to the above successful execution sub-case 2: If the answer is not completed, the decision action of round n indicates: based on the question, the current background information and the tool call result corresponding to the target task of round n-1, generate at least one main task, and set the execution count of the main task to 1, that is, a n :Based on Q,c n-1 ,o n-1 Generate a series of mainline tasks (type: main, times: 1).

[0343] Corresponding to the above successful execution sub-case 3: If the task stack is not empty, the decision action of the nth round means: do not generate new tasks, that is, a n : Do not generate new tasks.

[0344] Corresponding to the above successful execution sub-case 4: If the target task in round n-1 is a branch task, then the decision action in round n means: do not generate a new task, that is, a n : Do not generate new tasks.

[0345] In the above implementation, when the target task in the n-1th round is not a main task (i.e., a branch task), or is a main task but the task stack is not empty, the main task in the task stack can be continued to be executed. In this way, no new tasks will be generated, which can avoid repeated creation of unnecessary tasks when there are already tasks to be processed.

[0346] It should be noted that if in a certain round of task processing, there are multiple corresponding target tasks of the previous round, and if one of the target tasks of the previous round meets the execution failure conditions listed above, the corresponding methods listed below can be used to plan the decision-making actions of this round. Correspondingly, if one of the target tasks of the previous round meets the execution success conditions listed below, the corresponding methods listed below can be used to plan the decision-making actions of this round.

[0347] That is to say, the number of decision actions generated in each round is not limited. If multiple tasks are executed in the previous round, multiple decision actions can be planned in the next round. For example, the target tasks in the previous round are: Task 1: Generate exercises, and Task 2: Provide learning suggestions. If Task 1 fails, Task 2 succeeds, and the failure of Task 1 does not affect the execution of Task 2, then the decision actions can be planned according to the execution of the two tasks. For example, the decision action planned according to Task 1 is: Repeat Task 1. The decision action planned according to Task 2 is: Generate a new main task.

[0348] Of course, in order to ensure the successful execution of subsequent tasks, you can also plan according to the failure of execution first, and then plan according to the success of execution. Taking the above-mentioned situation as an example, the failure of Task 1 may cause the subsequent newly generated main line tasks to be unable to be completed. In this case, you can first plan the decision action according to Task 1: repeat Task 1. After Task 1 is successfully executed, plan a new decision action according to Task 1 and Task 2, and so on.

[0349] The specific adjustments can be flexibly made based on the actual situation, dependencies between tasks, etc., and this article will not go into details here.

[0350] In this way, the system can flexibly cope with multi-tasking concurrency and ensure the coherence and consistency of task processing. The number of decision actions generated in each round is not limited and can be adjusted dynamically according to actual conditions. This mechanism not only improves the flexibility and robustness of task processing, but also optimizes resource utilization and improves the object experience.

[0351] It should be noted that the above method is just a simple example. For example, using the task planning strategy π ToT The same effect can be achieved by combining with double-end sequences or using other combinations, which will not be repeated here.

[0352] In the above implementation, the nth round of decision action a is planned according to the system state. n , and then, we can decide action a according to the nth round n Update the task stack to T n , take out the current task to call the tool, and then repeat this process until the preset end condition is reached. The specific task planning system execution process is as follows:

[0353] In an optional implementation, before taking out the target task of the nth round from the task stack according to the decision action of the nth round, it is necessary to analyze whether the decision action of the nth round is not a designated decision action, wherein the designated decision action includes: task processing has been completed, task processing has failed;

[0354] If the decision action of the nth round is not the completion of task processing, nor the failure of task processing, but other decision actions, then the target task of the nth round can be taken out from the task stack according to the decision action of the nth round, and the subsequent process can be continued to ensure the coherence and consistency of task processing, dynamically adjust the task order, and improve the flexibility of task processing.

[0355] If the nth round of decision action is that the task processing has been completed, it means that the question has been answered. At this time, the preset end condition is met, the task processing is stopped, and the reply information is output. This timely termination of the task can avoid unnecessary waste of resources and improve the efficiency of task processing.

[0356] If the decision action in the nth round is task processing failure, it means that part of the question cannot be answered successfully, and the preset end condition is reached.

[0357] Of course, if the nth round of decision action is task processing failure, we can further analyze whether the subsequent tasks can continue to be executed. If they cannot continue to be executed, we can determine whether the preset end condition has been met. For example, if the question is: "Please help me find the nearest library and tell me how to apply for a library card", we need to obtain the current location, search for the nearest library, and provide a guide to applying for a library card. If the current location of the object cannot be obtained, the subsequent tasks (such as searching for the nearest library and providing a guide to applying for a library card) cannot continue to be executed. We can stop the task processing and output the reply information. For example, we can output the reply information: Sorry, I cannot obtain your current location, so I cannot find the nearest library for you. You can manually search for nearby libraries and consult the guide to applying for a library card. This can avoid unnecessary waste of resources, terminate tasks in time, and improve the efficiency of task processing.

[0358] Of course, if part of the task can still be executed, then the subsequent task processing rounds can be continued. For example, the question is: Please help me book a flight to Beijing and provide hotel recommendations. You need to book a flight and provide hotel recommendations. For example, if the flight booking fails, the subsequent task (providing hotel recommendations) can still be executed. In this way, the subsequent task processing rounds can be continued. This can effectively enhance the robustness of the system, ensure the flexibility and reliability of task processing, and avoid the interruption of the entire task process due to the failure of a single task.

[0359] In the above implementation, by analyzing the nth round of decision actions and deciding whether to continue the task according to its type, this mechanism improves the flexibility and robustness of task processing, optimizes resource utilization, ensures the coherence and consistency of tasks, and improves the object experience and transparency of the system.

[0360] In an optional implementation, S322 may be implemented as follows, including S3221 to S3223 ( Figure 3 not shown):

[0361] S3221: Generate a new task set based on the nth round of decision actions.

[0362] Specifically, in this step, a new task set can be generated within the specified task range set T according to the nth round of decision actions. The new task set includes the tasks generated in the nth round and specifically describes the type and execution number of the tasks generated in the nth round.

[0363] In this step, based on the nth round decision action a n, generate a series of new tasks within the specified task range set T These tasks constitute the new task set in this article, as follows:

[0364]

[0365] Among them, n k The number of tasks generated during the nth round of task planning, and its value range is: n k ≥0. If n k =0, which means that no new tasks need to be generated at present, and the new task set is empty.

[0366] The task range set T contains some possible tasks in one or some application backgrounds. These tasks are defined according to the specific application background and have a certain degree of universality. Each task has specific tool call information, including tool category name, tool input parameters, etc., corresponding to the tools in the tool pool.

[0367] In the embodiment of the present application, for a specific application context, all possible tasks in the application context are defined to form a task range set T.

[0368] For example, in an educational context, the task set T may include the following tasks:

[0369] Search for knowledge points: Use search engines to find specific knowledge points.

[0370] Generate exercises: Generate exercises based on knowledge points.

[0371] Correct homework: Automatically correct students' homework.

[0372] Provide study suggestions: Provide personalized study suggestions based on students' learning progress.

[0373] Record video explanations: Record video explanations of specific knowledge points.

[0374] For example, in the context of artificial intelligence, the task scope set T may include the following tasks:

[0375] Data Collection: Collect data from different data sources.

[0376] Data preprocessing: Cleaning and preprocessing the data.

[0377] Model training: Train machine learning models.

[0378] Model evaluation: Evaluate the performance of the model.

[0379] Model deployment: Deploy the model to a production environment.

[0380] Generate reports: Generate reports for model training and evaluation.

[0381] In an embodiment of the present application, when a new task needs to be generated, the decision action can indicate the type of new task to be generated, such as a main task or a branch task, which helps the system to make appropriate task planning based on the nature and importance of the current task; in addition, the reference information required to generate the new task can also be indicated, such as questions, background information, results of the previous round of tool calls, etc. These reference information make the generated new task more specific and targeted.

[0382] For example, in the educational context, the task scope set T includes the five tasks listed above, and the question is an object request to explain "Newton's Second Law". Combining the question and the task scope set T, the main task search knowledge point Newton's Second Law is generated.

[0383] In summary, the task range set T provides a general definition of all possible tasks, while the decision action generates specific and targeted new tasks by indicating the task type and reference information. This mechanism ensures the flexibility and adaptability of task planning, enabling the system to efficiently generate and execute tasks in different contexts.

[0384] It should be noted that the proposed task planning framework does not assume a specific application background. For actual task types in different application backgrounds, only the corresponding task range set T needs to be adjusted. It has strong versatility. By defining and adjusting the task range set T, appropriate new task sets can be generated according to different application backgrounds. This helps to ensure the flexibility and adaptability of task planning and improve the overall efficiency and performance of the system. In addition, the task planning performance in specific scenarios can be improved by adjusting π.

[0385] When several new tasks are generated, the current task stack is updated based on the new task set (the current task stack represents the task stack at this time), and the update method is as follows:

[0386] S3222: Update the task stack according to the new task set.

[0387] In this step, the tasks in the new task set are pushed from the top of the stack into the task stack through a push operation, and an updated task stack, namely, the task stack, can be obtained.

[0388]

[0389] Among them, the push operation means adding a new element to the top of the stack.

[0390] If the number of tasks included in the new task set is 0, then the task stack does not change before and after the update, that is, the task stack = task stack.

[0391] If the number of tasks included in the new task set is greater than 0, the number of tasks in the updated task stack will increase. In this case, when pushing the tasks in the new task set into the task stack, the pushing order can be determined according to the specific needs of the problem. That is, the dependencies of these tasks in the new task set are obtained according to the problem analysis, and the execution order of these tasks is determined based on this. Based on the determined execution order, these tasks in the new task set are pushed into the task stack.

[0392] Among them, there is a dependency relationship between the two tasks, which means that among the two tasks, the execution of one task must wait for the completion of the other task before it can start. This dependency ensures the orderliness and logic of the work and prevents problems caused by improper execution order.

[0393] For example, in a software development project, writing code (task A) may not start until the requirements analysis (task B) is completed. Here, task B is the predecessor task of task A, and task A is the successor task of task B. The predecessor task refers to the task that must be completed first, and the successor task refers to the task that depends on the results of the predecessor task before it can start.

[0394] Specifically, on the basis of determining the execution order of these tasks in the new task set, considering that the task stack works according to the last-in-first-out principle, in order to ensure that the tasks are executed in the correct order, the reverse operation should be performed based on this execution order to push the tasks into the task stack.

[0395] For example, suppose the new task set contains three tasks: data collection, data analysis, and report generation. First, we know from analysis that "data collection" is the premise of "data analysis", and the result of "data analysis" is the basis of "report generation". Therefore, the correct task execution order is: data collection->data analysis->report generation. Then, according to this order, the "report generation" task can be pushed into the task stack first, followed by "data analysis", and finally "data collection". This ensures that each task is executed only after the tasks it depends on are completed, thereby solving the problem efficiently and orderly.

[0396] S3223: Take the top task from the updated task stack as the target task for the nth round.

[0397] Based on the above S3222, the task stack can be updated, and then at least one task is taken out from it as the task to be executed in the nth round, which is recorded as the target task of the nth round. Correspondingly, the task to be executed in the n-1th round is the target task of the n-1th round.

[0398] In this step, the task is taken out from the task stack, which can be achieved through the pop operation. The target task of the nth round taken out can be recorded as tn ,as follows:

[0399] T n .pop()→t n .

[0400] If you need to take out multiple tasks, you can usually perform multiple pop operations, and take out a task at the top of the stack each time. Of course, you can also customize the pop operation to take out multiple tasks at a time.

[0401] When a task fails to be processed, the system can dynamically generate a new task set and update the task stack to evaluate the feasibility of subsequent tasks. If some tasks fail but subsequent tasks can still be executed, the system will continue to process these tasks to avoid the interruption of the entire task process due to the failure of a single task, thereby enhancing the robustness of the system and avoiding unnecessary waste of resources. For example, if a task fails and subsequent tasks cannot be executed, the system can terminate the task in time, release resources, and improve resource utilization. In addition, the flexibility of task processing is improved, and the order of tasks can be adjusted dynamically to ensure the coherence and consistency of tasks.

[0402] S323: Generate tool calling information for the n-th round target task according to the background information corresponding to the n-th round target task and the problem.

[0403] The background information is determined based on the execution status of the problem and related tasks. The tasks related to the problem include but are not limited to the tasks that have been executed, the tasks that are currently planned and not yet completed in the task stack, etc.

[0404] During the task execution process, tool call information refers to data used to instruct an automated system or script to perform a specific operation. In the embodiment of the present application, tool call information includes but is not limited to the following two parts:

[0405] The tool class name, which is the name of the program, script, or service that performs the operation, specifies the specific tool or application to be used.

[0406] For example, the tool category name of the calculation tool is calculator, the tool category name of the retrieval tool is retriever, the tool category name of the code execution tool is python sandbox, the tool category name of the data analysis tool is data analyzer, and so on.

[0407] Tool input parameters, which are the data or instructions that the tool needs to complete its task, provide the specific data or configuration settings required for the tool to run.

[0408] For example, calculation tools are usually used to perform mathematical operations or simple logical processing. For example, a simple calculator tool can input the following parameters: (1) operation: the type of operation, such as addition, subtraction, multiplication, and division. (2) operands: operands, that is, the values ​​involved in the operation.

[0409] Input parameters of search tools Search tools are used to query information from a database or index. For example, a SQL query tool can have the following input parameters: (1) query: Structured Query Language (SQL) query statement. (2) database: database name or connection string.

[0410] Input parameters of code execution tools Code execution tools are used to run scripts or code snippets. Such tools can input the following parameters: (1) script: the script content or script file path to be executed. args: the input parameters of the script. (2) env: the variables of the execution environment.

[0411] Input parameters of data analysis tools Data analysis tools are used to process data sets and extract useful information. Such tools can input the following parameters: (1) data: input data set, which can be a comma-separated values ​​(CSV) file path, database query results, etc. (2) method: analysis method, such as statistical summary, regression analysis, etc. (3) columns: data columns to be analyzed.

[0412] In addition to the tool category names and tool input parameters listed above, the tool call information in the embodiment of the present application may also include but is not limited to the following data:

[0413] (1) Tool version: Specify the tool version number. For example, use Python 3.8 to execute the script.

[0414] (2) Tool execution environment: specifies the environment information for tool execution, such as the operating system, dependent libraries, etc. For example, to execute a script in a Linux environment, you need to install a specific dependent library.

[0415] (3) Tool output path: Specify the output file or data storage path after the tool is executed. For example: save the result to / path / to / output / file.txt.

[0416] (4) Tool execution timeout: Specifies the maximum allowed time for tool execution. If the time is exceeded, the execution will be terminated. For example, set the timeout to 60 seconds.

[0417] (5) Tool execution permissions: Specify the permissions required for tool execution, such as read and write permissions, network access permissions, etc. For example, it needs to be run with administrator permissions.

[0418] (6) Tool execution log: Specify the logging method and path for tool execution. For example, log to / path / to / log / file.log.

[0419] (7) Tool callback function: specifies the callback function or script that is called after the tool is executed to process the result or trigger the next operation. For example, the post_process() function is called after the execution is completed.

[0420] (8) Tool dependencies: Specifies the dependencies required for tool execution, such as other tools, libraries, or services. For example, the request library is required.

[0421] (9) Tool configuration file: specifies the configuration file path required for tool execution, which is used to load configuration information. For example, the configuration file path is / path / to / config / config.json.

[0422] (10) Tool execution context: specifies the context information of tool execution, such as user information, session ID, etc. For example: the user ID is user123 and the session ID is session456.

[0423] (11) Tool execution conditions: specify the conditions for tool execution, such as the completion status of the predecessor task, a specific time point, etc. For example: Task B will only be executed after Task A is completed.

[0424] Through these additional tool call information, the tool execution process can be managed and controlled more comprehensively, ensuring the correctness and reliability of the task, which helps to improve the flexibility, maintainability and scalability of the system.

[0425] It should be noted that the several tools and tool call information listed above are just simple examples. In actual applications, other tools and related tool call information may be involved. For example, in actual applications, depending on task requirements, the tool call information may be more complex, contain more parameters or require interaction with the API, etc., which will not be repeated here.

[0426] In the embodiments of the present application, background information refers to the previous state or environmental details directly related to the current problem and task, which is determined based on the execution of the problem and related tasks, and includes a description of the current problem, a list of known tasks, the results of previous attempts to solve the problem, and any information that helps understand the current situation, etc., aiming to provide the necessary context for solving the problem.

[0427] Optionally, background information can be synthesized based on the current problem, the task to be performed, the results of the previous round of tool calls, and previous background information. Its role is to provide context for the tool calling agent. This information can help the tool calling agent better understand the state of the current environment, so as to select appropriate tools and parameters to solve the problem and generate appropriate tool calling information for the target task of the nth round.

[0428] Therefore, an optional implementation method is to generate tool call information in the following manner:

[0429] New background information is generated by summarizing the problems, task stacks, tool call results and background information (specifically the current background information) corresponding to the target tasks of the n-1th round; and tool call information for the target tasks of the nth round is generated based on the new background information and the target tasks of the nth round.

[0430] Among them, the problem is the question raised by the object or the problem that needs to be solved. The task stack contains the currently planned tasks related to the problem. The tool call result corresponding to the target task of round n-1 refers to the tool used in the process of processing the target task of round n-1 and the effect or output result produced when trying to solve the problem. The background information is updated in each round. The background information used when generating the tool call information of the target task of round n refers to the environmental status and other relevant information in the process of processing the target task of round n-1. The background information synthesized based on the above information can include all the details that are crucial to understanding the current situation.

[0431] Considering that as the task progresses, the results of each round of tool calls will affect the execution of subsequent tasks, once a round of target tasks is completed, the background information needs to be updated to reflect the latest progress, which includes recording the results of the nth round of target tasks and any new discoveries or changes to provide the latest context for subsequent tasks. In the nth round, the background information before the update is recorded as c n-1 , the updated background information is recorded as c n , o n-1 The tool call result corresponding to the target task in round n-1. The current task stack is T n , the update process is expressed as follows:

[0432] Sumarry(Q,T n,o n-1 ,c n-1 )→c n )).

[0433] In an embodiment of the present application, when summarizing the problem, task stack, tool call results and background information corresponding to the target task of the n-1th round, etc. to generate background information, the summarizing ability of LLM can be used, for example, the collected information is converted into a structured format (such as JSON format) so that the model can understand and process it more easily. Then, using this structured information as input, a request is sent to LLM. The request can be a prompt, requiring the model to generate a concise and clear background summary based on the provided information. For example, a prompt can be constructed such as: "Please summarize the background information required for the current task based on the following information: [Enter specific information]." Then send this prompt to LLM and wait for it to return a concise background summary.

[0434] LLM generates a summary text based on the input information, which will contain all the necessary information to support the current task requirements. Furthermore, the summary text generated by LLM can also be post-processed, such as removing redundant information, correcting grammatical errors, etc., to ensure that the final background information is clear and accurate. This method makes full use of LLM's powerful summarization and semantic understanding capabilities, making the generated background information both comprehensive and concise, which helps to better complete subsequent tasks.

[0435] In addition to using LLM, you can also use rule engines or expert systems for summarization. The rule engine can extract and integrate key information based on preset business logic and rules, while the expert system combines domain knowledge and reasoning mechanisms to generate background information. These two methods are particularly suitable for task scenarios with clear rules and clear logic. By configuring the corresponding rules or knowledge base, you can effectively extract information that is critical to the current task and ensure the accuracy and pertinence of task execution. In addition, you can also use the information extraction module in NLP technology to automatically identify entities, relationships and other important elements in the text, and use this as a basis to build the background information required for this round of target tasks, and so on.

[0436] For example, in the specific implementation, we first collect the problem, the current task stack, the results of the previous round of tool calls, and background information; then, organize this information into a structured format (such as JSON format); then, use the rule engine or NLP technology to extract key points from it. Finally, integrate the extracted key information to form concise and clear background information to provide the necessary contextual support for the current task. This process ensures the consistency and effectiveness of task processing.

[0437] It should be noted that the above-mentioned summarizing methods of the several background information are just simple examples. In addition, other summarizing methods are also applicable to the embodiments of the present application and will not be described in detail here.

[0438] In the above implementation, by summarizing the problem, task stack, the results of the previous round of tool calls and background information to generate background information and formulate a tool call plan based on it, this method can significantly improve the consistency and efficiency of task processing. It ensures that each operation is based on a complete context, avoids duplication of work, and improves the accuracy of problem solving and enhances the ability to adapt to environmental changes. In addition, this method also makes the entire task execution process more transparent, facilitates subsequent analysis and optimization, and thus supports more reasonable and effective decision-making.

[0439] In addition, by continuously updating background information, we can ensure that the agent always makes decisions based on the latest state changes, thereby improving the efficiency and accuracy of problem solving. In addition, updating background information also helps to identify which tools and strategies are effective and which are ineffective, thereby optimizing future task planning and execution strategies. This dynamic adjustment capability enables the system to maintain adaptability in an uncertain environment and improve the overall intelligence level.

[0440] In practical applications, the task execution process can be realized by the tool calling agent. The tool calling agent implements the operation of the target task of this round through tool calling. The specific implementation details are as follows:

[0441] In order to clarify the core problem that needs to be solved and its relationship with other tasks, the tool-calling agent first needs to understand the problem raised by the object and its context, including the results of related tasks that have been performed before; based on the above analysis, it is clear what the specific goal of this round is, that is, the target task of this round. This helps to focus on the work that needs to be completed at present.

[0442] Then, the tool calling agent selects the most suitable tool from the available tool pool according to the requirements of the target task of this round. The tool here can be an API call, a specific software module, or a service that performs a specific function, etc. This article does not make specific restrictions.

[0443] Then, the tool call agent creates specific tool call instructions, which contain the tool call information corresponding to the required task, such as the tool category name, all necessary parameters and configuration information, etc. For example, if the target task of this round is data collection, then the tool call information may include the specified data source address, the required data format, etc. Based on this, the tool call agent is used to actually execute the tool call. The agent is responsible for sending requests, processing responses, and updating the status or triggering the next action based on the results.

[0444] By following these steps, the system can effectively manage complex multi-stage tasks, ensuring that each step is based on the latest information and the results of the previous step.

[0445] S324: calling a tool according to the tool calling information to execute the n-th round target task, and obtaining a tool calling result corresponding to the n-th round target task.

[0446] Among them, the tool call result refers to the output or feedback information obtained after executing a specific tool, including but not limited to data, status code, message, etc., which reflects the effect or result of the tool execution.

[0447] In this process, the tool calling agent first searches for the tool with the specified name in the tool pool according to the specific tool category name in the generated tool calling information, and then prepares data or sets parameter values ​​according to the specific tool input parameters in the generated tool calling information, calls the found tool, and passes in the prepared parameters to execute the tool function. After the tool is executed, the output result of the tool is obtained, which is the tool calling result.

[0448] For example, based on updating the background information by any of the methods listed above, according to question Q, the target task t of round n n With the current background information c n , let the tool calling agent obtain the tool calling information of the tool calling in the nth round through ReAct, and call the corresponding tool in the tool pool to obtain the tool calling result o corresponding to the target task in the nth round n .

[0449] For example, if the tool call information indicates that the weather API needs to be called to obtain the precipitation probability forecast for the next 24 hours, and the input parameters include geographic location coordinates (latitude, longitude) and date, assuming that the tool category name is "WeatherAPI" and the tool input parameters are longitude and latitude and date, then find "WeatherAPI" in the tool pool, prepare longitude and latitude and date as the API request parameters, call the API and pass the parameters, and then obtain the precipitation probability data returned by the API as the tool call result corresponding to the target task in the nth round.

[0450] In an optional implementation, if there are multiple target tasks for the nth round, then S324 can be executed in parallel for multiple target tasks for the nth round to increase the execution speed of the task stack and speed up the overall process.

[0451] In practical applications, either synchronous or asynchronous tasks can be used, depending on actual needs.

[0452] Specifically, when synchronous tasks are executed in parallel, multiple tasks can run at the same time, but each task is still synchronous, which means that the operations within a task are executed sequentially, but the tasks themselves can run simultaneously on different processor cores.

[0453] For example, the subject asked: "Please explain what quantum computing is and give an example of its application scenario.":

[0454] Assume that the current task stack contains the following tasks: Task A: Explain the basic concepts of quantum computing. Task B: Find application scenarios of quantum computing. Task C: Arrange examples of application scenarios. Task D: Integrate the answer content.

[0455] Assuming that the target tasks of the nth round are Task A and Task B, Task A and Task B can be executed synchronously and in parallel. When explaining quantum computing and its application scenarios, explaining the concepts and finding application scenarios can be carried out at the same time, but the operations within each task are completed sequentially.

[0456] When asynchronous tasks are executed in parallel, not only can multiple tasks run at the same time, but each task can also be executed non-blockingly, and intermediate results can be sent to other tasks at any time, that is, other operations can be performed while waiting for a certain operation to be completed.

[0457] For example, the subject asked: "Please explain the causes of climate change and describe its impact on the ecosystem.":

[0458] Assume that the current task stack contains the following tasks: Task A: Explain the causes of climate change. Task B: Find the impact of climate change on the ecosystem. Task C: Arrange examples of specific impacts. Task D: Integrate the answer content.

[0459] Assuming that the target tasks for the nth round are Task A and Task B, Task A and Task B can be executed asynchronously and in parallel. When explaining climate change and its impact on the ecosystem, explaining the causes and finding the impacts can be done at the same time, and the tasks can communicate with each other at any time and organize examples of specific impacts at any time.

[0460] It should be noted that in this application, the task stack can more easily realize asynchronous execution and parallel processing of tasks. Especially when asynchronous operations are supported, the system can pre-plan the next task while executing one task, and even process multiple independent tasks in parallel, thereby improving the overall throughput.

[0461] In the above implementation, the corresponding tools are called from the tool pool to execute the nth round of target tasks in the way of synchronous / asynchronous task parallel execution, which can significantly improve the processing efficiency and resource utilization, while enhancing the flexibility and response speed of the system, ensuring error isolation, and supporting better scalability.

[0462] S321 to S324 above introduce the specific process of each round of task processing. In short, the above process can be realized by the interaction between the task planning agent and the tool calling agent. The task planning agent dynamically determines the next task type by receiving the tool calling result fed back by the tool calling agent to guide the tool calling agent to call the tool; and the tool calling agent calls the tool by generating the tool category name and the tool input parameters. The collection of called tools is stored in the tool pool, as mentioned above. Figure 6 shown.

[0463] The cycle can be ended by repeating the above steps S321 to S324 until the preset end condition is reached.

[0464] In the embodiment of the present application, the preset end condition refers to a pre-set condition for stopping answering questions, including but not limited to the following:

[0465] (1) The question has been answered. This means that the system has successfully completed all necessary tasks and provided a complete answer or solution. When the system confirms that there is no more relevant information to be supplemented, or when all tasks have been completed and the answer has been verified as complete, the end condition is considered to have been met, and further processing is stopped.

[0466] (2) Question answering failure, that is, in the process of answering the question, a task execution fails, and the number of failures reaches the preset upper limit, that is, the maximum number of retries (such as N repeat ), in order to avoid an infinite loop, the question can be considered to have been answered unsuccessfully in this case and the answering process can be terminated.

[0467] (3) Reaching the planning limit: For example, a maximum processing time is set. Once this time limit is exceeded, the system will stop processing regardless of whether the problem is completely solved to prevent indefinite resource occupation. Another example is setting a maximum planning round (such as N). Once the task processing round reaches this number limit, the system will stop processing regardless of whether the problem is completely solved to prevent indefinite resource occupation.

[0468] (4) External interruption, such as receiving an end instruction from an object. That is, the object may decide not to continue in the problem-solving process, or think that the existing information is sufficient. At this time, the object can actively issue an end instruction, and the system should immediately stop further processing. Or if the current task must be terminated due to external factors (such as system maintenance, emergency shutdown, etc.), the system will immediately stop further processing.

[0469] It should be noted that the several preset end conditions listed above are just simple examples. These additional preset end conditions can help the system respond to different scenarios more flexibly and ensure that the processing flow can be stopped in a timely manner even in complex or dynamic environments.

[0470] In the embodiment of the present application, after the preset end condition is reached, a reply information for the question may be output to the object. An optional implementation is as follows:

[0471] By summarizing the question, the task stack (which may be empty), the tool call results and background information corresponding to the target task in the n-1th round, the response information corresponding to the question is generated and output.

[0472] The reply information is the answer to the question, or the reply information indicates the current processing result of the question and the problems existing in the task processing process.

[0473] Referring to the several preset end conditions listed above, that is to say, in the embodiment of the present application, a reply message can be output to the object when the question is answered normally, or a reply message can be output to the object when the number of executions of a certain task reaches the maximum number of retries and the question cannot be answered normally, or a reply message can be output to the object when the task processing round reaches the maximum planned round. Among them, when the question has been answered normally, the task stack is empty, and when the object cannot answer normally, the task stack may not be empty (that is, it contains some tasks that have not been executed). Therefore, when generating reply information based on the task stack, it can be the following situations:

[0474] The first type of reply information: the task stack is empty, and the decision action of the nth round indicates that the task processing has been completed. Then, the tool call result o corresponding to the target task of the n-1th round is summarized. n-1 and background information c before the nth round of update n-1 (i.e., the current background information, because in this case the preset end condition will be reached and will not be updated) to obtain the reply information, recorded as the first type of reply information ans, indicating the complete answer to the question, namely:

[0475] Summary(Q,o n-1 ,c n-1 )→ans.

[0476] The second type of reply information: the task stack is not empty, and the decision action in the nth round indicates that the task processing has failed. Then, by summarizing the problem Q and the task stack T before the nth round update, n-1 (i.e. the current task stack, because in this case the preset end condition will be reached and it will no longer be updated), the tool call result o corresponding to the target task in round n-1 n-1 and background information c before the nth round of updaten-1 The reply information is recorded as the second type of reply information ans_with_error, which indicates the current processing result of the problem and the problems existing in the task processing process (such as which task cannot be successfully executed, which tasks have not been completed, etc.), that is:

[0477] Sumarry(Q,T n-1 ,o n-1 ,c n-1 )→ans_with_error.

[0478] The third type of reply information: the task processing round reaches the maximum planned round. In this case, the task stack may be empty or not empty. Then, by summarizing the problem Q and the task stack T updated after the nth round, n (It is also the current task stack, because in this case the preset end condition is not met, it will be updated), the tool call result o corresponding to the target task in the n-1th round n-1 and the background information c before the n-1th round of update n-1 Get the reply information, recorded as the third type of reply information ans_with_error, that is:

[0479] Sumarry(Q,T n ,o n-1 ,c n-1 )→ans_with_error.

[0480] It should be noted that, in an embodiment of the present application, the third type of reply information may be similar to the first type of reply information, that is, at the N-1 round (N is the maximum planned round), the question is completely answered, and ans_with_error is actually a complete answer at this time; of course, the third type of reply information may also be similar to the second type of reply information, that is, at the N-1 round, the question has not been completely answered, and ans_with_error indicates the current processing result of the problem, and the problems existing in the task processing process (such as which task cannot be successfully executed, and which tasks have not been completed, etc.).

[0481] Regardless of whether the task stack is empty, in general, the response information corresponding to the question is generated by summarizing the question, the task stack, the tool call results and background information corresponding to the target task in the n-1th round.

[0482] Similar to the process of summarizing background information described above, in an embodiment of the present application, when summarizing the summary questions, task stacks, tool call results and background information corresponding to the target task of the n-1th round, etc. to generate reply information, the summarizing ability of LLM can also be utilized. For example, the collected information is converted into a structured format (such as JSON format) so that the model can understand and process it more easily. Then, using this structured information as input, a request is sent to LLM. The request can be a prompt, requiring the model to generate a concise and clear background summary based on the provided information. For example, a prompt can be constructed such as: "Please summarize the answer to this question based on the following information: [Enter specific information]." Then send this prompt to LLM and wait for it to return a concise background summary.

[0483] Based on this input information, LLM generates a summary text that contains all the necessary information to answer the subject's question.

[0484] In addition, if the subject is not satisfied with the current response information, he or she can apply to regenerate the answer. In this case, LLM will repeat the above steps and once again integrate the current problem, the task to be performed, the results of the previous round of tool calls, and the previous background information to generate new response information. This approach not only ensures that each attempt is based on the latest context, but also continuously adjusts and optimizes the answer based on the subject's feedback until the subject's needs are met.

[0485] In the above implementation, since the background information of each round is comprehensively derived based on the current problem, the task to be performed, the result of the previous round of tool calls and the previous background information, the first type of reply information is generated by summarizing the problem, the tool call results and the background information corresponding to the target task of the n-1th round, which can ensure the comprehensiveness and accuracy of the answer. This method can make full use of the previous execution results and background information, so that the current answer is based on a complete and continuous context, avoid information omission or duplication, and make the answer more coherent and complete. In addition, by using the results of the previous round of tool calls and the previous background information, the nature of the problem can be understood more accurately, thereby providing a more precise answer.

[0486] like Fig.11 As shown, it is a flowchart of a task processing method in an embodiment of the present application, and the specific implementation process of the method is as follows:

[0487] S1101: Initialize background information, tool call results, current task, decision action, task stack, and current planning round n;

[0488] S1102: Determine whether the current planning round n is less than the maximum planning round N. If so, execute S1103; otherwise, execute S1114;

[0489] S1103: Update the current system state according to the question input by the object, the background information of the n-1th round, the tool call result of the n-1th round, the decision action of the n-1th round, the target task of the n-1th round and the task stack of the n-1th round;

[0490] S1104: Performing task planning based on the task planning strategy and the current system state through the task planning agent to obtain the nth round of decision actions;

[0491] S1105: If the decision action of the nth round is completed, the response information is obtained by summarizing the problem, the tool call result of the n-1th round and the background information of the n-1th round, and outputted;

[0492] S1106: If the decision action of the nth round is a failure, then a response message is obtained by summarizing the problem, the task stack of the n-1th round, the tool call result of the n-1th round, and the background information of the n-1th round, and outputted;

[0493] S1107: If the decision action of the nth round is other, then based on the decision action of the nth round within the specified task range set T, a series of new tasks are generated to form a new task set;

[0494] S1108: Update the task stack of the n-1th round according to the new task set to obtain the task stack of the nth round;

[0495] S1109: taking the top task from the task stack of the nth round as the target task of the nth round;

[0496] S1110: Generate round n background information by summarizing the problem, the round n task stack, the round n-1 tool call result, and the round n-1 background information;

[0497] S1111: Generate tool calling information for the n-th round target task according to the n-th round target task and the n-th round background information through the tool calling agent;

[0498] S1112: according to the tool calling information, calling the corresponding tool in the tool pool to execute the target task of the nth round, and obtaining the tool calling result of the nth round;

[0499] S1113: Set the current planning round n=n+1;

[0500] S1114: Obtain response information by summarizing the questions, the task stack of the nth round, the tool call results of the n-1th round, and the background information of the n-1th round, and output it.

[0501] exist Fig.11 The background information in round n-1 is the background information before the update in round n, c n-1 ; The task stack of the n-1th round is the task stack T before the update in the nth round n-1 ; The tool call result of the n-1th round is the abbreviation of the tool call result corresponding to the target task of the n-1th round; similarly, the tool call result of the nth round below is the abbreviation of the tool call result corresponding to the target task of the nth round.

[0502] In the implementation process listed in S1101 to S1114 above, the input is question Q and maximum planning round N, and the output is final answer A, which may be the reply information output in S1106 or S1107 or S1114.

[0503] Among them, in S1104, it is mainly based on the task planning strategy π listed above ToT , the task planning strategy guides the large model to conduct scientific process analysis on the results of executed tasks to generate new decision actions and produce one or more task types. Fig.12 The decision-making process is described in detail:

[0504] like Fig.12 As shown, it is a flowchart of a task planning method in an embodiment of the present application, and the specific implementation process of the method is as follows:

[0505] S1201: According to the current system status, determine whether the target task of the n-1th round is empty, if yes, execute S1202, otherwise, execute S1203;

[0506] S1202: Determine the nth round of decision-making action representation: Based on the problem, generate a series of main tasks, and set the execution times of these newly generated main tasks to 1;

[0507] S1203: Using LLM plan Determine whether the target task of round n-1 is executed successfully or failed. If it fails, execute S1204; if it succeeds, execute S1209;

[0508] S1204: Determine whether there is a branch task in the target task of round n-1, if yes, execute S1205, otherwise, execute S1206;

[0509] S1205: Determine the nth round of decision-making actions: Generate corresponding branch tasks, and set the execution times of these newly generated branch tasks to 1;

[0510] S1206: Determine whether the number of executions of the target task in the n-1th round is less than the maximum number of retries. If yes, execute S1207; otherwise, execute S1208;

[0511] S1207: Determine the decision action of the nth round: re-plan the current task according to the target task of the n-1th round;

[0512] S1208: Determine that the nth round of decision action indicates that the task processing has failed;

[0513] S1209: Determine whether the target task of round n-1 is a main task, if yes, execute S1210, otherwise, execute S1214;

[0514] S1210: Determine whether the current task stack is empty, if so, execute S1211, otherwise, execute S1214;

[0515] S1211: Using LLM plan Determine whether the question has been answered, if yes, execute S1212, otherwise, execute S1213;

[0516] S1212: Determine that the nth round of decision-making action indicates that the task processing has been completed;

[0517] S1213: Determine the nth round of decision action representation: Based on the problem, the current background information and the n-1th round of tool call results, generate a series of mainline tasks, and set the execution times of these newly generated mainline tasks to 1;

[0518] S1214: Determine the nth round of decision-making action representation: do not generate new tasks.

[0519] exist Fig.12 In the example, the current task stack represents the task stack before the nth round of update, which is T n-1 .

[0520] In the implementation process listed in S1201 to S1214 above, the input is the current system state updated based on S1103, and the output is the nth round of decision-making actions.

[0521] It should be noted that the above Fig.11 and Fig.12 The processes listed are just simple examples. Apart from these, other similar methods are also applicable to the embodiments of the present application and will not be described in detail here.

[0522] The following is a brief summary of the task processing method in the embodiment of the present application from the perspective of interaction between the terminal device and the server:

[0523] See also Fig.13 As shown, it is a logic diagram of interaction between a terminal device and a server in an embodiment of the present application. The following briefly describes the interaction logic between the terminal device and the server:

[0524] As mentioned above, the task planning system (i.e., the LLM Agent system mentioned above) can be run on the server side. The terminal device, as the front-end device for the object to interact with the task planning system, can be installed with the above-listed clients, such as the conversational AI software, which is responsible for receiving the questions input by the object and sending these requests to the task planning system. Then, the task planning system receives the questions through the task planning agent. In each round of task processing, the tool calling agent receives the tool calling results (affecting background information) of the n-1th round fed back by the tool calling agent, combined with information such as questions, and dynamically plans the target task of the nth round to guide the tool calling agent to call the tool. The tool calling agent considers which tool to call according to the target task of the nth round planned by the task planning agent, generates tool calling information, and calls the tools in the tool pool (such as computing tools, data analysis tools, code execution tools, retrieval tools, etc.) through the tool calling information to perform the task. After the task processing is completed, the task planning system returns the reply information to the question to the terminal device, and the terminal device displays the reply information through the front-end operation interface.

[0525] It should be noted that the interaction logic listed above is just a simple example. The specific implementation method can be found in the above embodiment, which will not be repeated here.

[0526] The following is a brief description of the effect of the task planning system proposed in this application:

[0527] Before using the task planning system proposed in this application, the single-agent system in the related art, such as a single tool-calling agent (referred to as a tool-calling system), is difficult to solve complex problems. For example, to calculate the month-on-month growth value of a certain indicator on a certain day of a certain month of a certain year (but the value does not exist in the data file), the tool-calling system will directly write code to calculate the same month-on-month value, but due to missing data, an execution error will occur, and the fault cannot be repaired later. Specifically, the tool-calling system will first try to read directly, and after failure, check whether there is data missing. After confirming that the data is missing, it will directly end the task (without autonomously calling the prediction tool), resulting in task failure.

[0528] When using the task planning system proposed in this application, when faced with complex problems, the system can effectively plan and execute tasks, and ultimately complete the tasks excellently. For the same problem, specifically, after observing missing data, the task planning system will call the prediction tool for prediction, and then use the existing results for calculation, thereby successfully completing the task.

[0529] In addition, by comparing the tool calling system and the task planning system proposed in this application on a series of tasks, the statistical experimental data obtained are as follows:

[0530] Table 1

[0531]

[0532]

[0533] It can be seen from the above experimental data that when faced with complex problems, the tool calling system sometimes ignores some tasks, fails to judge the sequence of tasks, and even ignores existing data. The task planning system proposed in this application does not have the above problems, and its performance in a series of tasks is greatly improved compared to the tool calling system alone.

[0534] In addition, it should be noted that the task stack in this application also supports reuse between tasks, that is, by storing executed tasks, the experience and results of these tasks can be reused, reducing duplication of work and further improving execution efficiency. This method can not only improve the system's concurrent processing capabilities, but also enhance the flexibility and efficiency of task management.

[0535] Based on the same inventive concept, the present application embodiment also provides a task processing device. Fig.14 As shown, it is a structural diagram of a task processing device 140 in an embodiment of the present application, which may include:

[0536] The task processing unit 141 is used to perform at least one round of task processing according to the question input by the object, and output the reply information corresponding to the question after reaching the preset end condition; wherein, the task processing unit 141 includes a task planning subunit 1411 and a tool calling subunit 1412, and the nth round of task processing includes the following steps:

[0537] The task planning subunit 1411 is used to plan the nth round of decision actions according to the problem and the tool call results corresponding to the target task of the n-1th round; the nth round of decision actions is used to indicate the task planning details of the nth round, where n is a positive integer;

[0538] According to the nth round decision action, taking out the nth round target task from the task stack; the task stack includes the currently planned tasks related to the problem;

[0539] The tool calling subunit 1412 is used to generate tool calling information for the nth round target task according to the background information corresponding to the nth round target task and the problem; the background information is determined according to the execution status of the problem and related tasks;

[0540] A tool is called according to the tool calling information to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

[0541] Optionally, the task planning subunit 1411 is specifically used for:

[0542] Generate a new task set according to the nth round of decision actions;

[0543] Updating the task stack according to the new task set;

[0544] The top task taken out from the updated task stack is used as the target task of the nth round.

[0545] Optionally, the task planning subunit 1411 is further configured to, before the tool calling subunit 1412 generates tool calling information for the n-th round target task according to the n-th round target task and the background information corresponding to the problem:

[0546] The background information is updated according to the problem, the task stack, and the tool call result corresponding to the target task of the n-1th round.

[0547] Optionally, the task processing unit 141 is specifically used for:

[0548] Generate response information corresponding to the question by summarizing the question, the task stack, the tool call result corresponding to the target task of the n-1th round, and the background information, and output the response information;

[0549] The reply information is the answer to the question, or the reply information indicates the current processing result of the question and the problems existing in the task processing process.

[0550] Optionally, the task planning subunit 1411 is specifically used for:

[0551] Analyze whether the target task of the n-1th round is empty;

[0552] If the target task of the n-1th round is empty, the decision action of the nth round indicates: based on the problem, generate at least one main task, and set the execution times of the main task to the initial value;

[0553] If the target task of the n-1th round is not empty, the decision action of the nth round is planned according to the task type of the target task of the n-1th round and the tool calling result.

[0554] Optionally, the task planning subunit 1411 is specifically used for:

[0555] Analyze whether the target task of the n-1th round is successfully executed according to the tool call result corresponding to the target task of the n-1th round;

[0556] If the execution of the target task of the n-1th round fails, planning the decision action of the nth round according to whether there is a branch task of the target task of the n-1th round;

[0557] If the target task of the n-1th round is successfully executed, the decision action of the nth round is planned according to whether the target task of the n-1th round is a main task.

[0558] Optionally, the task planning subunit 1411 is specifically used for:

[0559] If the target task of the n-1th round has a branch task, the decision action of the nth round indicates: generating a corresponding branch task, and setting the execution times of the branch task to an initial value;

[0560] If there is no branch task in the target task of the n-1th round, and the number of executions of the target task of the n-1th round has not reached the upper limit, then the decision action of the nth round indicates: re-planning tasks according to the target task of the n-1th round;

[0561] If there is no branch task for the target task of the n-1th round, and the execution times of the target task of the n-1th round reaches the upper limit, the decision action of the nth round indicates that the task processing fails.

[0562] Optionally, the task planning subunit 1411 is specifically used for:

[0563] If the target task of the n-1th round is a main task and the task stack is empty, then the decision action of the nth round is planned according to whether the question has been answered;

[0564] Otherwise, the nth round decision action indicates: no new task is generated.

[0565] Optionally, the task planning subunit 1411 is specifically used for:

[0566] If the question has been answered, the nth round of decision-making action means that the task processing has been completed;

[0567] If the question has not been answered, the nth round decision action indicates: based on the question, the background information and the tool call result corresponding to the target task of the n-1th round, at least one main task is generated, and the number of executions of the main task is set to the initial value.

[0568] Optionally, the task planning subunit 1411 is specifically used for:

[0569] If the n-th round decision action is not a designated decision action, taking out the n-th round target task from the task stack according to the n-th round decision action; wherein the designated decision action includes: task processing completed, task processing failed;

[0570] The task planning subunit 1411 is also used for:

[0571] If the n-th round decision action is a designated decision action, it is determined that the preset end condition is met.

[0572] Optionally, if the n-th round target task has one, correspondingly, each n-th round target task corresponds to one tool calling information, then the tool calling subunit 1412 is specifically used to:

[0573] For multiple target tasks of the nth round, the following process is performed in parallel:

[0574] A tool is called according to the tool calling information corresponding to the n-th round target task to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

[0575] As for task planning, the present application performs task planning once per round, and during task planning, the decision actions for each round are planned based on the problem and the tool call results of the tasks executed in the n-1th round. This task planning method refers to the execution status of previous tasks in each round of task planning, and can dynamically adjust downstream tasks according to the execution status of upstream tasks, ensuring that the decision actions for each round are planned with task dependencies taken into consideration, and the planning results are more accurate.

[0576] On this basis, a series of related tasks can be determined in advance through the task stack, which can reduce the need to frequently call LLM for re-planning. In addition, these planned tasks are saved in the stack in an orderly manner to ensure that the tasks are executed in a certain order. This helps to clarify the priority of tasks, avoid inefficiency caused by mutual interference between tasks, effectively reduce the number of re-planning times, and improve task planning efficiency.

[0577] In summary, in this application, the task stack is used to store the planned tasks in the form of a stack, and the task planning is performed in combination with the results of the n-1th round of tool calls. This planning strategy can guide the large model to conduct scientific process analysis on the results of the executed tasks to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning, taking into account planning efficiency while considering task dependencies and improving system robustness.

[0578] In addition, when performing task planning, this application makes a targeted design for task re-planning, thereby further enhancing the robustness of the LLM Agent system in the event of task failure.

[0579] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

[0580] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0581] After introducing the task processing method and apparatus according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0582] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.

[0583] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. In one embodiment, the electronic device may be a server, such as Figure 1 In this embodiment, the structure of the electronic device can be as follows: Fig.15 As shown, it includes a memory 1501 , a communication module 1503 and one or more processors 1502 .

[0584] The memory 1501 is used to store computer programs executed by the processor 1502. The memory 1501 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0585] The memory 1501 may be a volatile memory, such as a random-access memory (RAM); the memory 1501 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 1501 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1501 may be a combination of the above memories.

[0586] The processor 1502 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 1502 is used to implement the above-mentioned task processing method when calling the computer program stored in the memory 1501 .

[0587] The communication module 1503 is used to communicate with terminal devices and other servers.

[0588] The specific connection medium between the memory 1501, the communication module 1503 and the processor 1502 is not limited in the embodiment of the present application. Fig.15 In the embodiment, the memory 1501 and the processor 1502 are connected via a bus 1504. The bus 1504 is connected to the processor 1502 via a bus 1504. Fig.15 The connections between the other components are described with bold lines, which are only for illustration and are not intended to be limiting. The bus 1504 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Fig.15 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or one type of bus.

[0589] The memory 1501 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the task processing method of the embodiment of the present application. The processor 1502 is used to execute the above-mentioned task processing method, such as Figure 3 shown.

[0590] In another embodiment, the electronic device may also be other electronic devices, such as Figure 1 The terminal device 110 shown in FIG. 1 is a terminal device 110 shown in FIG. 1 . In this embodiment, the structure of the electronic device can be as follows: Fig.16As shown, it includes: a communication component 1610, a memory 1620, a display unit 1630, a camera 1640, a sensor 1650, an audio circuit 1660, a Bluetooth module 1670, a processor 1680 and other components.

[0591] The communication component 1610 is used to communicate with the server. In some embodiments, a circuit wireless fidelity (Wireless Fidelity, WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user to send and receive information through the WiFi module.

[0592] The memory 1620 can be used to store software programs and data. The processor 1680 executes various functions and data processing of the terminal device 110 by running the software programs or data stored in the memory 1620. The memory 1620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The memory 1620 stores an operating system that enables the terminal device 110 to run. In the present application, the memory 1620 can store an operating system and various application programs, and can also store a computer program for executing the task processing method of the embodiment of the present application.

[0593] The display unit 1630 can also be used to display information input by the user or information provided to the user and a graphical user interface (GUI) of various menus of the terminal device 110. Specifically, the display unit 1630 may include a display screen 1632 disposed on the front of the terminal device 110. The display screen 1632 may be configured in the form of a liquid crystal display, a light emitting diode, etc. The display unit 1630 may be used to display the front-end operation interface in the embodiment of the present application, etc.

[0594] The display unit 1630 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the terminal device 110. Specifically, the display unit 1630 may include a touch screen 1631 arranged on the front of the terminal device 110, which can collect user touch operations on or near it, such as clicking a button, dragging a scroll box, etc.

[0595] The touch screen 1631 can be covered on the display screen 1632, or the touch screen 1631 and the display screen 1632 can be integrated to realize the input and output functions of the terminal device 110. The integrated touch screen can be referred to as a touch display screen. In this application, the display unit 1630 can display the application and the corresponding operation steps.

[0596] The camera 1640 can be used to capture still images, and the user can publish the images taken by the camera 1640 through the application. The camera 1640 can be one or more. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the processor 1680 to convert it into a digital image signal.

[0597] The terminal device may further include at least one sensor 1650, such as an acceleration sensor 1651, a distance sensor 1652, a fingerprint sensor 1653, and a temperature sensor 1654. The terminal device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.

[0598] The audio circuit 1660, the speaker 1661, and the microphone 1662 can provide an audio interface between the user and the terminal device 110. The audio circuit 1660 can transmit the electrical signal converted from the received audio data to the speaker 1661, which is converted into a sound signal for output. The terminal device 110 can also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 1662 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1660 and converted into audio data, and then the audio data is output to the communication component 1610 to be sent to, for example, another terminal device 110, or the audio data is output to the memory 1620 for further processing.

[0599] The Bluetooth module 1670 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol. For example, the terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 1670 to exchange data.

[0600] The processor 1680 is the control center of the terminal device. It uses various interfaces and lines to connect various parts of the entire terminal. It executes various functions of the terminal device and processes data by running or executing software programs stored in the memory 1620 and calling data stored in the memory 1620. In some embodiments, the processor 1680 may include one or more processing units; the processor 1680 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1680. In the present application, the processor 1680 can run the operating system, application programs, user interface display and touch response, as well as the task processing method of the embodiment of the present application. In addition, the processor 1680 is coupled to the display unit 1630.

[0601] In some possible implementations, various aspects of the task processing method provided by the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the task processing method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 3 Follow the steps shown in .

[0602] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0603] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, apparatus, or device.

[0604] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.

[0605] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0606] The computer program for performing the operation of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and also conventional procedural programming languages ​​such as "C" language or similar programming languages. The computer program can be executed entirely on the user electronic device, partially on the user electronic device, as a separate software package, partially on the user electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In the case of a remote electronic device, the remote electronic device can be connected to the user electronic device through any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (for example, using an Internet service provider to connect through the Internet).

[0607] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0608] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0609] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain a computer-usable computer program.

[0610] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0611] These computer program commands may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer readable memory produce an article of manufacture comprising a command device, the command device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0612] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide the instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0613] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0614] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A task processing method, characterized in that: The method comprises: Perform at least one round of task processing according to the question input by the object, and output the reply information corresponding to the question after reaching the preset end condition; wherein the nth round of task processing includes the following steps: According to the problem and the tool call result corresponding to the target task of the n-1th round, plan the decision action of the nth round; the decision action of the nth round is used to indicate the task planning details of the nth round, where n is a positive integer; According to the nth round decision action, taking out the nth round target task from the task stack; the task stack includes the currently planned tasks related to the problem; Generating tool call information for the n-th round target task according to the background information corresponding to the n-th round target task and the problem; the background information is determined according to the execution status of the problem and related tasks; A tool is called according to the tool calling information to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

2. The method according to claim 1, characterized in that According to the n-th round decision action, taking out the n-th round target task from the task stack includes: Generate a new task set according to the nth round of decision actions; Updating the task stack according to the new task set; The top task taken out from the updated task stack is used as the target task of the nth round.

3. The method according to claim 1, characterized in that Before generating the tool calling information for the n-round target task according to the n-round target task and the background information corresponding to the problem, the method further includes: The background information is updated according to the problem, the task stack, and the tool call result corresponding to the target task of the n-1th round.

4. The method according to claim 1, characterized in that The outputting the reply information corresponding to the question includes: Generate response information corresponding to the question by summarizing the question, the task stack, the tool call result corresponding to the target task of the n-1th round, and the background information, and output the response information; The reply information is the answer to the question, or the reply information indicates the current processing result of the question and the problems existing in the task processing process.

5. The method according to claim 1, characterized in that The planning of the nth round of decision actions according to the problem and the tool call results corresponding to the target tasks of the n-1th round includes: Analyze whether the target task of the n-1th round is empty; If the target task of the n-1th round is empty, the decision action of the nth round indicates: based on the problem, generate at least one main task, and set the execution times of the main task to the initial value; If the target task of the n-1th round is not empty, the decision action of the nth round is planned according to the task type of the target task of the n-1th round and the tool calling result.

6. The method according to claim 5, characterized in that The planning of the nth round of decision actions according to the task type and tool calling result of the n-1th round of target tasks includes: Analyze whether the target task of the n-1th round is successfully executed according to the tool call result corresponding to the target task of the n-1th round; If the execution of the target task of the n-1th round fails, planning the decision action of the nth round according to whether there is a branch task of the target task of the n-1th round; If the target task of the n-1th round is successfully executed, the decision action of the nth round is planned according to whether the target task of the n-1th round is a main task.

7. The method according to claim 6, characterized in that The planning of the decision action of the nth round according to whether there is a branch task in the target task of the n-1th round includes: If the target task of the n-1th round has a branch task, the decision action of the nth round indicates: generating a corresponding branch task, and setting the execution times of the branch task to an initial value; If there is no branch task in the target task of the n-1th round, and the number of executions of the target task of the n-1th round has not reached the upper limit, then the decision action of the nth round indicates: re-planning tasks according to the target task of the n-1th round; If there is no branch task for the target task of the n-1th round, and the execution times of the target task of the n-1th round reaches the upper limit, the decision action of the nth round indicates that the task processing fails.

8. The method according to claim 6, characterized in that The planning of the n-th round of decision actions according to whether the n-1th round of target tasks is a main task includes: If the target task of the n-1th round is a main task and the task stack is empty, then plan the decision action of the nth round according to whether the question has been answered; Otherwise, the nth round decision action indicates: no new task is generated.

9. The method according to claim 8, characterized in that The planning of the nth round of decision-making actions according to whether the question has been answered includes: If the question has been answered, the nth round of decision-making action means that the task processing has been completed; If the question has not been answered, the nth round decision action indicates: based on the question, the background information and the tool call result corresponding to the target task of the n-1th round, at least one main task is generated, and the number of executions of the main task is set to the initial value.

10. The method according to any one of claims 1 to 9, characterized in that: The taking out the target task of the nth round from the task stack according to the decision action of the nth round includes: If the n-th round decision action is not a designated decision action, taking out the n-th round target task from the task stack according to the n-th round decision action; wherein the designated decision action includes: task processing completed, task processing failed; And, the method further comprises: If the n-th round decision action is a designated decision action, it is determined that the preset end condition is met.

11. The method according to any one of claims 1 to 9, characterized in that: If the n-th round target task has a corresponding tool calling information corresponding to each n-th round target task, then calling a tool according to the tool calling information to execute the n-th round target task and obtaining a tool calling result corresponding to the n-th round target task includes: For multiple target tasks of the nth round, the following process is performed in parallel: A tool is called according to tool calling information corresponding to an n-th round target task to execute the n-th round target task and obtain a tool calling result corresponding to the n-th round target task.

12. A task processing device, characterized in that: include: The task processing unit is used to perform at least one round of task processing according to the question input by the object, and output the reply information corresponding to the question after the preset end condition is reached; wherein the task processing unit includes a task planning subunit and a tool calling subunit, and the nth round of task processing includes the following steps: The task planning subunit is used to plan the nth round of decision actions according to the problem and the tool call results corresponding to the target task of the n-1th round; the nth round of decision actions are used to indicate the task planning details of the nth round, where n is a positive integer; According to the nth round decision action, taking out the nth round target task from the task stack; the task stack includes the currently planned tasks related to the problem; The tool calling subunit is used to generate tool calling information for the target task of the nth round according to the background information corresponding to the target task of the nth round and the problem; the background information is determined according to the execution status of the problem and related tasks; A tool is called according to the tool calling information to execute the n-th round target task, and a tool calling result corresponding to the n-th round target task is obtained.

13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The method comprises a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the methods of claims 1 to 11.

15. A computer program product, characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any one of the methods described in claims 1 to 11.

Citation Information

Patent Citations

  • Task processing method and device, computer device and storage medium

    CN108829521A

  • Processing method and device for abnormal process ending operation and electronic device

    CN109766701A

  • Task execution method and device, computer equipment and storage medium

    CN110991127A

  • Target model loading and updating method and device, readable medium and electronic equipment

    CN113641413A

  • Map data validity verification method and device, electronic equipment and storage medium

    CN117131954A

Cited By

  • System and method for dynamically updating front-end interface based on LLM (Language Language Model)

    CN119759459A

  • Task execution method, device and system, electronic device and storage medium

    CN120723411A

  • Task execution method based on intelligent agent

    CN120892475A

  • An agent-based task execution method

    CN120892475B

  • Intelligent agent-based information processing method and device and storage medium

    CN121031788A