A tool-based task processing method, device and electronic equipment

By calculating the similarity and applicability scores between tasks and tools, and combining the agent's memory data and tool collaboration, the accuracy problem of agents when faced with multiple tool choices is solved, achieving efficient and accurate task execution.

CN120892474BActive Publication Date: 2026-03-27ZHUOSHI SUNAC (CHENGDU) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-20
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

When faced with a large number of tool options, intelligent agents have difficulty selecting the right tool, resulting in inaccurate task execution. Existing technologies rely on large language models for direct judgment, leading to excessive cognitive load.

Method used

By calculating the similarity between the task description and the tool description, and combining the agent's current state and memory data, highly applicable candidate tools are selected, and the final tool is determined based on the synergy between the tools. The task is then executed using the retrieved reference memory data.

Benefits of technology

This precisely narrows down the range of tools available, ensuring the accuracy of task execution. It takes into account the current state of the agent, the task description, and the collaboration of tools, thereby improving the accuracy of tool selection and the reliability of task execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120892474B_ABST
    Figure CN120892474B_ABST
Patent Text Reader

Abstract

The application provides a tool-based task processing method and device and electronic equipment, and relates to the technical field of artificial intelligence. The method comprises the following steps: determining a plurality of candidate tools by using the similarity between a task description and a function description of a preset tool; calculating the applicability score of the candidate tools in the current state of an agent by using the key parameters of the candidate tools and the memory data of the agent; calculating the target score of the candidate tools by using the applicability score of the candidate tools, the similarity and the historical tool data of the candidate tools; determining a tool to be called from the candidate tools according to the target score of the candidate tools and the cooperativity between the candidate tools; retrieving reference memory data from the memory data based on the task description; and calling the tool to be called in combination with the reference memory data to execute a task to be processed. The application can comprehensively consider multiple factors, accurately narrow the selection range of the tool, ensure the accuracy of tool selection, and thus improve the accuracy of task execution.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a tool task processing method and device and electronic equipment. BACKGROUND

[0002] With the rapid development of artificial intelligence technology, using the powerful natural language understanding, reasoning and generation capabilities of large language models to build intelligent agents that can autonomously complete complex tasks has become a frontier hotspot in the field of artificial intelligence. Intelligent agents do not need to rely on user instructions to achieve autonomous thinking, decision-making and selection of tools to perform complex tasks.

[0003] When an intelligent agent performs a task through a tool, it usually provides all the description information of all available tools to the large language model, which then judges and selects the tools needed. Due to the large number of available tools, the large amount of tool descriptions brings a huge cognitive load, making it difficult to choose among many options, and relying solely on task descriptions when selecting tools can lead to inaccurate tool selection, which in turn can result in inaccurate task execution. SUMMARY

[0004] To address the above problems, the present application aims to provide a tool-based task processing method, device and electronic equipment that can filter tools based on task descriptions, the current state of the intelligent agent and the synergy between tools, reducing cognitive load and improving the accuracy of tool selection, thereby ensuring the accuracy of task execution.

[0005] To solve the above technical problems, the present application provides the following technical solutions:

[0006] In one aspect, the present application provides a tool-based task processing method, comprising:

[0007] Determining a plurality of candidate tools from the preset tools using the similarity between the task description corresponding to the task to be processed and the functional description of the preset tools;

[0008] For each candidate tool, calculating the suitability score of the candidate tool in the current state of the intelligent agent using the key parameters of the candidate tool and the memory data of the intelligent agent;

[0009] Calculating the target score of the candidate tool using the suitability score of the candidate tool, the similarity between the functional description of the candidate tool and the task description, and the historical tool data of the candidate tool;

[0010] Determining the tool to be called from the candidate tools according to the target score of the candidate tools and the synergy between the candidate tools;

[0011] retrieve reference memory data from the memory data based on the task description;

[0012] invoke the tool to be invoked to execute the task to be processed in combination with the reference memory data.

[0013] In another aspect, the present application also provides a tool-based task processing apparatus, comprising:

[0014] a candidate determining module configured to determine a plurality of candidate tools from the preset tools by using the similarity between the task description corresponding to the task to be processed and the function description of the preset tools;

[0015] a suitability calculating module configured to calculate, for each of the candidate tools, a suitability score of the candidate tool in the current state of the agent by using the key parameters of the candidate tool and the memory data of the agent;

[0016] a target calculating module configured to calculate a target score of the candidate tool by using the suitability score of the candidate tool, the similarity between the function description of the candidate tool and the task description, and the historical tool data of the candidate tool;

[0017] an invoking determining module configured to determine the tool to be invoked from the candidate tools according to the target scores of the candidate tools and the synergy between the candidate tools;

[0018] a retrieving module configured to retrieve reference memory data from the memory data based on the task description;

[0019] a processing module configured to invoke the tool to be invoked to execute the task to be processed in combination with the reference memory data.

[0020] In another aspect, the present application also provides an electronic device comprising a processor and a memory, wherein the memory stores a plurality of instructions; and the processor loads the instructions from the memory to execute the steps of any of the tool-based task processing methods provided by the present application.

[0021] In another aspect, the present application also provides a computer readable storage medium storing a plurality of instructions, wherein the instructions are adapted to be loaded by a processor to execute the steps of any of the tool-based task processing methods provided by the present application.

[0022] In another aspect, the present application also provides a computer program product comprising computer programs / instructions, wherein the computer programs / instructions are executed by a processor to implement the steps of any of the tool-based task processing methods provided by the present application.

[0023] The technical solutions provided by the present application have at least the following beneficial effects:

[0024] In the embodiment of the present application, the similarity between the task description corresponding to the task to be processed and the tool description is used to screen a plurality of candidate tools; for each candidate tool, the applicability score of the subsequent candidate in the current state of the agent is calculated through its key parameters and the memory data of the agent; the target score is calculated in combination with the applicability score, the similarity between the task description and the historical tool data; finally, the target tool is determined according to the target score and the synergy between tools, which accurately narrows down the range of tool selection, and finally the reference memory data is called to call the target tool to accurately execute the task. When confirming the target tool, the current state of the agent, the similarity between the task description and the historical tool data, and the synergy between tools are taken into account, which can accurately narrow down the range of tool selection and ensure the accuracy of tool selection, thereby improving the accuracy of task execution. BRIEF DESCRIPTION OF DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0026] Figure 1 is an application scenario diagram of the tool-based task processing method provided by the embodiment of the present application;

[0027] Figure 2 is a flow diagram of the tool-based task processing method provided by the embodiment of the present application;

[0028] Figure 3 is a diagram for calculating the applicability score of the candidate tool provided by the embodiment of the present application;

[0029] Figure 4 is a diagram for searching nodes in the graph provided by the embodiment of the present application;

[0030] Figure 5 is a structural diagram of the tool-based task processing device provided by the embodiment of the present application;

[0031] Figure 6 is a structural diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0032] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0033] It can be understood that, in the specific embodiments of the present application, the data related to user information needs to be obtained with the permission or consent of the user, and the collection, use and processing of the related data need to comply with the relevant laws, regulations and standards of the country and region.

[0034] For reference Figure 1 , a schematic diagram of an application scenario of the tool-based task processing method is shown. The application scenario can include a terminal 101 and a server 102, and the terminal 101 and the server 102 can exchange data through a network. The terminal 101 can be installed with a corresponding application program. The terminal 101 can be a mobile phone, a tablet computer, a smart Bluetooth device, a computer, a large screen, a robot, or the like. The server 102 can be a single server or a server cluster composed of multiple servers.

[0035] The user can send a task description corresponding to a to-be-processed task to the server 102 through the terminal 101. Then, the server 102 can determine a plurality of candidate tools from the preset tools by using the similarity between the task description corresponding to the to-be-processed task and the function description of the preset tools. For each candidate tool, the suitability score of the candidate tool in the current state of the agent is calculated by using the key parameters of the candidate tool and the memory data of the agent. The target score of the candidate tool is calculated by using the suitability score of the candidate tool, the similarity between the function description of the candidate tool and the task description, and the historical tool data of the candidate tool. The to-be-called tool is determined from the candidate tools according to the target score of the candidate tool and the cooperativeness between the candidate tools. The reference memory data is retrieved from the memory data based on the task description. The to-be-called tool is invoked to execute the to-be-processed task in combination with the reference memory data.

[0036] After the to-be-processed task is executed, the server 102 can send the task execution result to the terminal 101, so as to display the execution result to the user through the terminal 101.

[0037] In this embodiment, a tool-based task processing method is provided. As shown in Figure 2 , the specific process of the tool-based task processing method can be as follows:

[0038] S110, a plurality of candidate tools are determined from the preset tools by using the similarity between the task description corresponding to the to-be-processed task and the function description of the preset tools.

[0039] The to-be-processed task is a task that the agent currently needs to perform. The agent and the general model are different. The agent can autonomously think, make decisions, and perform complex tasks, that is, the agent can autonomously analyze the task and select a suitable tool to complete the task without relying on user instructions when performing the task. The task description can be used to describe the task target of the to-be-processed task. The task description can be in the form of text, image, audio, video, etc. In the embodiments of the present application, the task description is taken as an example to be described in the form of text.

[0040] The preset tool is a tool that can be called by the agent and is set in advance. The number of preset tools can be multiple. The function description of the preset tool is a text used to describe the function that the tool can implement. The preset tool and the corresponding function description can be pre-stored in the tool database, and data can be directly read from the tool database when needed.

[0041] In order to find a suitable tool from a large number of preset tools to perform the to-be-processed task, the task description can be used for retrieval in the tool database to obtain a plurality of candidate tools. The candidate tool is a preset tool whose function description is semantically similar to the task description. The number of candidate tools can be set according to actual needs, which is not specifically limited here.

[0042] As an implementation manner, the function description stored in the tool database can be a function description vector after vectorization processing. When determining the candidate tool, the task description can be converted into a task description vector using a text embedding model; the cosine similarity between the task description vector and each function description vector is calculated; each function description vector is arranged in descending order of cosine similarity; and the first number of function description vectors in the order are used as candidate tools. The candidate tools screened at this time are tools that are semantically highly relevant to the to-be-processed task, which can effectively reduce the range of subsequent tool screening and reduce the amount of data processing. The first number can be set according to actual needs, which is not specifically limited here.

[0043] In S120, for each candidate tool, the key parameters of the candidate tool and the memory data of the agent are used to calculate the applicability score of the candidate tool in the current state of the agent.

[0044] The memory data refers to the execution data generated by the agent when performing a task in a historical time period. The historical time period can be a time period before the current time, for example, a week before the current time, a month before the current time, etc. The memory data can include relevant data of the agent performing a task, such as a task identifier corresponding to the executed task, an execution result of the task, an execution completion time, etc.

[0045] The key parameter is a parameter that must be provided by the agent when calling the candidate tool. For example, when calling a financial analysis tool, the key parameters are the file identifier of the financial data to be analyzed and the period of analysis or comparison. After the agent obtains these two key parameters, it can accurately call the financial analysis tool to analyze the financial data.

[0046] The applicability score refers to the actual possibility of successfully calling the candidate tool under the current state of the agent. The higher the applicability score, the higher the possibility of successfully calling the candidate tool. The memory data records the execution data of the agent in the historical period. The parameters required for calling the candidate tool can be found in the memory data, and whether the found parameters can be used as key parameters is measured, so as to calculate the applicability score of the candidate tool.

[0047] The memory data of the agent can include short-term complete execution data and long-term compressed execution data. The short-term complete execution data refers to the data obtained by the agent by completely storing the execution data of the recently completed task. In order to save storage space, the agent only stores a small amount of short-term complete execution data, and compresses the complete execution data of the task that has been executed for a long time into a node in the knowledge graph for storage to obtain long-term compressed execution data. When calculating the applicability score of the candidate tool, only the short-term complete execution data is used.

[0048] As an implementation manner, when calculating the applicability score of the candidate tool, the short-term complete execution data of the agent can be obtained, and the key parameters of the candidate tool can be identified. The short-term complete execution data includes short-term calling tools and short-term calling results. In the short-term calling result, the associated field corresponding to the key parameter is searched, and the field value corresponding to the associated field is taken as a candidate parameter. According to the output time of the candidate parameter, the source of the candidate calling tool, and the format requirement of the key parameter, the candidate score of the candidate parameter is determined. The candidate calling tool is the short-term calling tool corresponding to the candidate parameter. The maximum value of the candidate scores of all candidate parameters corresponding to the candidate tool is taken as the applicability score of the candidate tool.

[0049] Meanwhile, refer to Figure 3 , which shows a schematic diagram for calculating the applicability score of the candidate tool. The memory data of the agent can be stored in a designated location, and the short-term complete memory data can be directly read from the designated location. As for the key parameters of the candidate tool, they can be pre-stored in the tool database, and their key parameters can be extracted from the tool database.

[0050] Among them, the short-term complete execution data can include short-term calling tools and short-term calling results, wherein the short-term calling tool is a tool used by the agent to perform a task, and the short-term calling result is a result output by the tool after the tool is called. The association field is the field of the parameter value corresponding to the key parameter in the memory data. If the association field is retrieved in the short-term complete execution data, the field value corresponding to the association field can be used as a candidate parameter. Since the short-term complete execution data can contain multiple candidate parameters, the candidate parameters can be scored to obtain candidate scores, and the maximum value of the candidate scores of all candidate parameters corresponding to the candidate tool is used as the final applicability score of the candidate tool.

[0051] Exemplarily, the short-term complete execution data can be:

[0052]

Memory data A - from task 7

[0053] task_id: "task_07"

[0054] key_finding: "Successfully downloaded the Q12025 financial report of 'A Company' from the official securities database."

[0055] tool_invocation_log: Call the download_from_sec tool, output {"file_id": "sec-q1-25-ft-xyz", "company": "A Company"}.

[0056] timestamp: "2025-06-13T15:10:00Z" (very new).

[0057]

Memory data B - from task 2

[0058] task_id: "task_02"

[0059] key_finding: "Found a link to the Q12025 financial report of 'A Company' on a certain financial blog and downloaded it."

[0060] tool_invocation_log: Call the web_search_and_download tool, output {"file_id": "blog-q1-25-ft-abc", "source_url": "some-blog.com / report"}.

[0061] timestamp: "2025-06-10T10:00:00Z" (3 days ago).

[0062] Memory data C - from task 4

[0063] task_id: "task_04"

[0064] key_finding: "The user mentioned 'A company's Q1 report' in the conversation."

[0065] tool_invocation_log: Call the user_input_parser tool, output {"mentioned_entities": ["A company", "Q1 report"]}.

[0066] Wherein, the task_id can record the corresponding task identifier; the tool_invocation_log is a tool invocation record, which contains short-term invocation tools such as the download_from_sec tool and short-term invocation result output {"file_id": "blog-q1-25-ft-abc", "source_url": "some-blog.com / report"}; and the timestamp is the execution completion time.

[0067] If the candidate tool is analyze_financial_report, the key parameters include report_file_id (string): the file ID of the report to be analyzed. For this key parameter, the corresponding associated field is file_id, which can be retrieved in the tool usage records in memory data A and memory data B. The field values corresponding to this associated field are "sec-q1-25-ft-xyz" and "blog-q1-25-ft-abc", respectively, that is, two candidate parameters corresponding to the key parameter are obtained.

[0068] For each candidate parameter, the candidate score of the candidate parameter can be calculated using the output time of the candidate parameter, the source of the candidate invocation tool, and the format requirements of the key parameter. Alternatively, the timeliness parameter of the candidate parameter can be calculated according to the output time of the candidate parameter and the current time; the trust parameter of the candidate parameter can be determined according to the inclusion relationship between the preset trusted tool and the candidate invocation tool; the format parameter of the candidate parameter can be determined by comparing the format requirements of the key parameter and the format of the candidate parameter; and the candidate score of the candidate parameter can be calculated by fusing the timeliness parameter, the trust parameter, and the format parameter.

[0069] The output time of the candidate parameter is the execution completion time in the short-term complete execution data, for example, the candidate parameter is "sec-q1-25-ft-xyz", and the output time is: 2025-06-13T15:10:00Z.

[0070] According to the output time of the candidate parameter and the current time, the timeliness parameter of the candidate parameter can be calculated. The timeliness parameter can be exponentially attenuated with time, and the higher the timeliness parameter value is, the stronger the timeliness of the candidate parameter is. The timeliness parameter can be calculated according to the following formula: T = x * e -kt ; wherein T represents the timeliness parameter; x represents an initial timeliness score, which can be set according to actual needs; k is an attenuation factor, which can be set according to actual needs; and t is the difference in days between the output time and the current time.

[0071] The trust parameter can be used to measure whether the candidate parameter is reliable, and the higher the value of the trust parameter is, the more reliable the candidate parameter is. The candidate calling tool refers to the short-term calling tool that outputs the candidate parameter in the short-term complete execution data. The preset trust tool is a reliable tool that is set in advance, and the preset trust tool is usually an official tool, which can ensure the reliability of the tool result. If the candidate calling tool exists in the preset trust tool, it means that the candidate calling tool is also reliable. The preset trust score corresponding to the preset trust tool and other tools can be set in advance, if the candidate calling tool is the preset trust tool, the preset trust score corresponding to the candidate calling tool is taken as the trust parameter, and if the candidate calling tool is not the preset trust tool, the preset trust score corresponding to other tools is taken as the trust parameter.

[0072] For example, the preset trust score corresponding to the preset trust tool is 1, and the preset trust score corresponding to other tools is 0.5. As in the foregoing example, the download_from_sec tool is an official tool, so the reliability score of the candidate parameter sec-q1-25-ft-xyz is 1.

[0073] The format parameter can be used to measure the matching degree between the format of the candidate parameter and the format requirement of the key parameter. Specifically, it can be compared whether the format of the candidate parameter and the format requirement of the key parameter are consistent, if they are consistent, the matching degree is a first value; if they are not consistent, the matching degree is a second value. The first value and the second value can be set according to actual needs, and the first value is greater than the second value. In the embodiments of the present application, the first value can be set to 1, and the second value can be set to 0.

[0074] Finally, the timeliness parameter, the trust parameter and the format parameter of the candidate parameter can be fused to calculate the candidate score of the candidate parameter. Alternatively, the weight corresponding to each parameter can be set in advance, and the candidate score is obtained by weighted summation.

[0075] As in the foregoing example, the timeliness parameter of the candidate parameter "sec-q1-25-ft-xyz" is 0.95, the trust parameter is 1, and the format parameter is 1; the timeliness parameter of the candidate parameter "blog-q1-25-ft-abc" is 0.4, the trust parameter is 0.5, and the format parameter is 1.

[0076] Assuming that the weight of the timeliness parameter is 0.4, the weight of the trust parameter is 0.4, and the weight of the format parameter is 0.2, the candidate score of the candidate parameter "sec-q1-25-ft-xyz" is (0.95 x 0.4) + (1.0 x 0.4) + (1.0 x 0.2) = 0.98; the candidate score of the candidate parameter "blog-q1-25-ft-abc" is (0.40 x 0.4) + (0.5 x 0.4) + (1.0 x 0.2) = 0.56.

[0077] It can be understood that there can be multiple key parameters for a candidate tool, and for a key parameter, there can be multiple candidate parameters, and then the candidate tool can correspond to multiple candidate parameters, and for each candidate parameter, the candidate score corresponding to each candidate parameter can be calculated in the above manner, and the maximum value in the candidate scores can be taken as the applicability score of the candidate tool. For example, the foregoing candidate tool has only one key parameter, report_file_id, the candidate score of the candidate parameter "sec-q1-25-ft-xyz" is 0.98, and the candidate score of the candidate parameter "blog-q1-25-ft-abc" is 0.56, then 0.98 is the applicability score of the candidate tool.

[0078] S130, calculating a target score of the candidate tool according to the applicability score of the candidate tool, the similarity between the function description of the candidate tool and the task description, and the historical tool data of the candidate tool.

[0079] The similarity between the function description of the candidate tool and the task description has been calculated in S110, and does not need to be calculated again here. The historical tool data refers to the data of the agent calling the tool in the historical time period, which can be updated after each call of the tool. In combination with the historical tool data, the applicability score, and the similarity between the candidate tool and the task description, the target score of the candidate tool can be calculated. The target score of the candidate tool can be used to determine the tool to be called.

[0080] As an implementation manner, the historical tool data can include historical calling data and calling cost data. The historical calling data can include the calling situation of the tool in the historical time period, such as the total number of calls, the number of successful calls, and the success rate of calls. The calling cost data refers to the cost paid by the agent for calling the tool, such as time delay and cost.

[0081] Optionally, in the calculation of the target score, the calling success rate of the candidate tool in a historical period can be obtained according to the historical calling data; the calling cost value of the candidate tool can be calculated according to the calling cost data; the first score can be calculated by summing the similarity between the function description and the task description of the candidate tool, the applicability score and the calling success rate according to a first preset weight; and the target score can be obtained by subtracting the product of the second preset weight and the calling cost value from the first score.

[0082] Each candidate tool has its corresponding historical calling data and calling cost data, that is, after the agent calls the tool, the historical calling data and the calling cost data of the tool called this time are updated to ensure the accuracy of the data.

[0083] The data structure of the historical calling data is as follows:

[0084]

[0085] When the tool is called by the agent, the total number of calls of the tool is increased by 1, regardless of success or failure, and if the tool is successfully called, the number of successful calls of the tool is increased by 1, and the timestamp of updating the historical calling data is recorded and the calling success rate of the tool is calculated and updated to the historical calling data.

[0086] As an implementation manner, the calling success rate can be directly calculated by dividing the number of successful calls by the total number of calls.

[0087] As another implementation manner, for a completely new tool that has never been called, directly calculating the success rate will cause a division by zero error, in order to avoid this problem, Laplace smoothing processing can be used. The initial success rate of 0.5 is assigned to the tool that has never been called, which can avoid the problem that the tool can never be selected. In order to ensure that the success rate of the tool can better reflect the stability of the tool in the near future, time decay can also be introduced. When a call is completed, the success rate is calculated as follows:

[0088] EMAnew = (current_outcome x a) + (EMAold x (1-a));

[0089] Wherein, current_outcome is whether the current called tool is successful, if successful, take 1, if not successful, take 0; EMAold represents the success rate obtained from the historical calling data; a is a smoothing factor, which can be set according to actual needs, for example, a can be set to 0.1 in the embodiment of the application, a determines the weight of the new data point, which makes the recent success or failure have a greater impact on the final score. EMAnew is the success rate calculated and updated to the historical calling data.

[0090] The historical invocation data can be updated after each invocation of the tool, and the invocation success rate corresponding to the candidate tool can be directly obtained from the historical invocation data.

[0091] The invocation cost data refers to the cost paid by the agent for invoking the tool, such as payment, time delay, consumption of computing resources, etc. For each tool in the preset tool library, a cost registration table can be set up to record the API fees, time delay, etc. generated by invoking the tool. Among them, the API fees can be obtained by the official billing method of the tool, and the expected time delay can be the average execution time of the tool calculated by recording the execution time of the agent each time the tool is invoked.

[0092] The units of cost and time are different, in order to more accurately calculate the invocation cost value of the tool, the cost and time can be normalized to the interval [0, 1]. The normalized cost and time can be weighted and summed according to the set weight to calculate the final invocation cost value.

[0093] For a candidate tool, and obtaining its corresponding applicability score, relevance score, invocation success rate and invocation cost value, in calculating the intermediate score, a first preset weight and a second preset weight can be set in advance. Among them, the first preset weight includes a first sub-weight, a second sub-weight and a third sub-weight, the first sub-weight is the weight of the relevance score, the second sub-weight is the weight of the applicability score, and the third sub-weight is the weight of the invocation success rate. Based on the first preset weight and each score, a first score can be calculated.

[0094] Specifically, the first score can be calculated by the following formula:

[0095] S1=x1*Relevance+x2*Applicability+x3*success;

[0096] Wherein, S1 represents the first score of the candidate tool; x1 represents the first sub-weight; Applicability represents the weight of the relevance score; x2 represents the second sub-weight; success represents the invocation success rate; x3 represents the third sub-weight.

[0097] The invocation cost value is a penalty term, the lower the invocation cost value, the smaller the cost paid by the agent for invoking the tool, and the agent is more inclined to choose the tool with low cost. The target score can be obtained by subtracting the product of the second preset weight and the invocation cost value from the first score. It can be understood that the weights used in the above calculation can be set according to actual needs, which are not limited here.

[0098] S140, determining the tool to be invoked from the candidate tools according to the target scores of the candidate tools and the synergy between the candidate tools.

[0099] The higher the target score of a candidate tool is, the more likely the candidate tool is to be selected as the tool to be invoked in executing a task. It can be understood that the execution of a task can require multiple tools to be used in cooperation. For example, the task to be processed is to analyze the financial performance of Company A in the first quarter of this year and compare it with the same period last year. In order to complete this task, a download tool needs to be used to download financial data, and an analysis tool needs to be used to analyze and compare the financial data. Therefore, when determining the tool to be invoked, not only the target scores of the candidate tools need to be considered, but also the synergy between the candidate tools needs to be considered.

[0100] As an implementation manner, when determining the tool to be invoked from the candidate tools based on the intermediate scores of the candidate tools and the synergy between the candidate tools, each intermediate tool corresponding to a tool function can be determined from the candidate tools according to the target scores of the candidate tools and the tool functions; the tool chain can be obtained by combining the intermediate tools based on the task description and the tool functions of the intermediate tools; for each tool chain, if the intermediate tools in the tool chain meet the synergy condition, the target score of the intermediate tool is added to obtain the updated target score of each intermediate tool; and the tool to be invoked is determined from the intermediate tools according to the updated target score of each intermediate tool.

[0101] Different tools can implement different functions, and the functions that can be implemented by a tool are tool functions. For the candidate tools corresponding to each tool function, the candidate tool with a higher target score is taken as the intermediate tool corresponding to the tool function. The specific task target is recorded in the task description, and by analyzing the task target, the calling sequence of the tools with different functions can be determined. For example, in the task of analyzing financial data, the data needs to be downloaded by using a download tool first, and then the downloaded data needs to be analyzed by using an analysis tool.

[0102] An intermediate tool is extracted from each tool function, and multiple tool chains can be obtained by combining the intermediate tools, that is, each tool function in the tool chain corresponds to an intermediate tool, and the intermediate tools are arranged in the calling sequence when completing the target task.

[0103] For these tool chains, it can be checked whether the intermediate tools in the tool chain meet the collaboration condition, which can be set according to actual needs. In an embodiment of the present application, for any intermediate tool in the tool chain, if the output of the previous intermediate tool of the intermediate tool is the input of the intermediate tool, it is determined that the collaboration condition is met; otherwise, it is determined that the collaboration condition is not met. For example, the tool chain contains tools y1 and y2 called in sequence; if the output of tool y1 can be seamlessly used as the input of tool y2, the collaboration condition is met; if the output of tool y1 cannot be directly used as the input of tool y2, such as the format of the output data of tool y1 and the format of the input data of tool y2 do not match, the collaboration condition is not met.

[0104] If the intermediate tools in the tool chain meet the collaboration condition, the target score of the intermediate tools in the tool chain can be processed by adding points, and the specific points added can be set according to actual needs. After the point adding process is completed, the updated target score can be obtained. It should be noted that for other intermediate tools that have not been processed by adding points, their target scores remain the same as before.

[0105] Finally, the tool chains with higher scores are screened out by using the updated target scores, so that the agent can select tools that can work collaboratively. After the double screening of scores and verification, a small number of candidate tools can be selected as tools to be verified.

[0106] In order to ensure that the agent can call these tools to execute the to-be-processed task, the verification model can be used to perform rationality verification on the tools to be verified. The verification model is a low-cost lightweight large language model. The verification model can receive a short prompt word to perform rationality and common sense checking on the tools to be verified. The prompt word can be set according to actual needs. In an embodiment of the present application, the prompt word template can be pre-set as:

task

available tools

task

available tools

[0107] S150, retrieving reference memory data from the memory data based on the task description.

[0108] When the agent executes the to-be-processed task, some context information is usually needed to ensure accurate execution of the to-be-processed task. Using the task description of the to-be-processed task, reference memory data can be retrieved from the memory data of the agent as the context when executing the to-be-processed task.

[0109] The aforementioned memory data can include short-term complete execution data and long-term compressed execution data, and the reference memory data can include short-term complete execution data and partial long-term compressed execution data, so that the agent can utilize complete details of a recent task and accurately associate relevant key knowledge fragments from massive historical data, thereby fundamentally solving the memory bottleneck in long-chain tasks.

[0110] The memory data is updated after the agent completes each task. As an implementation, the memory data can be obtained as follows: if the to-be-processed task is completed, the task execution data and tool invocation data of the to-be-processed task are obtained as short-term complete execution data, the task execution data includes completion time, task identifier, and execution result summary; if the number of short-term complete execution data is greater than a specified number, the to-be-compressed data is determined from the plurality of short-term complete execution data according to the completion time; a triple is extracted from the to-be-compressed data, the triple including a subject, a predicate, and an object; all triples of the to-be-compressed data, the task identifier, and the execution result summary are combined to generate a graph node as long-term compressed execution data.

[0111] After the agent completes the to-be-processed task, the task execution data and tool invocation data generated by executing the to-be-processed task can be obtained as short-term complete execution data. When the agent executes the to-be-processed task, the corresponding task identifier, execution result, and completion time can be obtained. In order to avoid excessive redundancy of data, the execution result can be summarized to obtain an execution result summary. The task execution data can include completion time, task identifier, and execution result summary. Of course, the task execution data can also include the task identifier of the previous task that triggered or provided a key precondition in the task, and whether the execution state of the task is successful or failed.

[0112] The tool invocation data can include the specific tools called in the to-be-processed task, the results of calling the tools, and the like. The task execution data and the tool invocation data can be directly obtained as short-term complete execution data. For example, the data structure of the short-term complete execution data can be as follows:

[0113] task_id: unique identifier of the task.

[0114] task_goal: original goal description of the task.

[0115] tool_invocation_log: a log list that details the information of all tool invocations in the task, including tool name, parameter, and key result summary.

[0116] key_finding: After distilling all outputs of this task, the core insight that is valuable to the final task goal.

[0117] status: The final status of the task, such as COMPLETED_SUCCESS, FAILED_REPLANNED.

[0118] timestamp: The timestamp when the task is completed.

[0119] causal_source_id: The task_id of the last task that triggered or provided the key precondition of this task.

[0120] The content carried in the short-term complete execution data is more detailed, and the number of short-term complete execution data is limited by the agent, that is, the number of short-term complete execution data cannot exceed the specified number. The specified number can be set according to actual needs, and no specific limitation is made here.

[0121] After the short-term complete execution data is generated, the number of current short-term complete execution data can be obtained, and if the number is greater than the specified number, part of the short-term complete execution data needs to be compressed to convert it into long-term compressed execution data. Specifically, in order to ensure the timeliness of the short-term complete execution data, the execution completion time in the short-term complete execution data can be obtained, and the short-term complete execution data with the execution completion time farthest from the current time is taken as the compressed data.

[0122] For example, the specified number is 3, and the short-term complete execution data includes [SSM_3, SSM_2, SSM_1], wherein SSM_3 has the shortest execution completion time from the current time, and SSM_1 has the longest execution completion time from the current time. At this time, a new task is executed and a new short-term complete execution data SSM_4 is generated, and SSM_1 needs to be converted into long-term compressed execution data, and SSM_1 is deleted from the short-term complete execution data, and the short-term complete execution data is [SSM_4, SSM_3, SSM_2].

[0123] As an implementation manner, when the compressed data is converted into long-term compressed execution data, part of the key data in the compressed data can be directly extracted as long-term compressed execution data. As an implementation manner, the compressed data can also be summarized to obtain corresponding summary data, and the summary data can be taken as long-term compressed execution data.

[0124] As an implementation manner, when the to-be-compressed data is converted into the long-term compressed execution data, subjects, predicates and objects can be extracted from the to-be-compressed data to form triples. It should be noted that all combinations of subjects, predicates and objects involved in the to-be-compressed data are extracted to form a plurality of triples. All the extracted triples, the task identifier corresponding to the to-be-processed task and the execution result summary are combined as a node in the graph data, and the node is taken as the long-term compressed execution data.

[0125] That is, the essence of the long-term compressed execution data of the intelligent agent is the graph data. The long-term compressed execution data of one is taken as a node in the graph data, and the association relationship between these data can be established through the nodes in the graph data to form the memory data with the association relationship.

[0126] Specifically, when the to-be-compressed data is converted into the long-term compressed execution data, the large language model can be used for processing. For example, a compression prompt word can be pre-set, which can include role information and specific compression requirements. The compression prompt word is input into the large language model, and the to-be-compressed data is taken as the input of the model, so as to guide the large language model to convert the to-be-compressed data into the long-term compressed execution data according to the specific compression requirements in the compression prompt word.

[0127] The compression prompt word can be "Role: You are a memory graph construction engine. Task: According to the content provided below, extract the core information and output it in strict JSON format. The JSON must include summary_finding, entities_relations and causal_link three keys. In entities_relations, try to extract all entities and their relationships in the form of [subject, predicate, object] triples as completely as possible."

[0128] If the to-be-compressed data is:

[0129]

[0130] After processing by the large language model, the obtained long-term compressed execution data is:

[0131]

[0132] It can be understood that after the to-be-compressed data is converted into the long-term compressed execution data, the to-be-compressed data can be deleted from the short-term complete execution data, and the number of the short-term complete execution data is always less than or equal to the specified number. The short-term complete execution data with a relatively long time distance from the current time is automatically converted into a node in the graph data, that is, the long-term compressed execution data.

[0133] In summary, the memory data of the agent includes a specified number of short-term complete execution data and long-term compressed execution data as nodes in the graph data. Whenever the agent completes the execution of a new to-be-processed task, the memory data is updated, i.e., part of the short-term complete execution data is converted into long-term compressed execution data according to the specified number and the time of completion of execution.

[0134] When the agent executes a task, it can also filter reference memory data from the memory data to provide rich context information for the execution of the task and improve the accuracy of task execution.

[0135] As an implementation, retrieving reference memory data from the memory data based on the task description can include extracting key entities from the task description and converting the key entities into a graph query statement. In the long-term compressed execution data, an entity node directly associated with the key entities is retrieved as a first node. Neighbor nodes of the first node in the execution data are determined as second nodes. Dependent nodes of the first node and the second nodes are obtained as third nodes. A reference subgraph is obtained by fusing the first node, the second nodes, and the third nodes. The reference subgraph is pruned, and reference memory data is generated based on the pruned reference subgraph and short-term complete execution data.

[0136] The agent can process the task description to extract key entities, for example, the task description is "analyze the background of the CEO of company A and its impact on the company", and the key entities extracted by the large language model are: company A, CEO, background. After extracting the key entities, the key entities can be used to search in the long-term compressed data to retrieve key data.

[0137] Specifically, since the long-term compressed data is a node in the graph data, in order to ensure the accuracy of the search, the extracted key entities can be converted into a graph query statement, and the graph query statement is used for multi-path search. For example, refer to Figure 4 , which shows a schematic diagram of searching nodes in a graph. First, the nodes related to the key entities in the graph can be searched as first nodes, for example, the node directly mentioning company A can be the first node, such as Figure 4 node A in

[0138] After finding the first node in the graph, the neighbor nodes of the first node can be found according to the association relationship between the nodes in the graph, and the neighbor nodes are taken as second nodes, in other words, the nodes in the graph that have a one-hop relationship with the first node are taken as second nodes. For example, Figure 4 nodes B, C, and F in

[0139] After the first node and the second node are determined, a causal backtracking can be performed in the graph based on the first node and the second node to find dependent nodes of the first node and the second node, wherein the dependent nodes refer to nodes that have an influence on the first node and the second node through a causal relationship. For ease of description, the first node and the second node are referred to as to-be-backtracked nodes here, and for the to-be-backtracked nodes, their parent nodes and ancestor nodes can be obtained, which are dependent nodes of the to-be-backtracked nodes and are referred to as third nodes. For example, the node D and the node E in the graph in FIG. 8. Figure 4

[0140] Fusing the first node, the second node and the third node can obtain a reference subgraph, which is highly related to the current task. In order to prevent information overload, the agent will perform pruning processing on the reference subgraph, and only retain a certain number of nodes that are the most important or most relevant, to obtain a pruned reference subgraph, and finally generate reference memory data based on the pruned reference subgraph and the short-term complete execution data.

[0141] As an implementation, when the reference subgraph is pruned and the reference memory data is generated based on the pruned reference subgraph and the short-term complete execution data, the semantic similarity between the task description and a reference node in the reference subgraph can be calculated, the pruning node can be determined from the reference node according to the execution completion time corresponding to the reference node and the semantic similarity, the pruning node can be deleted from the reference subgraph to obtain a pruned reference subgraph, and the pruned reference subgraph and the short-term complete execution data can be combined to obtain the reference memory data.

[0142] The reference node is a node in the reference subgraph, and each node represents a long-term compressed execution data containing some key information. For each reference node, the semantic similarity between the reference node and the task description can be calculated to find a node with higher relevance to the task description from the reference node. The long-term compressed execution data can also include an execution completion time, and a time parameter can be calculated according to the time difference between the execution completion time and the current time in a similar manner as described above. The semantic similarity and the time parameter are fused to calculate a reference score of the reference node. The higher the reference score, the closer the reference node is to the task description in terms of relevance or the closer the reference node is to the current time in terms of time distance. The reference nodes can be sorted according to the reference scores, a certain number of nodes at the back of the sorting can be taken as pruning nodes, and the pruning nodes can be deleted from the reference subgraph to obtain a pruned reference subgraph.

[0143] ​Finally, the pruned reference subgraph can be merged with short-term complete execution data to form reference memory data. Alternatively, the pruned reference subgraph can be converted into a short text summary, denoted as the reference summary, and then combined with the short-term complete execution data to form the final reference memory data. Reference memory data retrieved in this way ensures that the agent can utilize both complete data from recently completed tasks and accurately locate relevant key fragments from massive amounts of memory data, effectively solving the agent's memory bottleneck problem.

[0144] S160. Invoke the tool to be invoked based on the reference memory data to execute the task to be processed.

[0145] The reference memory data has a high data density and a clear structure, forming high-quality contextual data. The agent can combine the reference memory data to call the determined tools to execute the tasks to be processed, thereby ensuring the accuracy of task execution.

[0146] The tool-based task processing method provided in this invention can be applied to various complex task processing scenarios. For example, taking the comparative analysis of various production data as an example, the solution provided in this invention can comprehensively determine the tool to be invoked by combining multiple dimensions such as task description, the current state of the agent, and the coordination between tools, greatly narrowing the range of tool selection and improving the accuracy of tool selection. Memory data is divided into short-term complete execution data and long-term compressed execution data in the form of graph nodes. The retrieved reference memory data can avoid data overflow, and thus ensure the accuracy of task execution when using the reference memory data to invoke the tool to be invoked to execute the task.

[0147] To better implement the above methods, embodiments of the present invention also provide a tool-based task processing device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, large screen, robot, or other similar device; the server can be a single server or a server cluster composed of multiple servers.

[0148] For example, in this embodiment, the method of the present invention will be described in detail by taking the tool-based task processing device specifically integrated into the server as an example.

[0149] For example, such as Figure 5 As shown, the tool-based task processing device 200 may include a candidate determination module 210, an applicable calculation module 220, a target calculation module 230, a call determination module 240, a retrieval module 250, and a processing module 260, as follows:

[0150] The candidate determining module 210 is configured to determine a plurality of candidate tools from the preset tools by using similarity between a task description corresponding to the to-be-processed task and a function description of a preset tool.

[0151] The applicability calculating module 220 is configured to calculate, for each candidate tool, an applicability score of the candidate tool in the current state of the agent by using a key parameter of the candidate tool and memory data of the agent.

[0152] The target calculating module 230 is configured to calculate a target score of the candidate tool by using the applicability score of the candidate tool, similarity between the function description of the candidate tool and the task description, and historical tool data of the candidate tool.

[0153] The calling determining module 240 is configured to determine a to-be-called tool from the candidate tools according to the target scores of the candidate tools and cooperativeness between the candidate tools.

[0154] The retrieving module 250 is configured to retrieve reference memory data from the memory data based on the task description.

[0155] The processing module 260 is configured to call the to-be-called tool to execute the to-be-processed task in combination with the reference memory data.

[0156] In some embodiments, the memory data includes short-term complete execution data, and the applicability calculating module 220 is specifically configured to:

[0157] obtain short-term complete execution data of the agent and identify a key parameter of the candidate tool, wherein the short-term complete execution data includes a short-term called tool and a short-term calling result.

[0158] In the short-term calling result, an associated field corresponding to the key parameter is retrieved, and a field value corresponding to the associated field is taken as a candidate parameter.

[0159] A candidate score of the candidate parameter is determined according to an output time of the candidate parameter, a source of a candidate called tool, and a format requirement of the key parameter, wherein the candidate called tool is the short-term called tool corresponding to the candidate parameter.

[0160] A maximum value of candidate scores of all candidate parameters corresponding to the candidate tool is taken as the applicability score of the candidate tool.

[0161] In some embodiments, the applicability calculating module 220 is specifically configured to:

[0162] An aging parameter of the candidate parameter is calculated according to an output time of the candidate parameter and a current time.

[0163] determine a trust parameter of the candidate parameter according to a containing relationship between a preset trust tool and the candidate calling tool;

[0164] determine a format parameter of the candidate parameter by comparing a format requirement of the key parameter with a format of the candidate parameter;

[0165] fuse the time effectiveness parameter, the trust parameter and the format parameter to calculate a candidate score of the candidate parameter.

[0166] In some embodiments, the historical tool data includes historical calling data and calling cost data, and the target calculation module 230 is specifically configured to:

[0167] obtain a calling success rate of the candidate tool in a historical period according to the historical calling data;

[0168] calculate a calling cost value of the candidate tool according to the calling cost data;

[0169] calculate a first score by summing a similarity between the function description and the task description of the candidate tool, the applicability score and the calling success rate according to a first preset weight;

[0170] obtain a target score by subtracting a product of a second preset weight and the calling cost value from the first score.

[0171] In some embodiments, the calling determination module 240 is specifically configured to:

[0172] determine an intermediate tool corresponding to each tool function from the candidate tool according to the target score of the candidate tool and the tool function;

[0173] combine the intermediate tools to obtain a tool chain based on the task description and the tool function of the intermediate tools;

[0174] for each tool chain, if the intermediate tools in the tool chain meet a cooperation condition, add a score to the target score of the intermediate tools to obtain an updated target score of each intermediate tool;

[0175] determine a calling tool from the intermediate tools according to the updated target score of each intermediate tool.

[0176] In some embodiments, the memory data includes short-term complete execution data and long-term compressed execution data, and the long-term compressed execution data is a node in a graph, and the retrieval module 250 is specifically configured to:

[0177] extract a key entity from the task description and convert the key entity into a graph query statement;

[0178] In the long-term compressed execution data, an entity node directly associated with the key entity is retrieved as a first node;

[0179] A neighbor node of the first node in the long-term compressed execution data is determined as a second node;

[0180] Dependency nodes of the first node and the second node are obtained as third nodes;

[0181] A reference subgraph is obtained by fusing the first node, the second node, and the third nodes;

[0182] The reference subgraph is pruned, and reference memory data is generated based on the pruned reference subgraph and short-term complete execution data.

[0183] In some embodiments, the retrieval module 250 is specifically configured to:

[0184] A semantic similarity between the task description and a reference node is calculated, the reference node being a node in the reference subgraph;

[0185] A pruning node is determined from the reference nodes according to an execution completion time corresponding to the reference node and the semantic similarity;

[0186] The pruning node is deleted from the reference subgraph to obtain a pruned reference subgraph;

[0187] The pruned reference subgraph and the short-term complete execution data are combined to obtain reference memory data.

[0188] In some embodiments, the tool-based task processing apparatus can further include a memory generation module configured to:

[0189] If the to-be-processed task is executed, task execution data of the to-be-processed task and tool invocation data are taken as short-term complete execution data, the task execution data including an execution completion time, a task identifier, and an execution result summary;

[0190] If the number of the short-term complete execution data is greater than a specified number, to-be-compressed data are determined from the multiple short-term complete execution data according to the execution completion time;

[0191] Triples are extracted from the to-be-compressed data, the triples including a subject, a predicate, and an object;

[0192] All the triples of the to-be-compressed data, the task identifier, and the execution result summary are combined to generate a graph node as long-term compressed execution data.

[0193] In practice, the above modules can be implemented as independent entities or combined in any way to be implemented as the same or several entities. For the specific implementation of the above modules, please refer to the previous method implementation examples, which will not be repeated here.

[0194] As shown above, the tool-based task processing device in this embodiment can filter out multiple candidate tools by utilizing the similarity between the task description and the tool description corresponding to the task to be processed. For each candidate tool, the applicability score of the subsequent candidate in the current state of the agent is calculated based on its key parameters and the agent's memory data. Combining the applicability score, the similarity between the tool and the task description, and historical tool data, a target score is calculated. Finally, based on the target score and the synergy between tools, the tool to be invoked is determined, accurately narrowing the range of tool selection. Finally, the retrieved reference memory data is used to invoke the tool to be invoked to achieve accurate task execution. When confirming the tool to be invoked, the device takes into account the agent's current state, the similarity between the agent and the task description, historical tool data, and the synergy between tools, which can accurately narrow the range of tool selection, ensure the accuracy of tool selection, and thus improve the accuracy of task execution.

[0195] This invention also provides an electronic device, which can be a terminal, a server, or other similar devices. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers, etc.

[0196] In some embodiments, the tool-based task processing device may also be integrated into multiple electronic devices, such as multiple servers, with multiple servers implementing the tool-based task processing method of the present invention.

[0197] In this embodiment, a server will be used as an example for detailed description. For example, ... Figure 6 As shown, it illustrates a structural schematic diagram of the electronic device involved in an embodiment of the present invention, specifically:

[0198] The electronic device may include components such as a processor 310 with one or more processing cores, a memory 320 with one or more computer-readable storage media, a power supply 330, an input module 340, and a communication module 350. Those skilled in the art will understand that... Figure 6 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0199] The processor 310 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and lines, executing various functions of the electronic device and processing data by running or executing software programs and / or modules stored in the memory 320, and calling data stored in the memory 320. In some embodiments, the processor 310 can include one or more processing cores; in some embodiments, the processor 310 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 310.

[0200] The memory 320 can be used to store software programs and modules, and the processor 310 executes various functions and data processing by running the software programs and modules stored in the memory 320. The memory 320 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc.; the data storage area can store data created according to the use of the electronic device, etc. In addition, the memory 320 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory 320 can also include a memory controller to provide access for the processor 310 to the memory 320.

[0201] The electronic device also includes a power supply 330 for powering various components, and in some embodiments, the power supply 330 can be logically connected to the processor 310 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 330 can also include one or more direct current or alternating current power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power state indicator, and any other components.

[0202] The electronic device can also include an input module 340, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0203] The electronic device can also include a communication module 350, which in some embodiments can include a wireless module, and the electronic device can perform short-range wireless transmission through the wireless module of the communication module 350, thereby providing the user with wireless broadband Internet access. For example, the communication module 350 can be used to help the user send and receive emails, browse web pages, and access streaming media, etc.

[0204] Although not shown, the electronic device can further include a display unit and the like, which will not be described herein. Specifically, in the present embodiment, the processor 310 in the electronic device will load the executable file corresponding to the process of one or more application programs into the memory 320 according to the following instructions, and run the application program stored in the memory 320 by the processor 310, thereby realizing the steps in the method of each embodiment of the present application.

[0205] The specific implementation of each operation above can refer to the previous embodiments, which will not be described herein.

[0206] As can be seen from the above, the electronic device provided by the embodiments of the present application can filter out a plurality of candidate tools by using the similarity between the task description corresponding to the to-be-processed task and the tool description, for each candidate tool, calculate the applicability score of the subsequent candidate in the current state of the agent by the key parameters of the candidate tool and the memory data of the agent, combine the applicability score, the similarity between the task description and the historical tool data to calculate the target score, and finally determine the to-be-called tool according to the target score and the synergy between the tools, thereby accurately narrowing the range of tool selection, and finally calling the to-be-called tool by using the retrieved reference memory data to accurately execute the task. When confirming the to-be-called tool, the current state of the agent, the similarity between the task description, the historical tool data and the synergy between the tools are taken into account, which can accurately narrow the range of tool selection and ensure the accuracy of tool selection, thereby improving the accuracy of task execution.

[0207] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions or controlled by instructions related to hardware, which can be stored in a computer readable storage medium and loaded and executed by a processor.

[0208] To this end, the embodiments of the present application provide a computer readable storage medium, which stores a plurality of instructions capable of being loaded by a processor to execute the steps in any one of the tool-based task processing methods provided by the embodiments of the present application.

[0209] The storage medium can include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0210] According to an aspect of the present application, a computer program product or computer program is provided, which comprises computer programs / instructions stored in a computer readable storage medium. A processor of an electronic device reads the computer programs / instructions from the computer readable storage medium, and the processor executes the computer programs / instructions, so that the electronic device executes the method provided in any of the optional implementations of the tool selection aspect or the task execution aspect provided in the above embodiments.

[0211] Since the instructions stored in the storage medium can execute the steps in any of the tool-based task execution methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the tool-based task execution methods provided in the embodiments of the present application can be achieved. Details are described in the above embodiments, and will not be described here.

[0212] The above describes in detail a tool-based task execution method, device and electronic device provided in the embodiments of the present application. The principles and implementation manners of the present application are described by applying specific examples. The above embodiment descriptions are only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges can be changed. In summary, the content of the present description should not be understood as a limitation of the present application.

Claims

1. A tool-based task processing method, characterized in that, The method includes: By utilizing the similarity between the task description corresponding to the task to be processed and the functional description of the preset tools, multiple candidate tools are identified from the preset tools; For each candidate tool, using the key parameters of the candidate tool and the agent's memory data, the applicability score of the candidate tool in the agent's current state is calculated; The target score of the candidate tool is calculated based on its applicability score, the similarity between its functional description and task description, and its historical tool data. Based on the target scores of the candidate tools and the synergy between them, the tool to be invoked is determined from the candidate tools, including: determining the intermediate tool corresponding to each tool function from the candidate tools according to their target scores and tool functions; combining the intermediate tools to obtain a toolchain based on the task description and the tool functions of the intermediate tools; for each toolchain, if the intermediate tools in the toolchain meet the synergy conditions, adding points to the target scores of the intermediate tools to obtain the updated target scores of each intermediate tool; and determining the tool to be invoked from the intermediate tools based on the updated target scores of each intermediate tool. Retrieve reference memory data from the memory data based on the task description; The reference memory data is used to invoke the tool to be invoked to execute the task to be processed. The memory data includes short-term complete execution data. The step of calculating the applicability score of the candidate tool in the current state of the agent using the key parameters of the candidate tool and the agent's memory data includes: acquiring the agent's short-term complete execution data and identifying the key parameters of the candidate tool; the short-term complete execution data includes short-term calling tools and short-term calling results; retrieving the associated fields corresponding to the key parameters from the short-term calling results and using the field values ​​corresponding to the associated fields as candidate parameters; determining the candidate score of the candidate parameter based on the generation time of the candidate parameter, the source of the candidate calling tool, and the format requirements of the key parameter; the candidate calling tool being the short-term calling tool corresponding to the candidate parameter; and taking the maximum value among the candidate scores of all candidate parameters corresponding to the candidate tool as the applicability score of the candidate tool.

2. The method according to claim 1, characterized in that, The step of determining the candidate score of the candidate parameter based on the generation time of the candidate parameter, the source of the candidate calling tool, and the format requirements of the key parameter includes: Calculate the timeliness parameter of the candidate parameter based on the output time of the candidate parameter and the current time; The trust parameters of the candidate parameters are determined based on the inclusion relationship between the preset trusted tools and the candidate calling tools; By comparing the format requirements of the key parameters with the format of the candidate parameters, the format parameters of the candidate parameters are determined. By combining the timeliness parameter, the trust parameter, and the format parameter, the candidate score of the candidate parameter is calculated.

3. The method according to claim 1, characterized in that, The historical tool data includes historical call data and call cost data. The calculation of the target score for the candidate tool, based on its applicability score, the similarity between its functional description and task description, and its historical tool data, includes: The success rate of the candidate tool's call within the historical time period is obtained based on the historical call data; Calculate the call cost value of the candidate tool based on the call cost data; The first score is calculated by summing the similarity between the functional description and task description of the candidate tool, the applicability score, and the call success rate according to the first preset weight; The target score is obtained by subtracting the product of the second preset weight and the call cost value from the first score.

4. The method according to claim 1, characterized in that, The memory data includes short-term complete execution data and long-term compressed execution data, wherein the long-term compressed execution data is a node in the graph. The step of retrieving reference memory data from the memory data based on the task description includes: Extract key entities from the task description and transform the key entities into graph query statements; In the long-term compressed execution data, the entity node directly associated with the key entity is retrieved and designated as the first node; The neighboring nodes of the first node in the long-term compressed execution data are identified as the second node; Obtain the dependent nodes of the first node and the second node, and use them as the third node; A reference subgraph is obtained by merging the first node, the second node, and the third node; The reference subgraph is pruned, and reference memory data is generated based on the pruned reference subgraph and short-term complete execution data.

5. The method according to claim 4, characterized in that, The step of pruning the reference subgraph and generating reference memory data based on the pruned reference subgraph and short-term complete execution data includes: Calculate the semantic similarity between the task description and the reference node, where the reference node is a node in the reference subgraph; Based on the execution completion time corresponding to the reference node and the semantic similarity, pruning nodes are determined from the reference nodes; The pruned node is removed from the reference subgraph to obtain the pruned reference subgraph. The pruned reference subgraph and the short-term complete execution data are combined to obtain reference memory data.

6. The method according to claim 1, characterized in that, The memory data is obtained in the following way: If the pending task is completed, the task execution data and tool call data of the pending task are used as short-term complete execution data. The task execution data includes the execution completion time, task identifier, and execution result summary. If the number of short-term complete execution data is greater than the specified number, the data to be compressed is determined from the multiple short-term complete execution data according to the execution completion time; Extract triples from the data to be compressed, wherein the triples include a subject, a predicate, and an object; Combine all the triples of the data to be compressed, the task identifier, and the execution result summary to generate graph nodes as long-term compressed execution data.

7. A tool-based task processing apparatus for implementing the method as described in any one of claims 1 to 6, characterized in that, The device includes: The candidate determination module is used to determine multiple candidate tools from the preset tools by utilizing the similarity between the task description corresponding to the task to be processed and the functional description of the preset tools. An applicable calculation module is used to calculate the applicability score of each candidate tool in the current state of the agent, using the key parameters of the candidate tool and the agent's memory data. The target calculation module is used to calculate the target score of the candidate tool based on the applicability score of the candidate tool, the similarity between the functional description and the task description of the candidate tool, and the historical tool data of the candidate tool. The invocation determination module is used to determine the tool to be invoked from the candidate tools based on the target scores of the candidate tools and the synergy between the candidate tools. This includes: determining intermediate tools corresponding to each tool function from the candidate tools according to their target scores and tool functions; combining the intermediate tools to obtain a toolchain based on the task description and the tool functions of the intermediate tools; for each toolchain, if the intermediate tools in the toolchain meet the synergy conditions, adding points to the target scores of the intermediate tools to obtain an updated target score for each intermediate tool; and determining the tool to be invoked from the intermediate tools based on the updated target scores of each intermediate tool. The retrieval module is used to retrieve reference memory data from the memory data based on the task description; The processing module is used to combine the reference memory data to call the tool to be called in order to execute the task to be processed; The memory data includes short-term complete execution data. The step of calculating the applicability score of the candidate tool in the current state of the agent using the key parameters of the candidate tool and the agent's memory data includes: acquiring the agent's short-term complete execution data and identifying the key parameters of the candidate tool; the short-term complete execution data includes short-term calling tools and short-term calling results; retrieving the associated fields corresponding to the key parameters from the short-term calling results and using the field values ​​corresponding to the associated fields as candidate parameters; determining the candidate score of the candidate parameter based on the generation time of the candidate parameter, the source of the candidate calling tool, and the format requirements of the key parameter; the candidate calling tool being the short-term calling tool corresponding to the candidate parameter; and taking the maximum value among the candidate scores of all candidate parameters corresponding to the candidate tool as the applicability score of the candidate tool.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps in the tool-based task processing method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge graph question and answer method based on Monte Carlo tree search and multi-agent cooperation

    CN119884330A

  • Data sharing system and method for realizing multi-agent interaction

    CN120277143A