Multi-agent shared program memory method and system based on tool call graph

By constructing a shared program memory method for tool call graphs, the complexity and efficiency issues of tool call processes in large language model agents are solved, enabling successful experience sharing and efficient tool call among heterogeneous agents.

CN123050485APending Publication Date: 2026-11-06SHANDONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611551853.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-09
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing large language model agents suffer from problems such as complex tool selection, low invocation efficiency, and difficulty in effectively sharing and transferring successful experiences among different agents during the tool invocation process. In particular, in long-process, multi-tool, and cross-service tasks, existing memory methods lead to redundancy and erroneous migration.

Method used

The successful tool call trajectories of multiple heterogeneous large language model agents are abstracted into a tool call graph. A shared program memory pool is constructed. Through the execution order, tool selection and intermediate result transmission relationship of the tool call graph, memory entries are filtered and sorted, and structured prompts are provided to guide the tool call of the current task.

Benefits of technology

It enables the sharing of successful tool invocation experience among heterogeneous large language model agents, improves the execution reliability of complex tasks, reduces the need for redundant memory and repetitive planning, and improves the efficiency of tool invocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123050485A_ABST
    Figure CN123050485A_ABST
Patent Text Reader

Abstract

This invention relates to the field of large language model agents, and discloses a method and system for sharing program memory among multiple agents based on tool call graphs. The method includes: acquiring successful tool call trajectories from multiple heterogeneous large language model agents and abstracting them into tool call graphs; establishing memory entries for each tool call graph, containing historical execution success rates and structure-aware execution efficiency, sorting and retaining them according to semantic similarity to form semantic neighborhoods, and suppressing redundant memories; upon receiving a new task, calculating a retrieval score based on semantic relevance, execution success rate, and structure-aware execution efficiency, selecting the highest score as the reference program memory and converting it into structured prompt information to guide the current agent to reuse the high-level program structure such as tool call order, parameter dependencies, and intermediate result flow, regenerate parameters, and call the tool to obtain results; and updating the memory pool according to the execution results. This invention can improve the average completion rate of complex tool call tasks and reduce interaction overhead without modifying model parameters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of large language model intelligent agent technology, and specifically relates to a method and system for multi-agent shared program memory based on tool call graph. Background Technology

[0002] With the development of large language model technology, large language model agents are increasingly using external tools such as search engines, databases, computing, and software services to complete complex tasks. Unlike traditional text generation, tool invocation tasks not only require determining the tools to be invoked, but also constructing tool parameters, organizing multiple rounds of invocation, and handling intermediate results and data dependencies between different tools. The tool invocation process is particularly complex in long-process, multi-tool, and cross-service tasks.

[0003] Currently, methods to improve the tool-calling capabilities of large language models mainly include model training methods and memory augmentation methods. Model training methods train or fine-tune the large language model to enable it to learn tool selection and invocation methods, but require additional model training costs. Memory augmentation methods, on the other hand, save historical interactions, task trajectories, or prompts to provide references for subsequent tasks. However, existing memory methods typically save natural language content or complete interaction trajectories, which contain information related to specific tasks, parameters, and model inference processes, making effective sharing and transfer between different large language model agents difficult.

[0004] Meanwhile, historical tool invocation experiences with similar tasks vary in execution success rate and invocation efficiency. Saving all relevant experiences would lead to redundant shared memory and reduce retrieval effectiveness. Directly reusing parameters and tool outputs from historical trajectories could easily result in the erroneous transfer of information related to historical tasks to the current task. Therefore, a method is needed that can extract reusable program structures from historical tool invocation processes and combine execution quality and invocation efficiency to filter, store, and retrieve historical experiences.

[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0006] To address or at least alleviate one or more of the above problems, a method and system for sharing program memory among multiple agents based on tool call graphs are provided. This method can convert successful tool call experiences generated by multiple heterogeneous large language model agents into tool call graphs decoupled from specific model inference processes, and thereby construct, maintain, and retrieve shared program memory.

[0007] To achieve the above objectives, according to a first aspect of the present invention, a method for sharing program memory among multiple agents based on a tool call graph is provided, comprising the following steps:

[0008] S1. Obtain tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and filter out the tool call trajectories that successfully complete the tasks.

[0009] S2. The tool call trajectory of the successful completion of the task is abstracted into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and the execution order, tool selection and intermediate result transmission relationship are represented by execution order edges, tool call edges and data dependency edges.

[0010] S3. Establish a memory entry for each tool call graph and determine its quality information. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency.

[0011] S4. The newly established memory entries and existing memory entries in the shared program memory pool that have a semantic similarity that reaches a preset threshold are grouped into the same semantic neighborhood, and are sorted and retained according to the quality information to suppress redundant memory.

[0012] S5. Receive a new task query, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest score as the reference program memory.

[0013] S6. Convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and call the tool again to obtain results, and then update the shared program memory pool according to the execution results.

[0014] Furthermore, in S1, the tool call trajectory includes task query, execution steps arranged by execution round, the name of the tool called in each execution round, tool input parameters, tool output results, and task execution results;

[0015] The process of filtering tool call trajectories that successfully completed the task includes: determining whether the corresponding task was completed based on the final execution result of the task corresponding to each tool call trajectory; using tool call trajectories with successful task execution results as candidate trajectories for building shared program memory; and excluding tool call trajectories that failed to complete the task from the shared program memory pool.

[0016] Furthermore, in S2, the tool call graph is represented by a set of nodes and a set of directed edges; the set of nodes is constructed in the following way:

[0017] Based on the tool call trajectory, establish query nodes for storing task queries, establish an execution node set according to the execution round in which the tool call occurs, and establish a corresponding tool node for each tool call;

[0018] The process of establishing the tool node includes: standardizing the name of the tool being invoked to eliminate differences in the names of the same tool among different agents; extracting the input parameter structure of the tool invocation; using a language model to perform a factual summary of the original tool output; and compressing the original tool observation results into a task-related factual description to obtain a task-related summary of the tool node.

[0019] Furthermore, the set of directed edges includes execution order edges connecting adjacent execution nodes, tool call edges connecting execution nodes with tool nodes called in that execution round, and data dependency edges connecting tool nodes with intermediate result passing relationships;

[0020] The data dependency edges are established in the following way: based on the input parameter structure and output summary of the ordered tool calls, the usage relationship of subsequent tool calls on the results of previous tool calls is identified, the data dependency edges are established between tool nodes with usage relationships, and the intermediate variable mapping relationship from the output of the previous tool node to the input of the subsequent tool node is recorded; the tool call graph determined by the execution order edges and the data dependency edges is a directed acyclic graph.

[0021] Furthermore, in S3, the historical execution success rate is determined in the following way:

[0022] The large language model evaluator determines whether the corresponding task is completed based on the task query, tool call process, tool output results, and final task results, and converts the judgment results into corresponding success scores, which serve as a representation of the execution reliability of the tool call graph in historical tasks.

[0023] Furthermore, the execution efficiency of structure-aware processing is determined in the following way:

[0024] The degree of reuse of intermediate information is determined based on the number of data dependency edges and the number of tool nodes in the tool call graph.

[0025] The execution cost is obtained by multiplying the number of tool nodes, the number of execution nodes, and the number of data dependency edges in the tool call graph by their respective execution cost weight coefficients that are greater than zero.

[0026] The ratio of the intermediate information reuse level to the execution overhead is defined as the structure-aware execution efficiency; wherein, the intermediate information reuse level increases with the increase of the number of data dependency edges and decreases with the increase of the number of tool nodes, and the execution overhead increases with the increase of the number of tool nodes, the number of execution nodes and the number of data dependency edges. The structure-aware execution efficiency is used to reward tool call structures with a high degree of intermediate result reuse and to suppress tool call structures with many tool calls, long execution rounds or complex data dependencies.

[0027] Furthermore, in S4, those belonging to the same semantic neighborhood include:

[0028] Sentence vector encoding is performed on the task query corresponding to the newly established memory entry and the task query corresponding to the existing memory entry, respectively, and the cosine similarity between the two sentence vectors is calculated as the semantic similarity.

[0029] Existing memory entries with semantic similarity greater than or equal to a preset similarity threshold are identified as memory entries belonging to the same semantic neighborhood as the newly established memory entries;

[0030] When there are no memory entries belonging to the same semantic neighborhood, the newly created memory entry is directly written into the shared program memory pool;

[0031] When there are memory entries belonging to the same semantic neighborhood, the newly established memory entry and the memory entries belonging to the same semantic neighborhood form a candidate set. The candidate set is sorted in descending lexicographical order according to the tuple composed of the historical execution success rate and the structure-aware execution efficiency. Memory entries with high historical execution success rate are retained first, and when the historical execution success rates are the same, memory entries with high structure-aware execution efficiency are retained first. Only a preset number of memory entries at the top of the list are retained.

[0032] Furthermore, in S5, the calculation of the retrieval score includes:

[0033] The semantic similarity between the task query and the task query corresponding to the candidate memory entry, the historical execution success rate of the candidate memory entry, and the structure-aware execution efficiency of the candidate memory entry are multiplied by their respective weight coefficients (greater than zero) and then summed to obtain the retrieval score of the candidate memory entry.

[0034] The candidate memory entries are memory entries with a semantic similarity greater than or equal to a preset similarity threshold; the candidate memory entry with the highest retrieval score is selected as the reference program memory; when no candidate memory entry exists, the memory in the shared program memory pool is not invoked, and the current task is executed in the conventional tool invocation manner.

[0035] Further, in S6, the tool call graph of the reference program memory is converted into structured prompt information, including:

[0036] Traverse the execution nodes in the tool call graph along the execution order edge to obtain the sequence of execution nodes arranged by execution round;

[0037] For each execution node, traverse each tool node connected by the tool call edge according to the tool call index, and record the normalized tool name, input parameter structure, task-related summary and intermediate variable mapping relationship carried by the incoming data dependency edge pointing to the tool node in sequence, and generate an execution-oriented structured program memory prompt block containing the tool call order, parameter dependency relationship and intermediate result flow relationship;

[0038] The structured program memory prompt block is injected as reference information into the current task prompt, rather than as a static answer template for the current task. The large language model agent only reuses the high-level tool call program structure within it, and does not directly copy the task-specific parameters, tool output results, or final answers in the reference program memory. Instead, it regenerates tool parameters and intermediate variables according to the current task, and obtains the intermediate and final results required for the current task again through new tool calls.

[0039] To achieve the above objectives, according to a second aspect of the present invention, a multi-agent shared program memory system based on a tool call graph is provided, the system comprising:

[0040] The trajectory acquisition and filtering module is used to acquire tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and to filter out the tool call trajectories that successfully complete the tasks.

[0041] The tool call graph construction module is used to abstract the tool call trajectory of the successfully completed task into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and uses execution order edges, tool call edges and data dependency edges to represent the execution order of tool calls, tool selection and intermediate result transmission relationships, respectively.

[0042] A memory entry construction module is used to build a memory entry for each tool call graph and determine the quality information of the memory entry. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency.

[0043] The memory pool update module is used to classify newly created memory entries and existing memory entries in the shared program memory pool that have a semantic similarity of up to a preset threshold into the same semantic neighborhood, and sort and retain the memory entries in the semantic neighborhood according to the quality information to suppress redundant memory.

[0044] The memory retrieval module is used to receive new task queries, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest retrieval score as the reference program memory.

[0045] The program memory injection module is used to convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and obtain the result of the current task through the new tool call, and then update the shared program memory pool according to the execution result of the current task.

[0046] By adopting the above technical solution, the present invention has the following beneficial effects compared with the prior art.

[0047] This invention structures historical successful tool call trajectories into a tool call graph, separating the execution order of tool calls, tool selection relationships, and intermediate result data dependencies from the inference text and task-specific information of the specific large language model. This allows successful tool call experiences to be shared and transferred among heterogeneous large language model agents without modifying the parameters of the large language model.

[0048] This invention constructs quality information of memory entries by combining historical execution success rate and structure-aware execution efficiency, and limits the number of memory entries retained in the same semantic neighborhood by using semantic neighborhood and quality ranking, thereby suppressing redundant memory in the shared program memory pool and reducing the size of the memory pool and retrieval interference.

[0049] This invention selects reference program memory by jointly calculating the retrieval score based on semantic relevance, historical execution success rate, and structure-aware execution efficiency. The reference program memory is then converted into execution-oriented structured prompts and injected into the current task. This allows the current agent to reuse only the high-level tool call program structure and regenerate the specific parameters and intermediate results of the current task. This avoids the erroneous migration of specific information from historical tasks to the current task, thereby improving the execution reliability of complex tool call tasks and reducing the need for repetitive planning and tool interaction overhead.

[0050] The specific embodiments of the present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description

[0051] The accompanying drawings, as part of this invention, are provided to further illustrate the invention. The illustrative embodiments and descriptions of the invention are used to explain the invention, but do not constitute an undue limitation thereof. Clearly, the drawings described below are merely some embodiments; those skilled in the art can obtain other drawings based on these drawings without any creative effort.

[0052] Figure 1This is a flowchart illustrating the multi-agent shared program memory method based on tool call graphs in this specific embodiment.

[0053] Figure 2 This is a schematic diagram of the tool call diagram TCG in this specific embodiment.

[0054] Figure 3 This diagram illustrates a comparison of the average task success rate of the method of the present invention with other memory enhancement methods in this specific embodiment.

[0055] Figure 4 This is a schematic diagram of the structure of the multi-agent shared program memory system based on the tool call graph in this specific embodiment. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments will be clearly and completely described below with reference to the accompanying drawings. The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0057] In the following description, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0058] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of the present invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0059] Please see Figure 1 This invention provides a method for sharing program memory among multiple agents based on tool call graphs, comprising the following steps:

[0060] S1. Obtain tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and filter out the tool call trajectories that successfully complete the tasks.

[0061] S2. The tool call trajectory of the successful completion of the task is abstracted into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and the execution order, tool selection and intermediate result transmission relationship are represented by execution order edges, tool call edges and data dependency edges.

[0062] S3. Establish a memory entry for each tool call graph and determine its quality information. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency.

[0063] S4. The newly established memory entries and existing memory entries in the shared program memory pool that have a semantic similarity that reaches a preset threshold are grouped into the same semantic neighborhood, and are sorted and retained according to the quality information to suppress redundant memory.

[0064] S5. Receive a new task query, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest score as the reference program memory.

[0065] S6. Convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and call the tool again to obtain results, and then update the shared program memory pool according to the execution results.

[0066] Specifically, this invention converts successful tool call experiences generated by multiple heterogeneous large language model agents into tool call graphs decoupled from specific model inference processes, and further constructs a shared program memory pool. For subsequent new tasks, program memories related to the current task are retrieved from the shared program memory pool, and these program memories are provided to the current agent in the form of structured prompts, enabling the current agent to reuse the tool call structure from historical tasks. At the same time, the specific parameters required for the current task are regenerated, and the results of the current task are obtained through new tool calls. After the current task is successfully executed, the successful tool call trajectory formed by the current task is converted into new program memories and the shared program memory pool is updated, thereby forming a continuous evolution process of shared program memories.

[0067] In some embodiments, in S1, the tool call trajectory includes a task query, execution steps arranged by execution round, the name of the tool called in each execution round, tool input parameters, tool output results, and task execution results; the filtering of tool call trajectories that successfully complete the task includes: determining whether the corresponding task is completed based on the final execution result of the task corresponding to each tool call trajectory, using tool call trajectories with successful task execution results as candidate trajectories for constructing shared program memory, and excluding tool call trajectories that fail to complete the task from the shared program memory pool.

[0068] Specifically, multiple heterogeneous large language model agents receive external task queries and interact with the external tool environment based on their respective model capabilities, inference methods, and tool invocation strategies. These external tools may include search tools, database query tools, computing tools, software service interfaces, and tool services based on model context protocols, etc., which are not limited in this invention. During the execution of a task, the tool invocation process generated by the agents is recorded to form a tool invocation trajectory; wherein, the execution round is used to indicate the sequence of tool invocations, and the same execution round may contain one or more tool invocations.

[0069] For example, for a multi-step task that requires first querying information, then performing calculations using the query results, and finally calling another tool based on the calculation results to complete the task, the tool call process can be recorded as follows: In the first execution round, tool A is called to obtain the raw information; in the second execution round, tool B is called to perform calculations based on the output of tool A; in the third execution round, tool C is called to obtain the final result based on the output of tool B. In addition to the tool names and the order of call, the input-output relationships between each tool call are also recorded to facilitate the establishment of data dependencies later.

[0070] After obtaining the tool call trajectory, the trajectory is filtered based on the final task completion status. Only tool call trajectories that successfully completed the corresponding task are used as candidate program memories; trajectories that failed to complete the task are not directly used to build high-quality shared program memories. Through this filtering, the interference of invalid experiences such as incorrect tool selection, incorrect parameter construction, and incomplete tasks on the shared program memory pool can be reduced.

[0071] Please see Figure 2 In some embodiments, in S2, the tool call graph is represented by a set of nodes and a set of directed edges; the set of nodes is constructed in the following way: a query node for storing task queries is established according to the tool call trajectory, an execution node set is established according to the execution round in which the tool call occurs, and a corresponding tool node is established for each tool call; wherein, establishing the tool node includes: normalizing the name of the tool in this call to eliminate the name differences of the same tool among different agents, extracting the input parameter structure of this tool call, and using a language model to perform a factual summary of the original tool output, compressing the original tool observation results into a factual description related to the task, and obtaining a task-related summary of the tool node.

[0072] Specifically, for the successful tool call trajectory obtained in step S1, the inference text, formatting information, and intermediate information that are strongly related to the current task but cannot be reused are abstracted, and only the tool call program structure required for reuse in subsequent tasks is retained.

[0073] The tool call diagram is represented as follows:

[0074]

[0075] in, Represents a tool call graph; This represents the set of nodes in the tool call graph; This represents the set of directed edges in the tool call graph.

[0076] The node set is represented as:

[0077]

[0078] in, This represents a query node, used to store the task queries corresponding to the current tool call trajectory; This represents a set of execution nodes, arranged according to the execution round in which the tool was invoked. This represents a collection of tool nodes, used to represent the external tools that are actually invoked.

[0079] For the Each tool node is represented as:

[0080]

[0081] in, Indicates the first One tool node; This indicates the normalized tool name, used to eliminate different names or formats that different agents may use for the same tool; This indicates that the tool calls the corresponding input parameter structure or input parameter vector; This represents a task-related summary obtained after compressing the output of the tool.

[0082] The input parameter structure primarily retains the parameter types, fields, and relationships between parameters. Task-specific entities, identifiers, and numerical values ​​can be represented as reference information in subsequent structured memory hints, but need to be regenerated during the current task execution. The tool output summary retains factual information from the original tool output relevant to subsequent tool calls and task completion, without saving lengthy original tool observations.

[0083] The set of directed edges can be further represented as:

[0084]

[0085] in, This represents the set of directed edges in the tool call graph; Represents the set of edges indicating the execution order; This represents the set of edges that the tool calls; This represents the set of data-dependent edges.

[0086] Execution order edges are used to connect adjacent execution nodes, such as consecutive execution nodes. and Establish from point to The execution order edges are used to maintain the temporal order of the original tool call trajectory. Tool call edges connect the execution node to the tool node actually called in that execution round. Call tool nodes Then establish from point to Tool call edges record which tools were called in a given execution round. Data dependency edges represent the intermediate result transmission relationships between different tool calls. The output results are used by subsequent tool nodes When constructing input parameters, and Directed data dependency edges are established between tools, and the corresponding intermediate variable mapping relationships are recorded. This clearly indicates which intermediate results generated by the previous tool are used by the subsequent tool. Since the execution order edges follow the time order of the tool call trajectory, and the data dependency edges follow the direction in which intermediate results are passed from the preceding tool to the following tool, the constructed tool call graph is a directed acyclic graph.

[0087] like Figure 2 As shown, query node Used to represent task queries; execution node , , Arranged by execution round; tool nodes , , , These represent the corresponding tool calls. In a specific example, the tool is called in the first execution round. The second execution round simultaneously invokes the tool. and The third execution round calls the tool. ;tool The input parameters depend on the tool The output result is in and Establish data dependency edges between them. This graph structure can simultaneously express the order in which tools are called, the tools called in each round, and the data flow relationships between different tools.

[0088] In some embodiments, the directed edge set includes execution order edges connecting adjacent execution nodes, tool call edges connecting execution nodes to tool nodes called in that execution round, and data dependency edges connecting tool nodes with intermediate result transmission relationships. The data dependency edges are established by: identifying the usage relationship between subsequent tool calls and the results of previous tool calls based on the input parameter structure and output summary of the ordered tool calls; establishing the data dependency edges between tool nodes with usage relationships; and recording the intermediate variable mapping relationship from the output of the previous tool node to the input of the subsequent tool node. The tool call graph determined by the execution order edges and the data dependency edges is a directed acyclic graph.

[0089] Specifically, the summary module is used to compress the original tool output into a concise and factual description relevant to the current task. The gpt-o4-mini model is used with the following prompt template to reduce storage size and remove redundant observation information that is irrelevant to program reuse.

[0090] The system prompt reads: "You are the professional summarizing module in a multi-agent shared memory system. Please compress the given tool output into a strictly fact-based 1 to 3-sentence summary, without introducing information that does not exist in the tool output or changing the meaning of the original information."

[0091] The user suggestion is:

[0092] Task: {task_text}

[0093] Tool name: {tool_name}

[0094] Tool input parameters: {tool_args}

[0095] Tool output: {tool_result}

[0096] Please return to a concise summary of the tool's output and its key data.

[0097] Here, {task_text} represents the task description of the current task, {tool_name} represents the name of the currently invoked tool, {tool_args} represents the input parameters used in the current tool invocation, and {tool_result} represents the raw output returned by the current tool. The summary module extracts key facts and data that may be reused in subsequent task executions from the tool output based on the above inputs, and removes redundant observations irrelevant to program reuse, thus obtaining a task-related summary for the corresponding tool node.

[0098] For data dependencies, the usage relationship of subsequent tool calls on the output of preceding tools is identified based on the input parameters and output summaries of ordered tool calls, and the corresponding intermediate variable mappings are recorded.

[0099] In some embodiments, in S3, the historical execution success rate is determined as follows: the large language model evaluator judges whether the corresponding task is completed based on the task query, tool call process, tool output results and final task results, and converts the judgment result into the corresponding success rate score, which serves as a representation of the execution reliability of the tool call graph in historical tasks.

[0100] Specifically, for each successful tool call graph constructed in step S2, a corresponding program memory entry is created. Each memory entry is represented as:

[0101]

[0102] in, Indicates the first Each program remembers an entry; Indicates the first Tool call diagram corresponding to each memory entry; Indicates the first The historical execution success rate of each memory entry is used to measure the reliability of the corresponding tool's calling program in the execution of historical tasks; Indicates the first The structure-aware execution efficiency of memory entries is used to measure the degree to which the tool calling structure reuses intermediate information and its execution overhead.

[0103] Historical execution success rate In this embodiment, gpt-o4-mini is used as the Large Language Model Evaluator (LLM-as-a-Judge) to evaluate the task completion status of the corresponding tool call trajectory. The Large Language Model Evaluator determines whether the corresponding task is completed based on the task query, tool call process, tool output results, and final task results, and converts the evaluation results into historical execution success rates. When using the StableToolBench evaluation protocol, tasks are rated as resolved, questionable, and unresolved, corresponding to success scores of 1, 0.5, and 0, respectively. By adopting a unified task completion evaluation method, tool call trajectories generated by different heterogeneous large language models can be converted into comparable quality metrics.

[0104] In some embodiments, structure-aware execution efficiency is determined as follows: the degree of intermediate information reuse is determined based on the number of data dependency edges and the number of tool nodes in the tool call graph; the execution cost is obtained by multiplying the number of tool nodes, the number of execution nodes, and the number of data dependency edges in the tool call graph by their corresponding, greater than zero execution cost weight coefficients; the ratio of the degree of intermediate information reuse to the execution cost is determined as the structure-aware execution efficiency; wherein the degree of intermediate information reuse increases with the increase of the number of data dependency edges and decreases with the increase of the number of tool nodes, and the execution cost increases with the increase of the number of tool nodes, the number of execution nodes, and the number of data dependency edges; the structure-aware execution efficiency is used to reward tool call structures with a high degree of intermediate result reuse and to suppress tool call structures with many tool calls, long execution rounds, or complex data dependencies.

[0105] Specifically, firstly, the degree of information reuse in the tool call diagram is calculated. , is represented as:

[0106]

[0107] in, Indicates the first The degree of information reuse in the tool call graph; Tool call diagram The number of data dependency edges, i.e. the number of intermediate result transmission relationships between different tool calls; Tool call diagram The number of tool nodes in the system; To avoid division by zero when the number of tool nodes is small, the number of potential dependencies in a simple sequential tool call chain is used as a normalization reference. A higher degree of information reuse indicates that multiple tools can effectively utilize existing intermediate results, reducing redundant acquisition or computation; therefore, the corresponding tool call structure has higher program reuse value.

[0108] Further calculate the execution overhead of the tool call graph. , is represented as:

[0109]

[0110] in, Indicates the first The overall execution overhead of the tool call graph; The execution overhead weight representing the number of tool calls is used to control the impact of the number of tool calls on the overall execution overhead. Indicates the number of tool nodes; The execution overhead weight, representing the number of execution rounds, is used to control the impact of multiple execution rounds on the overall execution overhead. Indicates the number of execution nodes; The execution overhead weight, representing the complexity of data dependencies, is used to control the impact of data dependencies between tools on the overall execution overhead. In this embodiment, it is set... , , This gives execution rounds a higher overhead weight than a single tool call, while also taking into account the coordination overhead caused by data dependencies.

[0111] Furthermore, based on the degree of information reuse... and execution overhead Computational structure-aware execution efficiency :

[0112]

[0113] in, Indicates the first The structure-aware execution efficiency of memory entries; This indicates the degree of information reuse. Based on the above calculation method, tool call structures with a high degree of intermediate result reuse and fewer tool calls, execution rounds, and dependencies can achieve higher structure-aware execution efficiency; conversely, if the number of tool calls is high, the execution rounds are long, or the data dependencies are too complex, its structure-aware execution efficiency will decrease accordingly.

[0114] In some embodiments, S4, classifying memory entries into the same semantic neighborhood includes: encoding the task query corresponding to the newly established memory entry and the task query corresponding to the existing memory entry into sentence vectors, and calculating the cosine similarity between the two sentence vectors as semantic similarity; determining existing memory entries with semantic similarity greater than or equal to a preset similarity threshold as memory entries classified into the same semantic neighborhood as the newly established memory entry; when there are no memory entries classified into the same semantic neighborhood, directly writing the newly established memory entry into the shared program memory pool; when there are memory entries classified into the same semantic neighborhood, forming a candidate set with the newly established memory entry and the memory entries classified into the same semantic neighborhood, sorting them in descending lexicographical order according to the tuple composed of the historical execution success rate and the structure-aware execution efficiency, prioritizing the retention of memory entries with high historical execution success rates, and prioritizing the retention of memory entries with high structure-aware execution efficiency when historical execution success rates are the same, and retaining only a preset number of memory entries ranked first.

[0115] Specifically, the shared program memory pool is set as This includes several program memory entries already stored. For newly acquired memory entries... Obtain the task query from the tool call graph corresponding to the new memory entry. and from existing memory entries The corresponding tool calls the image to retrieve the task query. First, the sentence vector encoding functions are used respectively. The task queries are converted into vector representations, and the semantic similarity between two task queries is calculated using cosine similarity:

[0116]

[0117] in, Indicates task query With task query Semantic similarity between them; This indicates the task query corresponding to the new memory entry; Indicates the first Task query corresponding to each existing memory entry; This represents a sentence vector encoding function used to convert natural language task queries into vector representations. This represents the cosine similarity calculation function. In this embodiment, all-MiniLM-L6-v2 is used as the text embedding model to implement the sentence vector encoding function. For each task query of a memory entry, its sentence vector is encoded and cached when the memory entry is created, thereby reducing the overhead of repeated encoding during subsequent memory updates and retrieval processes.

[0118] Set a preset semantic similarity threshold. And construct and query the task Corresponding semantic neighborhood:

[0119]

[0120] in, Representation and Query A set of existing memory entries with sufficiently high semantic similarity; Indicates the current shared program memory pool; Represents the first in the shared program memory pool One memory entry; Indicates query Compared with existing queries Semantic similarity between them; This represents a preset semantic similarity threshold, used to determine whether two tasks belong to the same semantic neighborhood. In this embodiment, a threshold is set. .

[0121] when When empty, it means that there is no historical task in the shared program memory pool that is sufficiently similar to the current new memory entry. In this case, the new memory entry is directly added to the shared program memory pool.

[0122] when If not empty, add a new memory entry. Together with existing memory entries in the semantic neighborhood, they form a candidate set:

[0123]

[0124] in, This represents the candidate set consisting of the new memory entry and the existing memory entries in its semantic neighborhood; This represents the set of existing memory entries that meet the semantic similarity threshold. This indicates a newly acquired successful memory entry.

[0125] For memory entries in the candidate set, first sort them by tuple. Sort the data in descending order lexicographically, prioritizing comparisons of historical execution success rates. When historical execution success rates are the same, then compare the structure-aware execution efficiency. Therefore, priority is given to retaining tool call procedures with higher historical execution reliability; when historical execution reliability is the same, priority is given to retaining tool call procedures with more efficient structures. Subsequently, only the top-ranked procedures are retained. Each memory entry. In this embodiment, a memory entry is set. This means that a maximum of three high-quality program memories are retained for the same semantic neighborhood. This mechanism limits the size of the shared program memory pool while retaining different effective tool call programs, preventing the continuous accumulation of a large amount of redundant tool call experience for the same or similar tasks.

[0126] In some embodiments, S5, calculating the retrieval score includes: multiplying the semantic similarity between the task query and the task query corresponding to the candidate memory entry, the historical execution success rate of the candidate memory entry, and the structure-aware execution efficiency of the candidate memory entry by corresponding weight coefficients that are greater than zero, and then summing them to obtain the retrieval score of the candidate memory entry; wherein, the candidate memory entry is a memory entry with a semantic similarity greater than or equal to a preset similarity threshold; selecting the candidate memory entry with the highest retrieval score as the reference program memory; when there is no candidate memory entry, not calling the memory in the shared program memory pool, and executing the current task according to the conventional tool calling method.

[0127] Specifically, when a new task query Upon arrival, the system first iterates through the existing memory entries in the shared program memory pool, retrieving the task query from the tool call graph corresponding to each memory entry. And calculate the current task query according to the method described in step S4. Historical task query The semantic similarity between them. For those that satisfy The shared program memory pool is used as a candidate program memory for the current task. If no candidate program memory meets the semantic similarity threshold, it is considered that there is not enough relevant historical experience in the current shared program memory pool, and the shared program memory is not used to guide the current task. Instead, the current task is executed in the conventional tool invocation manner.

[0128] When candidate programs are remembered, the retrieval score is further calculated by comprehensively considering semantic relevance, historical execution success rate, and structure-aware execution efficiency.

[0129]

[0130] in, Indicates the current task query With the A comprehensive search score among candidate memory entries; This represents the semantic relevance weight, used to control the impact of the semantic similarity between the current task and historical tasks on the search results; This indicates the semantic similarity between the current task query and the historical task query; This represents the weight of historical execution success rate, used to control the impact of historical execution reliability on search results; Indicates the first The historical execution success rate of each memory entry; This represents the structure-aware execution efficiency weight, which is used to control the impact of tool call structure efficiency on search results; Indicates the first The structure-aware execution efficiency of each memory entry. In this embodiment, the following is set: , , By simultaneously considering semantic relevance, historical execution success rate, and structure-aware execution efficiency, we can avoid selecting memory entries with low execution reliability or low tool invocation structure efficiency based solely on historical experience and relying solely on semantic similarity.

[0131] After obtaining the retrieval scores for all candidate memory entries, the memory entry with the highest retrieval score is selected as the reference program for memorization, that is:

[0132]

[0133] in, This represents the reference program memory of the final selection; This represents the set of candidate memory entries that meet the semantic similarity threshold. Indicates the current query With candidate memory entries A comprehensive search score between them; This indicates that the entry that gives the highest overall search score will be selected.

[0134] In some embodiments, in S6, converting the tool call graph of the reference program memory into structured prompt information includes: traversing the execution nodes in the tool call graph along the execution order edge to obtain a sequence of execution nodes arranged by execution rounds; for each execution node, traversing each tool node connected by the tool call edge according to the tool call index, and sequentially recording the normalized tool name, input parameter structure, task-related summary, and intermediate variable mapping relationship carried by the incoming data dependency edge pointing to the tool node, generating an execution-oriented structured program memory prompt block containing the tool call order, parameter dependency relationship, and intermediate result flow relationship; the structured program memory prompt block is injected as reference information into the current task prompt, rather than as a static answer template for the current task. The large language model agent only reuses the high-level tool call program structure therein, and does not directly copy the task-specific parameters, tool output results, or final answers in the reference program memory. Instead, it regenerates tool parameters and intermediate variables according to the current task, and obtains the intermediate results and final results required for the current task again through new tool calls.

[0135] Specifically, in determining the reference procedure memory Then, retrieve the tool call graph stored within it. The tool call graph is serialized, converting the graph structure into structured text that can be directly input into a large language model. First, historical task queries are retrieved from the query nodes and used as task descriptions for reference tasks; then, the execution order edges are processed... Traverse the tool call graph to obtain the sequence of execution nodes arranged according to the execution round. ,in This indicates the total number of execution rounds. For the [number]th round... Each execution round, from the execution node Connected tool call edge Retrieve all tool nodes called in this round and sort them according to their tool call index. For each tool node... Record the names of the normalization tools in sequence. Input parameter structure and tool output summary Furthermore, traverse the inbound data dependency edges of this tool node. When data dependency edges exist At that time, record the current tool in the structured prompt information. Depends on preceding tools And record the corresponding intermediate variable mapping. .in, Indicates from the preceding tool node Output results to the current tool node The data mapping relationship between input parameters.

[0136] Through the above serialization process, the original graph structure can be converted into structured procedural memory cue blocks organized according to execution rounds. Each cue block includes at least the task intent, tool call order, tool name, input parameter structure, output summary, and intermediate result dependencies. In this embodiment, the structured procedural memory cue blocks are injected into the current task as "reference procedural memory," rather than serving as a static answer template for the current task. The current large language model agent is required to only refer to the high-level tool call procedural structure from historical tasks, and not directly copy specific entities, identifiers, values, tool outputs, or final answers from historical tasks.

[0137] Specifically, after injecting the reference program memory into the current task, the current agent first checks whether the historical tool call structure is applicable to the current task. If applicable, it constructs a tool call plan for the current task by referring to the historical execution order, tool selection relationships, and parameter dependencies. For specific parameters, entities, identifiers, and intermediate variables in the current task, they are regenerated according to the current task, and the corresponding results are obtained through new tool calls. Therefore, even if the current task and the historical task have similar task intentions, the specific execution results in the historical task are not directly reused. Instead, the program structure with transfer value in the historical task is reused, thereby reducing the risk of erroneously transferring specific information from the historical task to the current task.

[0138] In some embodiments, S6, updating the shared program memory pool based on the execution result of the current task includes: when the current task is not successfully completed, excluding the tool call trajectory of the current task from the shared program memory pool; when the current task is successfully completed, using the tool call trajectory of the current task as a new successful tool call trajectory, and re-executing S2 to S4, thereby updating the new memory entries obtained to the shared program memory pool.

[0139] Specifically, the heterogeneous large language model agent executes the current task under the structured program memory reference provided in step S6, and records the complete tool call trajectory generated by the current task. If the current task is not completed successfully, the tool call trajectory is marked as an unsuccessful task and is not directly written into the shared program memory pool as high-quality program memory, thereby avoiding the continuous pollution of the shared program memory by erroneous tool call structures. If the current task is completed successfully, the tool call trajectory of the current task is re-executed through the tool call graph construction process described in step S2 to obtain the tool call graph corresponding to the current task; subsequently, the memory entry construction process described in step S3 is executed to obtain new memory entries. The shared program memory pool is updated according to the semantic similarity matching, semantic neighborhood construction and quality ranking process described in step S4.

[0140] For historical memories that do not have sufficient semantic similarity to the new memory entry, the new memory entry is added to the shared program memory pool as an independent memory; for historical memories that have semantic similarity, the old and new memory entries are combined to form a candidate set, and the selection is based on the historical execution success rate. and structure-aware execution efficiency Sort the data and keep only the preset quantity. High-quality memory entries. Through the above method, newly generated successful tool call experiences can continuously enter the shared program memory pool, while redundant experiences that are highly similar to existing experiences but of lower quality are eliminated, thereby achieving the continuous evolution of the shared program memory.

[0141] Please see Figure 3 Furthermore, in one specific embodiment, the above method is experimentally verified.

[0142] This embodiment uses the StableToolBench as the benchmark for testing tool invocation tasks. The original StableToolBench test set contains 1100 tasks, of which 765 tasks were identified as stably executable and used as evaluation tasks. The experiment also uses the Chain-of-Thought (CoT) reasoning strategy for evaluation.

[0143] In this embodiment, Llama3.1-8B and Qwen3-235B are used as two heterogeneous large language model agents, forming a multi-agent tool invocation system. The two agents are tested using the same shared program memory pool to verify whether successful tool invocation experiences generated by one agent can be reused by the other heterogeneous agent.

[0144] During the shared program memory pool initialization phase, a new task query is generated for the benchmark test task using a large language model. This new query shares similar task intent, tool requirements, and tool invocation patterns with the original task, but differs in language expression and specific task parameters. In this embodiment, gpt-o4-mini is used to generate semantically similar task queries for initializing the shared program memory pool. The generated new task query maintains the overall intent, complexity, number of sub-objectives, and tool invocation and data dependency structure of the original task, while modifying the scenario, entities, identifiers, and specific values ​​within the task, thereby avoiding the shared program memory directly storing the test task itself.

[0145] The generated task queries are executed independently by Llama3.1-8B and Qwen3-235B, respectively. Only the tool call trajectories of successfully completed tasks are converted into tool call graphs and further memory entries are established. The resulting shared program memory pool is derived from successful tool call experience verified by actual execution, rather than directly using benchmark test results or manually constructed ideal tool call trajectories.

[0146] In the memory pool management process, all-MiniLM-L6-v2 is used as the text embedding model to encode task queries into sentence vectors and calculate the cosine similarity between queries; for the same semantic neighborhood, at most [number missing] are retained. One memory entry.

[0147] In this embodiment, the execution overhead weight for structure-aware execution efficiency is set to... , and ;in Indicates the weight of the number of tool calls. Indicates the weight of the execution round. This indicates the weighting of data dependency quantity. The weighting of the memory retrieval score is set to... , and ;in Represents semantic relevance weights. Indicates the weight of historical execution success rate. This represents the weight for structure-aware execution efficiency. Semantic similarity threshold. This is used to determine the semantic relevance range of candidate memories. For evaluating the task execution results, this embodiment uses the LLM-as-a-Judge approach to determine task success. Specifically, the large language model evaluator integrates the task query, the tool invocation process generated by the agent, the tool output, and the final task result to determine whether the task is completed. Under the StableToolBench evaluation protocol, resolved, questionable, and unresolved correspond to different success levels, and a success score for each task execution is obtained accordingly. The average task success rate is obtained by statistically analyzing the success scores of multiple test tasks.

[0148] To verify the effectiveness of the shared program memory method of this invention compared to memoryless tool invocation and other memory enhancement methods, the method of this invention (MemTool) was compared with memoryless (w / oMem), agent memory (A-Mem), and interactive memory sharing (INMS). Here, w / oMem represents a basic tool invocation method that does not use shared program memory; A-Mem represents a method based on agent memory; INMS represents a shared memory method oriented towards multiple agents; and the method of this invention employs a shared program memory mechanism based on a tool invocation graph. All methods were tested on the same task set and corresponding agents.

[0149] During the experiment, for each test task, Llama3.1-8B and Qwen3-235B independently executed tool calls, retrieving reference program memories from the same shared program memory pool when using the method of this invention. For the method of this invention, candidate memories are first filtered based on the semantic similarity between the current test task and historical task queries in the shared program memory pool; then, a retrieval score is calculated based on semantic relevance, historical execution success rate, and structure-aware execution efficiency; after selecting the memory entry with the highest score, its tool call graph is serialized into a structured program memory prompt and injected into the current task; finally, the current agent regenerates specific tool parameters based on the current task and completes the tool call.

[0150] Experimental results are as follows Figure 3 As shown. For Llama3.1-8B, under the Chain-of-Thought (CoT) inference strategy, the average task success rates for w / oMem, A-Mem, INMS, and the method of this invention are 28.9, 27.9, 27.7, and 33.5, respectively; for Qwen3-235B, under the CoT inference strategy, the average task success rates for w / oMem, A-Mem, INMS, and the method of this invention are 46.4, 42.8, 49.0, and 51.8, respectively. Figure 3 The experimental data shown demonstrates that the method described in this invention achieved high average task success rates on both the Llama3.1-8B and Qwen3-235B heterogeneous large language model agents. For example, the average task success rate of Llama3.1-8B using the method described in this invention was 33.5, an improvement of 4.6 compared to w / oMem's 28.9; the average task success rate of Qwen3-235B using the method described in this invention was 51.8, an improvement of 5.4 compared to w / oMem's 46.4.

[0151] In summary, this embodiment represents successful tool call trajectories in a structured tool call graph, preserving the tool call order, tool selection relationships, and intermediate result data dependencies. It also evaluates memory quality using historical execution success rate and structure-aware execution efficiency. Furthermore, it forms memory neighborhoods through semantic similarity and uses quality ranking to limit the number of redundant memories. When a new task is executed, a reference program memory is jointly selected based on semantic relevance, historical execution success rate, and structure-aware execution efficiency. This reference program memory is then converted into execution-oriented structured prompts, guiding the current heterogeneous large language model agent to reuse the high-level tool call program structure and recalculate the specific parameters and results of the current task. Experimental results show that this method can improve the completion ability of tool call tasks under different models, thus verifying the effectiveness of the shared program memory, quality preservation, and quality-guided retrieval mechanism described in this invention.

[0152] Please see Figure 4 Based on the same inventive concept, the present invention also provides a multi-agent shared program memory system based on tool call graphs, the system comprising:

[0153] The trajectory acquisition and filtering module is used to acquire tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and to filter out the tool call trajectories that successfully complete the tasks.

[0154] The tool call graph construction module is used to abstract the tool call trajectory of the successfully completed task into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and uses execution order edges, tool call edges and data dependency edges to represent the execution order of tool calls, tool selection and intermediate result transmission relationships, respectively.

[0155] A memory entry construction module is used to build a memory entry for each tool call graph and determine the quality information of the memory entry. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency.

[0156] The memory pool update module is used to classify newly created memory entries and existing memory entries in the shared program memory pool that have a semantic similarity of up to a preset threshold into the same semantic neighborhood, and sort and retain the memory entries in the semantic neighborhood according to the quality information to suppress redundant memory.

[0157] The memory retrieval module is used to receive new task queries, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest retrieval score as the reference program memory.

[0158] The program memory injection module is used to convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and obtain the result of the current task through the new tool call, and then update the shared program memory pool according to the execution result of the current task.

[0159] Based on the same inventive concept, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the multi-agent shared program memory method based on a tool call graph as described above.

[0160] The program product of the present invention for implementing the above-described method may employ a portable compact disk read-only memory and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In the present invention, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0161] It should be noted that a computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0162] Unless otherwise defined, the technical or scientific terms used in this invention shall have the general meaning understood by one of ordinary skill in the art to which this invention pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these” used in this invention do not indicate quantitative limitations and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this invention are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to these processes, methods, products, or devices. Words such as “connected,” “linked,” and “coupled” used in this invention are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. “A plurality” used in this invention refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. Normally, the character " / " indicates that the objects before and after it are in an "or" relationship. In this invention, the terms "first," "second," "third," etc., are used only to distinguish similar objects and do not represent a specific order of objects.

[0163] Obviously, the accompanying drawings are merely some examples or embodiments of the present invention. Those skilled in the art can apply the present invention to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, certain design, manufacturing, or production modifications made according to the technical content disclosed in the present invention are merely conventional technical means and should not be considered as insufficient disclosure of the present invention.

[0164] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-described technical content to create equivalent embodiments without departing from the scope of the present invention. The implementation schemes in the above embodiments can also be further combined or replaced. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. A multi-agent shared program memory method based on tool call graphs, characterized in that, Includes the following steps: S1. Obtain tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and filter out the tool call trajectories that successfully complete the tasks. S2. The tool call trajectory of the successful completion of the task is abstracted into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and the execution order, tool selection and intermediate result transmission relationship are represented by execution order edges, tool call edges and data dependency edges. S3. Establish a memory entry for each tool call graph and determine its quality information. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency. S4. The newly established memory entries and existing memory entries in the shared program memory pool that have a semantic similarity that reaches a preset threshold are grouped into the same semantic neighborhood, and are sorted and retained according to the quality information to suppress redundant memory. S5. Receive a new task query, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest score as the reference program memory. S6. Convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and call the tool again to obtain results, and then update the shared program memory pool according to the execution results.

2. The method according to claim 1, characterized in that, In S1, the tool call trajectory includes task query, execution steps arranged by execution round, the name of the tool called in each execution round, tool input parameters, tool output results, and task execution results; The process of filtering tool call trajectories that successfully completed the task includes: determining whether the corresponding task was completed based on the final execution result of the task corresponding to each tool call trajectory; using tool call trajectories with successful task execution results as candidate trajectories for building shared program memory; and excluding tool call trajectories that failed to complete the task from the shared program memory pool.

3. The method according to claim 1, characterized in that, In S2, the tool call graph is represented by a set of nodes and a set of directed edges; the set of nodes is constructed in the following way: Based on the tool call trajectory, establish query nodes for storing task queries, establish an execution node set according to the execution round in which the tool call occurs, and establish a corresponding tool node for each tool call; The process of establishing the tool node includes: standardizing the name of the tool being invoked to eliminate differences in the names of the same tool among different agents; extracting the input parameter structure of the tool invocation; using a language model to perform a factual summary of the original tool output; and compressing the original tool observation results into a task-related factual description to obtain a task-related summary of the tool node.

4. The method according to claim 3, characterized in that, The set of directed edges includes execution order edges connecting adjacent execution nodes, tool call edges connecting execution nodes with tool nodes called in that execution round, and data dependency edges connecting tool nodes with intermediate result passing relationships; The data dependency edges are established in the following way: based on the input parameter structure and output summary of the ordered tool calls, the usage relationship of subsequent tool calls on the results of previous tool calls is identified, the data dependency edges are established between tool nodes with usage relationships, and the intermediate variable mapping relationship from the output of the previous tool node to the input of the next tool node is recorded; the tool call graph composed of the execution order edges, the tool call edges, and the data dependency edges is a directed acyclic graph.

5. The method according to claim 1, characterized in that, In S3, the historical execution success rate is determined in the following way: The large language model evaluator determines whether the corresponding task is completed based on the task query, tool call process, tool output results, and final task results, and converts the judgment results into corresponding success rate scores, which serve as a representation of the execution reliability of the tool call graph in historical tasks.

6. The method according to claim 5, characterized in that, Structure-aware execution efficiency is determined in the following way: The degree of reuse of intermediate information is determined based on the number of data dependency edges and the number of tool nodes in the tool call graph. The execution cost is obtained by multiplying the number of tool nodes, the number of execution nodes, and the number of data dependency edges in the tool call graph by their respective execution cost weight coefficients that are greater than zero. The ratio of the intermediate information reuse level to the execution overhead is defined as the structure-aware execution efficiency; wherein, the intermediate information reuse level increases with the increase of the number of data dependency edges and decreases with the increase of the number of tool nodes, and the execution overhead increases with the increase of the number of tool nodes, the number of execution nodes and the number of data dependency edges. The structure-aware execution efficiency is used to reward tool call structures with a high degree of intermediate result reuse and to suppress tool call structures with many tool calls, long execution rounds or complex data dependencies.

7. The method according to claim 1, characterized in that, In S4, those belonging to the same semantic neighborhood include: Sentence vector encoding is performed on the task query corresponding to the newly established memory entry and the task query corresponding to the existing memory entry, respectively, and the cosine similarity between the two sentence vectors is calculated as the semantic similarity. Existing memory entries with semantic similarity greater than or equal to a preset similarity threshold are identified as memory entries belonging to the same semantic neighborhood as the newly established memory entries; When there are no memory entries belonging to the same semantic neighborhood, the newly created memory entry is directly written into the shared program memory pool; When there are memory entries belonging to the same semantic neighborhood, the newly established memory entry and the memory entries belonging to the same semantic neighborhood form a candidate set. The candidate set is sorted in descending lexicographical order according to the tuple composed of the historical execution success rate and the structure-aware execution efficiency. Memory entries with high historical execution success rate are retained first, and when the historical execution success rates are the same, memory entries with high structure-aware execution efficiency are retained first. Only a preset number of memory entries at the top of the list are retained.

8. The method according to claim 1, characterized in that, In S5, the calculation of the retrieval score includes: The semantic similarity between the task query and the task query corresponding to the candidate memory entry, the historical execution success rate of the candidate memory entry, and the structure-aware execution efficiency of the candidate memory entry are multiplied by their respective weight coefficients (greater than zero) and then summed to obtain the retrieval score of the candidate memory entry. The candidate memory entries are memory entries with a semantic similarity greater than or equal to a preset similarity threshold; the candidate memory entry with the highest retrieval score is selected as the reference program memory; when no candidate memory entry exists, the memory in the shared program memory pool is not invoked, and the current task is executed in the conventional tool invocation manner.

9. The method according to claim 1, characterized in that, In S6, the tool call graph of the reference program memory is converted into structured prompt information, including: Traverse the execution nodes in the tool call graph along the execution order edge to obtain the sequence of execution nodes arranged by execution round; For each execution node, traverse each tool node connected by the tool call edge according to the tool call index, and record the normalized tool name, input parameter structure, task-related summary and intermediate variable mapping relationship carried by the incoming data dependency edge pointing to the tool node in sequence, and generate an execution-oriented structured program memory prompt block containing the tool call order, parameter dependency relationship and intermediate result flow relationship; The structured program memory prompt block is injected as reference information into the current task prompt, rather than as a static answer template for the current task. The large language model agent only reuses the high-level tool call program structure within it, and does not directly copy the task-specific parameters, tool output results, or final answers in the reference program memory. Instead, it regenerates tool parameters and intermediate variables according to the current task, and obtains the intermediate and final results required for the current task again through new tool calls.

10. A multi-agent shared program memory system based on tool call graphs, characterized in that, The system includes: The trajectory acquisition and filtering module is used to acquire tool call trajectories formed by multiple heterogeneous large language model agents performing tasks in an external tool environment, and to filter out the tool call trajectories that successfully complete the tasks. The tool call graph construction module is used to abstract the tool call trajectory of the successfully completed task into a tool call graph TCG. The tool call graph includes query nodes, execution nodes and tool nodes, and uses execution order edges, tool call edges and data dependency edges to represent the execution order of tool calls, tool selection and intermediate result transmission relationships, respectively. A memory entry construction module is used to build a memory entry for each tool call graph and determine the quality information of the memory entry. The memory entry includes the tool call graph, historical execution success rate, and structure-aware execution efficiency. The memory pool update module is used to classify newly created memory entries and existing memory entries in the shared program memory pool that have a semantic similarity of up to a preset threshold into the same semantic neighborhood, and sort and retain the memory entries in the semantic neighborhood according to the quality information to suppress redundant memory. The memory retrieval module is used to receive new task queries, calculate the retrieval score of the task query and each memory entry based on semantic relevance and the quality information, and select the one with the highest retrieval score as the reference program memory. The program memory injection module is used to convert the tool call graph of the reference program memory into structured prompt information and inject it into the current large language model agent, so that it can reuse the high-level tool call program structure, regenerate tool parameters and obtain the result of the current task through the new tool call, and then update the shared program memory pool according to the execution result of the current task.