A task processing method and device, electronic equipment and storage medium
By combining task stacks and tool call sub-units, task planning is dynamically adjusted, solving the problems of difficult execution of complex tasks in single-agent systems and insufficient flexibility in multi-agent systems. This achieves efficient and accurate task planning and execution, improving the robustness and efficiency of the system.
Patent Information
- Application Number
- CN202411603831.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-11-08
AI Technical Summary
In existing technologies, single-agent systems face challenges such as large state spaces, uncertainty handling, and real-time multi-task execution when dealing with complex tasks, while multi-agent systems lack the flexibility for task planning under dynamic task requirements, making it difficult to perform task planning and execution efficiently and accurately.
A task stack mechanism is adopted, in which each round of task planning is based on the results of the previous round of tool calls. Combined with the planned tasks stored in the task stack, the task stack and tool call sub-units are used to execute tasks in an orderly manner, dynamically adjust downstream tasks, reduce the number of replanning, and ensure task dependency and efficiency.
It improves the accuracy and efficiency of task planning, reduces the number of replanning operations, enhances the robustness of the system, ensures that tasks are executed in an orderly manner according to priority, avoids interference between tasks, and improves the flexibility and reliability of the system.
Smart Images

Figure CN119537541B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to the field of artificial intelligence technology, and provides a task processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Task planning capability is one of the core competencies of Large Language Model (LLM) agent systems for solving complex problems. In related technologies, LLM agent systems used for task planning are broadly classified into single-agent systems and multi-agent systems.
[0003] For single-agent systems, the underlying LLM simultaneously undertakes the tasks of task planning and tool invocation (i.e., task execution), which places high demands on the LLM's capabilities. When encountering complex tasks, it faces challenges such as a large state space, handling uncertainty, and real-time multi-task execution.
[0004] For multi-agent systems, task planning techniques based on task lists are generally used. Global task planning is performed in the initial stage, creating a task list which is then executed. However, because the task list is created before the task begins, it lacks flexibility and struggles to cope with dynamically changing task requirements, such as dynamically selecting subsequent tasks after data integrity checks.
[0005] In conclusion, how to efficiently and accurately plan and execute tasks when facing complex problems is an urgent issue that needs to be addressed. Summary of the Invention
[0006] This application provides a task processing method, apparatus, electronic device, and storage medium for efficient and accurate task planning and execution.
[0007] This application provides a task processing method, including: Based on the question input by the object, perform at least one round of task processing until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the nth round of task processing includes the following steps: Based on the question and the tool call results corresponding to the (n-1)th round target task, plan the decision action for the nth round; the decision action for the nth round is used to indicate the task planning details for the nth round, where n is a positive integer; Based on the decision action in the nth round, the target task for the nth round is retrieved from the task stack; the task stack contains currently planned tasks related to the problem. Based on the background information corresponding to the target task of the nth round and the problem, tool invocation information for the target task of the nth round is generated; the background information is determined based on the problem and the execution status of related tasks. The tool is invoked based on the tool invocation information to execute the target task of the nth round, and the tool invocation result corresponding to the target task of the nth round is obtained.
[0008] This application provides a task processing device, comprising: The task processing unit is used to perform at least one round of task processing based on the question input by the object, until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the task processing unit includes a task planning subunit and a tool invocation subunit, and the nth round of task processing includes the following steps: The task planning subunit is used to plan the decision action for the nth round based on the problem and the tool call result corresponding to the target task in the (n-1)th round; the decision action for the nth round is used to indicate the task planning details for the nth round, where n is a positive integer; Based on the decision action in the nth round, the target task for the nth round is retrieved from the task stack; the task stack contains currently planned tasks related to the problem. The tool invocation subunit is used to generate tool invocation information for the nth round target task based on the background information corresponding to the problem; the background information is determined based on the problem and the execution status of related tasks. The tool is invoked based on the tool invocation information to execute the target task of the nth round, and the tool invocation result corresponding to the target task of the nth round is obtained.
[0009] Optionally, the task planning subunit is specifically used for: A new task set is generated based on the decision actions in the nth round. Update the task stack according to the new task set; The top task taken from the updated task stack will be used as the target task for the nth round.
[0010] Optionally, the task planning subunit is further configured to: before the tool invocation subunit generates tool invocation 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 updated based on the problem, the task stack, and the tool call results corresponding to the (n-1)th round target task.
[0011] Optionally, the task processing unit is specifically used for: By summarizing the problem, the task stack, the tool call results corresponding to the (n-1)th round target task, and the background information, a response message corresponding to the problem is generated and output. The response information is either the answer to the question or it represents the current processing result of the question and any problems encountered during the task processing.
[0012] Optionally, the task planning subunit is specifically used for: Analyze whether the target task in the (n-1)th round is empty; If the target task of the (n-1)th round is empty, then the decision action of the nth round means: based on the problem, generate at least one main task, and set the number of times the main task is executed to the initial value; If the target task of the (n-1)th round is not empty, then the decision action of the nth round is planned according to the task type and tool call result of the target task of the (n-1)th round.
[0013] Optionally, the task planning subunit is specifically used for: Based on the tool call results corresponding to the (n-1)th round target task, analyze whether the (n-1)th round target task was successfully executed; If the target task in the (n-1)th round fails, then the decision action for the nth round is planned based on whether there are any side tasks in the target task in the (n-1)th round. If the target task of the (n-1)th round is successfully executed, then the decision action of the nth round is planned according to whether the target task of the (n-1)th round is the main task.
[0014] Optionally, the task planning subunit is specifically used for: If the target task in the (n-1)th round has a side task, then the decision action in the nth round is: generate the corresponding side task, and set the number of times the side task is executed to the initial value; If the target task in the (n-1)th round has no side tasks and the number of times the target task in the (n-1)th round is executed has not reached the upper limit, then the decision action in the nth round means: replan the task according to the target task in the (n-1)th round; If the target task in the (n-1)th round has no side tasks, and the number of times the target task in the (n-1)th round is executed reaches the upper limit, then the decision action in the nth round indicates that the task processing has failed.
[0015] Optionally, the task planning subunit is specifically used for: If the target task of the (n-1)th round is the 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. Otherwise, the decision action in the nth round means: do not generate a new task.
[0016] Optionally, the task planning subunit is specifically used for: If the question has been answered, then the nth round of decision action indicates that the task processing has been completed. If the question is not fully answered, the decision action in the nth round means: based on the question, the background information, and the tool call result corresponding to the target task in the (n-1)th round, generate at least one main task, and set the number of executions of the main task to the initial value.
[0017] Optionally, the task planning subunit is specifically used for: If the decision action in the nth round is not a specified decision action, then the target task for the nth round is retrieved from the task stack according to the decision action in the nth round; wherein, the specified decision action includes: task processing has been completed, task processing has failed; The task planning subunit is also used for: If the decision action in the nth round is a specified decision action, then the preset termination condition is determined to have been met.
[0018] Optionally, if there are multiple target tasks in the nth round, and each target task in the nth round corresponds to a tool invocation information, then the tool invocation subunit is specifically used for: For multiple nth round target tasks, the following process is executed in parallel: The tool is invoked based on the tool invocation information corresponding to the nth round target task to execute the nth round target task and obtain the tool invocation result corresponding to the nth round target task.
[0019] An electronic device provided in this 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 performs the steps of any of the above-described task processing methods.
[0020] This application provides a computer-readable storage medium including a computer program. When the computer program is run on an electronic device, the computer program is used to cause the electronic device to perform the steps of any of the above-described task processing methods.
[0021] This application provides a computer program product, which includes 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, causing the electronic device to perform the steps of any of the above-described task processing methods.
[0022] The beneficial effects of this application are as follows: This application provides a task processing method, apparatus, electronic device, and storage medium. Regarding task planning, this application performs task planning once per round. During task planning, the decision-making actions in each round are planned based on the problem and the tool call results of the tasks executed in the previous round (initially empty). This task planning method ensures that the execution status of previous tasks is referenced in each round of task planning, allowing for dynamic adjustments to downstream tasks based on the execution status of upstream tasks. This guarantees that the decision-making actions in each round are planned with task dependencies considered, resulting in more accurate planning results.
[0023] Based on this, a series of related tasks can be pre-determined through the task stack, which can reduce the need for frequent calls to LLM for replanning. Furthermore, storing these planned tasks in an orderly manner in the stack can 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 replanning calls, and improve task planning efficiency.
[0024] In summary, this application utilizes a task stack to store planned tasks in a stack format and combines the results of the previous round of tool calls for task planning. This planning strategy can guide the large model to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning. It takes into account both task dependencies and planning efficiency, and improves system robustness.
[0025] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0026] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is an optional schematic diagram of an application scenario in an embodiment of this application; Figure 2 This is a schematic diagram of a large language model task planning system in an embodiment of this application; Figure 3 A flowchart illustrating the implementation of a task processing method provided in this application embodiment; Figure 4This is a schematic diagram of the front-end operation interface of an LLMAPP according to an embodiment of this application; Figure 5 This is a schematic diagram of a task stack storage process in an embodiment of this application; Figure 6 This is a logical diagram illustrating a task processing based on a multi-agent framework in an embodiment of this application. Figure 7 This is a logical diagram illustrating task planning based on a task planning agent in an embodiment of this application. Figure 8 This is a logical diagram illustrating the first type of planning decision-making action in this application embodiment; Figure 9 This is a logical diagram illustrating the second type of planning decision-making action in this application embodiment; Figure 10 This is a logical diagram illustrating the third planning decision-making action in this round of embodiments of the present application; Figure 11 This is a flowchart of a task processing method according to an embodiment of this application; Figure 12 This is a flowchart of a task planning method in an embodiment of this application; Figure 13 This is an example of an interaction logic diagram between a terminal device and a server in an embodiment of this application; Figure 14 This is a schematic diagram of the structure of a task processing device according to an embodiment of this application; Figure 15 This is a schematic diagram of the hardware structure of an electronic device using an embodiment of this application; Figure 16 This is a schematic diagram of the hardware structure of another electronic device using an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.
[0028] The following describes some of the concepts involved in the embodiments of this application.
[0029] 1. LLM: Refers to a deep learning model trained on massive amounts of text data, capable of performing various Natural Language Processing (NLP) tasks, such as generating natural language text or understanding the meaning of language text. Large language models typically use multiple transformer models and are trained on massive datasets, resulting in a very large scale. This is the powerful foundation for their ability to recognize, translate, predict, or generate text or other content. The task processing method in this application can be applied to LLM, specifically to LLM agent systems.
[0030] 2. Agent: Based on LLM, an intelligent operating system possesses certain abilities to think, remember, use tools, and act. An intelligent agent can perceive the environment, make decisions, and execute corresponding actions to influence the environment given a goal. Specifically, a single-agent system contains one independently operating agent, while a multi-agent system consists of multiple agents that cooperate or compete with each other to solve problems or complete tasks.
[0031] 3. Task Planning: This refers to the process of understanding the intent of an object (such as a user) based on LLM and then transforming that intent into a series of specific tasks. Each task typically involves a tool call, designed to utilize external tools or services to obtain necessary information or perform a specific operation. The Agent system executes these planned tasks in sequence, updating its status upon completion of each task and determining subsequent tasks based on the results, until all tasks are completed or the predetermined goal is achieved, thus forming the final answer or solution.
[0032] 4. Decision Action: This is a specific step in the task planning process. A decision action can include one or more task-type operations, such as querying a database or searching for network information, aimed at advancing the achievement of the task objective. Alternatively, a decision action may not involve any specific task, but rather be directly generated by the LLM to produce the final answer or take a default action. This design allows the agent to react quickly when necessary, avoiding unnecessary delays or resource waste.
[0033] 5. Function Call: This refers to the process of translating the LLM's understanding of the object's intent into a structured instruction format when processing object requests. This triggers calls to external Application Programming Interfaces (APIs) or tools. For example, a range of external tools can be invoked, such as calculators, search engines, and code compilers. This approach allows the LLM to leverage the functionality of external services, such as performing mathematical operations, searching online information, and writing and running code snippets, to enhance its own capabilities and provide more accurate and richer responses. The function call is implemented through standardized interfaces, ensuring consistency and reliability of the interaction. This enables the LLM to seamlessly integrate various external functions to meet the diverse needs of objects. In the task execution phase of this application, a function call is required.
[0034] 6. Stack: An abstract data structure that follows the First In First Out (FIFO) or Last In First Out (LIFO) principle. FIFO means that the element added to the stack first is removed first, while LIFO means that the element added to the stack last is removed first. Stack operations are limited to pushing and popping from the top. Adding a new element to the top of the stack is called pushing, and removing an element from the top of the stack is called popping.
[0035] A task stack is a specific application for task management and scheduling. In a task stack, tasks are arranged in a certain order, typically following a FIFO or LIFO principle. When a new task is added to the task stack, it is placed at the top, becoming the next task to be executed. When this task is completed, 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, helping to manage the execution order of tasks in the system, ensuring that tasks are executed on demand, and allowing for backtracking or restoration of task states when necessary. In the multi-agent system proposed in this application, the task stack can be used to manage the task allocation and execution flow among different agents.
[0036] 7. Planned Tasks and Target Tasks: Planned tasks refer to the specific tasks that have been identified and recorded during the task planning process. These tasks are typically stored in a task stack or other data structure, awaiting execution as planned. They represent intermediate results in the task management process, providing a basis for subsequent task scheduling and execution. Target tasks refer to the specific tasks that need to be completed during task execution. These tasks are selected from the planned tasks and are ready for execution. As in this paper, the task stack stores the currently planned tasks related to the problem in a certain order, and the task stack can be continuously updated, retrieving target tasks from the task stack for execution.
[0037] 8. Synchronous Tasks: These tasks require the previous operation to complete before the next operation can proceed. In synchronous mode, the program's control flow is linear; that is, the start of a subsequent task depends on the completion of the previous one. This mode often leads to blocking during execution because subsequent tasks cannot begin until the previous one is completed.
[0038] Asynchronous tasks refer to tasks that can begin execution without waiting for the previous task to complete. In asynchronous mode, a program can execute subsequent operations immediately after issuing a command, without waiting for the previous task to finish. Once the previous task completes, the program will notify the main program through callback functions, events, signals, etc.
[0039] Parallel execution refers to the simultaneous execution of multiple tasks within the same timeframe. This can be achieved through multithreading, multiprocessing, or by leveraging the concurrency capabilities provided by modern computer hardware (such as the number of central processing unit cores). Parallel execution can significantly improve program execution efficiency, especially when handling input / output (I / O) intensive tasks (such as network requests, disk reads and writes).
[0040] The design concept of the embodiments of this application is briefly introduced below: Building an LLM agent system that enables it to think autonomously and call upon tools to solve specialized problems is one of the important means of expanding the capabilities of LLM. When faced with complex problems, the ability to think in a planned manner and call upon tools is the key to LLM completing its tasks. To this end, a series of studies have been dedicated to developing the task planning capabilities of LLM agent systems.
[0041] In related technologies, LLM agent systems used for task planning are divided into two main categories: single-agent systems and multi-agent systems.
[0042] For single-agent systems, there are significant challenges when facing complex tasks.
[0043] For multi-agent systems, task planning techniques based on task lists are generally used. These algorithms perform global task planning in the initial stage, and some also update the TaskList upon completion of each subsequent task. However, these algorithms require a relatively fixed task planning path for the problem to be solved. For some problems, the type of subsequent task needs to be dynamically selected based on existing tasks. But because these algorithms lack consideration of task dependencies, it is difficult to dynamically select the next task type based on the results of existing task executions.
[0044] For example, when calculating the year-on-year and month-on-month comparison values of a certain indicator on a certain day, it is necessary to first check the data completeness. If the data is available, the calculation can be performed directly. If the data is missing, it is necessary to make a prediction first and then calculate or to end the task directly. In this case, 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 this kind of problem in principle.
[0045] In view of this, this application proposes a task processing method, apparatus, electronic device, and storage medium. Regarding task planning, this application performs task planning once per round, and during task planning, the decision-making actions in 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 ensures that the execution status of previous tasks is referenced in each round of task planning, allowing for targeted and dynamic adjustments to downstream tasks based on the execution status of upstream tasks. This guarantees that the decision-making actions in each round are planned with task dependencies considered, resulting in more accurate planning results.
[0046] Based on this, a series of related tasks can be pre-determined through the task stack, which can reduce the need for frequent calls to LLM for replanning. Furthermore, storing these planned tasks in an orderly manner in the stack can 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 replanning calls, and improve task planning efficiency.
[0047] In summary, this application utilizes a task stack to store planned tasks in a stack format and combines the results of the previous round of tool calls for task planning. This planning strategy can guide the large model to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning. It takes into account both task dependencies and planning efficiency, and improves system robustness.
[0048] Furthermore, after each task execution, there may be instances where the task fails or the results do not meet expectations. In such cases, task replanning is necessary. However, the algorithms in related technologies lack specific designs for task replanning when task execution fails, treating it the same as a general task execution result. This hinders the LLMA agent system from diagnosing errors and adjusting tasks in a timely manner, making the LLM Agent system lack robustness when solving practical problems.
[0049] To overcome the aforementioned problems, this application incorporates a targeted design for task replanning during task planning. For instance, in cases where task execution fails to achieve the expected results, this application categorizes tasks into main tasks and side tasks. In cases where main tasks fail, the task planning strategy in this application guides the LLM to determine whether to re-execute the task or retain the main task while adding new side tasks, thereby enhancing the robustness of the LLM Agent system in the event of task failure.
[0050] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0051] like Figure 1 The diagram shown is an application scenario illustration of an embodiment of this application. The application scenario diagram includes a terminal device 110 and a server 120.
[0052] In this application embodiment, the terminal device 110 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, in-vehicle terminals, and other devices. The terminal device may have a task-processing related client installed. This client can be software (such as a browser, conversational artificial intelligence (AI) software, etc.), or a webpage, mini-program, etc. The server 120 is the backend server corresponding to the software, webpage, mini-program, etc., or a server specifically used for task processing; this application does not impose specific limitations. The server 120 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0053] It should be noted that the task processing methods in the embodiments of this 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 both the terminal device 110 and the server 120. 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 based on the question until a preset termination condition is reached, and then output the corresponding response information for the question. 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: Task planning section: Based on the problem and the tool call results corresponding to the (n-1)th round target task, plan the decision action for the nth round. The decision action for the nth round is used to indicate the task planning details for the nth round. Based on the decision action for the nth round, retrieve the target task for the nth round from the task stack. The task stack contains currently planned tasks related to the problem, specifically the currently planned tasks in the task stack that have not yet been executed. Task execution section: Based on the background information corresponding to the target task and problem in the nth round, generate tool call information for the target task in the nth round; the background information is determined based on the problem and the execution status of related tasks; the tool is called based on the tool call information to execute the target task in the nth round and obtain the tool call result corresponding to the target task in the nth round.
[0054] Optionally, the above method can be applied to LLM Agent systems. An LLM Agent system refers to an intelligent agent system built using LLM as its core component, also known as the large language model task planning system in this paper, or simply a task planning system. These systems can perform various tasks, from simple information retrieval and text generation to more complex dialogue management, content creation, and even domain-specific decision support.
[0055] In this embodiment, the LLM Agent system is responsible for handling object requests, generating tasks, invoking tools, and summarizing information. Specifically, the LLM Agent system can run on a server or in a cloud environment (such as a cloud server). The server is responsible for storing the LLM Agent system's code, tool pool, database, and other resources, providing the necessary computing power to execute tasks, and handling requests from terminal devices, communicating with the terminal devices via a network. The terminal device, as the front-end device for interaction between the object and the LLM Agent system, can install the aforementioned clients, such as conversational AI software, responsible for receiving input from the object (such as questions or instructions) and sending these requests to the LLM Agent system. Simultaneously, the terminal device will also display the answers or execution results returned by the LLM Agent system.
[0056] In practical applications, task planning capability is one of the core competencies of LLM Agent systems in solving 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 described in this application to the traditional single-agent system. For example, LLM Agent system developers can add the task planning function proposed in this application to a traditional single-agent system by linking the task planning agent to the backend of the tool pool and the tool calling agent on the LLMAPP platform (LLMAPP is a front-end application of the LLM Agent system described in this paper).
[0057] like Figure 2 The diagram shown is a schematic of a large language model task planning system according to an embodiment of this application. The large language model task planning system proposed in this application includes three components: a function call agent, a tool pool, and a task planning agent.
[0058] The tool pool is a centralized collection of various tools or functional modules, providing a flexible and scalable framework that enables tool-calling agents to dynamically load and use the required tools to perform specific tasks. Tools within the tool pool can be scripts, API interfaces, command-line tools, library functions, or containerized services; they are uniformly managed and shared to improve resource utilization efficiency. Furthermore, the tool pool in this embodiment also supports dynamically adding or removing tools, facilitating system maintenance and expansion; these details will not be elaborated further here.
[0059] A tool invocation agent is a component specifically designed to interact with external services. It understands tool invocation information and performs corresponding operations, responsible for executing specific tasks. Its main responsibilities include generating tool invocation information, executing tool invocations, and providing feedback on results. Specifically, the tool invocation agent generates invocation instructions for a specified tool based on task requirements, including the tool category name and necessary tool input parameters. Then, it executes the generated tool invocation information, invoking tools from a tool pool to complete the specific task. Furthermore, the tool invocation agent can report the results of the tool invocation (such as success or failure) to the task planning agent to facilitate decision-making for subsequent tasks.
[0060] The task planning agent is the brain of the entire process, responsible for overall task management and coordination. Its main functions include task scheduling, which determines which subtask should be executed next based on the current state and resource availability. Furthermore, the task planning agent is used to evaluate the effectiveness of the current task execution based on the results returned by the tool's calling agent, and adjust subsequent task plans accordingly.
[0061] In practical applications, the work of these two agents is interdependent. The task planning agent provides high-level policy guidance, while the tool invocation agent is responsible for low-level operation execution. Their interaction ensures that tasks can be completed efficiently and flexibly according to predetermined goals. For example, if a tool invocation fails, the task planning agent can replan subsequent tasks based on the failure information provided by the tool invocation agent, selecting alternative solutions or trying other tools to achieve the final goal.
[0062] In one alternative implementation, the terminal device 110 and the server 120 can communicate via a communication network.
[0063] In one alternative implementation, the communication network is a wired network or a wireless network.
[0064] It should be noted that, Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.
[0065] In this embodiment of the application, when there are multiple servers, the multiple servers can form a blockchain, and the servers are nodes on the blockchain; as disclosed in the task processing method of this embodiment, the task-related data involved can be stored on the blockchain, such as questions, task stacks, tool call results, decision actions, background information, reply information, etc.
[0066] Furthermore, the embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0067] 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: In the field of customer service, LLM agent systems can not only automatically answer common customer inquiries and improve service efficiency, but also predict customer needs through in-depth analysis of customer behavior patterns, providing more precise service solutions, thereby enhancing customer satisfaction and loyalty. For example, they can recommend personalized products or services based on historical interaction records, making the customer experience more personalized.
[0068] In terms of educational support, LLM Agent systems leverage their powerful data processing capabilities to analyze students' learning habits and progress, thereby providing customized learning suggestions and resources to help students overcome learning obstacles and promote efficient knowledge absorption. Furthermore, these systems can also act as virtual teachers, providing real-time Q&A sessions, leading to a more equitable distribution of educational resources and promoting educational equity.
[0069] In the healthcare field, LLM Agent systems, with their ability to understand vast amounts of medical literature and clinical data, can not only provide initial health consultations but also assist doctors in analyzing patient conditions and providing diagnostic support. More importantly, these systems can play a crucial role in patient management and follow-up, monitoring changes in health indicators to warn of potential risks and thus enabling early intervention.
[0070] In the field of content creation, LLM Agent systems have demonstrated their ability to generate high-quality original text, whether it's news reports, professional articles, or literary works, quickly producing content tailored to specific themes and styles. This not only greatly enriches the content market but also provides creators with inspiration, promoting innovation and development in cross-media content production. Furthermore, these systems can be used to automate editing and proofreading processes, improving the efficiency and accuracy of the publishing workflow.
[0071] It should be noted that the application scenarios of LLM agent systems listed above are merely simple examples, and this article does not impose specific limitations on them. Due to their flexibility and adaptability, LLM agent systems can demonstrate broad application prospects in various fields.
[0072] Furthermore, it should be emphasized that the specific embodiments of this application involve relevant data of the object, such as the issues listed above. When the above embodiments of this application are applied to specific products or technologies, permission or consent from the object is required, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0073] The following describes the task processing method provided by the exemplary embodiments of this application in conjunction 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 this application, and the embodiments of this application are not limited in any way in this respect.
[0074] See Figure 3 The diagram shown is a flowchart of a task processing method provided in this application embodiment. Taking the server as the executing entity as an example, the specific implementation process of this method is as follows: S31~S32: S31: Problem with obtaining object input.
[0075] In this embodiment, the object can ask a question, and the server can obtain the question input by the object on the terminal device side. The object can be any object; for example, if the terminal device has conversational AI software installed, the object that inputs the question through that software can be considered an object in S31.
[0076] The questions include, but are not limited to, text, voice, images, videos, and URLs; this article does not make any specific restrictions on these.
[0077] There are many ways to input questions, such as typing, voice input, or selecting from preset questions. The following is a brief explanation of these input methods: Input method 1: Typing input.
[0078] This method is suitable for describing complex problems or instructions in detail, allowing objects to be modified and edited as they are entered, and is applicable to situations requiring precise expression.
[0079] Input method 2: Voice input.
[0080] This method eliminates the need for manual input, making it convenient and quick. It is especially suitable for use in mobile environments or situations requiring two-handed operation, such as sending messages while driving, controlling smart homes, or asking questions when it is impossible to type manually, such as while cooking.
[0081] Input method 3: Select from preset questions.
[0082] This method simplifies the input process and avoids misunderstandings caused by spelling errors or unclear expressions. It is suitable for customer service interfaces, online questionnaires, or any situation that requires standardized answers.
[0083] In addition to the input methods mentioned above, there are some more intelligent ways to input questions, such as gesture recognition input, which uses a camera to capture the object's movements to convey instructions, suitable for accessibility or augmented reality applications; touch screen input, which allows you to directly click or swipe on the screen to input information, suitable for mobile devices and tablets; and graphical interface input, which uses drag-and-drop elements, icon selection, etc. to construct questions, suitable for non-verbal speakers or children.
[0084] The question formats 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, improving the system's ease of use and inclusivity. By combining multiple input methods, the LLM Agent system can provide a more flexible and user-friendly interactive experience.
[0085] As mentioned above Figure 2 Taking the LLM Agent system as an example, once the system is set up, the user can ask questions in a dialogue. After asking a question, the LLM Agent system will autonomously plan tasks, call tools, and ultimately solve the problem. During this process, the user does not need to intervene manually and can see the specific task planning and execution process. Alternatively, the user can focus only on the final answer summarized by the LLM Agent system.
[0086] like Figure 4 As shown, this is a schematic diagram of the front-end operation interface of an LLMAPP according to an embodiment of this application. This interface is an object-oriented interactive interface. An object can open a chat window with the LLMAPP through S41 "Create New Dialogue" in the dialogue list section of this interface, as shown below. Figure 4 In the interface shown on the right, the LLM first introduces itself to the object, such as... Figure 4 The S42 in the message "Hello, this is LLMAPP. You can debug your LLM application here" allows the object to quickly understand the LLMAPP.
[0087] For example, an object can be accessed through... Figure 4 In the chat box S43, the user enters their question to the LLM Agent system. After the question is asked, the LLM Agent system can answer the user's question by planning and executing tasks based on the task processing method in this embodiment, and directly present the response information to the user on the interface.
[0088] In this embodiment of the application, for the object input problem, if the problem is relatively simple, it may only require executing one task to complete; if the problem is relatively complex, it may require executing multiple tasks sequentially. In general, it requires at least one round of task processing. The specific implementation method is as follows: S32: Perform at least one round of task processing based on the question input by the object until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the nth round of task processing includes the following steps S321~S324: S321: Based on the problem and the tool call results corresponding to the (n-1)th round target task, plan the decision action for the nth round.
[0089] The decision action in the nth round is used to indicate the details of the task planning in the nth round. In this application, n is a positive integer.
[0090] As mentioned above, each round of task processing includes two parts: task planning and task execution. S321~S322 is the task planning part, which can be implemented by the task planning agent. S323~S324 is the task execution part, which can be implemented by the agent called by the tool.
[0091] The tool call result for the target task in round n-1 (hereinafter referred to as the tool call result for round n-1, and other information is similar) refers to the result obtained after calling the tool in the previous round of the task execution during the loop process. When n=1, n-1=0, and the result is empty. Correspondingly, the result obtained after calling the tool in the task execution of round n is the tool call result for the target task in round n (hereinafter referred to as the tool call result for round n). The decision action in round n refers to the specific decision generated during the task planning process of round n. Similarly, the decision action in round n-1 refers to the specific decision generated during the task planning process of round n-1. This specific decision indicates the task planning details in the corresponding round, which include, but are not limited to: whether a new task needs to be planned in this round, the type of task to be planned, the current execution count, etc. When n=1, n-1=0, and this decision action is also empty, and other information is similar.
[0092] Specifically, in each round of task planning, the task planning agent, based on a pre-configured task planning strategy, analyzes the previous task execution and plans a decision action, such as the decision action in round n. In this embodiment, a decision action may include operations of one or more task types. Of course, a decision action may not include any specific task; for example, it may directly execute tasks in the task stack, or the LLM may directly generate the final answer or take a default behavior. In practical applications, different previous task execution situations will result in different decision actions, which will be explained in detail below and will not be repeated here.
[0093] S322: Based on the decision action of the nth round, retrieve the target task of the nth round from the task stack.
[0094] The task stack contains currently planned tasks related to the problem.
[0095] Here, the target task of round n refers to the task to be executed in round n of a loop. If round n is considered the current round, then the target task of round (n-1) refers to the task executed in the previous round of the current loop. 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 denoted as... The corresponding tool call results can be recorded as The target task of the nth round can be denoted as... The corresponding tool call results can be recorded as .
[0096] In multi-agent systems, task planning is a crucial step, especially when dealing with complex task sequences and coordination among multiple agents. Besides the task list-based task planning methods mentioned above, multi-agent systems can also employ sequential decision-making-based task planning techniques. This involves planning one step at a time and dynamically determining the next task type after each step. However, these algorithms require re-calling the LLM (Limited Decision Model) for task planning after each step, resulting in significant resource and time consumption and insufficient planning efficiency.
[0097] To overcome this problem, this application introduces a task stack. The task stack can store multiple planned tasks in an orderly manner, ensuring that tasks are executed in a specific order. This helps to clarify task priorities and avoid inefficiencies caused by interference between tasks. Furthermore, the task stack allows multiple small-scale LLM calls to be merged into fewer large-scale calls, reducing the cost of each call. For example, planning suggestions for multiple tasks can be obtained at once, 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.
[0098] like Figure 5 The diagram shown is a schematic of a task stack storage process in an embodiment of this application. Taking the last-in-first-out (LIFO) principle as an example... Figure 5 The process of performing a push operation on an empty stack, gradually pushing tasks onto it, for example, first pushing task a, then task b, then task c, and finally task d, where top represents the top of the stack.
[0099] Following the Last-In-First-Out (LIFO) principle, when performing a pop operation in the task stack and gradually removing tasks, task d is removed first, then task c, then task b, and finally task a.
[0100] Optionally, this application employs a multi-agent framework, constructing a task planning agent and a tool invocation agent, such as... Figure 6 As shown, it is a logical diagram of a task processing based on a multi-agent framework in an embodiment of this application.
[0101] Specifically, each round of task processing is mainly implemented through the interaction of a task planning agent and a function call agent. The steps required in each round of task processing can be divided into two parts: task planning and task execution.
[0102] Task planning refers to generating a series of ordered task sequences (which may be empty) based on the objective and current state before task execution. Task execution, on the other hand, is the execution of the planned tasks.
[0103] In this embodiment, the task planning agent primarily performs task planning, such as receiving a problem and dynamically planning the current round's target task based on the tool invocation results from the previous round's target task, combined with the background information corresponding to the current round, to guide the tool invocation agent in making tool invocations. The tool invocation agent, based on the target task planned by the task planning agent, considers which tool to invoke, generates tool invocation information, such as the tool category name and input parameters, and invokes the corresponding tool from the tool pool to execute the current round's target task. It then obtains the tool invocation results for the current round's target task and sends them back to the task planning agent.
[0104] For example Figure 6 As shown, the tool pool stores tools such as the calculator (for performing mathematical operations and formula calculations), the retriever (for retrieving information and data), the Python sandbox (for executing Python code snippets), and the data analyzer (for analyzing datasets). For example, if the task planning agent plans to calculate the area of a circle in this round, it will call the calculator; if it plans to find the population of city X, it will call the retriever; if it plans to write a simple Python function to calculate the sum of two numbers, it will call the code analyzer; if it plans to analyze a set of sales data to find the month with the highest sales, it will call the data analyzer, and so on.
[0105] Specifically, Figure 6 The framework process shown consists of the following three steps: Step 1: The task planning agent, based on the question input by the user, formulates a task planning strategy. The decision-making action for this round is considered, the task stack is updated, and the top task retrieved from the task stack is taken as the target task for this round, corresponding to the relevant descriptions in sections S321-S322 of this document. Furthermore, the task planning agent will summarize new background information based on the current task stack status, the tool call results corresponding to the target task in the previous round (initially empty), and the problem and historical background information. Specific implementation methods will be described in detail below and will not be repeated here.
[0106] The logic for the task planning agent to plan the current decision action is detailed below. Figure 7 The relevant descriptions will not be repeated here.
[0107] Step Two: The tool invocation agent, based on the problem, the target task of this round, and the current background information (referring to the new background information summarized in Step One), performs reflection and action (ReAct) to generate tool invocation information for the currently required tool, such as the tool category name and tool input parameters, corresponding to the relevant description in section S323 of this document. For specific implementation details, please refer to the following text.
[0108] Step 3: In the tool pool, the tool is invoked according to the tool category name and tool input parameters, and the tool invocation result of the target task in this round is returned, which corresponds to the relevant description in section S324 of this document. For specific implementation details, please refer to the following text.
[0109] ReAct is a framework for constructing intelligent agents, which divides the behavior of the tool-invoking agent in this application into two steps: Reasoning and Acting. In the reasoning phase, the tool-invoking agent infers the optimal action plan based on current information and past experience, generating tool invocation information for the currently needed tool. In the action phase, it executes specific actions, such as invoking external tools or services based on the previous action plan to perform the nth round of the target task. By repeatedly executing these two steps, it gradually approaches the goal until the task is completed.
[0110] The task planning system in this application will repeatedly execute steps one, two, and three until the task planning agent deems it possible to end the process and finally answer the question.
[0111] In the above approach, when the task planning agent plans the nth round of task execution, the tool invocation agent will invoke the corresponding tools according to the specific needs of the task. This not only improves the efficiency of task execution, but also ensures that the task can be completed correctly.
[0112] The design concept of the task planning agent in the embodiments of this application is briefly explained below: This application uses a Markov Decision Process (MDP) to model the task planning process and designs a task stack and task planning strategy. This system employs a task planning agent and utilizes a tool-invoking agent as the task executor, thus constructing a highly flexible and robust task planning system. This system significantly enhances the ability of LLM agent systems to solve complex task problems.
[0113] MDP is a mathematical model for sequential decision problems. In MDP, the changes in the system state follow the Markov property, meaning the current state depends only on the previous state and the action taken, and not on earlier historical states. During this process, the agent acts according to a certain policy based on the current state, enters a new state after executing the action, and observes feedback. The goal of MDP is usually to find a policy (such as the task planning policy in this paper). This maximizes the cumulative reward obtained by the agent over a long period of time.
[0114] In the design of the task planning agent, this application mainly focuses on the following two aspects: first, a closed-loop task planning system model based on MDP; and second, a task stack and task planning strategy-based approach. Task planning technology.
[0115] First, the former uses MDP to model the task planning system, realizing a sequential decision-making task planning and execution framework. It can dynamically adjust the downstream task type according to the execution status of upstream tasks, effectively solving the task dependency problem.
[0116] It should be noted that, besides MDP, other sequential decision-making methods can also be used to model task planning systems in practical applications. For example, 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, making it suitable for scenarios that require progressive task refinement. Reactive Planning can respond to changes in object input and environment in real time, dynamically generating new task sequences, suitable for scenarios requiring rapid response to changes. Partial Order Causal Link (POCL) allows for partial sequential relationships between tasks, rather than a strict linear order, suitable for scenarios requiring flexible adjustment of task order. Of course, other methods not listed are also applicable to the embodiments of this application, and will not be elaborated upon here.
[0117] Secondly, the latter uses a task stack to store planned tasks in a stack format and utilizes task planning strategies. The large model is guided to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions, producing one or more task types, which are stored in the task stack, thereby overcoming the problem of low efficiency in sequential decision-making task planning.
[0118] It should be noted that, in addition to task stacks, other similar methods can be used to store planned tasks in practical applications to overcome the low efficiency of sequential decision-making task planning, such as priority queues. Priority queues can sort tasks according to their priority. During dynamic task planning, the priority of tasks can be dynamically adjusted according to their urgency and importance. This is suitable for scenarios where the order of tasks needs to be dynamically adjusted according to their priority. By inserting and deleting tasks, high-priority tasks are ensured to be executed first.
[0119] Another example is the deque, which allows elements to be inserted and deleted from both ends. In dynamic task planning, tasks can be inserted or removed at any time to adjust the execution order of tasks, making it suitable for scenarios that require flexible control over the insertion and deletion of tasks.
[0120] Another example is the Task Tree, where tasks are organized in a tree structure. Each node can have multiple subtasks. It is suitable for scenarios where tasks have a hierarchical relationship and subtasks need to be managed. Subtasks can be dynamically added or deleted, and the execution order of tasks can be adjusted.
[0121] For example, a task list stores tasks in a list format, which can be executed sequentially or by priority. This is suitable for scenarios where tasks need to be executed in order or by priority. During dynamic task planning, tasks can be flexibly inserted and deleted, and the execution order of tasks can be adjusted.
[0122] The mechanisms listed above each have their advantages in dynamic task planning. The choice of which mechanism to use depends on the specific needs and scenarios. By selecting the appropriate mechanism, dynamic task planning can be managed and executed more effectively, improving the system's flexibility and robustness.
[0123] Of course, other methods not listed are also applicable to the embodiments of this application, and will not be described in detail here.
[0124] The methods listed above also support determining the decision-making actions for each round of task planning based on the tool call results of the previous round's target task. This allows for the effective handling of complex tasks and the provision of timely and accurate responses, such as through task planning strategies. The task list and other information will not be repeated here.
[0125] The following is combined Figure 7 The process of task planning based on a task planning agent in the embodiments of this application is briefly described below: See Figure 7As shown, this is a logical diagram illustrating task planning based on a task planning agent in an embodiment of this application. This application categorizes tasks into two types: main tasks and side tasks, such as... Figure 7 The listed task stack includes the following main tasks: Main Task 1, Main Task 2, ..., Main Task N, and the following side tasks: Side Task 1, Side Task 2.
[0126] in, Figure 7 The task planning logic shown is, simply put, the task planning strategy mentioned above. The large model is guided to conduct a scientific process analysis of the results of executed tasks in order to generate new decision-making actions.
[0127] Optionally, when planning the current decision-making action, such as Figure 7 As shown, it is necessary to comprehensively consider the task type of the previous task (such as main quest or side quest) and the result of the tool call (such as success or failure). Different combinations correspond to different decision actions. Simply put, they can be divided into the following four situations: If the target task in the previous round was the main task and was executed successfully, then the decision action in this round is: plan a new main task or execute according to the task stack. The specific decision action to take depends on whether the current task stack is empty.
[0128] If the target task in the previous round was the main task and failed to execute, the decision action in this round is: plan a new side task, replan the main task, retry N times, or end directly after reaching the retry limit. The specific decision action to take depends on whether there were side tasks in the target task in the previous round and whether the number of times the side tasks were repeated has reached the limit.
[0129] If the target task in the previous round was a side task and it was executed successfully, then the decision action in this round is: return to the main task in the task stack.
[0130] If the target task in the previous round was a side task and failed to execute, the decision action in this round is: plan a new side task, replan the main task, retry N times, or end directly after reaching the retry limit. The specific decision action to take depends on whether the number of times the side task in the previous round was repeated has reached the limit.
[0131] Task planning agents based on task planning strategies After considering the decision-making 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. Then, the task at the top of the stack is popped 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 status, the tool call results corresponding to the target task of the previous round (hereinafter referred to as the previous round tool call results), the questions input by the object, and historical background information. The specific implementation method will be described in detail below and will not be repeated here.
[0132] The task planning process in S321 is explained in detail below: For a task planning problem, this application proposes to model the decision process using MDP. In MDP, the changes in the system state follow the Markov property, that is, the current state depends only on the previous state and the action taken, and not on earlier historical states. The task planning intelligence can take action according to a certain strategy based on the current state.
[0133] Accordingly, in this application embodiment, an optional implementation method is as follows: Based on the input question, current background information, tool call results from the previous round (e.g., round n-1), decision actions from the previous round, target tasks from the previous round, and the current task stack, update the system state; based on the updated system state, plan the decision actions for the current round (e.g., round n).
[0134] The questions raised by the object ensure that decisions always revolve around the object's core needs. Current background information provides context for the current task execution, aiding in understanding the task's latest progress. The results of the previous tool call reflect the actual effect of the previous operation, helping the system evaluate the current state. The previous decision action records the decision made in the previous step, facilitating traceability and adjustment. The previous target task clarifies the task objective of the previous step, ensuring the continuity of the planned tasks. The current task stack provides the execution order and dependencies of tasks, ensuring orderly execution.
[0135] In this application, when performing several rounds of task processing in a loop, the system state needs to be obtained in each round. Decision-making and action and tool call results Specifically, the question of inputting objects is... This indicates that in the nth round of task processing, the system state is as follows: express, Including known background information The result of the tool call in the (n-1)th round Decision-making actions in the (n-1)th round The target task executed in the (n-1)th round The task stack before the update in round n is: (Updated to) ),Right now: .
[0136] Initially, 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.
[0137] Of course, in addition to these, other information from the previous round can also be referenced to determine the system status. For example, object feedback can be consulted; real-time feedback from objects can provide important information to help the system adjust task planning and improve object satisfaction. Historical task records can also be referenced, as they can help the system identify common problems and solutions, improving task processing efficiency. Furthermore, task dependencies can be considered; understanding the dependencies between tasks ensures that the order and dependencies of tasks are handled correctly, avoiding task conflicts. Finally, resource status can be considered; the current availability of resources (such as computing resources and network bandwidth) affects task execution, ensuring effective resource utilization.
[0138] By comprehensively considering these factors, the system can gain a more complete understanding of the task's background and status, thereby making more reasonable and efficient decisions.
[0139] Optionally, when determining the system state, the specific content of the target task mentioned here includes, but is not limited to: guidance on the execution of the task. (For example, if this task calls a tool, how should tool input be performed?) This task category... (Main quest or side quest) and the number of times the task is called repeatedly. (i.e., the current execution count, for example) ),Right now: .
[0140] Of course, in addition to these, the task content can also include: the importance and urgency of the task; the current status of the task, such as not started, in progress, paused, completed, or failed; the dependencies between the task and other tasks; the time limit for the task to be completed within a specific time; the expected output after the task is completed; environmental information for task execution, such as network conditions and computing resources; historical execution records of the task, including previous execution results and feedback; the specific reasons for task failure; and so on. By comprehensively considering these task contents, the system can gain a more comprehensive understanding of the background and status of the task, thereby making more reasonable and efficient decisions. This information helps improve the flexibility, adaptability, and robustness of task planning.
[0141] In the embodiments of this application, based on The task planning agent in the task planning system will utilize task planning strategies. Make plans and take action. (That is, the decision action in the nth round), namely: .
[0142] Then, actions can be taken based on the decision made in the nth round. Update the task stack by to The system retrieves the current task, invokes the tool, and repeats this process until the preset termination condition is met. The specific execution flow of the task planning system will be explained below.
[0143] In this embodiment, the information such as the current background information, the result of the previous tool call, the previous decision action, the previous target task, and the current task stack accurately reflects the previous state and the actions taken. Based on this information, and combined with the question raised by the object, the system state is updated to determine the current state. This allows for efficient and accurate planning of decision actions based on the current state. By comprehensively utilizing this information to plan the current round of decision actions, the flexibility, adaptability, robustness, and efficiency of task planning can be significantly improved, while also enhancing the system's transparency and traceability. Especially when a task fails or the result does not meet expectations, the system can replan based on the current state to ensure the smooth execution of the task.
[0144] The specific design of the task planning in this application is explained below: In the design of the task planning agent, this application designs a task planning strategy. The task planning agent in the task planning system will utilize task planning strategies. Planning and task planning strategies The large model is guided to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions, producing one or more task types, which are stored in the task stack, thereby overcoming the problem of low efficiency in sequential decision-making task planning.
[0145] 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 sub-task or decision point; (2) Logical path: Each node is connected by logical relationships to form one or more logical paths, which guide the LLM to reason and generate according to the predetermined ideas; (3) Dynamic adjustment: The Tree of Thoughts can dynamically adjust the path according to the progress of the task execution and the intermediate results to ensure that the generated content always meets the expected goals.
[0146] In this embodiment of the application, the task planning strategy The goal of answering the questions posed by the audience is broken down into multiple smaller tasks, and these tasks are organized in a hierarchical structure. This helps LLM to reason and generate more systematically, and is a task planning strategy. The generation path can also be dynamically adjusted based on task progress and intermediate results, improving flexibility.
[0147] The task planning strategies in the embodiments of this application are described below. Please provide a detailed explanation: In this embodiment of the application, tasks are divided into two categories: main tasks (or simply main tasks) and side tasks.
[0148] 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 address the main questions or needs raised by the object. It is usually the most important part of the entire process and directly affects the achievement of the final goal. It requires LLM to accurately understand the core of the problem, provide clear, accurate and direct answers, and ensure the correctness and usability of information to meet the object's primary needs.
[0149] Side tasks are optional auxiliary tasks that can be completed while the main task is being done. They are used to address non-core needs or potential problems related to the main task while handling the main request of the object. For example, they can provide additional background information, suggestions, or extended knowledge to enhance the object's overall understanding and experience. Although this information is not necessary, it can increase the richness and value of the answer.
[0150] Based on this, the task processing flow in this application can be designed as an ordered process, in which each step determines the next action based on the result of the previous step. Of course, in the first round of task processing, there is no previous step. Therefore, in S321, an optional implementation method is as follows: First, based on the current system state, analyze whether the target task in round n-1 is empty.
[0151] If the target task of round (n-1) is empty, it means that round n is actually the first round of task processing. The previous task stack is empty, and correspondingly, the target task of round (n-1) is also empty. In other words, the task to be processed in the current round is the first task. Since the task stack is empty, some main tasks need to be generated to execute first.
[0152] 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 round n-1, etc., it is only necessary to generate tasks based on the problem.
[0153] Optionally, if the target task in round n-1 is empty, then the decision action in round n is: based on the problem, generate at least one main task and set the number of executions of the newly generated main task to the initial value. This helps to observe the progress of the task and possible repeated executions.
[0154] The initial value can be any number and can be flexibly set according to actual needs in practical applications. This article does not make specific restrictions. Generally, it can be set to 0, indicating that a certain task has not been executed before.
[0155] Based on this, each subsequent execution of the task will update the execution count. The update method is: latest execution count = current execution count + preset step size. The preset step size can be any value and can be flexibly set according to actual needs in practical applications. This article does not impose specific limitations, but it can generally be set to 1, meaning that the execution count increases by 1 for each previous execution.
[0156] In the first round of task processing (n=1) for a certain problem, this application plans the decision-making actions. (i.e., the decision action in the nth round): based on Generate a series of main quests ( , ).
[0157] Specifically, by analyzing the questions or instructions provided by the object, extracting key information, understanding its core needs, and based on this information or needs, generating at least one clear, specific, and executable main task to directly respond to the object's request, ensuring that the answer is accurate and targeted.
[0158] In the embodiments of this application, these newly generated main tasks should be the core parts that can directly solve the problem, so as to ensure that an effective workflow can be built from scratch without historical task data, and the life cycle of the task can be managed by counting the number of executions.
[0159] Below are a few simple examples of generating main tasks based on questions: Example 1: Suppose the question is: "I want to know how to make pizza at home." Based on this, a main task can be generated, which is: provide a simple home pizza recipe, including a list of required ingredients and step-by-step instructions.
[0160] Example 2: Suppose the problem is: "Please help me find the nearest library and tell me how to get a library card." Based on this, two main tasks can be generated: Main task 1 is: find the location of libraries near the target, and main task 2 is: list the steps and required documents for obtaining a library card at each library found. Main task 2 depends on main task 1.
[0161] Example 3: Suppose the problem is: "I can't open the Word document on my computer, it says there's a formatting error, what should I do?" Based on this, a main task can be generated, which is: to guide the user to repair the damaged Word document, including trying to use recovery tools or converting the document format.
[0162] The main tasks listed above directly address the needs of the target audience and provide specific and effective solutions.
[0163] In this embodiment of the application, the specific number of main tasks generated is not limited; it can be one, two, or even more.
[0164] Conversely, if the target task of round (n-1) is not empty, it indicates 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).
[0165] In subsequent rounds of task processing, considering the nature of the target task in round n-1 and the results of its tool calls, we can better connect the tasks before and after, ensuring consistency and coherence in decision-making, and thus more effectively plan the action plan for round n. Therefore, when making decisions, in addition to referring to the tool call results corresponding to the target task in round n-1, we can also refer to the task type of the target task in round n-1. Of course, in addition to this, we can also refer to some other information from round n-1, such as feedback from the reference object, historical task records, task dependencies, resource status, etc.
[0166] Optionally, if the target task in round n-1 is not empty, then the decision action in round n is planned based on the task type and tool call result of the target task in round n-1.
[0167] Specifically, evaluating the results of the tools or methods used in the (n-1)th round of the target task can help determine whether the target task in the (n-1)th round was successfully completed, or whether the strategy needs to be adjusted. Furthermore, determining the type of action to take next, based on the type of target task in the (n-1)th round, can identify whether the strategy to continue or the method to be changed in the nth round, ensuring the consistency of the overall process and the alignment of the goals.
[0168] In this application embodiment, the next decision-making action 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 side task or main task. Of course, if it is determined that the question has been answered or cannot be answered further, the next decision-making action based on the above analysis also includes, but is not limited to: completion, failure, etc.
[0169] The planning logic listed above ensures that each task is optimized and adjusted based on feedback from previous work, thereby improving the efficiency and accuracy of problem-solving. In this way, it is possible to dynamically adapt to new situations or unforeseen problems that arise during the process.
[0170] It should be noted that the above is a simplified explanation of the decision-making process based on whether the current round is the first round. In general, in the first round, it is sufficient to plan the main task based on the problem. However, in other rounds, it is necessary to plan the decision actions based on some details related to the target task of the (n-1)th round, such as the task type and the results of tool calls.
[0171] See Figure 8 As shown, it is a logical diagram of the first planning round n decision action in the embodiments of this application. Figure 8 This means first determining the target task for round n-1 based on the current system state. Is it empty? If so, then determine the decision action for the nth round: Based on the problem, generate a series of main tasks, and set the execution count of these newly generated main tasks to 1, i.e. :based on Generate a series of main quests ( , Otherwise, use (i.e., the task planning agent) determines whether the target task in round n-1 was successfully executed or failed. Based on the judgment result, the cases are discussed separately. If the execution fails, it is divided into the following failure cases 1, 2, and 3. If the execution is successful, it is divided into the following success cases 1 and 2. For details, please refer to the relevant introduction below, which will not be repeated here.
[0172] The planning process for decision-making actions in rounds other than the first round will be explained in detail below: As the above shows, in other rounds, the decision-making actions for the nth round need to be planned based on the task type and tool call results of the target task in the (n-1)th round. This application considers that the success or failure of the task directly affects the direction of subsequent decisions. If the target task in the (n-1)th round fails, it is necessary to first resolve the remaining issues or try different strategies; if successful, it is possible to decide whether to continue advancing the main process or start a new branch based on the task type (main line or side line). This ensures that each decision is based on the latest and most effective information, improving the efficiency and success rate of the overall process. Therefore, it is possible to first analyze whether the target task in the (n-1)th round was successful based on the tool call results, and then make different decisions based on the task type.
[0173] Therefore, when planning the decision-making action for the nth round based on the task type and tool call results of the (n-1)th round target task, one possible implementation method is: Based on the tool call results corresponding to the (n-1)th round of target tasks, analyze whether the (n-1)th round of target tasks was successfully executed; specifically, there are the following two cases: (i) If the target task in round n-1 fails to be executed, then the decision action in round n is planned based on whether there are side tasks in the target task in round n-1.
[0174] In other words, If execution fails, then according to Do side quests exist? Determine. .
[0175] Specifically, if the target task in round n-1 fails, check if there are any side tasks in the target task of round n-1. If there are side tasks, these side tasks may need to be prioritized to support or correct the execution of the main task. For example, a side task might be to provide the necessary resources or conditions to overcome obstacles in the main task. If there are no side tasks, the main task can be re-planned.
[0176] In other words, to address situations where task execution fails to achieve the expected results, this application categorizes tasks into two types: main tasks and side tasks. For cases where main tasks fail, a task planning strategy is implemented. This will guide the LLM to determine whether to re-execute the task or retain the main task while adding new side tasks, thereby enhancing the robustness of the agent system in the event of task failure.
[0177] Assume each task has a preset maximum number of retries, denoted as . This indicates the maximum number of times each task can be attempted when answering a question. The maximum number of retries can be the same or different for different tasks. When different tasks are set with different maximum retries, the system can flexibly adjust the retry strategy based on the characteristics and importance of the tasks.
[0178] One possible implementation is to plan the decision-making action for the nth round based on whether there are side tasks in the target task of the (n-1)th round, and then consider the following cases: (1) Execution failure scenario one: If the target task in round n-1 has a side task, then the decision action in round n is: generate the corresponding side task, and set the number of times the side task is executed to the initial value; Specifically, when there are side tasks in the (n-1)th round of the target task, it means that the main task may depend on the completion of certain auxiliary tasks. In this case, the decision action in the nth round is to generate new side tasks and set the execution count of the side tasks to an initial value, such as 1 in the above example. This indicates that the system will prioritize processing these side tasks to support the completion of the main task.
[0179] In other words, Execution failed, and When side quests exist, To generate the corresponding side quests ( , ).
[0180] When generating corresponding side tasks, in order to provide necessary support for the main task and ensure the achievement of the final goal, the number of tasks to be generated can be determined based on the complexity of the task, resource availability, and time constraints. By analyzing the tool call results and core requirements of the target task in round n-1, a necessary number of auxiliary tasks are generated to support the completion of the main task.
[0181] Suppose the main task is to "help the subject book a flight," but the subject doesn't have enough points when attempting to book. In this case, the generated side tasks could include: querying and acquiring points: helping the subject find ways to earn more points; confirming points redemption rules: confirming whether points can be directly used for flight bookings, or if there are other redemption rules; exploring alternatives: if points are insufficient and cannot be obtained in the short term, exploring other payment methods or other relevant companies. These side tasks are all designed to support the successful completion of the main task, ensuring the subject can successfully book a flight.
[0182] In this way, the system can handle complex task chains in a more organized manner, improving the efficiency and success rate of task completion.
[0183] (2) Execution failure scenario two: If there are no side tasks for the target task in round n-1, and the number of times the target task in round n-1 has been executed has not reached the upper limit, then the decision action in round n is: re-plan the task based on the target task in round n-1; Specifically, if the target task in round n-1 has no side tasks, but the number of times the task itself has been executed has not reached the preset maximum number of retries, then the decision action for the current round is to re-plan the task of the previous round and achieve the task objective by adjusting the strategy or method.
[0184] Specifically, replanning a task means replanning the current task. If the target task for the nth round has not yet been determined, the current task is the target task for the (n-1)th round. In other words, replanning the target task for the (n-1)th round means continuing to execute the target task for the (n-1)th round, keeping the task type unchanged, and increasing the number of executions by a preset step size, such as +1.
[0185] In other words, Execution failed. There are no side quests, and hour, To re-plan the current task ( , ).
[0186] Assume the main task is to "find and provide the address of the nearest library", and the maximum number of retries is... Set to 3 times: for example The search attempted to parse the object's location information and search for nearby libraries, but failed due to unclear object location information. The execution count is 1, which is less than the maximum retry count of 3, and there are no side tasks. Therefore, according to... In the event of failure, the decision action in round n is to replan the current task. The task type remains the main task "find the nearest library address," but the number of executions increases from 1 to 2, allowing for subsequent queries to obtain more specific location information. After obtaining more information, the search for the nearest library is attempted again.
[0187] In general, each time When a task fails but the maximum number of retries has not been reached, the task planning agent will replan the current task, increasing the likelihood of success by acquiring more detailed information. This process refines the requirements of the task, ultimately aiming to solve the problem.
[0188] In this way, the system will replan and try to execute the same task again each time a task fails but the maximum number of retries has been reached, until the task succeeds or the maximum number of retries has been reached.
[0189] (3) Execution failure scenario three: If there are no side tasks for the target task in round n-1, and the number of times the target task in round n-1 can be executed has reached the limit, then the decision action in round n indicates that the task processing has failed.
[0190] Specifically, if the target task in round n-1 has no side tasks, and the number of times the task has been executed has reached the preset 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 target, therefore it is determined that this task cannot be completed by the current means.
[0191] In other words, Execution failed. There are no side quests, and hour, This indicates a failure (i.e., the task processing failed).
[0192] The main task remains "find and provide the address of the nearest library", with a maximum number of retries. For example, if we set it to 3 times: Suppose that after multiple attempts, the search still fails, and the maximum number of retries (3) has been reached, then 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 task failure affects the execution of other subsequent tasks, it indicates that the question cannot be answered, meaning that not only this task has failed, but the entire processing process has also failed. Conversely, if the task failure does not affect the execution of subsequent tasks, then the planning of subsequent tasks can continue.
[0193] In this embodiment, by setting a maximum number of retries, the system can avoid endlessly looping through unsolvable problems, thus preventing resource waste. When the maximum number of retries is reached, the system can clearly determine that the task has failed and take appropriate measures, such as notifying the recipient or logging the error. Furthermore, by limiting the number of retries, the system's resource usage can be effectively managed, ensuring that excessive resources are not consumed on a task that is unlikely to succeed.
[0194] The logic described above, which plans the current round's decision-making actions based on the previous round's task status, helps the system dynamically adjust its strategy when encountering task failures, considering the availability of auxiliary tasks and the limit on the number of attempts. This ensures that the problem is solved as efficiently as possible within a limited number of attempts. When a side task is available, it is processed first; when the main task fails multiple times, ineffective efforts are stopped promptly to avoid meaningless repetitive operations. This approach improves the flexibility and efficiency of task management.
[0195] See Figure 9 As shown, it is a logical diagram of the second planning round n decision action in the embodiments of this application. Figure 9 The target task in round n-1 is introduced. Not empty, and use (That is, the task planning agent) determines that if the target task in round n-1 fails, it plans three possible actions for round n, corresponding to failure scenarios one, two, and three mentioned above. In simple terms: Failure scenario 1: If the target task in round n-1 has side tasks, the decision action for round n is: generate the corresponding side tasks, and set the execution count of these newly generated side tasks to 1, i.e. Generate side quests ( , ); Failure Scenario 2: If the target task in round n-1 has no side tasks, and the execution count of the target task in round n-1 has not reached the maximum retry count, then the decision action for round n is determined as follows: re-plan the current task based on the target task in round n-1, i.e. Re-planning the current task ( , ); Execution failure scenario three: If the target task in round n-1 has no side tasks, and the execution count of the target task in round n-1 has reached the maximum retry count, then the decision action for round n indicates: task processing failed, i.e. :fail.
[0196] For specific implementation methods, please refer to the above embodiments, which will not be repeated here.
[0197] The above details several scenarios where the target task fails in round n-1. In general, considering that previous task failures may require prioritizing side tasks, new side tasks can be planned. If no side tasks exist, the main task can be replanned. The process can end directly after N retries (the maximum number of planning rounds) or reaching the retry limit (the maximum number of retries).
[0198] In this embodiment, through dynamic analysis and planning of decision-making actions, the system can flexibly respond to changes in tasks, ensuring the continuity and consistency of task processing. Furthermore, the system can provide timely feedback on task processing status, offer some feasible solutions, reduce user waiting time and frustration, and improve user satisfaction and trust.
[0199] Next, we will explain in detail the several scenarios in which the target task in the (n-1)th round is successfully executed: (ii) If the target task of the (n-1)th round is successfully executed, then the decision action of the nth round is planned according to whether the target task of the (n-1)th round is the main task.
[0200] In other words, If the execution is successful, then according to Is it a main quest? Determine. .
[0201] Specifically, if the target task in round (n-1) is successfully executed, it is necessary to further determine whether the target task in round (n-1) is a main task. If it is a main task, it usually means that the next main action can be carried out as originally planned. If it is a side task, then there is no need to generate a new task, and the next action can be determined based on the status of the main task.
[0202] For example, if all side quests have been completed, then efforts can be focused back on the main quest. This analytical approach helps the system make reasonable decisions in complex and ever-changing task environments, ensuring the effectiveness and consistency of the task flow.
[0203] The following is based on Is it a main quest? Determine. Here are some specific explanations for the following situations: When planning the decision-making actions for the nth round based on whether the target task of the (n-1)th round is the main task, there are two cases: (1) Successful execution scenario one: If the target task in round n-1 is the main task and the task stack is empty, then the decision action for round n is planned based on whether the questions have been answered.
[0204] Specifically, if the target task in round (n-1) is the main task and the current task stack is empty, then it is necessary to check whether the object's problem has been fully answered or resolved. One possible implementation is as follows: Successful execution sub-case one: If the question has been answered, it means that the question raised by the user has been fully answered or resolved. In this case, the decision action for the current round is "Complete," indicating that the system has determined that sufficient information or solutions have been provided to meet the user's needs, and no new tasks or further actions are required. "Complete" in this case can include closing the task, ending the dialogue, clearing relevant context information, etc., to ensure that the system is ready to receive the next request or dialogue.
[0205] In other words, Execution successful. When the answer is empty and all questions have been answered, To be completed.
[0206] Successful execution sub-case two: If the question is not fully answered, it indicates that the question raised by the object has not been completely resolved. In this case, it may be necessary to generate a new task to continue processing the remaining unresolved parts. Optionally, the decision action in round n represents: based on the question, background information, and the tool call result corresponding to the target task in round n-1, generate at least one main task, and set the execution count of the main task to an initial value, such as 1, which helps to manage and observe the independent progress of each task and avoids confusion between the states of different tasks.
[0207] In other words, Execution successful. If the answer is empty and the question has not been fully answered, Based on Generate a series of main quests ( , ).
[0208] In this case, the newly generated main quests will target the unresolved parts of the problem, aiming to supplement missing information or provide further assistance, and the number of main quests to be generated will depend on the actual situation, which is not specifically limited in this article.
[0209] In this embodiment, by analyzing the problem and the background information of the (n-1)th round, it can be ensured that the generated new tasks can cover the unresolved parts of the problem; by utilizing the results of tool calls corresponding to the target task in the (n-1)th round, the current state of the problem can be better understood, and the next action plan can be formulated based on this. Generating new main tasks based on this existing information can ensure that they remain coherent with previous tasks, forming an orderly task flow, thereby improving the efficiency of problem solving.
[0210] In summary, that is Execution successful. It is the Lord, and When it is empty, use Determine if the question has been answered completely: If the answer is complete, then Completed (i.e., task processing has been completed); If the answer is not completed, then Based on Generate a series of main quests ( , ).
[0211] Suppose the question is: "Please help me find the nearest library and tell me if book A is there." For example, the objective task (main task) in the (n-1)th round is to find the nearest library, and the task is executed successfully. At this point, we analyze whether the current task stack is empty. Assuming that the task stack is empty, we can use the task planning agent to check whether the question "Please help me find the nearest library and tell me if there is book A there" has been answered.
[0212] Clearly, although the nearest library has been found, the availability of book A has not yet been confirmed. The question is not yet fully answered. In this case, based on the question (confirming book availability), the background information from round n-1 (the nearest library is public library B), and the tool call result corresponding to the target task in round n-1 (the nearest library has been found), a new main task is generated. The new task type is "main," and the execution count is set to the initial value of 1. For example, the following two specific tasks are generated: Task 1: Check the book inventory of public library B. Type: Primary, Number of executions: 1, Objective: Confirm whether book A is in stock.
[0213] Task 2: If book A is in stock, help the object reserve the book. Type: Main, Number of executions: 1, Objective: Ensure the object can reserve the book.
[0214] It should be noted that the above examples are just simple illustrations. Of course, when generating new main tasks, in addition to generating new main tasks based on the problem, background information, and the tool call results corresponding to the (n-1)th round target task, the following information can also be referenced to generate main tasks: For example, considering the object's preferences and historical behavior, such as past request patterns and frequently used service channels, can help generate tasks that better match the object's expectations. Another example is considering the object's current context, such as time, location, and other external factors. This information helps the system better understand the object's actual needs and generate more accurate tasks. Furthermore, utilizing information from knowledge bases and databases can supplement key data points that may have been missed in the (n-1)th round of the target task, thus generating more comprehensive tasks. In addition, clarifying the object's ultimate purpose ensures that the generated tasks directly address the final goal, avoiding deviations from the core requirements. In some cases, if the object provides additional feedback or instructions in the (n-1)th round of the target task, this information can also be taken into account to generate tasks that are closer to the object's actual needs.
[0215] It should be noted that the reference information listed above can also be used in combination. For example, it can be combined with the object's preferences and historical behavior as well as the object's current context to generate a more accurate main task, etc. This article does not make specific limitations on this.
[0216] Let's take the above-mentioned question as an example: "Please help me find the nearest library and tell me if they have book A." A new main task can be generated based on the problem, the background information of round n-1, and the tool call results corresponding to the target task of round n-1. The type of the new task is "main", and the number of executions is set to the initial value of 1.
[0217] Of course, additional information can also be considered, such as the object's preferences: the object frequently visits the library on weekends and likes to reserve books. Context: the current time is Friday afternoon, and the object may be planning to go to the library this weekend. Knowledge base information: the opening hours and reservation process of public library B. Object feedback: the object mentions having a library membership card but is unsure if it has expired, etc., generating the following specific tasks: Task 1: Check the book inventory of public library B. Type: Primary, Number of executions: 1, Objective: Confirm whether book A is in stock.
[0218] Task 2: Help the recipient reserve the book. Type: Primary, Number of executions: 1, Objective: Ensure the recipient is able to reserve the book.
[0219] Task 3: Confirm the membership card status of the recipient. Type: Primary, Number of executions: 1, Objective: Ensure the membership card is valid so that the recipient can borrow books smoothly.
[0220] In the above implementation, after the main task is completed, the system checks whether the questions raised by the target have been answered. The system ensures that the task processing flow ends when the previous round of target task is successful and all questions are fully answered, ensuring the integrity of the task loop and preventing omissions or unresolved issues. It also ensures that if the previous round of target task is successful but the questions are not fully answered, a new main task is generated to continue solving the problem, thus ensuring that the target's questions are fully resolved. Simultaneously, generating new main tasks based on the above information ensures that the generated main tasks not only solve the current part of the problem but also prepare for subsequent steps, ensuring the continuity and effectiveness of task management and problem-solving. This generates more comprehensive main tasks that are tailored to the target's actual needs, ensuring that the target's questions are thoroughly resolved in the future.
[0221] (2) Successful execution scenario two: Otherwise, the decision action in the nth round is: do not generate a new task.
[0222] Specifically, this actually includes the following two sub-cases where no new tasks are generated: Successful execution sub-case 3: If the target task in round n-1 is the main task, but the task stack is not empty, then the decision action in round n is: do not generate a new task.
[0223] That is, in Execution successful. It is the Lord, but If it is not empty, To avoid generating new tasks.
[0224] Specifically, in If the stack is not empty, it means there are still unfinished tasks in the current task stack. Therefore, there is no need to generate new tasks; you can simply retrieve a task from the task stack and execute it.
[0225] Let's take the above-mentioned question as an example: "Please help me find the nearest library and tell me if they have book A." For example, the objective task (main task) of the (n-1)th round is to find the nearest library and execute it 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.
[0226] In this case, there is no need to generate a new main task. After the target task in round n-1 is successfully executed, the tasks in the current task stack will be executed sequentially until the problem is completely resolved.
[0227] In the above implementation, determining whether to generate a new task by checking whether the task stack is empty can avoid creating unnecessary tasks when there are already tasks to be processed, ensure that existing resources are allocated and used reasonably, and ensure that the task stack does not become chaotic due to duplicate tasks. This helps to maintain the orderliness of task management, ensures the efficient operation of the task planning system, and ensures that problems can be handled in a timely and complete manner.
[0228] Successful execution sub-case four: If the target task in round n-1 is not the main task (but a side task), then the decision action in round n is: do not generate a new task.
[0229] That is, in Execution successful, but In the case of support, To avoid generating new tasks.
[0230] In practical applications, side tasks usually provide the necessary prerequisites or auxiliary information for the main task. Therefore, the completion of a side task means that a part of the current task chain has been solved. At this time, the main task can continue without worrying about the missing part of the task. Furthermore, if the side task has been successfully executed, the main task already has the necessary auxiliary information or resources. Generating a new task may cause duplication of work and waste of resources.
[0231] Therefore, in the above If it is a side quest rather than a main quest, then considering quest dependencies, completeness, and avoiding redundancy, there is no need to generate a new quest.
[0232] Let's take the above-mentioned question as an example: "Please help me find the nearest library and tell me if they have book A." For example, the target task (side task) in the (n-1)th round is to obtain the current location information of the object. After successful execution, the main task can be continued by referring 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.
[0233] In the above implementation, the completion of these side tasks provides the necessary prerequisites for the main task. Therefore, 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 continuity of task execution, and ensuring the effective use of resources.
[0234] See Figure 10 As shown, it is a logical diagram of the third planning round n decision action in the embodiment of this application. Figure 10 The target task in round n-1 is introduced. Not empty, and use (i.e., the task planning agent) determines that if the target task in round n-1 is successfully executed, it plans two possible actions for round n, which correspond to the above-mentioned successful execution situation one (including successful execution sub-situations one and two) and successful execution situation two (including successful execution sub-situations three and four).
[0235] In practical applications, if the target task is successfully executed in the (n-1)th round, the following logic can be used to plan decision-making actions: Determine whether the objective task in round (n-1) is a main task; If the target task in round n-1 is a main task, then it is necessary to further analyze whether the task stack is empty, which can be divided into four cases: If the task stack is empty, then plan the decision action for the nth round based on whether all questions have been answered: Corresponding to the first successful sub-case mentioned above: If the answer is completed, then the decision action in the nth round indicates that the task processing is complete, i.e. :Finish; Corresponding to the second successful sub-case mentioned above: If the answer is not completed, the decision action in the nth round means: based on the question, the current background information, and the tool call result corresponding to the target task in the (n-1)th round, generate at least one main task, and set the execution count of the main task to 1, that is... :based on Generate a series of main quests ( , ).
[0236] Corresponding to the third successful sub-case mentioned above: if the task stack is not empty, then the decision action in the nth round indicates: do not generate a new task, that is... : Do not generate new tasks.
[0237] Corresponding to the above successful execution sub-case four: If the target task in round n-1 is a side task, then the decision action in round n is: do not generate a new task, that is... : Do not generate new tasks.
[0238] In the above implementation, if the target task in the (n-1)th round is not a main task (i.e. a side task), or if it is a main task but the task stack is not empty, the main task in the task stack can continue to be executed. In this way, no new tasks are generated, which can avoid creating unnecessary tasks repeatedly when there are already tasks to be processed.
[0239] It should be noted that if there are multiple target tasks in the previous round during a certain round of task processing, and a target task in the previous round meets the execution failure conditions listed above, then the corresponding decision-making actions in this round can be planned using the methods listed below. Conversely, if a target task in the previous round meets the execution success conditions listed below, then the corresponding decision-making actions in this round can be planned using the methods listed below.
[0240] In other words, there is no limit to the number of decision actions generated in each round. If multiple tasks were executed in the previous round, multiple decision actions can be planned for the next round. For example, if the target tasks in the previous round were: Task 1: Generate practice questions, and Task 2: Provide learning suggestions. If Task 1 fails but Task 2 succeeds, and the failure of Task 1 does not affect the execution of Task 2, then decision actions can be planned separately based on the execution status of the two tasks. For example, based on Task 1, the decision action planned is: Repeat Task 1. Based on Task 2, the decision action planned is: Generate a new main task.
[0241] Of course, to ensure the successful execution of subsequent tasks, we can first plan based on the scenario of failure, and then plan based on the scenario of success. Taking the above-mentioned scenario as an example, the failure of Task 1 may prevent the completion of the newly generated main quest. In this case, we can first plan the decision action based on Task 1 as: repeat the execution of Task 1. After Task 1 is executed successfully, we can then plan new decision actions based on Task 1 and Task 2, and so on.
[0242] The specific adjustments can be made flexibly based on the actual situation and the dependencies between tasks, which will not be elaborated on here.
[0243] In this way, the system can flexibly handle multi-task concurrency, ensuring the continuity and consistency of task processing. The number of decision actions generated in each round is not limited and can be dynamically adjusted according to actual conditions. This mechanism not only improves the flexibility and robustness of task processing but also optimizes resource utilization and enhances the user experience.
[0244] It should be noted that the above methods are just simple examples; for instance, task planning strategies can also be used. Combining it with paired-end sequences, or using other combinations, can achieve the same effect, which will not be repeated here.
[0245] In the above implementation, the nth round of decision-making action is planned based on the system state. Then, actions can be taken based on the decision made in the nth round. Update the task stack to The system retrieves the current task, invokes the relevant tools, and repeats this process until the preset termination condition is met. The specific execution flow of the task planning system is as follows: In one optional implementation, before retrieving the target task of the nth round from the task stack according to the decision action of the nth round, it is also necessary to analyze whether the decision action of the nth round is a specified decision action, wherein the specified decision actions include: task processing has been completed, task processing has failed. If the decision action in round n is neither a completed task nor a failed task, but another decision action, then the target task of round n can be retrieved from the task stack based on the decision action in round n, and the subsequent process can continue. This ensures the continuity and consistency of task processing, dynamically adjusts the task order, and improves the flexibility of task processing.
[0246] If the decision action in the nth round is "task processing completed", it means that the question has been answered and the preset termination condition has been met. At this point, task processing can be stopped, and the reply information can be output. This timely termination of the task can avoid unnecessary waste of resources and improve the efficiency of task processing.
[0247] If the decision action in the nth round is a task processing failure, it means that part of the problem cannot be answered successfully, and the preset termination condition has been met.
[0248] Of course, if the decision action in the nth round is a task failure, further analysis can be performed to see if subsequent tasks can continue. If they cannot continue, it confirms that the preset termination condition has been met. For example, if the problem is: "Please help me find the nearest library and tell me how to get a library card," it requires obtaining the current location, searching for the nearest library, and providing a library card application guide. If the current location cannot be obtained, subsequent tasks (such as searching for the nearest library and providing a library card application guide) cannot continue. The task processing should then stop, and a response message should be output, such as: "Sorry, I cannot obtain your current location, therefore I cannot find the nearest library for you. You can manually search for nearby libraries and consult the library card application guide." This avoids unnecessary resource waste, terminates the task in a timely manner, and improves task processing efficiency.
[0249] Of course, if some tasks can still be performed, subsequent task processing rounds can continue. For example, if the question is: "Please help me book a flight to Beijing and provide hotel recommendations," the task involves booking a flight and providing hotel recommendations. Even if booking the flight fails, the subsequent task (providing hotel recommendations) can still be performed. This can effectively enhance the robustness of the system, ensure the flexibility and reliability of task processing, and avoid interrupting the entire task process due to the failure of a single task.
[0250] In the above implementation, by analyzing the decision-making action in the nth round and determining whether to continue executing the task based on its type, this mechanism improves the flexibility and robustness of task processing, optimizes resource utilization, ensures the continuity and consistency of tasks, and enhances the user experience and system transparency.
[0251] In an optional implementation, S322 can be implemented as follows, including S3221 to S3223 ( Figure 3 (not shown): S3221: Generate a new set of tasks based on the decision actions in the nth round.
[0252] Specifically, in this step, based on the decision action in the nth round, within the specified task range set... A new task set is generated internally, which contains the tasks generated in the nth round, and specifically describes the type and number of times the tasks generated in the nth round are executed.
[0253] In this step, based on the decision action in the nth round Within the defined task scope set Within, a series of new tasks are generated. These tasks constitute the new task set in this paper, as follows: LLM plan .
[0254] in, Let be the number of tasks generated during the nth round of task planning, and its value range is: This means that no new tasks need to be generated at the moment, and the set of new tasks is empty.
[0255] Task Scope Set It includes a number of possible tasks for one or more application contexts. These tasks are defined according to the specific application context and have a certain degree of generality. Each task has specific tool invocation information, including the tool category name, tool input parameters, etc., and corresponds to the tools in the tool pool.
[0256] In this application embodiment, for a specific application context, defining all possible tasks within that application context constitutes a task scope set. .
[0257] For example, in an educational context, the set of task scopes This may include the following tasks: Searching for knowledge points: Using a search engine to find specific knowledge points.
[0258] Generate practice questions: Generate practice questions based on knowledge points.
[0259] Homework grading: Automatically grades students' homework.
[0260] Provide learning suggestions: Offer personalized learning suggestions based on the student's learning progress.
[0261] Record video explanations: Record video explanations of specific knowledge points.
[0262] For example, in the context of artificial intelligence, the set of task scopes This may include the following tasks: Data collection: Collecting data from different data sources.
[0263] Data preprocessing: cleaning and preprocessing data.
[0264] Model training: Training a machine learning model.
[0265] Model evaluation: Evaluate the performance of the model.
[0266] Model deployment: Deploying the model to the production environment.
[0267] Generate reports: Generate reports on model training and evaluation.
[0268] In the embodiments of this application, when a new task needs to be generated, the decision action can indicate the type of the new task to be generated, such as a main task or a side task. This helps the system to make appropriate task planning based on the nature and importance of the current task. In addition, it can also indicate the reference information required to generate the new task, such as the problem, background information, and the results of the previous round of tool calls. This reference information makes the generated new task more specific and targeted.
[0269] For example, in an educational context, the set of task scopes Includes the five tasks listed above, with the question being an object requesting an explanation of "Newton's Second Law," combining the question and task scope. Generate the main task and search for the knowledge point Newton's second law.
[0270] In summary, it refers to the set of task scopes. It provides a general definition for all possible tasks, while decision-making actions generate specific, 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.
[0271] It should be noted that this application does not assume any specific application context in the proposed task planning framework. For different actual task types in different application contexts, only the corresponding task scope set needs to be adjusted. It has strong versatility, and can define and adjust the task scope set. It can generate appropriate new task sets based on different application contexts. This helps ensure the flexibility and adaptability of task planning, improving the overall efficiency and performance of the system. Furthermore, adjustments can be made... Improve task planning performance in specific scenarios.
[0272] When several new tasks are generated, the current task stack (which represents the task stack at this point) is updated based on the new task set, as follows: S3222: Update the task stack based on the new task set.
[0273] In this step, the tasks in the new task set are pushed from the top of the stack onto the task stack through the push operation, thus obtaining the updated task stack.
[0274] .
[0275] The push operation means adding a new element to the top of the stack.
[0276] If the new task set contains 0 tasks, then the task stack remains unchanged before and after the update, i.e., task stack = task stack.
[0277] If the number of tasks 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 tasks from 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 based on the problem analysis, and the execution order of these tasks is determined accordingly. Based on the determined execution order, these tasks from the new task set are pushed into the task stack.
[0278] In this context, a dependency relationship between two tasks means that the execution of one task must wait for the completion of the other task before it can begin. This dependency ensures the orderliness and logic of the work and prevents problems caused by improper execution order.
[0279] For example, in a software development project, writing code (task A) may not begin until requirements analysis (task B) is completed. Here, task B is a prerequisite task for task A, while task A is a subsequent task for task B. A prerequisite task is one that must be completed first, and a subsequent task depends on the result of the prerequisite task to begin.
[0280] Specifically, based on determining the execution order of these tasks in the new task set, and considering that the task stack operates on the last-in-first-out principle, in order to ensure that the tasks are executed in the correct order, the operation should be reversed based on this execution order to push the tasks into the task stack.
[0281] For example, suppose a new task set includes three tasks: data collection, data analysis, and report generation. First, analysis reveals that data collection is a prerequisite for data analysis, and the results of data analysis are the foundation for report generation. Therefore, the correct task execution order is: data collection -> data analysis -> report generation. Following this order, the report generation task can be pushed onto the task stack first, followed by data analysis, and finally data collection. This ensures that each task is executed only after its dependent tasks are completed, thus solving the problem efficiently and systematically.
[0282] S3223: The top task of the updated task stack will be taken as the target task for the nth round.
[0283] Based on the above S3222, the task stack can be updated, and then at least one task can be taken out as the task to be executed in the nth round, denoted as the target task of the nth round. Correspondingly, the task to be executed in the (n-1)th round is the target task of the (n-1)th round.
[0284] In this step, tasks are removed from the task stack, which can be achieved using a pop operation. The target task removed in the nth round can be denoted as... ,as follows: .
[0285] If multiple tasks need to be retrieved, multiple pop operations can usually be performed, with each pop operation retrieving one task from the top of the stack. Of course, a custom pop operation can also be defined to retrieve multiple tasks at once.
[0286] This mechanism allows the system to dynamically generate new task sets and update the task stack when task processing fails, assessing the feasibility of subsequent tasks. If some tasks fail, but subsequent tasks can still be executed, the system will continue processing these tasks, preventing the entire task flow from being interrupted due to the failure of a single task, thus enhancing system robustness and avoiding unnecessary resource waste. For example, if a task fails and subsequent tasks cannot continue, the system can terminate the task in a timely manner, releasing resources and improving resource utilization. Furthermore, it increases the flexibility of task processing, enabling dynamic adjustment of task order to ensure task continuity and consistency.
[0287] S323: Generate tool call information for the target task of the nth round based on the background information corresponding to the target task and problem of the nth round.
[0288] This background information is determined based on the problem and the execution status of related tasks. These problem-related tasks include, but are not limited to, tasks that have already been executed, and tasks currently planned but not yet completed in the task stack.
[0289] During task execution, tool invocation information refers to data used to instruct an automation system or script to perform specific operations. In this embodiment, tool invocation information includes, but is not limited to, the following two parts: The tool category name, which is the name of the program, script, or service that performs the operation, specifies the specific tool or application to be used.
[0290] For example, the tool category name for calculation tools is "calculator," the tool category name for retrieval tools is "retriever," the tool category name for code execution tools is "python sandbox," and the tool category name for data analysis tools is "data analyzer," and so on.
[0291] Tool input parameters are the data or instructions that the tool needs to complete the task, providing the specific data or configuration settings required for the tool to run.
[0292] For example, calculation tools are typically used to perform mathematical operations or simple logical processing. For example, a simple calculator tool can take the following parameters: (1) operation: operation type, such as addition, subtraction, multiplication, and division. (2) operands: operands, i.e., the values involved in the operation.
[0293] Input parameters of a retrieval tool: A retrieval tool is used to query information from a database or index. For example, an SQL query tool can take the following parameters: (1) query: Structured Query Language (SQL) query statement. (2) database: database name or connection string.
[0294] Input parameters for code execution tools: Code execution tools are used to run scripts or code snippets. These tools can take the following parameters as input: (1) script: The content of the script to be executed or the path to the script file. args: The input parameters of the script. (2) env: Variables of the execution environment.
[0295] Input parameters of data analysis tools: Data analysis tools are used to process datasets and extract useful information. These tools can take the following input parameters: (1) data: Input dataset, 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.
[0296] In addition to the tool category names and tool input parameters listed above, the tool invocation information in this application embodiment may also include, but is not limited to, the following types of data: (1) Tool version: Specifies the version number of the tool. For example: Use Python 3.8 to execute the script.
[0297] (2) Tool execution environment: Specifies the environment information for tool execution, such as operating system, dependent libraries, etc. For example, to execute a script in a Linux environment, specific dependent libraries need to be installed.
[0298] (3) Tool output path: Specifies the output file or data storage path after the tool is executed. For example: Save the results to / path / to / output / file.txt.
[0299] (4) Tool execution timeout: Specifies the maximum allowed time for the tool to execute. Execution will terminate if this time is exceeded. For example: Set the timeout to 60 seconds.
[0300] (5) Tool execution permissions: Specify the permissions required for the tool to execute, such as read and write permissions, network access permissions, etc. For example: It needs to be run with administrator privileges.
[0301] (6) Tool execution log: Specifies the logging method and path for tool execution. For example: Logs are recorded to / path / to / log / file.log.
[0302] (7) Tool callback function: Specifies the callback function or script to be called after the tool finishes execution, used to process the results or trigger the next operation. For example: call the post_process() function after execution.
[0303] (8) Tool Dependencies: Specifies the dependencies required for the tool to execute, such as other tools, libraries, or services. For example: It depends on the requests library.
[0304] (9) Tool configuration file: Specifies the path to the configuration file required for the tool to execute, used to load configuration information. For example: The configuration file path is / path / to / config / config.json.
[0305] (10) Tool execution context: Specifies the context information for tool execution, such as user information, session ID, etc. For example: User ID is user123, and session ID is session456.
[0306] (11) Tool execution conditions: Specify the conditions for the tool to be executed, such as the completion status of the prerequisite tasks, a specific time point, etc. For example: Task B will only be executed after Task A is completed.
[0307] These additional tool call information allow for more comprehensive management and control of the tool execution process, ensuring the correctness and reliability of tasks and helping to improve the system's flexibility, maintainability, and scalability.
[0308] It should be noted that the 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 the task requirements, the tool call information may be more complex, containing more parameters or requiring interaction with APIs, etc., which will not be elaborated here.
[0309] In the embodiments of this application, background information refers to the preceding state or environmental details directly related to the current problem and task. It 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 to understand the current situation, aiming to provide the necessary context for solving the problem.
[0310] Optionally, the background information can be derived by combining the current problem, the task to be executed, the result 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.
[0311] Therefore, one possible implementation is to generate tool invocation information in the following manner: By summarizing the problem, task stack, tool call results and background information (specifically the current background information) corresponding to the (n-1)th round target task, new background information is generated; based on the new background information and the nth round target task, tool call information for the nth round target task is generated.
[0312] Here, "problem" refers to the question posed by the object or the problem that needs to be solved. The task stack contains currently planned tasks related to the problem. The tool call result corresponding to the (n-1)th round target task refers to the tools used and their effects or outputs during the process of attempting to solve the problem in the (n-1)th round target task. Background information is updated in each round. The background information used when generating the tool call information for the nth round target task refers to the environmental state and other relevant information during the (n-1)th round target task processing. The background information derived from the above information can contain all the details crucial for understanding the current situation.
[0313] Considering that the results of each round of tool calls will affect the execution of subsequent tasks as the task progresses, once a round of the target task is completed, the background information needs to be updated to reflect the latest progress. This includes recording the results of the nth round of the target task and any new findings or changes, in order to provide the latest context for subsequent tasks. In the nth round, the background information before the update is denoted as... The updated background information is denoted as c. n , This represents the tool call result corresponding to the target task in round (n-1). The current task stack is... The update process is represented as follows: ).
[0314] In this embodiment, when summarizing the problem, task stack, tool call results corresponding to the (n-1)th round target task, and background information to generate background information, the summarization capabilities of the LLM can be utilized. For example, the collected information can be converted into a structured format (such as JSON) so that the model can more easily understand and process it. Then, using this structured information as input, a request is sent to the LLM. The request can be a prompt, asking 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: [specific input information]." This prompt is then sent to the LLM, waiting for it to return a concise background summary.
[0315] LLM generates a summary text based on the input information, which contains all the necessary information to support the current task requirements. Furthermore, the summary text generated by LLM can be post-processed, such as removing redundant information and correcting syntax errors, to ensure that the final background information is clear and accurate. This method fully leverages the powerful summarizing and semantic understanding capabilities of LLM, resulting in background information that is both comprehensive and concise, thus facilitating better completion of subsequent tasks.
[0316] In addition to LLM, rule engines or expert systems can also be used for summarization. Rule engines can extract and integrate key information based on preset business logic and rules, while expert systems combine domain knowledge and reasoning mechanisms to generate background information. These two methods are particularly suitable for task scenarios with well-defined rules and clear logic. By configuring appropriate rules or knowledge bases, information crucial to the current task can be effectively extracted, ensuring the accuracy and relevance of task execution. Furthermore, information extraction modules in NLP technology can be used to automatically identify entities, relationships, and other important elements in text, using this as a basis to construct the background information required for the current target task, and so on.
[0317] For example, in practice, the process begins by collecting information on the problem, the current task stack, the results of the previous tool call, and background information. This information is then organized into a structured format (such as JSON). Next, a rule engine or NLP technology is used to extract key points. Finally, the extracted key information is integrated to form concise and clear background information, providing necessary contextual support for the current task. This process ensures the continuity and effectiveness of task processing.
[0318] It should be noted that the above-listed methods of summarizing background information are just simple examples. Other summarizing methods are also applicable to the embodiments of this application, and will not be elaborated on here.
[0319] In the above implementation, background information is generated by summarizing the problem, task stack, results of the previous tool call, and background information, and a tool call plan is formulated accordingly. This method significantly improves the coherence and efficiency of task processing. It ensures that each operation is based on a complete context, avoids repetitive work, improves the accuracy of problem-solving, and enhances adaptability to environmental changes. Furthermore, this method makes the entire task execution process more transparent, facilitating subsequent analysis and optimization, thereby supporting more rational and effective decision-making.
[0320] Furthermore, by continuously updating background information, the agent can ensure that it always makes decisions based on the latest state changes, thereby improving the efficiency and accuracy of problem-solving. Updating background information also helps identify which tools and strategies are effective and which are ineffective, thus optimizing future task planning and execution strategies. This dynamic adjustment capability enables the system to remain adaptable in uncertain environments, improving its overall intelligence level.
[0321] In practical applications, task execution can be achieved by a tool invoking an intelligent agent. The intelligent agent then invokes the tool to perform operations on the target task in the current round. The specific implementation details are as follows: To clarify the core problem that needs to be solved and its relationship with other tasks, the tool calling the agent first needs to understand the problem posed by the object and its context, including the results of related tasks previously executed. Based on the above analysis, the specific goal to be executed in this round is clarified, that is, the target task of this round. This helps to focus on the work that needs to be completed at present.
[0322] Subsequently, the tool-calling agent selects the most suitable tool from the available tool pool based on the needs of the target task in 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 any specific restrictions.
[0323] Then, the tool invocation agent creates specific tool invocation instructions. These instructions contain tool invocation information corresponding to the required task, such as the tool category name, all necessary parameters, and configuration information. For example, if the target task for this round is data collection, the tool invocation information might include the specified data source address and the required data format. Based on this, the tool invocation agent is used to actually execute the tool invocation. The agent is responsible for sending requests, processing responses, and updating the status or triggering the next action based on the results.
[0324] Through 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.
[0325] S324: Invoke the tool based on the tool invocation information to execute the target task of the nth round and obtain the tool invocation result corresponding to the target task of the nth round.
[0326] The tool call result refers to the output or feedback information obtained after executing a specific tool, including but not limited to data, status codes, messages, etc., which reflects the effect or result of the tool execution.
[0327] In this process, the tool invocation agent first searches for a tool with the specified name in the tool pool based on the specific tool category name in the generated tool invocation information. Then, based on the specific tool input parameters in the generated tool invocation information, it prepares data or sets parameter values, invokes the found tool, passes in the prepared parameters, and executes the tool function. After the tool completes its execution, the output result of the tool is obtained, which is the tool invocation result.
[0328] For example, based on updating the background information using any of the methods listed above, and according to the question... The target task of the nth round t n With current background information The tool-invoking agent obtains the tool invoking information for the nth round via ReAct, and then invokes the corresponding tool from the tool pool to obtain the tool invoking result for the target task in the nth round. .
[0329] For example, if the tool call information indicates that a weather API needs to be called to obtain the precipitation probability forecast for the next 24 hours, and the input parameters include geographic coordinates (latitude, longitude) and date, assuming the tool category name is "WeatherAPI" and the tool input parameters are latitude, longitude and date, then "WeatherAPI" is found in the tool pool, the latitude, longitude and date are prepared as the API request parameters, the API is called and the parameters are passed, and then the precipitation probability data returned by the API is obtained as the tool call result corresponding to the target task in the nth round.
[0330] In one alternative implementation, if there are multiple target tasks in the nth round, then S324 can be executed in parallel for the multiple target tasks in the nth round to improve the execution speed of the task stack and speed up the overall process.
[0331] In practical applications, either synchronous or asynchronous tasks can be executed in parallel, depending on the specific needs.
[0332] Specifically, when synchronous tasks are executed in parallel, multiple tasks can run simultaneously, but each task remains synchronous. This means that operations within a task are executed sequentially, but these tasks themselves can run simultaneously on different processor cores.
[0333] For example, a question might be asked: "Please explain what quantum computing is and give an example of its application." Suppose the current task stack contains the following tasks: Task A: Explain the basic concepts of quantum computing. Task B: Find application scenarios for quantum computing. Task C: Compile examples of application scenarios. Task D: Integrate the answer content.
[0334] Suppose that the target tasks in the nth round are task A and task B, and task A and task B can be executed synchronously and in parallel. When explaining quantum computing and its application scenarios, explaining concepts and finding application scenarios can be done simultaneously, but the operations within each task are completed sequentially.
[0335] When asynchronous tasks are executed in parallel, not only can multiple tasks run simultaneously, but each task can also execute non-blockingly, sending intermediate results to other tasks at any time. In other words, while waiting for one operation to complete, other operations can be performed.
[0336] For example, the question might be: "Please explain the causes of climate change and its impact on ecosystems." Suppose the current task stack contains the following tasks: Task A: Explain the causes of climate change. Task B: Find the impacts of climate change on ecosystems. Task C: Compile examples of specific impacts. Task D: Integrate the answers.
[0337] Suppose that the target tasks in the nth round are Task A and Task B, which can be executed asynchronously and in parallel. When explaining climate change and its impact on ecosystems, the explanation of causes and the identification of impacts can be carried out simultaneously, and the tasks can communicate with each other at any time and compile examples of specific impacts.
[0338] It should be noted that the task stack in this application makes it easier to achieve asynchronous execution and parallel processing of tasks. Especially when asynchronous operations are supported, the system can pre-plan the next task while one task is being executed, or even process multiple independent tasks in parallel, thereby improving the overall throughput.
[0339] In the above implementation, the method of synchronous / asynchronous task parallel execution is used to call the corresponding tools from the tool pool to execute the target task of the nth round, which can significantly improve processing efficiency and resource utilization, while enhancing the system's flexibility and response speed, ensuring error isolation, and supporting better scalability.
[0340] The above steps S321-S324 describe the specific process of each round of task processing. In simple terms, this process can be implemented through the interaction of a task planning agent and a tool invocation agent. The task planning agent dynamically determines the next task type by receiving the tool invocation results from the tool invocation agent, thus guiding the tool invocation agent to invoke tools. The tool invocation agent invokes tools by generating tool category names and tool input parameters. The set of invoked tools is stored in a tool pool, as described above. Figure 6 As shown.
[0341] By repeating steps S321 to S324 until the preset termination condition is met, the loop can be terminated.
[0342] In this embodiment of the application, the preset termination condition refers to a pre-set condition for stopping answering questions, including but not limited to the following: (1) The question has been answered. This means that the system has successfully completed all the necessary tasks and provided a complete answer or solution. When the system confirms that there is no more relevant information to supplement, or that all tasks have been completed and the answer has been verified as complete, it is considered to have met the termination condition and thus stops further processing.
[0343] (2) Question answering failure, that is, during the process of answering questions, a task fails to be executed, and the number of failures reaches the preset upper limit, i.e., the maximum number of retries (e.g. To avoid an infinite loop, in this case, the question can be considered unanswered, and the answering process can be terminated.
[0344] (3) Reaching planning limits: For example, set a maximum processing time. Once this time limit is exceeded, the system will stop processing regardless of whether the problem is completely solved, in order to prevent indefinite resource occupation. Another example is setting a maximum number of planning rounds (such as N). Once the number of rounds of task processing reaches this limit, the system will stop processing regardless of whether the problem is completely solved, in order to prevent indefinite resource occupation.
[0345] (4) External interruption, such as receiving an end command from the object, that is, the object may decide not to continue during the problem-solving process, or believe that the existing information is sufficient. In this case, the object can actively issue an end command, 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.
[0346] It should be noted that the preset termination conditions listed above are just simple examples. These additional preset termination conditions can help the system respond more flexibly to different scenarios and ensure that the processing flow can be stopped in a timely manner even in complex or dynamic environments.
[0347] In this embodiment of the application, after the preset termination condition is met, a response message for the problem can be output to the object. An optional implementation is as follows: By summarizing the problem, the task stack (which may be empty), the tool call results and background information corresponding to the target task in round n-1, the corresponding response information is generated and output.
[0348] The response information is either the answer to the question, or it indicates the current processing result of the question and any problems encountered during the task processing.
[0349] Referring to the aforementioned preset termination conditions, in this embodiment, a response can be output to the object when the question is answered normally, when a task has reached its maximum retry count and cannot answer the question normally, or when the task processing rounds have reached the maximum planned rounds. Specifically, when the question has been answered normally, the task stack is empty; when the object cannot answer normally, the task stack may not be empty (i.e., it may contain some tasks that have not yet been executed). Therefore, when generating response information based on the task stack, the following situations may occur: First type of response information: The task stack is empty, and the decision action in the nth round indicates that the task processing has been completed. Therefore, the problem is summarized. The tool call results corresponding to the target task in round n-1 Background information before the nth update (That is, the current background information, because in this case the preset termination condition will be met and no further updates will be made.) The reply information is recorded as the first type of reply information. This represents the complete answer to the question, i.e.: S .
[0350] The second type of response information: If the task stack is not empty, and the decision action in the nth round indicates that the task processing failed, then the problem is summarized. Task stack before the nth update (i.e., the current task stack, because in this case the preset termination condition will be reached and no further updates will be made), the tool call result corresponding to the target task in the (n-1)th round. Background information before the nth update The reply received is recorded as the second type of reply. This indicates the current processing result of the problem, and the problems existing in the task processing (such as which tasks cannot be executed successfully, which tasks have not yet been completed, etc.). .
[0351] The third type of response information: The task processing rounds have reached the maximum planned rounds. In this case, the task stack may be empty or not. The solution involves summarizing the problem. The task stack after the nth update (This is also the current task stack, because the preset termination condition has not been met in this case, so it will be updated.) The tool call result corresponding to the target task in round n-1. Background information before the (n-1)th update The reply received is recorded as the third type of reply. ,Right now: .
[0352] It should be noted that, in the embodiments of this application, the third type of response information may be similar to the first type of response information, that is, at round N-1 (N is the maximum planning round), the question is completely answered. In fact, it's a complete answer; of course, this third type of response might also be similar to the second type, meaning that the question hasn't been fully answered in round N-1. It indicates the current processing result of the problem, as well as the problems that exist in the task processing process (such as which task cannot be executed successfully, and which tasks have not yet been completed).
[0353] Without considering whether the task stack is empty, in general, the corresponding response information is generated by summarizing the question, the task stack, the tool call results and background information corresponding to the target task in the (n-1)th round.
[0354] Similar to the process of summarizing background information described above, in this embodiment, when summarizing the problem, task stack, tool call results corresponding to the (n-1)th round target task, and background information to generate response information, the summarization capabilities of the LLM can also be utilized. For example, the collected information can be converted into a structured format (such as JSON) so that the model can more easily understand and process it. Then, using this structured information as input, a request is sent to the LLM. The request can be a prompt, asking 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: [specific input information]." This prompt is then sent to the LLM, waiting for it to return a concise background summary.
[0355] LLM will generate a summary text based on this input information, which will contain all the necessary information to answer the object's question.
[0356] Furthermore, if the user is not satisfied with the current response, they can request a regeneration of the answer. In this case, LLM will repeat the above steps, again integrating the current problem, the tasks to be performed, the results of the previous tool call, and previous background information to generate a new response. 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 user's feedback until it meets their needs.
[0357] In the above implementation, since the background information for each round is derived from the current problem, the task to be performed, the results of the previous round of tool calls, and prior background information, generating the first type of response information by summarizing the problem, the tool call results corresponding to the (n-1)th round's target task, and the background information ensures the comprehensiveness and accuracy of the answer. This method fully utilizes previous execution results and background information, ensuring the current answer is built on a complete and continuous context, avoiding information omissions or repetitions, and making the answer more coherent and complete. Furthermore, utilizing the results of the previous round of tool calls and prior background information allows for a more accurate understanding of the essence of the problem, thereby providing a more precise answer.
[0358] like Figure 11 The diagram shown is a flowchart of a task processing method according to an embodiment of this application. The specific implementation process of this method is as follows: S1101: Initialize background information, tool call results, current task, decision action, task stack, and current planning round n; S1102: Determine whether the current planning round n is less than the maximum planning round N. If yes, execute S1103; otherwise, execute S1114. S1103: Update the current system state based on the question input by the object, the background information of round n-1, the tool call result of round n-1, the decision action of round n-1, the target task of round n-1, and the task stack of round n-1; S1104: The task planning agent performs task planning based on the task planning strategy and the current system state to obtain the decision action in the nth round. S1105: If the decision action in the nth round is not completed, then obtain the response information by summarizing the problem, the tool call results in the (n-1)th round, and the background information in the (n-1)th round, and output it; S1106: If the decision action in round n fails, then obtain the response information by summarizing the problem, the task stack of round n-1, the tool call result of round n-1, and the background information of round n-1, and output it; S1107: If the decision action in the nth round is other, then based on the decision action in the nth round, a series of new tasks are generated within the specified task range set T, forming a new task set; S1108: Update the task stack of round n-1 based on the new task set to obtain the task stack of round n; S1109: The top task of the nth round task stack will be taken out as the target task of the nth round. S1110: Generate background information for round n by summarizing the problem, the task stack of round n, the tool call results of round n-1, and the background information of round n-1; S1111: Through tool invocation of the intelligent agent, generate tool invocation information for the target task of the nth round based on the target task of the nth round and the background information of the nth round; S1112: Based on the tool call information, call the corresponding tool from the tool pool to execute the target task of the nth round and obtain the tool call result of the nth round; S1113: Let the current planning round n = n + 1; S1114: Obtain the response information by summarizing the problem, the task stack of round n, the tool call results of round n-1, and the background information of round n-1, and output it.
[0359] exist Figure 11 In this context, the background information in round n-1 is the same as the background information before the update in round n. The task stack for round n-1 is the same as the task stack before the update in round n. The result of the tool call in round n-1 is an abbreviation of the result of the tool call corresponding to the target task in round n-1; similarly, the result of the tool call in round n below is an abbreviation of the result of the tool call corresponding to the target task in round n.
[0360] In the implementation process listed in S1101 to S1114 above, the input is the question Q and the maximum planning round N, and the output is the final answer A, which can be the response information output in S1106, S1107 or S1114.
[0361] In S1104, the main focus is on the task planning strategies listed above. The task planning strategy guides the large model to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions and produce one or more task types. The following section combines... Figure 12 The decision-making process for this part will be explained in detail: like Figure 12 The diagram shown is a flowchart of a task planning method according to an embodiment of this application. The specific implementation process of this method is as follows: S1201: Based on the current system state, determine whether the target task of round n-1 is empty. If it is, execute S1202; otherwise, execute S1203. S1202: Determine the decision action representation for the nth round: Based on the problem, generate a series of main tasks, and set the execution count of these newly generated main tasks to 1; S1203: Use Determine whether the target task in round n-1 was successfully executed or failed. If it failed, execute S1204; if it succeeded, execute S1209. S1204: Determine whether there is a side task for the target task in round n-1. If yes, execute S1205; otherwise, execute S1206. S1205: Determine the decision action representation for the nth round: generate the corresponding side task, and set the execution count of these newly generated side tasks to 1; S1206: Determine whether the number of times the target task in the (n-1)th round is executed is less than the maximum number of retries. If it is, execute S1207; otherwise, execute S1208. S1207: Determine the decision action for the nth round: Re-plan the current task based on the target task of the (n-1)th round; S1208: Determine the decision action for the nth round: Task processing failed; S1209: Determine whether the target task of round n-1 is the main task. If it is, execute S1210; otherwise, execute S1214. S1210: Determine if the current task stack is empty. If it is, execute S1211; otherwise, execute S1214. S1211: Use Determine whether the question has been answered. If yes, execute S1212; otherwise, execute S1213. S1212: Determine the decision action for the nth round: Task processing is complete; S1213: Determine the decision action representation for the nth round: Based on the problem, current background information, and the tool call result of the (n-1)th round, generate a series of main tasks, and set the execution count of these newly generated main tasks to 1; S1214: Determine the decision action for the nth round: Do not generate a new task.
[0362] exist Figure 12 In the table, the current task stack represents the task stack before the nth update round, which is... .
[0363] In the implementation process listed in S1201~S1214 above, the input is the current system state updated based on S1103, and the output is the decision action of the nth round.
[0364] It should be noted that the above Figure 11 and Figure 12The listed processes are just simple examples. Other similar methods are also applicable to the embodiments of this application, and will not be described in detail here.
[0365] The task processing method in this application embodiment is briefly summarized and explained from the perspective of the interaction between the terminal device and the server: See Figure 13 The diagram shown illustrates the interaction logic between a terminal device and a server in an embodiment of this application. The interaction logic between the terminal device and the server is briefly described below: As mentioned above, the task planning system (i.e., the LLM Agent system mentioned earlier) can run on the server side. The terminal device, acting as the front-end device for interaction between the object and the task planning system, can install the clients listed above, such as conversational AI software. This client is responsible for receiving input questions from the object and sending these requests to the task planning system. The task planning system then receives the questions through a task planning agent. During each round of task processing, it dynamically plans the target task for the nth round based on the tool invocation results (influencing background information) from the received tool invocation agent, combined with the question and other information, to guide the tool invocation agent in making tool invocations. The tool invocation agent, based on the target task planned by the task planning agent for the nth round, considers which tools to invoke, generates tool invocation information, and invokes tools from the tool pool (such as computing tools, data analysis tools, code execution tools, retrieval tools, etc.) to execute the task. After the task processing is complete, the task planning system returns a response to the question to the terminal device, which then displays this response through its front-end interface.
[0366] It should be noted that the interaction logic listed above is just a simple example. For specific implementation methods, please refer to the above embodiments, which will not be repeated here.
[0367] The following is a brief explanation of the effects of the task planning system proposed in this application: Before using the task planning system proposed in this application, single-agent systems in related technologies, such as a single tool-calling agent (hereinafter referred to as a tool-calling system), struggled to solve complex problems. For example, calculating the month-on-month growth value of a certain indicator on a certain day of a certain month of a certain year (but this value does not exist in the data file), the tool-calling system would directly write code to calculate the month-on-month value, but due to missing data, execution errors would occur, and subsequent fault repair would be impossible. Specifically, the tool-calling system would first attempt to read directly; if that failed, it would check for missing data; if missing data was confirmed, it would directly terminate the task (without autonomously calling the prediction tool), thus causing the task to fail.
[0368] When faced with complex problems, the task planning system proposed in this application can effectively plan and execute tasks, ultimately achieving excellent task completion. Specifically, for the same problem, after observing missing data, the task planning system will call a prediction tool to make a prediction, and then use the existing results to perform calculations, thereby successfully completing the task.
[0369] Furthermore, by comparing the tool invocation system and the task planning system proposed in this application on a series of tasks, the statistical experimental data obtained are as follows: Table 1
[0370] The experimental data above shows that when faced with complex problems, the tool-calling system sometimes ignores some tasks, fails to judge the order of tasks, or even ignores existing data. However, the task planning system proposed in this application does not have the above problems, and its performance in a series of tasks is significantly improved compared to the tool-calling system alone.
[0371] Furthermore, it should be noted that the task stack in this application also supports the reuse of tasks. That is, by storing executed tasks, the experience and results of these tasks can be reused, reducing repetitive work and further improving execution efficiency. This approach not only improves the system's concurrent processing capabilities but also enhances the flexibility and efficiency of task management.
[0372] Based on the same inventive concept, embodiments of this application also provide a task processing device. For example... Figure 14 As shown, it is a structural schematic diagram of a task processing device 140 according to an embodiment of this application, which may include: The task processing unit 141 is used to perform at least one round of task processing based on the question input by the object, until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the task processing unit 141 includes a task planning subunit 1411 and a tool invocation subunit 1412, and the nth round of task processing includes the following steps: The task planning subunit 1411 is used to plan the decision action for the nth round based on the problem and the tool call result corresponding to the target task in the (n-1)th round; the decision action for the nth round is used to indicate the task planning details for the nth round, where n is a positive integer; Based on the decision action in the nth round, the target task for the nth round is retrieved from the task stack; the task stack contains currently planned tasks related to the problem. The tool invocation subunit 1412 is used to generate tool invocation 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 problem and the execution status of related tasks. The tool is invoked based on the tool invocation information to execute the target task of the nth round, and the tool invocation result corresponding to the target task of the nth round is obtained.
[0373] Optionally, the task planning subunit 1411 is specifically used for: A new task set is generated based on the decision actions in the nth round. Update the task stack according to the new task set; The top task taken from the updated task stack will be used as the target task for the nth round.
[0374] Optionally, the task planning subunit 1411 is further configured to: before the tool invocation subunit 1412 generates tool invocation 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 updated based on the problem, the task stack, and the tool call results corresponding to the (n-1)th round target task.
[0375] Optionally, the task processing unit 141 is specifically used for: By summarizing the problem, the task stack, the tool call results corresponding to the (n-1)th round target task, and the background information, a response message corresponding to the problem is generated and output. The response information is either the answer to the question or it represents the current processing result of the question and any problems encountered during the task processing.
[0376] Optionally, the task planning subunit 1411 is specifically used for: Analyze whether the target task in the (n-1)th round is empty; If the target task of the (n-1)th round is empty, then the decision action of the nth round means: based on the problem, generate at least one main task, and set the number of times the main task is executed to the initial value; If the target task of the (n-1)th round is not empty, then the decision action of the nth round is planned according to the task type and tool call result of the target task of the (n-1)th round.
[0377] Optionally, the task planning subunit 1411 is specifically used for: Based on the tool call results corresponding to the (n-1)th round target task, analyze whether the (n-1)th round target task was successfully executed; If the target task in the (n-1)th round fails, then the decision action for the nth round is planned based on whether there are any side tasks in the target task in the (n-1)th round. If the target task of the (n-1)th round is successfully executed, then the decision action of the nth round is planned according to whether the target task of the (n-1)th round is the main task.
[0378] Optionally, the task planning subunit 1411 is specifically used for: If the target task in the (n-1)th round has a side task, then the decision action in the nth round is: generate the corresponding side task, and set the number of times the side task is executed to the initial value; If the target task in the (n-1)th round has no side tasks and the number of times the target task in the (n-1)th round is executed has not reached the upper limit, then the decision action in the nth round means: replan the task according to the target task in the (n-1)th round; If the target task in the (n-1)th round has no side tasks, and the number of times the target task in the (n-1)th round is executed reaches the upper limit, then the decision action in the nth round indicates that the task processing has failed.
[0379] Optionally, the task planning subunit 1411 is specifically used for: If the target task of the (n-1)th round is the 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. Otherwise, the decision action in the nth round means: do not generate a new task.
[0380] Optionally, the task planning subunit 1411 is specifically used for: If the question has been answered, then the nth round of decision action indicates that the task processing has been completed. If the question is not fully answered, the decision action in the nth round means: based on the question, the background information, and the tool call result corresponding to the target task in the (n-1)th round, generate at least one main task, and set the number of executions of the main task to the initial value.
[0381] Optionally, the task planning subunit 1411 is specifically used for: If the decision action in the nth round is not a specified decision action, then the target task for the nth round is retrieved from the task stack according to the decision action in the nth round; wherein, the specified decision action includes: task processing has been completed, task processing has failed; The task planning subunit 1411 is also used for: If the decision action in the nth round is a specified decision action, then the preset termination condition is determined to have been met.
[0382] Optionally, if there are multiple target tasks in the nth round, and each target task in the nth round corresponds to a tool invocation information, then the tool invocation subunit 1412 is specifically used for: For multiple nth round target tasks, the following process is executed in parallel: The tool is invoked according to the tool invocation information corresponding to the nth round target task to execute the nth round target task and obtain the tool invocation result corresponding to the nth round target task.
[0383] Regarding task planning, this application performs task planning once per round. During task planning, the decision-making actions in each round are planned based on the problem and the tool call results of the task executed in round n-1. This task planning method ensures that the execution status of previous tasks is referenced in each round of task planning, and downstream tasks can be dynamically adjusted based on the execution status of upstream tasks. This ensures that the decision-making actions in each round are planned with consideration of task dependencies, resulting in more accurate planning results.
[0384] Based on this, a series of related tasks can be pre-determined through the task stack, which can reduce the need for frequent calls to LLM for replanning. Furthermore, storing these planned tasks in an orderly manner in the stack can 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 replanning calls, and improve task planning efficiency.
[0385] In summary, this application utilizes a task stack to store planned tasks in a stack format and combines the results of the (n-1)th round of tool calls for task planning. This planning strategy can guide the large model to conduct a scientific process analysis of the results of executed tasks in order to generate new decision actions, thereby overcoming the problem of low efficiency in sequential decision-making task planning. It takes into account both task dependencies and planning efficiency, and improves system robustness.
[0386] Furthermore, this application incorporates a targeted design for task replanning during task planning, thereby further enhancing the robustness of the LLM Agent system in the event of task failure.
[0387] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.
[0388] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0389] Having introduced the task processing method and apparatus according to exemplary embodiments of this application, we will now introduce an electronic device according to another exemplary embodiment of this application.
[0390] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0391] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. In one embodiment, the electronic device may be a server, such as... Figure 1 The server 120 is shown. In this embodiment, the electronic device can be structured as follows: Figure 15 As shown, it includes a memory 1501, a communication module 1503, and one or more processors 1502.
[0392] 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. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0393] Memory 1501 may be volatile memory, such as random-access memory (RAM); memory 1501 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1501 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1501 may be a combination of the above-described memories.
[0394] Processor 1502 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 1502 is used to implement the above-described task processing method when it calls a computer program stored in memory 1501.
[0395] The communication module 1503 is used to communicate with terminal devices and other servers.
[0396] This application embodiment does not limit the specific connection medium between the memory 1501, communication module 1503, and processor 1502. This application embodiment... Figure 15 The memory 1501 and the processor 1502 are connected via a bus 1504, and the bus 1504 is in Figure 15 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1504 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 15 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.
[0397] The memory 1501 stores a computer storage medium, which stores computer-executable instructions for implementing the task processing method of this application embodiment. The processor 1502 is used to execute the above-described task processing method, such as... Figure 3 As shown.
[0398] In another embodiment, the electronic device can also be other electronic devices, such as... Figure 1 The terminal device 110 is shown. In this embodiment, the electronic device can be structured as follows: Figure 16 As shown, it includes components such as: communication component 1610, memory 1620, display unit 1630, camera 1640, sensor 1650, audio circuit 1660, Bluetooth module 1670, processor 1680, etc.
[0399] The communication component 1610 is used to communicate with the server. In some embodiments, it may include a Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology, and the electronic device can help the user send and receive information through the WiFi module.
[0400] The memory 1620 can be used to store software programs and data. The processor 1680 executes various functions of the terminal device 110 and performs data processing by running the software programs or data stored in the memory 1620. The memory 1620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, 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 this application, the memory 1620 may store the operating system and various application programs, and may also store computer programs that execute the task processing methods of the embodiments of this application.
[0401] The display unit 1630 can also be used to display information input by the user or information provided to the user, as well as various menus of the terminal device 110, in a graphical user interface (GUI). 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 as a liquid crystal display, a light-emitting diode, or the like. The display unit 1630 can be used to display the front-end operation interface, etc., as described in the embodiments of this application.
[0402] The display unit 1630 can also be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device 110. Specifically, the display unit 1630 may include a touch screen 1631 disposed on the front of the terminal device 110, which can collect touch operations of the user on or near it, such as clicking buttons, dragging scroll boxes, etc.
[0403] The touchscreen 1631 can be placed on top of the display screen 1632, or the touchscreen 1631 and the display screen 1632 can be integrated to realize the input and output functions of the terminal device 110. After integration, it 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.
[0404] Camera 1640 can be used to capture still images, which users can then share via an application. There can be one or multiple cameras 1640. An object is projected onto a photosensitive element through a lens, generating an optical image. This 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, which is then transmitted to the processor 1680 for conversion into a digital image signal.
[0405] The terminal device may also include at least one sensor 1650, such as an accelerometer 1651, a proximity sensor 1652, a fingerprint sensor 1653, and a temperature sensor 1654. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.
[0406] Audio circuitry 1660, speaker 1661, and microphone 1662 provide an audio interface between the user and terminal device 110. Audio circuitry 1660 converts received audio data into electrical signals, which are then transmitted to speaker 1661, where they are converted into sound signals for output. Terminal device 110 may also be equipped with volume buttons for adjusting the volume of the sound signal. On the other hand, microphone 1662 converts collected sound signals into electrical signals, which are received by audio circuitry 1660, converted into audio data, and then output to communication component 1610 for transmission to, for example, another terminal device 110, or to memory 1620 for further processing.
[0407] The Bluetooth module 1670 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1670, thereby exchanging data.
[0408] The processor 1680 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions 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 handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1680. In this application, the processor 1680 can run the operating system, applications, user interface display and touch response, and the task processing method of the embodiments of this application. Furthermore, the processor 1680 is coupled to the display unit 1630.
[0409] In some possible implementations, various aspects of the task processing method provided in this application can also be implemented as a program product, which includes a computer program. When the program product is run on an electronic device, the computer program causes the electronic device to perform the steps of the task processing method according to the various exemplary embodiments of this application described above. For example, the electronic device can perform actions such as... Figure 3 The steps are shown in the figure.
[0410] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0411] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.
[0412] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.
[0413] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0414] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The computer program can execute entirely on the user's electronic device, partially on the user's electronic device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).
[0415] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this 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 and embodied by multiple units.
[0416] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0417] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.
[0418] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, produce a mechanism for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0419] These computer program commands may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the commands stored in the computer-readable storage medium produce an article of manufacture including command means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0420] These computer program commands can also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing the commands executed on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0421] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0422] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A task processing method, characterized in that, The method includes: Based on the question input by the object, perform at least one round of task processing until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the nth round of task processing includes the following steps: Based on the question and the tool call results corresponding to the (n-1)th round target task, plan the decision action for the nth round; the decision action for the nth round is used to indicate the task planning details for the nth round, where n is a positive integer; A new task set is generated based on the decision action in the nth round; the task stack is updated based on the new task set; the top task taken from the updated task stack is used as the target task for the nth round; the task stack contains currently planned tasks related to the question; the tasks in the new task set include at least one of main tasks and side tasks; the main task is the task that must be completed to achieve the main goal when answering the question; the side task is an auxiliary task that can be selectively completed when completing the main task; Based on the question, the task stack, and the tool call results corresponding to the (n-1)th round target task, update the background information corresponding to the question; based on the nth round target task and the updated background information, generate tool call information for the nth round target task; The tool is invoked based on the tool invocation information to execute the target task of the nth round, and the tool invocation result corresponding to the target task of the nth round is obtained.
2. The method as described in claim 1, characterized in that, The output of the response information corresponding to the question includes: By summarizing the problem, the task stack, the tool call results corresponding to the (n-1)th round target task, and the background information, a response message corresponding to the problem is generated and output. The response information is either the answer to the question or it represents the current processing result of the question and any problems encountered during the task processing.
3. The method as described in claim 1, characterized in that, The step of planning the decision-making action for the nth round based on the problem and the tool call results corresponding to the (n-1)th round target task includes: Analyze whether the target task in the (n-1)th round is empty; If the target task of the (n-1)th round is empty, then the decision action of the nth round means: based on the problem, generate at least one main task, and set the number of times the main task is executed to the initial value; If the target task of the (n-1)th round is not empty, then the decision action of the nth round is planned according to the task type and tool call result of the target task of the (n-1)th round.
4. The method as described in claim 3, characterized in that, The step of planning the decision-making action for the nth round based on the task type and tool call results of the (n-1)th round target task includes: Based on the tool call results corresponding to the (n-1)th round target task, analyze whether the (n-1)th round target task was successfully executed; If the target task in the (n-1)th round fails, then the decision action for the nth round is planned based on whether there are any side tasks in the target task in the (n-1)th round. If the target task of the (n-1)th round is successfully executed, then the decision action of the nth round is planned according to whether the target task of the (n-1)th round is the main task.
5. The method as described in claim 4, characterized in that, The step of planning the decision-making action for the nth round based on whether there are side tasks in the (n-1)th round target task includes: If the target task in the (n-1)th round has a side task, then the decision action in the nth round is: generate the corresponding side task, and set the number of times the side task is executed to the initial value; If the target task in the (n-1)th round has no side tasks and the number of times the target task in the (n-1)th round is executed has not reached the upper limit, then the decision action in the nth round means: replan the task according to the target task in the (n-1)th round; If the target task in the (n-1)th round has no side tasks, and the number of times the target task in the (n-1)th round is executed reaches the upper limit, then the decision action in the nth round indicates that the task processing has failed.
6. The method as described in claim 4, characterized in that, The step of planning the decision-making action for the nth round based on whether the target task of the (n-1)th round is the main task includes: If the target task of the (n-1)th round is the 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. Otherwise, the decision action in the nth round means: do not generate a new task.
7. The method as described in claim 6, characterized in that, The step of planning the nth round of decision-making actions based on whether the question has been answered includes: If the question has been answered, then the nth round of decision action indicates that the task processing has been completed. If the question is not fully answered, the decision action in the nth round means: based on the question, the background information, and the tool call result corresponding to the target task in the (n-1)th round, generate at least one main task, and set the number of executions of the main task to the initial value.
8. The method according to any one of claims 1 to 7, characterized in that, The process involves generating a new task set based on the decision actions in the nth round, and updating the task stack based on the new task set. The top task removed from the updated task stack will be used as the target task for the nth round, including: If the decision action in the nth round is not a specified decision action, then a new task set is generated based on the decision action in the nth round; the task stack is updated based on the new task set; the top task taken from the updated task stack is used as the target task in the nth round; wherein, the specified decision action includes: task processing has been completed, task processing has failed; Furthermore, the method further includes: If the decision action in the nth round is a specified decision action, then the preset termination condition is determined to have been met.
9. The method according to any one of claims 1 to 7, characterized in that, If there are multiple target tasks in the nth round, each target task in the nth round corresponds to a tool invocation information. The step of invoking a tool according to the tool invocation information to execute the target task in the nth round and obtaining the tool invocation result corresponding to the target task in the nth round includes: For multiple nth round target tasks, the following process is executed in parallel: The tool is invoked based on the tool invocation information corresponding to the nth round target task to execute the nth round target task and obtain the tool invocation result corresponding to the nth round target task.
10. A task processing device, characterized in that, include: The task processing unit is used to perform at least one round of task processing based on the question input by the object, until a preset termination condition is met, and then output the corresponding response information for the question; wherein, the task processing unit includes a task planning subunit and a tool invocation subunit, and the nth round of task processing includes the following steps: The task planning subunit is used to plan the decision action for the nth round based on the problem and the tool call result corresponding to the target task in the (n-1)th round; the decision action for the nth round is used to indicate the task planning details for the nth round, where n is a positive integer; A new task set is generated based on the decision action in the nth round; the task stack is updated based on the new task set; the top task taken from the updated task stack is used as the target task for the nth round; the task stack contains currently planned tasks related to the question; the tasks in the new task set include at least one of main tasks and side tasks; the main task is the task that must be completed to achieve the main goal when answering the question; the side task is an auxiliary task that can be selectively completed when completing the main task; The tool invocation subunit is used to update the background information corresponding to the problem based on the problem, the task stack, and the tool invocation result corresponding to the (n-1)th round target task; and to generate tool invocation information for the nth round target task based on the nth round target task and the updated background information. The tool is invoked based on the tool invocation information to execute the target task of the nth round, and the tool invocation result corresponding to the target task of the nth round is obtained.
11. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1 to 9.
12. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1 to 9.
13. A computer program product, characterized in that, The method includes 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, causing the electronic device to perform the steps of any one of claims 1 to 9.
Citation Information
Patent Citations
Task execution method and device, computer equipment and storage medium
CN110991127A
Map data validity verification method and device, electronic equipment and storage medium
CN117131954A
