Intelligent agent dynamic tool generation method, equipment and medium
Through the dynamic tool generation method of intelligent agents, using the large inference model and isolated container sandbox verification mechanism, the problem of insufficient adaptability of the tool library in existing agent development is solved, the on-demand expansion and security verification of the tools are realized, and a closed loop of continuous evolution of capabilities is formed.
Patent Information
- Application Number
- CN202510818932.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-09-19
AI Technical Summary
The current development of general-purpose agents is still in the semi-automated stage, which makes it difficult to meet the rich and ever-changing needs. The existing tool library is difficult to adapt to complex and changing scenarios, and tool updates are lagging and lack security.
By reasoning with a large model to parse task information, two-stage similarity matching is performed to generate tool code, which is then verified in an isolated container sandbox to ensure security and compatibility. The generated tools are automatically added to the preset tool library.
It achieves automatic expansion of tool capabilities based on real-time needs, solves the problem of delayed tool updates, ensures the security and compatibility of new tools, and forms a closed loop of continuous evolution of capabilities.
Smart Images

Figure CN120669959A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent agents, and specifically to methods, devices, and media for generating dynamic tools for intelligent agents. Background Art
[0002] An agent is an agent that can perceive the environment and take actions to achieve specific goals. It can be software, hardware or a system with autonomy, adaptability and interaction capabilities.
[0003] Current mainstream agent development platforms generally offer a plug-and-play tool marketplace, allowing developers to directly access pre-built API plug-ins (e.g., web search, data analysis, payment interfaces, etc.). However, the overall development of general-purpose agents is still in a semi-automated stage: developers lead tool design, the platform provides extension interfaces, and large models handle logical orchestration. This semi-automated stage limits the capabilities of general-purpose agents. Even with a large number of pre-built tools, it is difficult to meet the diverse and ever-changing needs of users. Summary of the Invention
[0004] In order to solve the above problems, this application proposes a method for generating dynamic tools for intelligent agents, including:
[0005] Obtain task information input by the user, perform semantic analysis on the task information through the inference model, and obtain the tools required for the information task;
[0006] For the required tool, a two-stage similarity matching is performed with each preset tool, and when the matching result is lower than a preset threshold, dynamic tool generation is triggered;
[0007] Generate prompt words based on the semantic analysis results corresponding to the required tools, and call the universal large model to generate tool codes according to the prompt words;
[0008] The tool code is verified through the constructed isolated container sandbox, and after the verification is passed, the tool code is encapsulated into a new tool, and the new tool is used as the required tool, and the new tool is added as a preset tool.
[0009] In one example, semantic parsing of the task information is performed using a large inference model to obtain the tools required for the information task, specifically including:
[0010] Performing semantic analysis on the task information through the inference model, and splitting the task information into multiple execution steps;
[0011] For each execution step, determine the required tools corresponding to the execution step.
[0012] In one example, a two-stage similarity matching is performed on the required tool with each preset tool, specifically including:
[0013] For the required tool, similarity matching is performed between the semantic parsing result of the required tool in the current execution step and the functional description corresponding to each preset tool, and preset tools having a first similarity matching result higher than a first preset threshold are selected to form a candidate tool set;
[0014] For each preset tool in the tool set to be selected, determining the corresponding input parameter information and output parameter information;
[0015] Determining input compatibility and output compatibility with the previous preset tool and the next preset tool in the execution step, respectively, based on the input parameter information and the output parameter information;
[0016] A weighted sum is performed based on the input compatibility and the output compatibility to obtain a second similarity matching result.
[0017] In one example, generating prompt words based on the semantic parsing results corresponding to the required tools specifically includes:
[0018] Determining a preset prompt word template, wherein the prompt word template at least includes format constraints and function constraints;
[0019] The functional constraints are improved based on the semantic parsing results of the required tool in the current execution step; and the format constraints are improved based on the execution environment of the required tool and its corresponding input compatibility and output compatibility;
[0020] Generate prompt words based on the improved prompt word template.
[0021] In one example, the tool code is verified through a constructed isolated container sandbox, specifically including:
[0022] Creating an isolated container sandbox and initializing the isolated container sandbox;
[0023] Deploy the tool code to the test directory of the isolated container sandbox and run the tool code through the corresponding unit test framework;
[0024] Based on the input test data, obtain the corresponding output data;
[0025] Determine the functional test result of the tool code based on the comparison of the output data with the expected data; monitor the execution path of the tool code to determine the code coverage; and perform a security scan on the tool code to determine the vulnerability level;
[0026] A verification result of the tool code is obtained according to the functional test result, the code coverage, and the vulnerability level.
[0027] In one example, the method further includes:
[0028] Determining that the tool code verification fails and determining the type of error;
[0029] If the error type is that the function test result is abnormal, adjusting the function constraint of the prompt word;
[0030] If the error type is the code coverage or the vulnerability level, the format constraint of the prompt word is adjusted.
[0031] In one example, the method further includes:
[0032] Perform AI risk detection to detect whether the tool code contains dangerous commands; detect whether the tool code contains sensitive data transmission actions; and perform prompt word injection vector detection on the prompt words corresponding to the tool code.
[0033] In one example, the task information is used for visualization of e-commerce data; the required tools include at least an e-commerce price crawler tool and a data visualization tool.
[0034] On the other hand, the present application also proposes an intelligent agent dynamic tool generation device, comprising:
[0035] at least one processor; and,
[0036] a memory communicatively connected to the at least one processor; wherein,
[0037] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the intelligent agent dynamic tool generation method as described in any of the above examples.
[0038] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as the method for generating a dynamic tool for an intelligent agent as described in any of the above examples.
[0039] The method for generating dynamic tools for intelligent agents proposed in this application can bring the following beneficial effects:
[0040] 1. Automatically analyze task requirements and generate adaptation tools through large models, eliminating dependence on preset tool libraries and being able to cope with more complex and changing scenarios.
[0041] 2. Through a two-stage similarity matching mechanism, tool gaps are accurately identified, triggering a dynamic generation process that enables the intelligent agent to expand its capabilities based on real-time needs. This solves the problem of lagging tool updates in traditional solutions and enables on-demand tool expansion.
[0042] 3. Ensure the security of newly generated tools through isolated container sandbox verification mechanism to prevent malicious code or incorrect implementation from damaging the system, and maintain reliability while automating expansion capabilities.
[0043] 4. The newly generated tools are automatically added to the preset library, forming a complete closed loop of "demand perception-tool generation-experience accumulation", so that the intelligent body can continuously accumulate specialized tools as it is used, and achieve continuous evolution of capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0045] Figure 1 Schematic diagram of the process of generating a dynamic tool for an intelligent agent in an embodiment of the present application;
[0046] Figure 2 This is a schematic diagram of a method for generating a dynamic tool for an intelligent agent in one scenario in an embodiment of the present application;
[0047] Figure 3 This is a schematic diagram of an intelligent agent dynamic tool generation device in an embodiment of the present application. DETAILED DESCRIPTION
[0048] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0049] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.
[0050] like Figure 1 and Figure 2 As shown, the embodiment of the present application provides a method for generating a dynamic tool of an intelligent agent, including:
[0051] S101: Obtain task information input by the user, perform semantic analysis on the task information through the inference big model, and obtain the tools required for the information task.
[0052] Task information refers to the relevant tasks input by the user for the agent. The task may include text information, image information, etc. For example, it may be a data query task, an image processing task, a text generation task, etc.
[0053] The inference model can be linked to the corresponding interface locally or in the cloud to call the inference model. The inference model can be independently built or an open source multimodal language model obtained through the network.
[0054] The inference model performs semantic analysis on task information and breaks it down into multiple execution steps. For example, if a user enters a task to design a holiday poster that meets certain requirements, the inference model performs semantic analysis and breaks it down into the following steps: 1. Obtain relevant holiday images; 2. Process the holiday images; 3. Generate relevant copy; 4. Combine the image and copy to create a poster; 5. Save and output the poster; and 6. Send the poster to the user.
[0055] For each execution step, the required tools corresponding to the execution step are determined. Still taking the above-mentioned holiday poster as an example, in step 1, the required tools may be image acquisition tools, which may include keyword search tools and prompt word image generation tools, respectively used for image search and generation; in step 2, the required tools may be image processing tools, which may include background generation tools, image segmentation tools, and image synthesis tools, respectively used for background generation, image segmentation, and image synthesis of the obtained images; in step 3, the required tools may be text processing and generation tools, which may include stylized text generation tools and text rendering tools, respectively used for generating text forms of corresponding styles based on text content and rendering the text forms; in step 4, the required tools may be image synthesis and typesetting tools, which may include multi-image synthesis tools, etc., which may be used to synthesize multiple images according to specified positions, sizes, and transparency; in step 5, the required tools may be file operation tools, which may include image saving tools, used to save and output images in corresponding formats; in step 6, the required tools may be interface calling tools, which output the saved images by calling corresponding interfaces.
[0056] S102: performing a two-stage similarity matching on the required tool and each preset tool, and triggering dynamic tool generation when the matching result is lower than a preset threshold.
[0057] Two-stage similarity matching means that when similarity matching is performed between the required tool and the preset tool, matching is performed in two stages in sequence. After passing the matching requirements of the first stage, the matching requirements of the second stage are entered, and based on the matching results of the second stage, it is determined whether there is a preset tool that matches the requirements.
[0058] Specifically, for the required tool, similarity matching is performed between the semantic parsing result of the required tool in the current execution step and the functional description corresponding to each preset tool, and preset tools with a first similarity matching result higher than a first preset threshold are screened to form a set of candidate tools.
[0059] The semantic parsing results of the required tools can be obtained by inferring the corresponding execution steps of the task information through the large inference model. For example, when the required tool is an image acquisition tool, its semantic parsing result can be as "1. Obtain relevant holiday images" in the above example. Of course, it can also go further based on needs and use more specific sub-steps in the execution step as the semantic parsing result. For example, "obtain relevant holiday images through keyword search" is used as the semantic parsing result.
[0060] Some commonly used preset tools are pre-generated and stored in the tool library. When a preset tool is generated, it usually includes a functional description of the tool. The semantic parsing result is matched with the functional description for similarity. When the first similarity matching result is higher than a first preset threshold (for example, set to 0.75), the preset tool is considered to have similar functionality to the currently required tool and is selected as a candidate tool to form a candidate tool set.
[0061] For each preset tool in the selected tool set, determine its corresponding input parameter information and output parameter information. The input parameter information and output parameter information may include the data format, data size limit, and whether input is required for each tool. This information can be obtained by analyzing the corresponding function signature.
[0062] Based on the input parameter information and output parameter information, the input compatibility and output compatibility with the previous and next preset tools in the execution step are determined. If the current execution step only contains a single preset tool, the corresponding input compatibility and output compatibility can be obtained by using the output parameters and input parameters of the preset tools in the previous or next execution step, respectively. Of course, if the current execution step contains other preset tools, the corresponding previous and next preset tools can be selected from the current execution step based on the execution order of the preset tools.
[0063] Based on the input compatibility and output compatibility, a weighted sum is performed to obtain the second similarity matching result. Generally speaking, the weights of input compatibility and output compatibility can be considered the same, but for some pre-built tools, one compatibility may be more important than the other. This can be set according to needs.
[0064] If a pre-installed tool exists that meets the requirements for two-stage similarity matching, and its first similarity matching result is higher than the first preset threshold, and its second similarity matching result is higher than the second preset threshold, then the pre-installed tool can be considered to meet the requirements of the required tool and selected as the required tool. If there are multiple pre-installed tools whose second similarity matching results are higher than the second preset threshold, the pre-installed tool with the highest weighted sum of the first and second similarity matching results can be selected as the required tool.
[0065] S103: Generate prompt words based on the semantic analysis results corresponding to the required tools, and call the general large model to generate tool codes according to the prompt words.
[0066] The general large model is similar to the inference large model and can also be a multimodal large language model. Based on practical function and cost considerations, the general large model and the inference large model can be the same or different multimodal large language models.
[0067] Specifically, a pre-set prompt word template is determined, which contains at least format constraints and functional constraints. Format constraints primarily specify formal requirements such as the output structure, language, and interface specifications of the tool code generated by the large model. This ensures that the generated code can be correctly parsed, integrated, and called by the system, ensuring that the generated tool can be called by a general intelligent agent. Functional constraints, on the other hand, primarily specify substantive requirements such as the specific tasks that the generated tool code must complete, the core logic to be implemented, the sub-tools and services to be called, and the business rules or restrictions to be followed. This ensures that the generated code truly addresses user needs.
[0068] The functional constraints are improved through the semantic parsing results of the required tool in the current execution step; and the format constraints are improved according to the execution environment of the required tool and its corresponding input compatibility and output compatibility.
[0069] In large model prompts, the positions to be filled in are represented by variable symbols. When generating prompts, the corresponding content is added to the variable symbols in the corresponding positions to complete the prompt template. In combination with a template engine (such as a Java or Python framework), prompts are generated based on the completed prompt template.
[0070] Based on the generated prompt words, the general large model generation tool code is called, and the hybrid generation method of the template engine and the large model is integrated. This can effectively solve the problems of chaotic code generation structure and irregular input and output. At the same time, the API description file of the tool code is output and provided to the subsequent steps for functional verification.
[0071] S104: The tool code is verified through the constructed isolated container sandbox, and after the verification is passed, the tool code is encapsulated into a new tool, and the new tool is used as the required tool, and the new tool is added as a preset tool.
[0072] After the tool code is generated, it needs to be tested. Only after the test passes can it be packaged into a corresponding tool for use.
[0073] Specifically, an isolated container sandbox is created and initialized. For example, virtualization technology (such as Docker, gVisor, Kata Containers, or a dedicated sandbox API) is used to dynamically create an isolated container as the isolated container sandbox. Initialization can include pre-installing certain runtime environments within the sandbox container, such as the Python interpreter, JVM, Node.js, etc., which are determined based on the tool code language. Basic libraries and external libraries that the tool code explicitly declares as dependent can also be pre-installed. Resource restrictions can also be imposed, including CPU, memory, disk space, network access permissions, and execution time limits.
[0074] Deploy the tool code to the test directory of the isolated container sandbox and run it using the corresponding unit testing framework. Use the tool code as a test case to test it. Within the sandbox, execute the test script using the corresponding unit testing framework (for example, pytest or unittest for Python, or JUnit for Java).
[0075] Based on the input test data, the corresponding output data is obtained; based on the comparison of the output data with the expected data, the functional test results of the tool code are determined. The test data and expected data can be pre-generated based on the function of the code tool through a general large model.
[0076] Monitor the execution paths of the instrumented code to determine code coverage. Code coverage quantifies the proportion of instrumented code that was executed during testing.
[0077] Perform a security scan on the tool code to determine vulnerability levels. Run OWASP security scanning tools within the sandbox or on the code files within the sandbox, such as OWASP ZAP passive scanning or static application security testing (SAST) tools for the corresponding language version.
[0078] The tool code verification results are obtained based on the functional test results, code coverage, and vulnerability level. Generally speaking, the tool code passes the test when the output data in the functional test results is 100% consistent with the expected data, the code coverage is higher than 80%, and the vulnerability level is lower than low risk.
[0079] Whenever the isolated container sandbox is finished using it, it needs to be destroyed immediately.
[0080] In addition, if it is determined that the tool code verification has failed, you can return to the general large model to modify the tool code and retest.
[0081] At this point, the error type is determined. There are three error types for the three tests mentioned above.
[0082] If the error type is abnormal function test results, it is considered that the description of the function may be inaccurate. In this case, the functional constraints of the prompt word are adjusted, for example, a corresponding description is newly added.
[0083] If the error type is code coverage or vulnerability level, it is considered that the template engine content needs to be optimized. At this time, the format constraints of the prompt words are adjusted, for example, modifying the function signature specification and dependency declaration format.
[0084] Because the tool code is generated by artificial intelligence (AI), traditional detection solutions, such as OWASP scanning, only cover known vulnerabilities and often fail to detect the unique risks of AI-generated code.
[0085] Based on this, AI risk detection can also be performed to detect whether the tool code contains dangerous commands; for example, the rm-rf command, which is used to delete files and directories in the Linux system, is a dangerous command.
[0086] Detect whether the tool code contains sensitive data transmission actions; used to check whether there is a risk of the code sending sensitive data to external servers.
[0087] Prompt injection vector detection is performed on the prompt words corresponding to the generated tool code. Prompt injection is an attack method against large language model applications. Attackers construct special inputs to bypass the application's expected logic and force the large model to perform unauthorized operations. Prompt injection vector detection can detect whether prompt injection has occurred. For example, it can check whether the prompt words contain words in a preset blacklist and monitor the large model's behavior for abnormalities (such as returning SQL commands or system operations).
[0088] 1. Automatically analyze task requirements and generate adaptation tools through large models, eliminating dependence on preset tool libraries and being able to cope with more complex and changing scenarios.
[0089] 2. Through a two-stage similarity matching mechanism, tool gaps are accurately identified, triggering a dynamic generation process that enables the intelligent agent to expand its capabilities based on real-time needs. This solves the problem of lagging tool updates in traditional solutions and enables on-demand tool expansion.
[0090] 3. Ensure the security of newly generated tools through isolated container sandbox verification mechanism to prevent malicious code or incorrect implementation from damaging the system, and maintain reliability while automating expansion capabilities.
[0091] 4. The newly generated tools are automatically added to the preset library, forming a complete closed loop of "demand perception-tool generation-experience accumulation", so that the intelligent body can continuously accumulate specialized tools as it is used, and achieve continuous evolution of capabilities.
[0092] In one embodiment, the example of “generating an e-commerce data crawler tool” is used for explanation.
[0093] When the user inputs the demand, the user instruction is "obtain the price fluctuation data of a certain brand and model of mobile phone on the e-commerce platform in the past three months and generate a visual report."
[0094] Analyze user needs and break down tasks using a large inference model. This requires planning for two steps: product data acquisition and report generation. Furthermore, identify the need for an "e-commerce price crawler" and a "data visualization tool."
[0095] Dynamic tool detection is performed. Based on the tool usage identified by the inference model, a search and match is performed in the preset tool library. A match exists for the data visualization tool (similarity 0.95>0.75), but no match exists for the e-commerce price crawler tool (similarity 0.62<0.75), triggering code generation.
[0096] To trigger tool code generation, specify the requirement as an e-commerce crawler tool. Use a Selenium-based Java crawler framework template engine and create a prompt: "Use the Selenium-based Java crawler framework to write an e-commerce crawler tool that retrieves price fluctuation data for a certain brand and model of mobile phones from an e-commerce platform over the past three months, and provide API documentation that complies with the OpenAPI 3.0 plan." Enter the prompt into the general model, obtain the tool code output by the model, and specify the RESTful interface as interface A. Interface A is an example description and does not represent the actual interface content.
[0097] Perform sandbox deployment verification, compile and package the generated code, and deploy it to a virtual isolated environment using Docker. Generate test cases based on the RESTful interface, including checks to see if the product name is the aforementioned brand and model, and whether the date is within the past three months. Vulnerability scanning is also performed to ensure the security and quality of the tool code.
[0098] Execute tool calls and outputs. After passing test verification, add the e-commerce price crawler tool to the preset tool library, continue user task processing, call the tool to crawl data information, and submit the output information to the second step of visual report generation, finally completing all user tasks.
[0099] like Figure 3 As shown, the embodiment of the present application further provides an intelligent agent dynamic tool generation device, including:
[0100] at least one processor; and,
[0101] a memory communicatively connected to the at least one processor; wherein,
[0102] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the intelligent agent dynamic tool generation method as described in any of the above embodiments.
[0103] An embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as the method for generating a dynamic tool for an intelligent agent as described in any of the above embodiments.
[0104] The various embodiments in this application are described in a progressive manner. Similar portions between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device and medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, refer to the descriptions of the method embodiments.
[0105] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects to their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0106] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0107] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0108] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0109] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0110] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0111] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0112] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0114] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
Claims
1. A method for generating a dynamic tool for an intelligent agent, characterized in that: include: Obtain task information input by the user, perform semantic analysis on the task information through the inference model, and obtain the tools required for the information task; For the required tool, a two-stage similarity matching is performed with each preset tool, and when the matching result is lower than a preset threshold, dynamic tool generation is triggered; Generate prompt words based on the semantic analysis results corresponding to the required tools, and call the universal large model to generate tool codes according to the prompt words; The tool code is verified through the constructed isolated container sandbox, and after the verification is passed, the tool code is encapsulated into a new tool, and the new tool is used as the required tool, and the new tool is added as a preset tool.
2. The method according to claim 1, characterized in that The task information is semantically parsed by reasoning with a large model to obtain the tools required for the information task, specifically including: Performing semantic analysis on the task information through the inference model, and splitting the task information into multiple execution steps; For each execution step, determine the required tools corresponding to the execution step.
3. The method according to claim 2, characterized in that For the required tools, a two-stage similarity matching is performed with each pre-installed tool, specifically including: For the required tool, similarity matching is performed between the semantic parsing result of the required tool in the current execution step and the functional description corresponding to each preset tool, and preset tools having a first similarity matching result higher than a first preset threshold are selected to form a candidate tool set; For each preset tool in the tool set to be selected, determining the corresponding input parameter information and output parameter information; Determining input compatibility and output compatibility with the previous preset tool and the next preset tool in the execution step, respectively, based on the input parameter information and the output parameter information; A weighted sum is performed based on the input compatibility and the output compatibility to obtain a second similarity matching result.
4. The method according to claim 3, characterized in that Generate prompt words based on the semantic analysis results corresponding to the required tools, specifically including: Determining a preset prompt word template, wherein the prompt word template at least includes format constraints and function constraints; The functional constraints are improved based on the semantic parsing results of the required tool in the current execution step; and the format constraints are improved based on the execution environment of the required tool and its corresponding input compatibility and output compatibility; Generate prompt words based on the improved prompt word template.
5. The method according to claim 1, wherein Verify the tool code through the constructed isolated container sandbox, specifically including: Creating an isolated container sandbox and initializing the isolated container sandbox; Deploy the tool code to the test directory of the isolated container sandbox and run the tool code through the corresponding unit test framework; Based on the input test data, obtain the corresponding output data; Determine the functional test result of the tool code based on the comparison of the output data with the expected data; monitor the execution path of the tool code to determine the code coverage; and perform a security scan on the tool code to determine the vulnerability level; A verification result of the tool code is obtained according to the functional test result, the code coverage, and the vulnerability level.
6. The method according to claim 5, characterized in that The method further comprises: Determining that the tool code verification fails and determining the type of error; If the error type is that the function test result is abnormal, adjusting the function constraint of the prompt word; If the error type is the code coverage or the vulnerability level, the format constraint of the prompt word is adjusted.
7. The method according to claim 5, characterized in that The method further comprises: Perform AI risk detection to detect whether the tool code contains dangerous commands; detect whether the tool code contains sensitive data transmission actions; and perform prompt word injection vector detection on the prompt words corresponding to the tool code.
8. The method according to claim 1, characterized in that The task information is used for visual display of e-commerce data; the required tools include at least an e-commerce price crawler tool and a data visualization tool.
9. An intelligent agent dynamic tool generation device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the intelligent agent dynamic tool generation method according to any one of claims 1 to 8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured as the intelligent agent dynamic tool generation method according to any one of claims 1 to 8.
Citation Information
Cited By
Data crawling method and device, electronic equipment and storage medium
CN121479039A