Tool calling method and device, electronic equipment, medium and program product

By using a large language model for task planning and external tool invocation, the system addresses the shortcomings of existing intelligent agent systems in terms of intelligence and parameter extraction in complex task processing, achieving efficient and robust automated task execution and result optimization.

CN121501384APending Publication Date: 2026-02-10INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202511784584.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-01
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing intelligent agent systems lack intelligence, accuracy, and scalability in handling complex tasks and collaborating with multiple tools, making it difficult to meet the requirements of real production environments. In particular, they exhibit closed-loop reasoning defects when querying external data, performing complex calculations, and operating across systems, and their parameter extraction and completion capabilities are insufficient, leading to call failures or abnormal results.

Method used

The system uses a large language model for task planning and response, autonomously determines whether to call external tools and the type of tools, accurately extracts parameter information using prompt word templates, and supplements parameters when necessary to optimize the results and improve the success rate and accuracy of the call. The system also combines semantic recombination and format standardization to process the results.

Benefits of technology

It enhances the system's decision-making intelligence and flexibility under complex tasks, achieves efficient and robust automated task execution, improves the accuracy of parameter extraction and the success rate of invocation, and enhances the overall response efficiency and intelligence level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121501384A_ABST
    Figure CN121501384A_ABST
Patent Text Reader

Abstract

The invention provides a tool calling method and device, electronic equipment, a medium and a program product, and can be applied to the technical field of big data and the technical field of artificial intelligence. The method comprises the steps of obtaining target task information, inputting the target task information into a large language model for analysis, and generating a task planning response; a tool calling strategy is determined based on the task planning response, and the process of determining the tool calling strategy comprises the steps of judging whether an external tool is called or not and determining the type of the tool; under the condition that an external tool needs to be called, utilizing a first cue word template to guide the large language model to extract parameter information of a target tool from the target task information; and calling the target tool based on the parameter information to obtain first task response information returned by the target tool.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of big data technology and artificial intelligence technology, and more specifically to a tool invocation method, apparatus, device, medium and program product. Background Technology

[0002] With the rapid development of Large Language Models (LLMs) in the field of natural language processing, intelligent agent systems built based on LLMs have become an important direction for intelligent interaction. However, existing intelligent agents still have significant limitations in handling complex tasks and multi-tool collaboration, making it difficult to meet the requirements of intelligence, accuracy, and scalability in real-world production environments.

[0003] Currently, many systems employ two modes: a simple input-output response mode and a fixed-logic tool invocation mode. The former simply passes user input to the model to generate a response; its structure is simple but relies on the model's internal knowledge, making it difficult to handle tasks involving external data queries, complex calculations, or cross-system operations. The latter triggers tool invocations through preset keywords or rules; while it can expand functionality, its tool invocation logic is rigid and lacks semantic flexibility, making it prone to false triggers or missed triggers. Furthermore, existing systems lack intelligence in parameter extraction and completion, failing to accurately identify incomplete or ambiguous parameters and lacking a dynamic follow-up mechanism with the user, leading to invocation failures or abnormal results. Even when tools are successfully invoked, the results are often unoptimized, resulting in poor readability when directly output, thus impacting user experience and system interaction. Summary of the Invention

[0004] In view of the above problems, this application provides tool invocation methods, apparatus, devices, media and program products.

[0005] According to a first aspect of this application, a tool invocation method is provided, the method comprising: acquiring target task information; inputting the target task information into a large language model for analysis to generate a task planning response; determining a tool invocation strategy based on the task planning response, wherein the process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type; if it is necessary to invoke an external tool, using a first prompt word template to guide the large language model to extract parameter information of the target tool from the target task information; and executing the invocation of the target tool based on the parameter information to obtain first task response information returned by the target tool.

[0006] According to an embodiment of this application, the method further includes: obtaining a second prompt word template without calling external tools; guiding the large language model to generate second task response information based on the target task information and the second prompt word template; and performing an accuracy check on the second task response information; in response to the accuracy check failing, triggering the large language model to regenerate the Nth task response information based on the second prompt word template until the accuracy check passes, wherein N is a positive integer greater than 2.

[0007] According to an embodiment of this application, the step of invoking the target tool based on the parameter information includes: performing an integrity check based on the parameter information; if the integrity check passes, invoking the corresponding target tool interface to execute the invoking of the target tool; if the integrity check fails, determining the missing parameters, obtaining supplementary parameter information based on the missing parameters and the large language model, and executing the invoking of the target tool based on the supplementary parameter information.

[0008] According to an embodiment of this application, obtaining supplementary parameter information based on the missing parameter and the large language model includes: determining the semantic description and data type of the missing parameter, generating a supplementary request prompt; inputting the supplementary request prompt into the large language model to generate natural language follow-up information and candidate parameter values, wherein the natural language follow-up information is used to guide the user to supplement parameters and select parameter values; and sending the natural language follow-up information and the candidate parameter values ​​to the user terminal to receive supplementary parameter information fed back by the user.

[0009] According to an embodiment of this application, the method further includes: determining a result optimization strategy based on the first task response information, the result optimization strategy including at least one of semantic reorganization, language polishing, and format standardization; and performing result optimization processing on the first task response information using the large language model based on the result optimization strategy.

[0010] According to an embodiment of this application, the step of determining the tool invocation strategy based on the task planning response further includes: calculating a comprehensive confidence score based on the task planning response, the target tool function description, and historical tool execution information, wherein the comprehensive confidence score includes at least a weighted fusion result of semantic matching degree and historical invocation success rate; dynamically adjusting a preset confidence score threshold based on the target task information using the large language model to obtain a target threshold; and updating the tool invocation strategy using the large language model in response to the comprehensive confidence score being lower than the target threshold.

[0011] According to an embodiment of this application, the method further includes: in response to executing the call to the target tool, monitoring for parameter transmission anomalies, tool execution anomalies, or model response anomalies; in response to detecting an anomaly, repeatedly executing the process of obtaining the parameter information using the large language model and calling the target tool based on the parameter information; and in response to the number of repeated executions reaching a preset number, triggering the large language model to generate anomaly explanation information.

[0012] A second aspect of this application provides a tool invocation apparatus, the apparatus comprising: a data acquisition module, configured to: acquire target task information, input the target task information into a large language model for analysis, and generate a task planning response; a strategy determination module, configured to: determine a tool invocation strategy based on the task planning response, wherein the process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type; a parameter information extraction module, configured to: when an external tool needs to be invoked, guide the large language model to extract parameter information of the target tool from the target task information using a first prompt word template; and a tool invocation module, configured to: execute the invocation of the target tool based on the parameter information to obtain first task response information returned by the target tool.

[0013] A third aspect of this application provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.

[0014] A fourth aspect of this application also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.

[0015] The fifth aspect of this application also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.

[0016] According to embodiments of this application, by utilizing a large language model to perform semantic analysis and planning on target task information, the system can autonomously determine whether external tools need to be called and determine the appropriate tool type based on the task content, thereby improving the system's decision-making intelligence and flexibility in complex tasks. By guiding the large language model with a first prompt word template to accurately extract the parameter information required by the target tool from the user input, the system effectively avoids parameter omission or misidentification problems under traditional rule matching methods, improves the accuracy of parameter extraction and the success rate of invocation, and thus enables efficient and robust automated task execution in multi-tool and multi-task scenarios, improving overall response efficiency and intelligence level. Attached Figure Description

[0017] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0018] Figure 1 The illustrations depict application scenarios of tool invocation methods, apparatus, devices, media, and program products according to embodiments of this application.

[0019] Figure 2 A flowchart illustrating a tool invocation method according to an embodiment of this application is shown schematically;

[0020] Figure 3 A flowchart illustrating a method for obtaining supplementary parameter information according to some exemplary embodiments of this application is shown schematically;

[0021] Figure 4 The illustration shows a schematic diagram of a method for determining a tool invocation strategy according to some exemplary embodiments of this application;

[0022] Figure 5 This schematically illustrates a structural block diagram of a tool invocation device according to an embodiment of the present application; and

[0023] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a tool invocation method according to an embodiment of this application. Detailed Implementation

[0024] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.

[0025] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0026] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0027] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).

[0028] In recent years, with the development of large language models in the field of natural language processing, intelligent agent systems built upon large language models have gradually become an important direction for intelligent interaction. These systems, by combining the semantic understanding, logical reasoning, and natural language generation capabilities of large language models, achieve more natural language interaction between humans and machines, and are widely used in areas such as intelligent customer service, knowledge-based question answering, office assistants, programming assistants, tool invocation, and multimodal decision-making. However, existing intelligent agent systems based on large language models still have significant limitations in handling complex tasks and multi-tool collaboration, making it difficult to meet the requirements of intelligence, accuracy, and scalability in real-world production environments.

[0029] Currently, some intelligent agent systems can be broadly categorized into two modes: a simple input-output response mode and a tool-calling mode with fixed logic. In the simple response mode, the system directly passes the user's input task or question to a large language model, which then generates a response based on its internal knowledge and returns it to the user. This mode is simple in structure and low in implementation cost, but because it relies entirely on the existing knowledge and language generation capabilities of the large language model, it cannot handle tasks involving external data queries, complex calculations, or cross-system operations. For example, when a task requires calling a database, executing a program, accessing an application programming interface (API), or integrating information from an external knowledge base, simply relying on the model's output often fails to yield correct results, exhibiting a clear "closed-loop reasoning" defect.

[0030] Another type of pattern is the fixed-logic tool invocation pattern. This pattern pre-defines specific keywords, rules, or intent mapping logic within the system. When the system detects certain words or semantic patterns in the user input, it automatically triggers the corresponding tool invocation, such as a computing tool, knowledge retrieval interface, or external API. This approach expands the system's functional boundaries to some extent, enabling the agent to perform some practical operations beyond language understanding. However, the core problem with this pattern lies in the rigidity and lack of semantic flexibility of its tool invocation logic. Because it relies on predefined rules, the system cannot dynamically adjust the tool invocation strategy based on task semantics, contextual relationships, or environmental states. This can easily lead to false triggers (invocations when they shouldn't be) or missed triggers (failure to invoke when they should be), resulting in task execution failure or incorrect output.

[0031] Furthermore, existing intelligent agent systems generally suffer from deficiencies in parameter extraction and completion capabilities. When user input contains incomplete, ambiguous, or natural language-described tool parameters, the system often fails to accurately identify and parse these parameters, and lacks intelligent interaction mechanisms to follow up or supplement missing information. This results in tool invocation failures, abnormal invocation results, or task execution interruptions. On the other hand, even if the tool is successfully invoked, the raw results returned are usually presented in the form of structured data or technical terms, lacking language organization and content optimization. If the system directly feeds back these unprocessed results to the user, not only will the readability be poor, but the user experience and the system's interactivity will also be significantly reduced.

[0032] Based on this, embodiments of this application provide a tool invocation method, the method comprising: acquiring target task information; inputting the target task information into a large language model for analysis to generate a task planning response; determining a tool invocation strategy based on the task planning response, wherein the process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type; when an external tool needs to be invoked, using a first prompt word template to guide the large language model to extract parameter information of the target tool from the target task information; and executing the invocation of the target tool based on the parameter information to obtain first task response information returned by the target tool. According to embodiments of this application, by using a large language model to perform semantic analysis and planning on target task information, the system can autonomously judge whether an external tool needs to be invoked and determine the appropriate tool type based on the task content, thereby improving the decision-making intelligence and flexibility of the system under complex tasks; by using a first prompt word template to guide the large language model to accurately extract the parameter information required by the target tool from the user input, the problem of parameter omission or misidentification under traditional rule matching methods is effectively avoided, improving the accuracy of parameter extraction and the success rate of invocation, thereby enabling efficient and robust automated task execution in multi-tool, multi-task scenarios, improving overall response efficiency and intelligence level.

[0033] It should be noted that the tool invocation methods, apparatus, devices, media, and program products defined in this application can be used in the fields of big data technology and artificial intelligence technology, and can also be used in a variety of fields other than big data technology and artificial intelligence technology. The application fields of the tool invocation methods, apparatus, devices, media, and program products provided in the embodiments of this application are not limited.

[0034] In the technical solution of this application, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.

[0035] In scenarios where personal information is used for automated decision-making, the methods, devices, and systems provided in this application all offer users corresponding operation entry points, allowing them to choose to agree to or reject the automated decision results; if the user chooses to reject, the process proceeds to expert decision-making. Here, "expert decision-making" refers to the decision-making activities of personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.

[0036] Figure 1 The illustrations depict application scenarios of tool invocation methods, apparatus, devices, media, and program products according to embodiments of this application.

[0037] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0038] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0039] In the embodiments of this application, the first terminal device 101 can be an example of the first device, and the second terminal device 102 and / or the third terminal device 103 can be an example of at least one second device. The first device and the second device can communicate collaboratively through an internal client mechanism to implement the data distribution and rendering logic described in the tool invocation method.

[0040] In some embodiments, the first device and at least one second device may be different display modules, windows or screens on the same computing terminal (such as a host), or multiple physical devices that work together through a network, such as different client instances deployed on a desktop computer, tablet terminal or mobile device respectively.

[0041] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smart mobile terminals, tablet computers, laptop computers, and desktop computers.

[0042] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0043] It should be noted that the tool invocation method provided in this application embodiment can generally be executed by server 105. Correspondingly, the tool invocation device provided in this application embodiment can generally be located in server 105. The tool invocation method provided in this application embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the tool invocation device provided in this application embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.

[0044] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0045] The following will be based on Figure 1 The described scene, through Figures 2-4 The tool invocation method of the disclosed embodiments will be described in detail.

[0046] Figure 2 A flowchart illustrating a tool invocation method according to an embodiment of this application is shown.

[0047] like Figure 2 As shown, the tool invocation method 200 of this embodiment includes operations S210 to S240.

[0048] In operation S210, target task information is obtained, and the target task information is input into the large language model for analysis to generate a task planning response.

[0049] In the embodiments of this application, the target task information can be obtained by the user through various forms such as natural language input, graphical interface interaction, voice commands, or program interface requests. For example, the user can input "Please analyze recent sales data and generate a trend chart" or "Query the project progress in the database for 2024," and the system will parse this input as the target task information. The target task information may include a task description, target object, constraints, expected output format, and optional contextual dialogue information. By introducing a multimodal input parsing mechanism, the system can extract semantically related task elements from text, speech, images, or structured data, ensuring that the large language model can obtain a complete task context during the analysis phase.

[0050] After receiving the target task information, the large language model can perform semantic understanding and task parsing operations to generate a task planning response. For example, this process may include multiple steps such as task intent recognition, subtask decomposition, required knowledge domain determination, and external tool dependency analysis. For instance, when the user inputs the task "Generate a statistical report based on user feedback data," the system can use the large language model to determine that the task contains two sub-goals: "data analysis" and "report generation," and further identify the data analysis tools and report template generation modules that need to be invoked. The task planning response can be represented in a structured form, such as a tree-like task diagram, a JavaScript object representation (JSON format) task plan, a process description, or a set of operation intents, thereby facilitating the determination of tool invocation strategies in subsequent stages.

[0051] In some embodiments, the large language model can personalize task planning based on contextual historical task information, system configuration parameters, and user characteristics. Specifically, if a user has repeatedly requested data visualization-related tasks, the model can prioritize planning task schemes that include visualization components during the analysis phase, thereby achieving user habit adaptation. For complex tasks involving multi-step logical reasoning or external resource dependencies, the system can generate a multi-stage execution plan with dependency order in the task planning response. For example, when the input task is "retrieves customer information from the company database and generates an annual sales report," the model can generate a planning structure of "first calling the database retrieval interface, then calling the report generation tool."

[0052] In some embodiments, the analysis process of the large language model can be further combined with external knowledge bases or semantic indexing systems to improve the accuracy and professionalism of task planning. The model can reference domain knowledge when generating task planning responses, such as proprietary terminology and standards from fields like finance, healthcare, programming, or engineering design, making the generated task planning results more relevant to specific business scenarios. For example, in a healthcare scenario, given the input "Analyze patient test results and generate diagnostic suggestions," the model will automatically plan a three-stage structure of "data extraction—feature comparison—diagnosis generation" based on a medical knowledge graph, and indicate which auxiliary diagnostic tools may be invoked subsequently.

[0053] To enhance the model's ability to understand complex tasks, the system can introduce prompt word templates. These templates can include task intent guidance, structured input information hints, and planning generation constraints to improve the consistency of the model's output planning. For example, a prompt word template might include instructions such as "Please decompose the following task into several sub-tasks and label the external tools or knowledge resources required for each sub-task," ensuring that the model follows predetermined logic when generating task planning responses. This embodiment enables the system to automatically adjust its task planning approach when facing different types of tasks (such as data querying, document generation, code execution, and image recognition), thereby achieving multi-scenario adaptation.

[0054] In some embodiments, the task planning response may also include confidence information or execution priority information to guide subsequent tool invocation decisions. For example, the system may attach a semantic matching confidence value to each subtask in the task planning response to indicate the model's level of trust in the planned path; when the confidence is low, the system may regenerate the task plan or obtain user confirmation in subsequent operations through a self-correction mechanism.

[0055] In operation S220, a tool invocation strategy is determined based on the task planning response. The process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type.

[0056] In embodiments of this application, after generating a task planning response, the intelligent agent system can determine a tool invocation strategy based on the task planning response. For example, a large language model can intelligently determine whether a task requires the invocation of external tools and the type of tool to be invoked by analyzing the planning response. Specifically, the system first parses the semantic information in the task planning response, extracting features such as the task objective, input data type, and expected output format. Then, combined with the system's internal tool registration information and functional descriptions, it matches the most suitable tool for completing the task. For instance, when the task planning response contains verbs such as "calculate," "query," or "draw," the system can determine that the task involves external computation or data operations, thereby generating a tool invocation strategy containing specific tool invocation instructions.

[0057] In some embodiments, the process of determining the tool invocation strategy may include a dynamic judgment mechanism combining semantic matching analysis and contextual reasoning. For example, when parsing a task planning response, the large language model can utilize multi-turn dialogue context or historical task records to comprehensively evaluate the nature of the task. For instance, when a user consecutively issues two tasks, "analyze data" and "draw a trend chart," the model can infer that the subsequent task is related to a data visualization tool, thereby automatically selecting a combination strategy of data analysis and visualization tools. If the model determines that the task can be completed using its internal knowledge, it will generate a strategy of "not invoking external tools"; if it determines that the task depends on external computation, querying, or file operations, it will generate a strategy of "invoking external tools," specifying the specific tool type and invocation conditions within the strategy.

[0058] In some embodiments, the process of determining the tool invocation strategy can also be combined with a tool capability description library. This library records the input / output specifications, function labels, and invocation constraints of each external tool. When analyzing the task planning response, the large language model can match the task objective with the tool function description based on semantic similarity calculations. For example, if the task planning response contains semantic fragments such as "generate weekly report documents" or "format statistical results," the system can automatically match text generation or report formatting tools and prioritize the tool type with the highest matching confidence. In cases where multiple candidate tools exist, the system can further rank them based on tool invocation success rate, historical performance data, or execution latency metrics to ultimately determine the optimal invocation strategy.

[0059] To improve the accuracy of strategy judgment, a confidence evaluation mechanism can be introduced into the tool invocation strategy determination process. When determining whether to invoke an external tool, the large language model can generate a confidence score for each candidate tool, representing the reliability of the tool's match with the task. The system can preset a dynamic threshold; when the highest confidence score falls below the threshold, the model can automatically trigger a self-correction mechanism to regenerate or revise the tool invocation strategy. For example, when handling ambiguous task requests (such as "help me optimize performance"), the model can initially determine that code analysis tools or configuration detection tools may be involved, but if the confidence score is insufficient, it will reconfirm the invocation path by supplementing the question or regenerating the plan.

[0060] In some embodiments, the determination of tool invocation strategies can also incorporate user permissions and resource constraints. When analyzing task planning responses, the system can simultaneously consider information such as user roles, accessible toolsets, system security policies, and real-time resource load. For example, when a regular user requests the "Export Database Tables" task, if the system detects that the user lacks data access permissions, the model can mark the task as "Restricted Invocation" in the strategy and automatically generate an alternative (such as "Generate Sample Data Report"). When the system detects that the target tool is currently unavailable or resources are overloaded, the strategy can be adjusted to delayed execution or task allocation to a backup node to ensure overall system stability and security.

[0061] In some embodiments, the system may also introduce a mapping mechanism between task types and tool invocation patterns. This mechanism is based on a semantic mapping table trained by a large language model, which pre-associates different categories of tasks with typical tool types. For example, tasks such as "text summarization" and "question-answering generation" correspond to natural language generation tools; tasks such as "data statistics" and "regression prediction" correspond to computation and analysis tools; and tasks such as "document formatting" and "chart creation" correspond to visualization and layout tools. After receiving a task planning response, the large language model can quickly select a matching pattern based on the task type and fine-tune the invocation strategy in conjunction with the current context to achieve low-latency and high-accuracy strategy generation.

[0062] To enhance system interpretability, tool invocation strategies can be represented using structured strategies. The system can output the model-generated strategies in JSON or task graph format, explicitly recording information such as whether external tools are invoked, the type of tool invoked, the method of obtaining parameters, and the execution order.

[0063] In operation S230, when it is necessary to call an external tool, the large language model is guided to extract the parameter information of the target tool from the target task information using the first prompt word template.

[0064] In the embodiments of this application, when it is determined that the target task requires the invocation of an external tool, a first prompt word template can be used to guide the large language model to extract the parameter information of the target tool from the target task information. Specifically, the system can automatically select the prompt word template corresponding to the determined tool type. The prompt word template may include parameter names, parameter types, example formats, semantic constraints, and dependencies between parameters, etc., to standardize the reasoning logic of the large language model when extracting parameters. For example, for a "database query tool", the template may include parameter slots such as "table name", "query field", and "filter conditions". When the model parses the task description "Please query the total sales in 2024", it can automatically identify parameter information such as "year = 2024", "field = sales amount", and "operation = aggregation statistics", generating structured parameter extraction results, thereby ensuring the accuracy and executability of the tool invocation.

[0065] In some embodiments, to enhance parameter recognition capabilities across different task contexts, the first prompt word template can adopt a hierarchical structure, including a general prompt word layer and a tool-specific prompt word layer. The general layer instructs the large language model to perform the basic logic of parameter extraction, such as "Please identify the operation objects, operation conditions, and output requirements involved in the task." The specific layer supplements the semantic features of the target tool, such as "If the tool is computational, please extract the computational target and numerical parameters," or "If the tool is image generation, please extract the style, size, and theme description." Through this hierarchical template mechanism, the system can automatically switch template content under different task types, enabling the large language model to possess both general parsing capabilities and adapt to the parameter format requirements of specific tools, achieving a balance between semantic generalization and domain accuracy.

[0066] In some embodiments, when performing parameter extraction, the large language model can combine task context and historical interaction information to perform multi-round semantic reasoning to complete implicit parameters or disambiguate fuzzy parameters. For example, when a user inputs "Help me draw a quarterly sales chart," the task description does not explicitly state the quarterly range or data source. The model can automatically infer from the historical task context that the data table previously used by the user is a "sales data table," and infer that the current time range corresponds to the "latest quarter." Guided by the template, the model can output the completed parameter set, such as "Data source = sales data table," "Time range = Q4," and "Chart type = line chart," and make the result available for use by subsequent tools.

[0067] In some embodiments, the parameter extraction process can employ a structured generation approach, directly outputting data in a format conforming to the tool interface specification. For example, large language models can generate key-value pairs or JSON structured data under template constraints. This structured output can be directly parsed by the system without additional format conversion, thereby reducing intermediate processing steps and improving execution efficiency. For tools requiring complex parameter nesting (such as machine learning training interfaces or image generation APIs), the model can generate multi-level parameter structures according to the hierarchical descriptions in the prompt word template, achieving automatic adaptation to complex tasks.

[0068] To support cross - tool parameter sharing and unified management, the system can establish a parameter semantic mapping table when extracting parameters. This mapping table is used to record the corresponding relationships of parameter semantics between different tools. For example, "input file path" can be shared as "data_path" in data analysis tools and model training tools. After the large - language model extracts the parameters, the system can automatically convert the parameters into the standard form of the target tool according to the mapping table, thus achieving the consistency and reusability of cross - tool calls. For example, when the user's consecutive task is "analyze sales data and draw a report chart", the model can reuse the result of the data query parameters extracted for the first time in the subsequent visualization tool call without re - extraction, improving the execution efficiency of the task chain.

[0069] In another embodiment, when extracting parameters, the large - language model can also combine an external knowledge base for semantic completion and standardization. For example, when the task involves specific industry terms (such as "annual net income", "gross profit margin"), the model can look up the corresponding field definitions and calculation logics from the financial knowledge base, and thus output parameter names consistent with the database fields.

[0070] In some embodiments, to handle the multi - tool linkage scenario in complex tasks, the first prompt template can guide the model to extract parameter information for multiple tools simultaneously. The system can identify the task chain in the task planning response and apply the template to each subtask to extract the corresponding parameters respectively. For example, for the task "query sales data from the database and draw an annual trend chart", the system can first extract query parameters for the "database query tool", and then extract visualization parameters for the "chart drawing tool", and finally generate a combined call strategy. This process outputs a multi - tool parameter set by the large - language model under the guidance of the template, thus achieving the automatic connection and coordinated execution of multi - step tasks.

[0071] In operation S240, based on the parameter information, perform the call of the target tool to obtain the first task response information returned by the target tool.

[0072] In the embodiments of the present application, after parameter extraction, the call of the target tool can be performed based on the parameter information, and the first task response information returned by the target tool can be obtained. Specifically, the system generates a call request that meets the requirements of the tool interface according to the parameter information, and establishes a communication connection with the external tool through the tool management module. For example, when the target tool is a data analysis interface, the system can construct a query statement or an API request body according to the extracted parameters, send it to the specified data service endpoint, and receive the analysis result as the first task response information. When the target tool is a text generation or visualization tool, the system automatically selects the corresponding output mode according to the task type and parameter configuration, such as text summary, image rendering, table filling, or file export.

[0073] To ensure the universality and stability of tool calls, the system can adopt a unified tool interface standard to encapsulate different types of external tools. Each tool has a corresponding functional description file during the registration phase, including input parameter definitions, output format specifications, and error handling strategies. When executing operation S240, the system can automatically adapt the request format based on the parameter information and the tool description file, and parse and standardize the returned results after the call. For example, for drawing interfaces from different vendors, the system can automatically map fields such as image size, style type, and text prompts through a unified encapsulation layer, achieving a consistent calling experience across platforms.

[0074] In some embodiments, when executing external tool calls, the system can combine an asynchronous task queue with a status callback mechanism to improve the processing efficiency of long-running tasks. When the target tool's execution process requires a long time (such as model training, batch computation, or document generation), the system can immediately return a task identifier after the call and add the execution status to the task management queue. Subsequently, the system obtains the tool's execution status through polling or callback listening, and extracts the final result as the first task response information after the task is completed. This design enables the system to manage the execution process of multiple tool tasks simultaneously, achieving concurrent scheduling and load balancing, and significantly improving multi-task processing efficiency.

[0075] In some embodiments, the external tool invocation process can also be coupled with security and access control mechanisms. Before executing the invocation, the system can verify the current user's identity and invocation permissions to prevent unauthorized operations or illegal data access. For example, in an enterprise-level deployment scenario, when a user requests the "export sales report" task, the system will verify whether the user has the corresponding database access rights based on role permissions. If the permissions are insufficient, the invocation will be aborted and a security warning message will be returned. Simultaneously, when interacting with external tools, the system can encrypt and temporarily cache sensitive parameters during transmission to ensure data security and traceability during the invocation process.

[0076] In some embodiments, the tool invocation process can be combined with execution logs and tracing mechanisms to support result auditing and performance optimization. When invoking a tool, the system automatically records information such as request parameters, invocation time, execution time, and return status, and writes this data to a log database. This data can be used for subsequent invocation statistics and performance analysis. For example, the system can calculate the average response time and invocation success rate of different tools, thereby prioritizing the selection of the most performant tool type during subsequent task planning. Furthermore, when abnormal results occur, the system can trace the invocation process based on the logs to reproduce the task execution path for problem diagnosis and strategy optimization.

[0077] In another embodiment, external tool calls can also be combined with a large language model for result verification and consistency checks. After the system receives the tool's returned results, the large language model can perform semantic comparison and logical consistency checks on the result content based on the task planning response and input parameters. For example, when a database query tool returns tabular data, the model can verify whether the returned results match the request conditions; when a text generation tool is called, the model can determine whether the generated content meets the task objectives and semantic constraints. If inconsistencies or abnormal output are detected, the system can automatically trigger a retry mechanism or call a backup tool to execute the task, thereby improving the overall reliability and accuracy of task execution.

[0078] In some embodiments, to improve the reusability and manageability of cross-task results, the system can store the first task response information in a task cache or result knowledge base after executing the target tool call. This knowledge base is used to save the input-output mapping relationship between tasks for subsequent tasks to reference or reuse. For example, when a user requests "generate project report document" multiple times, the system can directly retrieve the result of the most recent call, provide reusable output after verifying the data validity, thereby reducing redundant calculations and the number of external calls.

[0079] In some embodiments, the tool invocation mechanism can also support multi-tool cascading and composite invocation scenarios. Specifically, multiple tools can be invoked sequentially according to the execution dependencies in the task planning response, with the output of the previous tool serving as the input of the next. For example, in the task "Analyze sales data and generate visualization charts," the system can first invoke a data analysis tool to obtain statistical results, and then invoke a chart drawing tool to generate the corresponding image. This multi-level invocation can be automatically managed by the system for data flow and parameter mapping without user intervention, thereby achieving automatic cross-module collaboration. For complex tasks, the system can also insert model self-checking or result optimization modules into the invocation chain to ensure the quality of the final output.

[0080] According to embodiments of this application, by constructing a complete intelligent process from task understanding, strategy decision-making, parameter extraction to tool execution, automated task processing and external tool collaboration driven by a large language model are achieved. The system can perform semantic parsing and structured planning on user-input natural language tasks, automatically determine whether external tools need to be called and identify the optimal tool type, then accurately extract the parameters required by the target tool through prompt word templates, and finally complete the tool call and obtain the response result based on the parameter information. This technical solution enables the intelligent agent to possess end-to-end capabilities from task intent recognition to executable operation generation, significantly improving the system's decision-making intelligence, execution accuracy, and scalability in complex task scenarios, reducing manual intervention and rule dependence, and achieving efficient, stable, and scalable automated task execution.

[0081] The tool invocation method of this application will be specifically described below by way of preferred embodiments.

[0082] In the embodiments of this application, when the system determines during the task planning phase that the current task can be completed without calling external tools, the system can execute the corresponding natural language processing flow to ensure the accuracy and consistency of the model's output results. Specifically, a predefined second prompt word template can be obtained first. The second prompt word template is used to guide the large language model to generate task responses without relying on external tools. The second prompt word template may include a description of the task intent, semantic constraints, format specifications, and output requirements, etc., to ensure that the responses generated by the model meet the requirements of the target task in terms of logic, semantics, and expression.

[0083] To ensure that the second task response information generated by the large language model meets the task objectives, the system can perform an accuracy verification process after the model outputs. The verification process can be evaluated based on multi-dimensional metrics, such as semantic consistency, factual correctness, logical completeness, and format conformity. For example, for the task "Please calculate 2 to the power of 10," the system can verify whether the model-generated result matches the expected mathematical calculation value; for the task "Please summarize the main content of the following text," it can compare the consistency between the model output and the topic of the input text. When a response deviates from the objective or contains obvious errors, the system determines that the accuracy verification has failed.

[0084] For cases where validation fails, the system can trigger a regeneration mechanism for the large language model based on the second prompt word template. The system can use previous erroneous outputs as negative feedback signals and add improvement instructions to the template, such as "Please answer again, ensuring logical consistency and avoiding factual errors," to guide the model to optimize results in the next generation. This regeneration process can be iterated multiple times until the model output passes accuracy validation, with the number of regenerations dynamically adjustable. Here, N is a positive integer greater than 2. The system can also automatically control the number of iterations based on task complexity and response stability, ensuring result quality while avoiding unnecessary recalculation.

[0085] Furthermore, the accuracy verification process can combine the model's own confidence assessment with external knowledge verification mechanisms. When the model output results have low confidence, the system can proactively trigger a regeneration operation; if the task involves factual content (such as time, numerical values, or entity relationships), the system can also compare and confirm through an external knowledge base or verification module, thereby ensuring the authenticity and reliability of the generated results. For example, for the task "Please explain the basic principles of quantum computing," the system can call the built-in knowledge review module to cross-validate the model-generated content to prevent errors or fabricated information.

[0086] According to embodiments of this application, by introducing a second prompt word template and a multi-round result verification mechanism, the system possesses reliable task execution and result self-correction capabilities without invoking external tools. This solution not only improves the model's answer accuracy and expression quality in knowledge-based tasks, but also constructs a self-optimizing closed loop through cyclic generation and dynamic verification mechanisms, thereby achieving a high-quality, controllable, and adaptively corrective intelligent task response process.

[0087] In the embodiments of this application, after the system extracts the parameters required by the target tool, it can execute the call to the external tool based on the parameter information. To ensure the validity of the tool call and the correctness of the execution result, the parameter information can first be checked for completeness. Specifically, the verification process is used to verify whether the parameters generated by the model meet the call requirements of the target tool interface, including whether the required fields are complete, whether the parameter types match, whether the value range is reasonable, and whether the logical relationship between the parameters is consistent. For example, when calling a data query tool, it can check whether key parameters such as the query table name, field name, and time range are complete, and determine whether the filtering conditions conform to the semantic specifications. If the parameters pass the completeness check, the system directly calls the corresponding target tool interface to execute the task and uses the result returned by the external tool as the first task response information.

[0088] If the integrity check fails, the system will further identify the missing parameters and obtain supplementary parameter information based on the missing parameters and the large language model. Specifically, the system can identify which parameters are missing or do not meet the requirements, generate corresponding supplementary request prompts, input these prompts into the large language model, and guide the model to infer reasonable candidate parameters or generate follow-up questions for user interaction based on the task context.

[0089] Furthermore, after obtaining the supplementary parameter information, the updated parameter set can be validated again to ensure that the supplementary information remains consistent with the original task requirements. Once the validation passes, the system re-invokes the target tool interface to execute the task. For example, if the task is "generate statistical charts" but the initial input lacks the "statistical dimension" parameter, the system will re-initiate the plotting call after obtaining the supplementary parameter "statistics by month," thus obtaining output results that meet the user's expectations.

[0090] In some embodiments, the system can also combine historical task records and semantic memory mechanisms to prioritize inferring reasonable values ​​from historical context when detecting missing parameters. For example, if a user continuously performs tasks related to the same dataset, the system can automatically reuse valid parameters extracted from previous tasks, avoiding repeated queries and parameter generation, thereby reducing the number of interactions and improving task response speed. Furthermore, the system can dynamically adjust the model completion strategy based on task complexity and the number of missing parameters, such as prioritizing high-confidence parameters, step-by-step completion, or multiple rounds of confirmation, to achieve a more robust parameter generation process.

[0091] According to embodiments of this application, by introducing parameter integrity verification and a parameter completion mechanism based on a large language model before tool invocation, the correctness and executability of external tool invocation are ensured. This scheme enables the system to adaptively reason and complete task execution even when faced with complex scenarios involving incomplete input, semantic ambiguity, or missing context, thereby improving the success rate of tool invocation, the interactive intelligence of the system, and the stability of task processing.

[0092] In the embodiments of this application, in order to solve the problem of missing parameters caused by incomplete input information or ambiguous user expression when the intelligent agent system executes external tool calls, thereby improving the intelligence level of parameter completion and the success rate of tool calls, a method for automatically identifying missing types and generating interactive follow-up prompts can be introduced.

[0093] Figure 3 The flowchart illustrating a method for obtaining supplementary parameter information according to some exemplary embodiments of this application is shown schematically.

[0094] like Figure 3 As shown, the method for obtaining supplementary parameter information includes operations S310 to S330.

[0095] In operation S310, the semantic description and data type of the missing parameter are determined, and a supplementary request prompt is generated.

[0096] Specifically, the location and role of missing parameters in the task semantics can be identified by analyzing the interface description files of the task planning response and the target tool. For example, when the task planning response is "generate quarterly sales statistics chart" but the "statistical time range" parameter is missing, the system can infer from the parameter definition file of the tool interface and the task context that the semantic description of the missing parameter is "time range" and the data type is "time interval".

[0097] Furthermore, the system can leverage the semantic understanding capabilities of a large language model to determine the semantic attributes of missing parameters through context parsing and dependency analysis. The model first performs semantic role labeling on user input and task planning responses, identifying elements such as task objectives, operational objects, and constraints. Then, it determines the semantic category of the missing field based on its dependency relationships in the syntactic tree. For example, when a user inputs "Please draw a product sales trend chart," if product category information is missing, the system can infer the semantic description of the missing parameter as "target product category" with a data type of "string enumeration value" based on the relationship between the predicate "draw" and the object "product sales trend chart."

[0098] After identifying the semantic description and data type of the missing parameter, a supplementary request prompt can be generated. This prompt can include a clear query template, parameter context information, and optional input formats. For example, the generated prompt could be: "Missing parameter: Time range. Please confirm the time period you wish to analyze, such as the entire year of 2023 or the most recent quarter."

[0099] In operation S320, the supplementary request prompt is input into the large language model to generate natural language follow-up information and candidate parameter values. The natural language follow-up information is used to guide the user to supplement parameters and select parameter values.

[0100] Natural language probing information is used to ask users questions in a human-friendly language, such as "Please confirm whether you want to analyze the entire year of 2024 or quarterly data?". Candidate parameter values ​​can be automatically provided from the context or knowledge base based on the model's reasoning ability, such as "2024Q1", "2024 whole year", "last six months", etc. This enables a natural transition from semantic recognition to human-computer interaction, giving the system the ability to proactively ask questions and make intelligent suggestions.

[0101] In operation S330, the natural language follow-up information and the candidate parameter values ​​are sent to the user terminal, and supplementary parameter information is received from the user. The user can provide confirmation or correction information through text input, option selection, or voice reply. After receiving feedback, the system formats and verifies the supplementary parameters and updates them to the task parameter set to form a complete and executable parameter information set.

[0102] According to embodiments of this application, by determining the semantic description and type of missing parameters, the system can accurately identify the missing parameter location and its contextual meaning, and achieve targeted completion prompts; by using a large language model to generate natural language follow-up questions and candidate values, the interactive experience is greatly improved, making the parameter completion process more natural, intelligent and efficient; through user feedback loops, the system realizes parameter self-correction and dynamic updates, significantly improving the success rate of tool invocation and the stability of task execution.

[0103] In the embodiments of this application, after the system obtains the first task response information returned by the external tool, in order to further improve the readability, professionalism, and consistency of the output results, the system can perform result optimization processing on the response information. Specifically, the system first performs content analysis on the results returned by the tool, identifies its semantic structure, information density, and expression style, and determines corresponding result optimization strategies based on this. The result optimization strategies include at least one of semantic reorganization, language polishing, and format standardization, which are used to guide the subsequent large language model optimization and generation process.

[0104] In some embodiments, semantic reorganization is used to restructure the logical structure and extract key points from the original content returned by the tool. The system can combine the semantic intent and target constraints in the task planning response to perform information filtering and logical optimization on the results, including extracting key conclusions, merging duplicate information, adjusting the semantic order, or supplementing contextual explanations. For example, when an external tool returns complex statistical results, the system can extract key information through semantic reorganization and place it at the beginning of the output, while presenting auxiliary content in a hierarchical or numbered manner, thereby improving the logical coherence and information aggregation of the results.

[0105] In some embodiments, language polishing is used to optimize the natural language expression of the results, making the output more fluent, accurate, and professionally consistent. The system can leverage a large language model to perform sentence structure adjustments, terminology standardization, tone correction, and text refinement while maintaining semantic integrity. For example, after invoking translation tools, summarization tools, or code interpretation tools, the system can polish the returned results to make them more consistent with user reading habits or industry writing standards. Through language polishing, the system can generate more natural, clear, and directly usable text for presentation or delivery.

[0106] In some embodiments, format normalization is used to ensure that the optimized results conform to preset display standards or system interface specifications. The system can automatically apply appropriate format templates based on the task type or output requirements, converting the result content into a structured, hierarchical, or standardized format. For example, when the task is "generating a quarterly report summary," the system can automatically format the optimized content into a four-part structure of "Summary—Analysis—Conclusion—Recommendation"; when the task is displaying the results of an interface call, the system can normalize the results into JSON or tabular form to facilitate data integration and downstream system calls.

[0107] In some embodiments, result optimization strategies can be used individually or in combination to adapt to the characteristics of different types of task results and user needs. When the results returned by external tools are relatively standardized but awkwardly expressed, the system can only enable the language polishing strategy to optimize the sentence structure and expression style of the large language model while keeping the information unchanged. When the result information is complex and the logic is loose, the semantic reorganization strategy can be used first to organize the results hierarchically and highlight the key points. When the results need to be called by other systems or displayed in a formatted manner, the system can only apply the format normalization strategy to convert the output into a structured format that conforms to the interface or report standards. In addition, when dealing with comprehensive tasks, the system can also automatically combine multiple optimization strategies according to the result characteristics. For example, it can first perform semantic reorganization to extract the core points, then perform language polishing to improve fluency, and finally achieve standardized output of the results through format normalization.

[0108] In the embodiments of this application, by determining the result optimization strategy based on the first task response information and performing result optimization processing using a large language model, intelligent reconstruction of the semantics, language, and format of the results returned by external tools is achieved. This technical solution not only improves the readability and professional consistency of the result content, but also enhances the system's output adaptability and user experience in multi-task and multi-domain scenarios.

[0109] In the embodiments of this application, in order to solve the problem that the tool invocation decision process in existing intelligent agent systems lacks flexibility and is difficult to dynamically adapt to changes in task semantics, the following method is also provided.

[0110] Figure 4 The illustration shows a schematic diagram of a method for determining a tool invocation strategy according to some exemplary embodiments of this application.

[0111] like Figure 4 As shown, the method for determining the tool invocation strategy may include operations S410 to S430.

[0112] In operation S410, based on the task planning response, target tool function description and historical tool execution information, a comprehensive confidence score is calculated. The comprehensive confidence score includes at least a weighted fusion result of semantic matching degree and historical call success rate.

[0113] The overall confidence score quantifies the compatibility between the current task and the target tool. Its calculation includes at least a weighted fusion of semantic matching and historical call success rate. The semantic matching score is calculated by a large language model using semantic vector similarity, and is used to assess the semantic fit between the task description and the tool's functionality. The historical call success rate can be derived from statistical results of past task execution records, reflecting the tool's stability and reliability in similar task scenarios. For example, when the task is "generate customer data reports," if the report generation tool has a high execution success rate and strong semantic matching in similar tasks, the overall confidence score will be high, thus increasing the probability of it being selected as the call target.

[0114] In operation S420, based on the target task information, the preset confidence threshold is dynamically adjusted using the large language model to obtain the target threshold.

[0115] Specifically, the system can dynamically generate optimal thresholds by analyzing features such as task complexity, contextual semantic density, and tool dependency through large language models. For example, when the task semantics are ambiguous or the information is incomplete, the system can automatically lower the threshold to allow the use of more exploratory tools; when the task semantics are clear and the model's own knowledge is sufficient to answer the question, the system can raise the threshold to reduce unnecessary external calls.

[0116] In operation S430, in response to the overall confidence level falling below the target threshold, the tool invocation strategy is updated using the large language model. The update process may include reassessing task requirements, introducing alternative candidate tools, or adjusting the tool invocation order. The model may regenerate the strategy description based on the task planning response, for example, updating from "invoke data analysis tools" to "perform text extraction first, then invoke the statistical analysis module," thereby optimizing the execution logic of the invocation chain.

[0117] In some embodiments, to improve the accuracy of confidence calculation and policy updates, the system may also introduce time decay weights and environmental context factors. Time decay weights are used to reduce the impact of outdated tasks in historical data, maintaining the timeliness of policy decisions; environmental context factors (such as system load, tool availability, etc.) are used to adjust policy weights in real time, making system decisions more consistent with the current operating state. For example, under high load conditions, the system may prioritize tools with shorter execution times to improve response speed.

[0118] Through the above-mentioned comprehensive confidence calculation, dynamic threshold adjustment and strategy self-updating mechanism, the system realizes intelligent tool invocation strategy determination based on task semantics and historical behavior, thereby not only improving the accuracy and success rate of tool invocation, but also having good adaptability and interpretability.

[0119] In the embodiments of this application, to improve the stability and self-healing capability of the system under complex task scenarios, when the intelligent agent executes a target tool call, the system can perform anomaly monitoring and adaptive recovery processing throughout the entire call process. Specifically, while executing an external tool call, the system can monitor in real time for anomalies such as parameter transmission anomalies, tool execution anomalies, or model response anomalies. Parameter transmission anomalies include issues such as incorrect parameter types, missing parameters, or format mismatches; tool execution anomalies include situations such as external interface timeouts, resource unreachability, execution interruptions, or empty result returns; model response anomalies refer to phenomena such as logical contradictions, semantic inconsistencies, or empty content in the responses generated by the large language model. By continuously monitoring these anomaly signals, the system can detect problems in an early stage, prevent erroneous results from propagating to subsequent processes, and thus ensure the robustness of task execution.

[0120] In some embodiments, when the system detects the above-mentioned anomaly, it will automatically trigger an exception handling mechanism and repeat the parameter acquisition and tool invocation process. The system can reuse the large language model to obtain the parameter information to correct any previous parameter errors or inconsistencies. For example, if a tool invocation returns an error or the interface rejects the request, the system can automatically initiate a secondary parameter extraction request to the large language model, generate a corrected parameter set, and re-execute the tool invocation based on the new parameters.

[0121] In some embodiments, to prevent the system from getting stuck in an infinite loop or wasting resources, when the number of repeated executions reaches a preset threshold, the system will trigger a large language model to generate exception explanation information. The exception explanation information may include the exception type, possible causes, and suggested handling solutions. For example, when an external API continuously times out or parameter validation fails, the model can generate explanatory output, such as "The external tool called by this task is temporarily unavailable; it is recommended to check the network status or replace it with an alternative interface," and provide feedback to the user or system management module in natural language.

[0122] By introducing anomaly monitoring, repetitive execution, and anomaly explanation mechanisms, the system can automatically detect, repair, and explain problems when tool calls fail or task execution is abnormal, thereby improving the fault tolerance, self-recovery, and decision interpretability of the intelligent agent system. This design enables the system to maintain high stability and sustainable operation in real-world application environments, making it suitable for multi-model collaboration, cross-system task scheduling, and long-cycle intelligent decision-making scenarios.

[0123] In the embodiments of this application, the tool invocation method can be widely applied to intelligent agent systems based on large language models to achieve intelligent connection between natural language tasks and external tool operations. This method enables the intelligent agent to autonomously determine whether to invoke external resources, select appropriate tools, and automatically extract parameters when facing different types of tasks, thereby achieving an efficient and dynamic task execution process.

[0124] For example, the method can be applied to a data analytics intelligent agent system. When a user inputs "Please analyze the sales trends of the past three months," the system first obtains the task information and inputs it into a large language model for semantic analysis, generating a task planning response. The model identifies that the task involves time series data analysis and visualization output, therefore, in the strategy determination stage, it determines that external statistical analysis tools and chart drawing interfaces need to be called. Subsequently, the system extracts task parameters (such as time range, data source path, output type, etc.) through the first prompt word template, and calls the corresponding data analysis API based on the extracted parameters. Finally, the system returns a report with trend charts and explanatory text as the first task response information, realizing the automated conversion from natural language tasks to data analysis execution.

[0125] For example, the method can be applied to cross-system operational agents, such as intelligent execution systems combining Robotic Process Automation (RPA) and LLM. When a user inputs "Please export the customer list for this quarter from the Customer Relationship Management System and generate a sales forecast," the system determines through task planning that the task involves two stages: cross-system data access and model calculation. The large language model identifies two tools that need to be called in the planning response: the Customer Relationship Management data interface and the predictive analysis model. The system then extracts parameters such as "System Name = Customer Relationship Management," "Export Field = Customer Information," and "Forecast Period = Quarter" from the prompt word template, and executes the two external tool calls sequentially. Finally, the prediction results are returned to the user in the form of a structured report, realizing the fully automated execution of the task chain.

[0126] Corresponding to the above-described tool invocation method, embodiments of this application also provide a tool invocation device.

[0127] Figure 5 A schematic block diagram of a tool invocation apparatus according to an embodiment of this application is shown.

[0128] like Figure 5 As shown, the tool invocation device 500 of this embodiment includes a data acquisition module 510, a strategy determination module 520, a parameter information extraction module 530, and a tool invocation module 540.

[0129] The data acquisition module 510 can be used to acquire target task information, input the target task information into a large language model for analysis, and generate a task planning response. In one embodiment, the data acquisition module 510 can be used to perform the operation S210 described above, which will not be repeated here.

[0130] The strategy determination module 520 can be used to determine a tool invocation strategy based on the task planning response. The process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type. In one embodiment, the strategy determination module 520 can be used to execute the operation S220 described above, which will not be repeated here.

[0131] The parameter information extraction module 530 can be used to guide the large language model to extract parameter information of the target tool from the target task information when an external tool needs to be called, using a first prompt word template. In one embodiment, the parameter information extraction module 530 can be used to perform the operation S230 described above, which will not be repeated here.

[0132] The tool invocation module 540 can be used to invoke the target tool based on the parameter information to obtain the first task response information returned by the target tool. In one embodiment, the tool invocation module 540 can be used to perform the operation S240 described above, which will not be repeated here.

[0133] According to embodiments of this application, the tool invocation device 500 may further include a self-generation module. The self-generation module can be used to obtain a second prompt word template without invoking external tools; guide the large language model to generate second task response information based on the target task information and the second prompt word template; and perform accuracy verification on the second task response information; in response to a failure to pass the accuracy verification, trigger the large language model to regenerate the Nth task response information based on the second prompt word template until the accuracy verification passes, where N is a positive integer greater than 2.

[0134] According to an embodiment of this application, the tool invocation module 540 can also be used to perform integrity verification based on the parameter information; if the integrity verification passes, the corresponding target tool interface is invoked to execute the invocation of the target tool; if the integrity verification fails, missing parameters are determined, supplementary parameter information is obtained based on the missing parameters and the large language model, and the invocation of the target tool is executed based on the supplementary parameter information.

[0135] According to an embodiment of this application, the tool invocation module 540 can also be used to determine the semantic description and data type of the missing parameter, generate a supplementary request prompt word; input the supplementary request prompt word into the large language model to generate natural language follow-up information and candidate parameter values, the natural language follow-up information being used to guide the user to supplement parameters and select parameter values; and send the natural language follow-up information and the candidate parameter values ​​to the user terminal to receive supplementary parameter information from the user.

[0136] According to embodiments of this application, the tool invocation device 500 may further include an optimization module. The optimization module may be configured to determine a result optimization strategy based on the first task response information, the result optimization strategy including at least one of semantic reorganization, language polishing, and format normalization; and, based on the result optimization strategy, utilize the large language model to perform result optimization processing on the first task response information.

[0137] According to an embodiment of this application, the strategy determination module 520 can also be used to calculate a comprehensive confidence level based on the task planning response, the target tool function description, and historical tool execution information, wherein the comprehensive confidence level includes at least a weighted fusion result of semantic matching degree and historical call success rate; dynamically adjust a preset confidence level threshold based on the target task information using the large language model to obtain a target threshold; and update the tool call strategy using the large language model in response to the comprehensive confidence level being lower than the target threshold.

[0138] According to an embodiment of this application, the tool invocation device 500 may further include a monitoring module. The monitoring module may be configured to monitor for parameter transmission anomalies, tool execution anomalies, or model response anomalies in response to the invocation of the target tool; to repeatedly execute the process of obtaining the parameter information using the large language model and invoking the target tool based on the parameter information in response to detecting an anomaly; and to trigger the large language model to generate an anomaly explanation information in response to the number of repeated executions reaching a preset number.

[0139] According to embodiments of this application, any multiple modules among the data acquisition module 510, strategy determination module 520, parameter information extraction module 530, and tool invocation module 540 can be merged into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this application, at least one of the data acquisition module 510, strategy determination module 520, parameter information extraction module 530, and tool invocation module 540 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the data acquisition module 510, strategy determination module 520, parameter information extraction module 530, and tool invocation module 540 can be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.

[0140] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a tool invocation method according to an embodiment of this application.

[0141] like Figure 6 As shown, an electronic device 600 according to an embodiment of this application includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage portion 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.

[0142] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in said one or more memories.

[0143] According to embodiments of this application, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the input / output (I / O) interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.

[0144] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.

[0145] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 602 and / or RAM 603 and / or one or more memories other than ROM 602 and RAM 603 described above.

[0146] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the tool invocation method provided in the embodiments of this application.

[0147] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0148] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0149] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, it performs the functions defined in the system of this application embodiment. According to the embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0150] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0151] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0152] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.

[0153] The embodiments of this application have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of this application. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Without departing from the scope of this application, those skilled in the art can make various substitutions and modifications, all of which should fall within the scope of this application.

Claims

1. A method for invoking a tool, characterized in that, The method includes: Obtain target task information, input the target task information into a large language model for analysis, and generate a task planning response; Based on the task planning response, a tool invocation strategy is determined, wherein the process of determining the tool invocation strategy includes determining whether to invoke an external tool and determining the tool type; When external tools need to be invoked, the first prompt word template guides the large language model to extract the parameter information of the target tool from the target task information; and The target tool is invoked based on the parameter information to obtain the first task response information returned by the target tool.

2. The method according to claim 1, characterized in that, The method further includes: Obtain the second prompt word template without calling external tools; Based on the target task information and the second prompt word template, the large language model is guided to generate second task response information; and The accuracy of the second task response information is verified; if the accuracy verification fails, the large language model is triggered to regenerate the Nth task response information based on the second prompt word template until the accuracy verification passes, where N is a positive integer greater than 2.

3. The method according to claim 1, characterized in that, The step of invoking the target tool based on the parameter information includes: Integrity verification is performed based on the parameter information; If the integrity verification passes, the corresponding target tool interface is invoked to execute the target tool call; If the integrity check fails, the missing parameters are determined, supplementary parameter information is obtained based on the missing parameters and the large language model, and the target tool is called based on the supplementary parameter information.

4. The method according to claim 3, characterized in that, The process of obtaining supplementary parameter information based on the missing parameters and the large language model includes: Determine the semantic description and data type of the missing parameter, and generate supplementary request prompts; The supplementary request prompt is input into the large language model to generate natural language follow-up information and candidate parameter values. The natural language follow-up information is used to guide the user to supplement parameters and select parameter values. The natural language follow-up information and the candidate parameter values ​​are sent to the user terminal, and supplementary parameter information is received from the user.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Based on the first task response information, a result optimization strategy is determined, and the result optimization strategy includes at least one of semantic reorganization, language polishing, and format standardization. as well as Based on the aforementioned result optimization strategy, the large language model is used to optimize the response information of the first task.

6. The method according to claim 1, characterized in that, The tool invocation strategy based on the task planning response determination also includes: Based on the task planning response, target tool function description, and historical tool execution information, a comprehensive confidence score is calculated. The comprehensive confidence score includes at least a weighted fusion result of semantic matching degree and historical call success rate. Based on the target task information, the preset confidence threshold is dynamically adjusted using the large language model to obtain the target threshold; as well as In response to the overall confidence level falling below the target threshold, the tool invocation strategy is updated using the large language model.

7. The method according to claim 1, characterized in that, The method further includes: In response to the call to execute the target tool, monitor for abnormal parameter passing, abnormal tool execution, or abnormal model response; In response to the detection of an anomaly, the process of obtaining the parameter information using the large language model is repeated, and the target tool is invoked based on the parameter information. as well as In response to the preset number of repeated executions, the large language model is triggered to generate abnormal explanation information.

8. A tool calling device, characterized in that, The device includes: The data acquisition module is used to: acquire target task information, input the target task information into a large language model for analysis, and generate a task planning response; The strategy determination module is used to: determine a tool invocation strategy based on the task planning response, wherein the process of determining the tool invocation strategy includes judging whether to invoke an external tool and determining the tool type; The parameter information extraction module is used to: when an external tool needs to be invoked, guide the large language model to extract the parameter information of the target tool from the target task information using a first prompt word template; and The tool invocation module is used to: execute the invocation of the target tool based on the parameter information, so as to obtain the first task response information returned by the target tool.

9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Method for enhancing personality and task linkage capability of role large model and related products

    CN121743483A

  • Large model calling detection method and device, medium and equipment

    CN122132274A

  • Data calling method and apparatus

    CN122347125A