Search

CN-121860069-B - Intelligent task planning and executing method and system for interactive command line tool

CN121860069BCN 121860069 BCN121860069 BCN 121860069BCN-121860069-B

Abstract

The invention provides an intelligent task planning and executing method and system for an interactive command line tool, comprising S1, generating a corresponding command sequence template for each operation of a target tool by using a first large language model, constructing an executable knowledge base, S2, calculating the semantic similarity between task description and each command sequence template to obtain a candidate set, selecting the most relevant template as a search context by using a second large language model, S3, modeling the task executing process as a state diagram searching problem based on the search problem The algorithm selects candidate nodes from reachable nodes of the current node, selects an optimal node according to the current state and the search context by using a second large language model, S4 executes an execution action corresponding to the optimal node, and outputs by using a second large language model analysis tool to adjust heuristic values of the corresponding nodes and execute corresponding rollback strategies, S5, repeats steps S3 to S4 until an reasoning result display task reaches a target node or the number of times of attempts exceeds a preset threshold.

Inventors

  • CHEN ZHIDE
  • LIU QIHUI
  • ZHOU ZHAOBIN
  • ZHU KEXIN
  • FENG CHEN

Assignees

  • 福建师范大学

Dates

Publication Date
20260512
Application Date
20260316

Claims (7)

  1. 1. An intelligent task planning and executing method for an interactive command line tool is characterized by comprising the following steps: s1, constructing an executable knowledge base, namely generating a corresponding command sequence template for each operation of a target tool based on source codes and metadata of the target tool by using a first large language model; s2, knowledge retrieval and context construction, namely calculating semantic similarity between task description of a current task and each command sequence template in an executable knowledge base, extracting front K command sequence templates with highest similarity as candidate sets, and selecting a command sequence template most relevant to the current task from the candidate sets by using a second large language model as a retrieval context; S3, searching and enhancing the planning, namely modeling the current task execution process as a state diagram searching problem, taking a discrete state of a tool as a node, taking a state transition relation as an edge, starting from an initial state, and iteratively searching subsequent nodes, wherein for each current node, the method is based on The algorithm selects k candidate nodes from the reachable nodes of the current node, and selects an optimal node from the candidate nodes according to the current tool state, the search context and the history execution record by utilizing the second large language model; S4, performing closed loop execution and feedback reasoning, namely executing an execution action corresponding to the optimal node to acquire tool output, performing structural analysis and state reasoning on the tool output by using a second large language model, adjusting heuristic values of the corresponding nodes according to a reasoning result, and executing a corresponding rollback strategy; S5, iterating the loop, namely repeating the steps S3 to S4 until the reasoning result shows that the task reaches a target node or the number of attempts exceeds a preset threshold; The method is based on the following steps for each current node The algorithm selects k candidate nodes from the reachable nodes of the current node, and the method is specifically as follows: According to the node type, each node in the state diagram Presetting basic heuristic value And setting initial dynamic heuristic value for each node : Wherein For the confidence weight parameter, 0 < alpha≤1, Is a node Is a search confidence level of (a); introducing a closed-loop dynamic adjustment mechanism based on time steps and feedback coefficients, and updating corresponding nodes according to closed-loop execution and feedback reasoning results of the previous iteration Heuristic values of (2): , wherein, Representing nodes The heuristic value after the updating is performed, Representing nodes The heuristic value before the update is applied, Update coefficients based on the execution feedback; Based on Node evaluation function calculation of algorithm from starting node through reachable node Total estimated cost of arrival at target node : Wherein, the To reach the node from the initial node Is a substantial cost of the price to be paid, To be from the initial node to the current node At the practical cost of (a) the (c) is, To be from the current node Reach to reach node The single step transfer cost of (a), namely the corresponding edge weight; For updated reachable nodes Heuristic values of (2); For all reachable nodes Corresponding total estimated cost And (4) performing ascending sorting, and selecting reachable nodes corresponding to the first k total estimated cost as candidate nodes.
  2. 2. The intelligent task planning and execution method for an interactive command line tool according to claim 1, wherein the construction of the executable knowledge base specifically comprises: acquiring source codes and metadata of all operation modules of a target tool, wherein the source codes and the metadata comprise a command identifier, a necessary parameter set, an optional parameter set, a default value, a suitable condition and expected output; Generating a corresponding original command sequence template for each operation of the target tool by using a first large language model based on source codes and metadata of the target tool, wherein each original command sequence template corresponds to a plurality of command sequences, and representing dynamic parameters by using placeholders; The original command sequence template is converted into a high-dimensional vector representation through an embedded model, and the obtained command sequence template is stored in a vector database and a semantic index is established.
  3. 3. The intelligent task planning and execution method for an interactive command line tool according to claim 1, wherein the constructing of the state diagram comprises: defining a node set to represent discrete states of the tool, including an initial state, a configuration state, an execution state, a success state, and a failure state; Defining a set of edges to represent a state transition relationship; the definition side weight represents different types of state transition costs, and is predefined according to expert experience.
  4. 4. The intelligent task planning and execution method for an interactive command line tool according to claim 1, wherein the method for determining the confidence of the search is as follows: According to the node Determining the required knowledge type and constructing a query vector; Retrieving and node in executable knowledge base Knowledge segments that match the desired knowledge type; if the search is successful, calculating the distance between the query vector and each searched knowledge segment vector And will As the semantic similarity, if the highest semantic similarity is higher than a preset threshold, the method will Assigning a value to the highest semantic similarity, otherwise And setting the preset low confidence value.
  5. 5. The intelligent task planning and execution method for an interactive command line tool according to claim 1, wherein the structured parsing and state reasoning for tool output by using the second large language model specifically comprises: identifying the state of the command execution result by using the second large language model; if the task is in the successful execution state, evaluating task progress by using a second large language model, and judging whether the current tool output indicates that the task is propelled to a target state; if the execution failure state is in, the error message in the output of the second large language model analysis tool is utilized to classify the failure cause into parameter error, state error, environment error, authority error, resource error, network error or other errors.
  6. 6. The intelligent task planning and execution method for an interactive command line tool according to claim 5, wherein the adjusting heuristic values of corresponding nodes and executing corresponding rollback policies according to reasoning results specifically comprises: When the command execution is successful and the task advances to the target state, the update coefficient is set , Represents the decay rate of the heuristic value upon successful execution, an Reducing heuristic values of executed nodes to strengthen a successful path; when the command execution is successful but the task does not progress, the update coefficient is set Keeping the current heuristic value of the executed node unchanged; when command execution fails, determining nodes needing to update heuristic values according to failure types and setting update coefficients , Represents the increasing proportion of heuristic values at the time of execution failure, an And executing corresponding rollback strategy according to the failure category, and updating the current node to the position after rollback.
  7. 7. An intelligent task planning and execution system for an interactive command line tool, comprising a processor, a memory, and a computer program stored on the memory, wherein the processor, when executing the computer program, specifically performs the steps in the intelligent task planning and execution method for an interactive command line tool according to any one of claims 1-6.

Description

Intelligent task planning and executing method and system for interactive command line tool Technical Field The invention belongs to the technical field of artificial intelligence, and particularly relates to an intelligent task planning and executing method and system for an interactive command line tool. Background The large language model (Large Language Model, LLM) exhibits strong capabilities in terms of natural language understanding and generation, and has been widely used in the fields of dialog systems, code generation, knowledge questions and answers, and the like. In recent years, researchers have begun to explore core inference engines that use large language models as agents, enabling them to interact with external tools and environments, automatically completing complex tasks. The intelligent agent system based on the large language model has great application potential in the fields of software development, data analysis, system operation and maintenance and the like. The interactive command line tool is an important interface for computer system management and operation, and is widely applied to the professional fields of database management, container arrangement, network configuration, security test and the like. Such tools typically have complex command syntax, rich parameter configurations, and diversified output formats. Traditionally, the use of these tools requires a skilled person to have a great deal of field knowledge and a great deal of operational experience. The large language model intelligent body is utilized to realize the automatic operation of the interactive command line tool, so that the professional threshold can be obviously reduced, the working efficiency can be improved, and the human error can be reduced. However, existing large language model based tool operation agents face the following core technical challenges: First, the semantic to command conversion gap problem. The large language model mainly learns general language knowledge in a pre-training stage, and lacks accurate cognition for an accurate using method of a tool in a specific field. When the model attempts to generate a tool command, it is easy to create a "illusion" phenomenon that the generated command appears plausible in terms of syntax structure, but contains non-existent parameter names, incorrect command formats, or incompatible combinations of options. This gap between semantic understanding and executable commands results in a lower success rate for automated task execution. Second, the problem of difficulty in multi-step mission planning. Complex tasks typically require the execution of multiple interdependent command steps, with the correct execution of subsequent commands being dependent on the successful completion of the predecessor commands. The existing large language model intelligent agent mostly adopts linear decision frames such as ReAct and the like, and selects the next action according to the current observation in each step. This mode lacks an understanding of the overall task structure and an efficient backtracking mechanism-when a step fails to perform, it is difficult for the agent to systematically explore alternatives, easily trapping the dead-loop of repeatedly attempting the same failed path. Thirdly, the problem of difficult analysis of tool output and state judgment is solved. The output information of the command line tool is complex and changeable, and comprises various types such as state display, execution results, warning information, error prompt and the like. Correctly resolving these outputs and judging the task execution state accordingly is the key to achieving closed loop control. However, although the large language model is good at high-level reasoning, the large language model performs poorly when the detail output by the processing tool is different, and it is difficult to accurately distinguish different states such as "command grammar error", "command execution is successful but task is not completed", "task is completely successful", and the like, so that subsequent decision errors are caused. Fourth, knowledge retrieval and task execution are disjointed. Retrieval enhancement generation (RETRIEVAL-Augmented Generation, RAG) techniques enhance model capabilities by retrieving relevant information from an external knowledge base, alleviating the illusion problem to some extent. However, conventional RAG methods typically retrieve descriptive text information, such as a tool manual or instructions for use. The model still needs to convert the retrieved text information into executable commands, which may still introduce errors. In addition, the retrieved knowledge is also lacking in systematic solutions as to how to effectively guide task planning. In summary, how to construct an intelligent task execution system that can directly retrieve executable knowledge, effectively plan in a complex state space, and adaptively adjust policies according to tool fee