Intelligent agent planning enhancement method based on knowledge graph
By constructing an agent planning enhancement method based on knowledge graphs, the problems of incompleteness and stability in agent task planning are solved, the success rate and stability of multi-step, multi-tool tasks are improved, and the cost and complexity of manual maintenance are reduced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Ningbo Institute of Surveying, Mapping and Remote Sensing Technology (Ningbo Natural Resources and Planning Survey and Monitoring Center)
- Filing Date
- 2026-04-30
- Publication Date
- 2026-06-02
Smart Images

Figure CN122132147A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method for enhancing agent planning based on knowledge graphs. Background Technology
[0002] Existing intelligent agent task planning and tool invocation technologies typically involve a large language model generating a multi-step sub-task sequence based on user instructions, and then invoking external tools (such as retrieval, querying, computation, and spatial analysis) step by step during execution to complete complex tasks.
[0003] In practical applications, more powerful large language models can often provide more reasonable planning structures and higher task success rates, but they have high inference overhead, high computing power and latency costs, and private deployment places higher demands on hardware resources, concurrency capabilities and operation and maintenance support, resulting in higher overall deployment and usage costs. In contrast, although weaker large language models have lower inference costs and deployment resource requirements, making them suitable for deployment in resource-constrained or edge scenarios, they are more prone to problems such as incomplete planning, unreasonable step order, and mismatched tool selection in multi-step, multi-tool agent tasks, leading to lower overall planning success rates and insufficient stability.
[0004] To alleviate these problems, existing technologies employ templated prompts or manual rules to guide the planning process. However, this approach relies on continuous maintenance and iteration by domain experts. Furthermore, as the number of tools and application scenarios increases, the scale of templates and rules expands rapidly, making version unification difficult, migration and reuse capabilities weak, and failing to cover diverse task requirements. Consequently, it is challenging to achieve stable and reliable planning results while ensuring low-cost deployment. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide an intelligent agent planning enhancement method based on knowledge graph, which improves the planning success rate and stability of multi-tool and multi-step tasks under low deployment cost conditions, and reduces the dependence on long-term maintenance of manual templates and rules.
[0006] The technical solution adopted by this invention to solve the above-mentioned technical problems is: a knowledge graph-based agent planning enhancement method, characterized by the following steps: Step 1: Collect the set of execution links successfully generated by the first intelligent agent when processing multiple tasks. The set of execution links includes multiple execution links, and each execution link includes multiple sub-tasks arranged in sequence and the tools used to execute each sub-task. Step 2: Construct a knowledge graph for the execution link set to generate an execution link knowledge graph; the execution link knowledge graph includes subtask nodes, tool nodes, structural framework nodes, subtask sequence edges, relationship edges between subtasks and tool calls, tool sequence edges, and relationship edges between structural framework nodes and tool nodes; Step 3: Obtain the current task instruction, use the second agent to process the current task, and combine the execution link knowledge graph in Step 2 when the second agent processes the current task to obtain the planning output result with enhanced planning ability; the original planning ability of the second agent is lower than that of the first agent. The specific method for obtaining the planning output results is as follows: Step 3-1: Filter the structural framework nodes to obtain the recommended structural framework nodes for the current task; Step 3-2: Generate a planning skeleton based on the recommended structural framework nodes of the current task; Step 3-3: Combine the current task, the recommended structural framework information of the current task, and the planning skeleton to obtain planning enhancement prompts. Then, input the planning enhancement prompts, the recommended structural framework information of the current task, and the execution link knowledge graph into the second agent to obtain the planning output result of the second agent.
[0007] Specifically, the construction method of subtask nodes, tool nodes, subtask sequence edges, relationship edges between subtasks and tool calls, and tool sequence edges in step 2 is as follows: Each subtask is constructed into a subtask node; Obtain the tools used in each subtask and build each tool into a tool node; Establish a directed sequential edge between each subtask and the subtask node corresponding to its next subtask; this sequential edge is called the subtask sequential edge. Establish a relationship edge between each subtask node and its corresponding tool node. This relationship edge is the relationship edge between the subtask and the tool call relationship. For each execution chain, the tools used by each subtask are recorded in the order of the subtasks in the subtask sequence to obtain the tool call sequence. A directed sequential edge is established between each tool in the tool call sequence and the tool node corresponding to its next tool. This sequential edge is called the tool sequence edge.
[0008] Furthermore, the specific construction method of the structural framework nodes and the relationship edges between the structural framework nodes and tool nodes in step 2 is as follows: A sliding window approach is used to generate at least one fixed-length tool subsequence for each execution chain tool call sequence, and all tool subsequences that appear more than a preset number of times in all execution chains are selected. The selected tool subsequences are recorded as high-frequency tool subsequences, and a structural framework node is established for each high-frequency tool subsequence. Establish a relationship edge between each structural frame node and the tool node corresponding to each tool in its high-frequency tool subsequence. This relationship edge is the relationship edge between the structural frame node and the tool node.
[0009] To ensure the number of tool subsequences while avoiding tool omissions, when generating at least one fixed-length tool subsequence for each execution chain's tool call sequence, the sliding window always starts from the first tool in the tool call sequence and ends when the sliding window ends at the last tool in the tool call sequence.
[0010] Preferably, each structural frame node includes the following information: the high-frequency tool subsequence corresponding to the current structural frame node, the number of times the high-frequency tool subsequence corresponding to the current structural frame node appears, and the vector of the current structural frame node.
[0011] Specifically, no. Each structural frame node The vector is obtained as follows: Get the Each structural frame node semantic channel vectors and structural channel vectors The semantic channel vector and the structural channel vector are fused to obtain the structural framework node vector. The calculation formula is: ; in, For a fixed length of tool subsequence, For the first Each structural frame node The first in the high-frequency tool subsequence A tool, for The tool vector, The calculation formula is: , for The text description, To generate vectors using an encoder.
[0012] Preferably, the specific method for obtaining the recommended structural framework node of the current task in step 3-1 is as follows: obtain the semantic channel vector of the current task, calculate the similarity between the semantic channel vector of the current task and the vector of each structural framework node, and take the structural framework node with the highest similarity as the recommended structural framework node of the current task.
[0013] Preferably, in step 3-2, the planning skeleton is composed of a sequence of tool call steps. The specific method for generating the sequence of tool call steps is as follows: each tool is mapped with a tool call step in the order of the high-frequency tool subsequence to which the recommended structural framework node belongs, and the tool call steps mapped to each tool are combined into a sequence of tool call steps in the order of the tools. Each tool invocation step includes locating the tool node corresponding to each tool in the execution chain knowledge graph, reading its tool name and tool description, using the tool name and tool description as the functional description of the tool invocation step, and generating analysis operation prompts for the tool invocation step.
[0014] Preferably, both the first and second intelligent agents are composed of large language models.
[0015] Compared with existing technologies, the advantages of this invention are as follows: By collecting the execution link set successfully generated by intelligent agents with strong planning capabilities when handling multiple tasks, and constructing a knowledge graph for the execution link set, structural framework nodes are formed during the construction of the knowledge graph. When intelligent agents with weak planning capabilities handle new tasks, the knowledge graph can provide planning skeletons and planning enhancement prompts for them. This significantly improves the success rate and stability of multi-step, multi-tool task planning while maintaining the advantages of low computing power and low deployment cost for intelligent agents with weak planning capabilities. At the same time, this invention transforms planning guidance technology from templated prompts or manual rules to a structured and reusable structural framework, reducing the dependence on domain experts to continuously write and maintain template rules, improving the efficiency of adapting to new tools and scenarios, and making the planning process more interpretable and traceable, which is convenient for engineering deployment and iterative optimization. Attached Figure Description
[0016] Figure 1 This is a flowchart of the intelligent agent planning enhancement method based on knowledge graph in an embodiment of the present invention. Detailed Implementation
[0017] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0018] like Figure 1 As shown, the knowledge graph-based agent planning enhancement method in this embodiment includes the following steps: Step 1: Collect the set of execution links successfully generated by the first intelligent agent when processing multiple tasks. The set of execution links includes multiple execution links, and each execution link includes multiple sub-tasks arranged in sequence and the tools used to execute each sub-task. Step 2: Construct a knowledge graph for the execution link set to generate an execution link knowledge graph; the execution link knowledge graph includes subtask nodes, tool nodes, structural framework nodes, subtask sequence edges, relationship edges between subtasks and tool calls, tool sequence edges, and relationship edges between structural framework nodes and tool nodes; Step 3: Obtain the current task instruction and use the second agent to process the current task. When the second agent processes the current task, it combines the execution link knowledge graph in Step 2 to obtain the planning output result with enhanced planning ability. The original planning ability of the second agent is lower than that of the first agent.
[0019] In this embodiment, each execution link is represented as a multi-step sub-task sequence, namely: the first... Execution chain , , and The first The first subtask, the second subtask, and the third subtask in the execution chain. Each subtask includes a subtask description and the tools used to execute the current subtask. The subtask description clarifies the intent and operation of the subtask, while the tools used to execute the current subtask are the tools invoked to execute the current subtask.
[0020] In this embodiment, the subtask node is constructed as follows: each subtask is constructed into a subtask node; each subtask node contains a unified structured field, namely: a node identifier that uniquely identifies the subtask node, a description of the current subtask, and an associated tool. The associated tool is the tool called to execute the current subtask, and the tool name and key parameters of the tool are recorded.
[0021] In this embodiment, the tool node is constructed as follows: the tools used by each subtask are obtained, and each tool is constructed into a tool node; each tool node includes the following information: a tool identifier, a tool name, and a tool description to uniquely identify the tool node, wherein the tool description is a specific functional description of the tool.
[0022] In this embodiment, the subtask sequence edge is constructed as follows: a directed sequence edge is established between each subtask and the subtask node corresponding to its next subtask. This sequence edge is the subtask sequence edge.
[0023] In this embodiment, the relationship edge between subtasks and tool calls is constructed as follows: a relationship edge is established between each subtask node and its corresponding tool node, and this relationship edge is the relationship edge between subtasks and tool calls.
[0024] In this embodiment, the tool sequence edge is constructed as follows: for each execution link, the tools used by each subtask are recorded in the order of the subtasks in the subtask sequence to obtain the tool call sequence, and a directed sequence edge is established between each tool in the tool call sequence and the tool node corresponding to its next tool. This sequence edge is the tool sequence edge.
[0025] In this embodiment, the structural framework node is constructed as follows: a sliding window is used to generate at least one fixed-length tool subsequence for each execution link's tool call sequence, and all tool subsequences that appear more than a preset number of times in all execution links are selected. The selected tool subsequences are recorded as high-frequency tool subsequences, and a structural framework node is established for each high-frequency tool subsequence.
[0026] In this embodiment, when generating at least one fixed-length tool subsequence for each execution chain's tool call sequence, the sliding window always starts from the first tool in the tool call sequence and ends when the sliding window reaches the last tool in the tool call sequence; all execution chains generate tool subsequences of the same fixed length. The preset number of attempts is determined based on experience or experimental confirmation.
[0027] In this embodiment, each structural frame node includes the following information: a unique identifier for the current structural frame node, the high-frequency tool subsequence corresponding to the current structural frame node, the sequence length of the high-frequency tool subsequence, the number of times the high-frequency tool subsequence corresponding to the current structural frame node appears, the structural frame description, and the vector of the current structural frame node.
[0028] This structural framework description is based on the functional descriptions of the tool nodes corresponding to each tool in the high-frequency tool subsequence. A description template is constructed, and a large language model is invoked to generate a natural language structural description to summarize the general meaning and applicable scenarios of the tool; A structural framework Structural framework description It is generated in the following way. , For the first A structural framework The corresponding high-frequency tool subsequence, , , and These are the first, second, and third tools in the high-frequency tool subsequence, respectively. A tool, A function that generates a concise, structured summary text from the input information is often used in large language models.
[0029] To support subsequent semantic retrieval and agent planning enhancements based on the structural framework, this step performs multi-channel vectorization encoding on the structural framework nodes, forming a structured structural framework node vector library. Each structural frame node The vector is obtained as follows: Get the Each structural frame node semantic channel vector and structure channel vector ;Transfer semantic channel vectors and structure channel vector By merging, we obtain the structural framework node vector. ; The calculation formula is: , This indicates vector concatenation; The calculation formula is: , To generate vectors using an encoder; The calculation formula is: ; in, For a fixed length of tool subsequence, For the first Each structural frame node The first in the high-frequency tool subsequence A tool, for The tool vector, The calculation formula is: , for The text description, , for Tool name, for Tool description, and All of this information comes from the tool nodes.
[0030] In this embodiment, the relationship edge between structural frame nodes and tool nodes is constructed as follows: establish a relationship edge between each structural frame node and the tool node corresponding to each tool in its high-frequency tool subsequence. This relationship edge is the relationship edge between structural frame nodes and tool nodes.
[0031] In this embodiment, the specific method for obtaining the planning output result is as follows: Step 3-1: Filter the structural framework nodes to obtain the recommended structural framework nodes for the current task; Step 3-2: Generate a planning skeleton based on the recommended structural framework nodes of the current task; Step 3-3: Set the current task The recommended structural framework information and planning skeleton of the current task are spliced together to obtain planning enhancement prompts. The planning enhancement prompts, the recommended structural framework information of the current task, and the execution link knowledge graph are then input into the second intelligent agent to obtain the planning output result of the second intelligent agent.
[0032] The specific method for obtaining the recommended structure framework nodes of the current task in step 3-1 above is as follows: Obtain the current task semantic channel vector Calculate the semantic channel vector of the current task. Based on the similarity with the vector of each structural frame node, the structural frame node with the highest similarity is selected as the recommended structural frame node for the current task. The calculation formula is: , Using the same text encoder as in the structural framework vector acquisition process, the task instructions are vectorized to obtain semantic channel vectors; the aforementioned similarity is used to calculate the semantic channel vector of the current task. Cosine similarity with each structural frame node vector.
[0033] In step 3-2 above, the planning skeleton consists of a sequence of tool call steps. The specific generation method of the tool call step sequence is as follows: according to the order of the high-frequency tool subsequence to which the recommended structural framework node belongs, each tool is mapped with a tool call step. The tool call steps mapped to each tool are then assembled into a tool call step sequence according to the order of the tools. Each tool call step includes locating the tool node corresponding to each tool in the execution link knowledge graph, reading its tool name and tool description, using the tool name and tool description as the functional description of the tool call step, and generating the analysis operation prompts that are recommended to be executed for the tool call step.
[0034] The planning output of the second agent in step 3-3 above The formula is: ; in, To enhance the planning and information display, The formula is: , Recommended structural framework nodes for the current task Structural framework description, To plan the framework, Functions to be concatenated; This is the execution link knowledge graph in step 2; A collection of tool nodes; It is the second intelligent agent.
[0035] The planning output of the second agent This can be represented by a sequence of subtasks. , , and These are the first, second, and third subtask nodes obtained from the planning of the second intelligent agent, respectively. Each sub-task node contains at least a description of the tool invocation steps and a recommended tool identifier.
[0036] This embodiment also relates to a computer-readable storage medium storing a computer program that can be read and executed by a processor. When the computer program is executed by the processor, it implements the knowledge graph-based intelligent agent planning enhancement method described above.
[0037] In this invention, both the first and second intelligent agents are composed of large language models. The large language model that makes up the first intelligent agent has a stronger planning ability, while the large language model that makes up the second intelligent agent has a weaker planning ability. Therefore, this application mines high-frequency tool subsequences from the execution link set successfully generated by the first intelligent agent when processing multiple tasks, and abstracts them into a reusable structural framework. The structural framework is represented by vectors, and a searchable structural framework vector library is established. When facing a new task, the user task is semantically vectorized, and the structural framework with the highest similarity is retrieved from the structural framework vector library. The corresponding planning skeleton and guidance prompts are then generated and provided as planning enhancement input to the second intelligent agent with weaker planning ability. This constrains the planning step sequence and tool selection logic of the second intelligent agent, thereby improving the planning success rate, stability, and interpretability while maintaining the advantages of low computing power and low deployment cost, and reducing the dependence on manual templates and rule maintenance.
[0038] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A knowledge graph-based agent planning enhancement method, characterized in that... Includes the following steps: Step 1: Collect the set of execution links successfully generated by the first intelligent agent when processing multiple tasks. The set of execution links includes multiple execution links, and each execution link includes multiple sub-tasks arranged in sequence and the tools used to execute each sub-task. Step 2: Construct a knowledge graph for the execution link set to generate an execution link knowledge graph; the execution link knowledge graph includes subtask nodes, tool nodes, structural framework nodes, subtask sequence edges, relationship edges between subtasks and tool calls, tool sequence edges, and relationship edges between structural framework nodes and tool nodes; Step 3: Obtain the current task instruction, use the second agent to process the current task, and combine the execution link knowledge graph in Step 2 when the second agent processes the current task to obtain the planning output result with enhanced planning ability; the original planning ability of the second agent is lower than that of the first agent. The specific method for obtaining the planning output results is as follows: Step 3-1: Filter the structural framework nodes to obtain the recommended structural framework nodes for the current task; Step 3-2: Generate a planning skeleton based on the recommended structural framework nodes of the current task; Step 3-3: Combine the current task, the recommended structural framework information of the current task, and the planning skeleton to obtain planning enhancement prompts. Then, input the planning enhancement prompts, the recommended structural framework information of the current task, and the execution link knowledge graph into the second agent to obtain the planning output result of the second agent.
2. The agent planning enhancement method according to claim 1, characterized in that: The specific construction method of subtask nodes, tool nodes, subtask sequence edges, relationship edges between subtasks and tool calls, and tool sequence edges in step 2 is as follows: Each subtask is constructed into a subtask node; Obtain the tools used in each subtask and build each tool into a tool node; Establish a directed sequential edge between each subtask and the subtask node corresponding to its next subtask; this sequential edge is called the subtask sequential edge. Establish a relationship edge between each subtask node and its corresponding tool node. This relationship edge is the relationship edge between the subtask and the tool call relationship. For each execution chain, the tools used by each subtask are recorded in the order of the subtasks in the subtask sequence to obtain the tool call sequence. A directed sequential edge is established between each tool in the tool call sequence and the tool node corresponding to its next tool. This sequential edge is called the tool sequence edge.
3. The agent planning enhancement method according to claim 2, characterized in that: The specific construction method for the structural framework nodes and the relationship edges between structural framework nodes and tool nodes in step 2 is as follows: A sliding window approach is used to generate at least one fixed-length tool subsequence for each execution chain tool call sequence, and all tool subsequences that appear more than a preset number of times in all execution chains are selected. The selected tool subsequences are recorded as high-frequency tool subsequences, and a structural framework node is established for each high-frequency tool subsequence. Establish a relationship edge between each structural frame node and the tool node corresponding to each tool in its high-frequency tool subsequence. This relationship edge is the relationship edge between the structural frame node and the tool node.
4. The agent planning enhancement method according to claim 3, characterized in that: When generating at least one fixed-length tool subsequence for each execution chain's tool call sequence, the sliding window always starts from the first tool in the tool call sequence and ends when the sliding window ends at the last tool in the tool call sequence.
5. The agent planning enhancement method according to claim 3, characterized in that: Each structural frame node includes the following information: the high-frequency tool subsequence corresponding to the current structural frame node, the number of times the high-frequency tool subsequence corresponding to the current structural frame node appears, and the vector of the current structural frame node.
6. The agent planning enhancement method according to claim 5, characterized in that: No. Each structural frame node The vector is obtained as follows: Get the Each structural frame node semantic channel vectors and structural channel vectors The semantic channel vector and the structural channel vector are fused to obtain the structural framework node vector. The calculation formula is: ; in, For a fixed length of tool subsequence, For the first Each structural frame node The first in the high-frequency tool subsequence A tool, for The tool vector, The calculation formula is: , for The text description, To generate vectors using an encoder.
7. The agent planning enhancement method according to claim 6, characterized in that: The specific method for obtaining the recommended structural framework nodes of the current task in step 3-1 is as follows: Obtain the semantic channel vector of the current task, calculate the similarity between the semantic channel vector of the current task and the vector of each structural framework node, and take the structural framework node with the highest similarity as the recommended structural framework node for the current task.
8. The agent planning enhancement method according to claim 7, characterized in that: The planning skeleton in step 3-2 consists of a sequence of tool call steps, and the specific method for generating the tool call step sequence is as follows: According to the order of the high-frequency tool subsequence to which the recommended structural framework node belongs, each tool is mapped to a tool invocation step, and the tool invocation steps mapped to each tool are combined into a tool invocation step sequence according to the order of the tools. Each tool invocation step includes locating the tool node corresponding to each tool in the execution chain knowledge graph, reading its tool name and tool description, using the tool name and tool description as the functional description of the tool invocation step, and generating analysis operation prompts for the tool invocation step.
9. The agent planning enhancement method according to any one of claims 1 to 8, characterized in that: Both the first and second agents are composed of large language models.