Agent-based code generation method and device, electronic equipment and storage medium

CN122672776APending Publication Date: 2026-09-01BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611105609.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-09-01

AI Technical Summary

Technical Problem

[0003]然而,在基于多智能体框架的代码生成实践中,如果某一智能体的任务处理结果存在错误,该错误结果可能在多个智能体之间逐级传递,进而引发错误逐级放大的问题,影响代码生成质量

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122672776A_ABST
    Figure CN122672776A_ABST
Patent Text Reader

Abstract

This disclosure provides an agent-based code generation method, relating to the field of computer technology, and particularly to the field of artificial intelligence technology. The specific implementation scheme is as follows: In response to receiving a code generation task, the code generation task is split into a sequence of subtasks with chained dependencies; for any adjacent subtask in the subtask sequence, a first agent matching the preceding subtask in the adjacent subtask sequence is invoked to execute the preceding subtask, obtaining the execution result of the preceding subtask; the execution result of the preceding subtask is validated, obtaining a validation result; if the validation result indicates that the execution result of the preceding subtask is valid, a second agent matching the following subtask in the adjacent subtask sequence is invoked to execute the following subtask; in response to the valid execution result of the last subtask in the subtask sequence, a code generation result is obtained. This disclosure also provides a code generation apparatus, electronic device, storage medium, and program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more particularly to the field of artificial intelligence technology. More specifically, this disclosure provides a method, apparatus, electronic device, and storage medium for generating code based on intelligent agents. Background Technology

[0002] With the rapid development of artificial intelligence technology, intelligent agents have made significant progress in fields such as natural language understanding and code generation. By constructing a multi-agent framework, it is possible to utilize multiple intelligent agents to collaboratively process complex tasks.

[0003] However, in code generation practices based on a multi-agent framework, if the task processing result of a certain agent is incorrect, the incorrect result may be propagated among multiple agents, leading to the problem of error amplification at each level and affecting the quality of code generation. Summary of the Invention

[0004] This disclosure provides a method, apparatus, device, and storage medium for generating code based on intelligent agents.

[0005] According to one aspect of this disclosure, a code generation method is provided, comprising: in response to receiving a code generation task, splitting the code generation task into a sequence of subtasks with chained dependencies; for any adjacent subtask in the subtask sequence, invoking a first agent matched with the preceding subtask in the adjacent subtask sequence to execute the preceding subtask, and obtaining the execution result of the preceding subtask; validating the execution result of the preceding subtask, and obtaining a validation result; if the validation result indicates that the execution result of the preceding subtask is valid, invoking a second agent matched with the following subtask in the adjacent subtask sequence to execute the following subtask; and obtaining a code generation result in response to the valid execution result of the last subtask in the subtask sequence.

[0006] According to another aspect of this disclosure, an agent-based code generation apparatus is provided, comprising: a splitting module, configured to split the code generation task into a sequence of subtasks with chained dependencies in response to receiving a code generation task; a first execution module, configured to, for any adjacent subtask in the subtask sequence, invoke a first agent matching the preceding subtask in the adjacent subtask sequence to execute the preceding subtask, thereby obtaining the execution result of the preceding subtask; a verification module, configured to verify the validity of the execution result of the preceding subtask, thereby obtaining a verification result; a second execution module, configured to, if the verification result indicates that the execution result of the preceding subtask is valid, invoke a second agent matching the following subtask in the adjacent subtask sequence to execute the following subtask; and an output module, configured to, in response to the valid execution result of the last subtask in the subtask sequence, obtain a code generation result.

[0007] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a method provided according to this disclosure.

[0008] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing a computer to perform the methods provided according to this disclosure.

[0009] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method provided according to this disclosure.

[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0011] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0012] Figure 1 This is an exemplary system architecture diagram of a code generation method and apparatus applicable according to an embodiment of the present disclosure;

[0013] Figure 2 This is a flowchart of an agent-based code generation method according to an embodiment of the present disclosure;

[0014] Figure 3 This is a schematic diagram of an agent-based code generation process according to an embodiment of the present disclosure;

[0015] Figure 4 This is a schematic diagram of an agent invoking a knowledge instance in a code generation method according to an embodiment of the present disclosure;

[0016] Figure 5 This is a block diagram of an agent-based code generation apparatus according to an embodiment of the present disclosure;

[0017] Figure 6 This is a block diagram of an electronic device to which a code generation method can be applied, according to an embodiment of the present disclosure. Detailed Implementation

[0018] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0019] With the rapid development of artificial intelligence technology, intelligent agents have made significant progress in fields such as natural language understanding and code generation. By constructing a multi-agent framework, it is possible to utilize multiple intelligent agents to collaboratively process complex tasks. However, in the practice of code generation based on a multi-agent framework, if the task processing result of one intelligent agent is incorrect, the erroneous result may be propagated among multiple intelligent agents, leading to the problem of error amplification at each level and affecting the quality of code generation.

[0020] Figure 1 A schematic diagram of an example environment 100 to which the methods according to embodiments of the present disclosure can be applied is shown. In this example environment 100, an application 125 is installed on a terminal device 110. A user 140 can interact with the application 125 via the terminal device 110 and / or an attached device of the terminal device 110.

[0021] In some embodiments, application 125 can be downloaded and installed on terminal device 110. In some embodiments, application 125 can also be accessed in other ways, such as through a web page. Figure 1 In example environment 100, in response to application 125 being launched, terminal device 110 can display the interface 150 of application 125.

[0022] In some embodiments, terminal device 110 can communicate with server 130 to provide services to application 125. Terminal device 110 can be any type of mobile terminal, fixed terminal, or portable terminal, including mobile phones, desktop computers, laptop computers, notebook computers, netbook computers, tablet computers, media computers, multimedia tablets, personal communication system (PCS) devices, personal navigation devices, personal digital assistants (PDAs), audio / video players, digital cameras / camcorders, television receivers, radio receivers, e-book devices, gaming devices, or any combination thereof, including accessories and peripherals of these devices or any combination thereof. In some embodiments, terminal device 110 can also support any type of user-facing interface. Application 125 can be various types of computing systems / servers capable of providing computing power, including but not limited to mainframes, edge computing nodes, and computing devices in cloud environments.

[0023] In some embodiments, application 125 can provide interaction capabilities with an intelligent agent. Application 125 may include an application specifically designed to provide services to an intelligent agent, or an application integrated with an intelligent agent. Although Figure 1 The image shows a single application, but in reality, multiple applications can be installed on the terminal device 110.

[0024] In embodiments of this disclosure, multiple agents 160 can be deployed locally on terminal device 110 or remotely. In the case of remote deployment, terminal device 110 can directly invoke the agents or invoke them via server 130. Exemplarily, agent 160 may have intelligent dialogue and task processing capabilities. Terminal device 110 provides an interface 150 that can present interactions with agent 160. In interface 150, user 140 can initiate task requests to agent 160 by inputting natural language (e.g., text input or voice input). Optionally, user 140 can upload online or offline file dialogues to instruct agent 160 to assist in completing various tasks.

[0025] In embodiments of this disclosure, during interaction with user 140, agent 160 can respond to user 140's requests and handle tasks instructed by the user. In some embodiments, during task processing, agent 160 can invoke one or more tools 165 to assist in task execution and the provision of task results as needed. These tools 165 can be of any type, such as text generation tools, file reading tools, information search tools, online or offline databases, image processing tools, chart generation tools, web page creation tools, etc.

[0026] In some embodiments, environment 100 may further include a management node for multiple agents 160, which can interact with the agents 160. In some examples, the management node may, in response to a task request from user 140, determine the task requirements corresponding to the task request. The management node may then, based on the task requirements, assign the task request to the agent 160 that matches the task requirements, requesting that agent 160 to perform the task. In other examples, the management node may also determine an execution plan for the task based on the task requirements. The execution plan may indicate one or more subtasks required to complete the task. The management node may assign these one or more subtasks to one or more agents 160, which will then execute their respective subtasks. Regarding the management node, in some examples, the management node may be implemented by one of the multiple agents 160. In other examples, the management node may be implemented by a machine learning model, such as a language model.

[0027] In some embodiments, agent 160 may be constructed based on one or more machine learning models. In some embodiments, the machine learning model on which agent 160 is based may include at least a language model, such as a large language model. In some embodiments, the machine learning model on which agent 160 is based may include a multimodal model capable of handling multiple modal inputs, such as text input, visual input (e.g., images, videos), audio input, etc. These machine learning models may include content-generating models capable of generating corresponding outputs based on model inputs. In some embodiments, the machine learning model may receive text-modal model inputs (e.g., natural language and / or machine language) and / or non-text-modal model inputs (e.g., images, speech, videos, etc.), and may obtain corresponding model outputs based on model inputs and prompts, thereby completing the task execution.

[0028] It should be noted that the code generation method provided in this disclosure can generally be executed by terminal device 110, server 130, or intelligent agent 160. Correspondingly, the code generation apparatus provided in this disclosure can generally be located in terminal device 110, server 130, or intelligent agent 160. The code generation method provided in this disclosure can also be executed by a server or server cluster that is different from terminal device 110, server 130, or intelligent agent 160 but capable of communicating with them. Correspondingly, the code generation apparatus provided in this disclosure can also be located in a server or server cluster that is different from terminal device 110, server 130, or intelligent agent 160 but capable of communicating with them.

[0029] The code generation method provided in this disclosure can be applied to scenarios that require automated code generation, such as software development, database operation and maintenance, script generation, and system testing, and is especially suitable for software development scenarios based on intelligent agents.

[0030] The code generation method provided in this disclosure breaks down the code generation task into multiple subtasks with chained dependencies during the code generation process. For any adjacent subtasks, the output of the preceding subtask is validated. If the output of the preceding subtask is valid, the subsequent subtask is executed. This method effectively avoids the propagation of erroneous results through the code generation process, thus preventing errors from amplifying at each level and improving the accuracy of the generated code.

[0031] Figure 2 This is a flowchart of an agent-based code generation method according to an embodiment of the present disclosure.

[0032] like Figure 2 As shown, the method 200 may include operations S210 to S250.

[0033] In operation S210, in response to receiving a code generation task, the code generation task is split into a sequence of subtasks with chained dependencies.

[0034] In operation S220, for any adjacent subtask in the subtask sequence, the first agent that matches the preceding subtask in the adjacent subtask is called to execute the preceding subtask, and the execution result of the preceding subtask is obtained.

[0035] In operation S230, the execution result of the preceding subtask is validated to obtain the validation result.

[0036] In operation S240, if the verification result indicates that the execution result of the preceding subtask is valid, the second agent that matches the subsequent subtask in the adjacent subtask is invoked to execute the subsequent subtask.

[0037] In operation S250, in response to the valid execution result of the last subtask in the subtask sequence, the code generation result is obtained.

[0038] Next, the various operations of this embodiment will be described in detail by way of example.

[0039] In operation S210, in response to receiving a code generation task, the code generation task is split into a sequence of subtasks with chained dependencies.

[0040] For example, a code generation task can be broken down into a sequence of subtasks with chained dependencies. A sequence of subtasks may include multiple subtasks, and the chained dependencies indicate that any adjacent subtasks in the sequence are executed sequentially.

[0041] In operation S220, for any adjacent subtask in the subtask sequence, the first agent that matches the preceding subtask in the adjacent subtask is called to execute the preceding subtask, and the execution result of the preceding subtask is obtained.

[0042] For example, the subtask executed earlier in the order of any two adjacent subtasks can be designated as the preceding subtask, and the subtask executed later in the order of execution as the following subtask. The first agent is configured to execute the preceding subtask according to its execution requirements and output the corresponding execution result. The execution result may include the execution status of the preceding subtask and the output data generated by the preceding subtask.

[0043] For example, an intelligent agent can be a proxy capable of perceiving its environment and taking actions to achieve a specific goal. An intelligent agent can make judgments and decisions based on its learned knowledge and algorithms, and then execute actions to influence the environment or achieve predetermined goals.

[0044] For example, in the code generation process, the intelligent agent used to implement code generation may include a requirements analysis agent, a solution design agent, a code design agent, and a functional acceptance agent. The requirements analysis agent can receive code generation requirements and convert them into developable requirements analysis results, which can be text data stored in a lightweight markup language format. The solution design agent can generate specific code generation solutions based on the requirements text. The code design agent can generate executable code text according to the code generation solution. The functional acceptance agent verifies whether the generated code text is usable and meets the code generation requirements.

[0045] In operation S230, the execution result of the preceding subtask is validated to obtain the validation result.

[0046] For example, validating the execution result of a preceding subtask may include validating the output data generated by the preceding subtask, such as determining whether the output data generated by the preceding subtask is complete, whether the output data generated by the preceding subtask is reasonable, and whether the output data generated by the preceding subtask is usable.

[0047] In operation S240, if the verification result indicates that the execution result of the preceding subtask is valid, the second agent that matches the subsequent subtask in the adjacent subtask is invoked to execute the subsequent subtask.

[0048] For example, if it is determined that the output data generated by the preceding subtask is complete, reasonable and usable, the second agent corresponding to the subsequent subtask in the execution order is called to execute the subsequent subtask, thereby avoiding the error generated during the execution of the preceding subtask from affecting the execution of the subsequent subtask and avoiding the step-by-step propagation of error in the subtask sequence.

[0049] In operation S250, in response to the valid execution result of the last subtask in the subtask sequence, the code generation result is obtained.

[0050] For example, the agents matching each subtask in the subtask sequence are called sequentially to execute the corresponding subtasks. If the execution result of the last subtask is valid, it indicates that each subtask in the subtask sequence has been executed correctly.

[0051] The code generation method provided in this disclosure splits the code generation task into multiple subtasks with chained dependencies during the code generation process. For any adjacent subtasks among the multiple subtasks, the validity of the output result of the preceding subtask is verified. If the output result of the preceding subtask is valid, the subsequent subtask is executed.

[0052] This method verifies the validity of the output results of multiple subtasks, which can promptly detect errors generated during the execution of subtasks. This effectively prevents erroneous results from being propagated step by step in the code generation process, thus avoiding the amplification of errors and improving the accuracy of the code generation results.

[0053] Figure 3 This is a schematic diagram of an agent-based code generation process according to an embodiment of the present disclosure.

[0054] like Figure 3 As shown, in the code generation process 300, the subtask sequence includes a requirements analysis task 301, a solution design task 302, a code design task 303, and a functional acceptance task 304. One or more of the tasks 301, 302, 303, and 304 can be executed by an intelligent agent. For example, these tasks can be executed by different intelligent agents, or at least two tasks can be executed by the same intelligent agent. For instance, the tasks 301, 302, 303, and 304 can be executed by a requirements analysis intelligent agent, a solution design intelligent agent, a code design intelligent agent, and a functional acceptance intelligent agent, respectively.

[0055] As an optional approach, the execution results of the requirements analysis task 301, the solution design task 302, the code design task 303, and the functional acceptance task 304 can be validated by the verification agent 310, and the validation results of the execution results of each task can be obtained respectively.

[0056] Next, the process of validating the execution results of the requirement analysis task 301, the solution design task 302, the code design task 303, and the functional acceptance task 304 by the verification agent 310 will be explained in an illustrative manner.

[0057] As an optional approach, if the preceding subtask is a requirements analysis task, the execution result of the requirements analysis task includes the requirements analysis results; the validity of the execution result of the preceding subtask is verified to obtain the verification result, including: performing at least one of the following verifications on the requirements analysis results to obtain the verification result: verifying the completeness, clarity, feasibility, and acceptability of the requirements analysis results; verifying whether the requirements analysis results include complete state routing description data; verifying whether the requirements analysis results meet the preset traceability compliance requirements.

[0058] For example, the requirements analysis results may include text data stored in a lightweight markup language (Markdown) format. The requirements analysis results may include multiple requirement points, which may be derived from breaking down code generation requirements expressed in natural language.

[0059] For example, performing a completeness check on the requirements analysis results can include verifying whether the requirements analysis results include all requirement points in the code generation requirements. For instance, it could involve verifying whether the requirements analysis results include all functionalities, boundary conditions, and exception handling methods in the code generation requirements.

[0060] For example, verifying the clarity of the requirements analysis results can include checking whether the descriptions of each requirement point in the requirements analysis results are accurate and unambiguous, and whether there are any logical contradictions.

[0061] For example, performing a feasibility check on the requirements analysis results can include checking whether each requirement is feasible, such as whether each requirement is technically feasible or feasible with existing hardware or software resources.

[0062] For example, the acceptance verification of the requirements analysis results can include verifying whether each requirement has clear and quantifiable acceptance criteria and whether an acceptance plan can be designed accordingly.

[0063] For example, state routing description data can represent the entire rule flow of the system transitioning from the current state to the target state and synchronously executing associated response actions after receiving a specified trigger event. Verification of the requirements analysis results includes verifying the completeness of the state routing description data throughout the entire execution chain, and verifying whether the state routing logic is complete and clear.

[0064] For example, verifying whether the results of the requirements analysis meet the preset traceability compliance requirements can include verifying whether the processes of data generation, flow, storage, and destruction are recorded in the requirements. For instance, if critical data is modified, verify whether the modification is recorded, and whether the data before and after the modification is recorded.

[0065] The embodiments disclosed herein, by verifying the requirements analysis results and confirming the requirements before solution design, can avoid code generation errors caused by misunderstandings and code function omissions caused by omissions of requirements, thus ensuring code generation quality and improving the interpretability of the code generation process.

[0066] As an optional approach, if the preceding subtask is a solution design task, the execution result of the solution design task includes the solution design result; the validity of the execution result of the preceding subtask is validated to obtain the validation result, including: performing at least one of the following validations on the solution design result to obtain the validation result: validation of missing requirements, requirement deviation, and over-design of the solution design result; validation of whether the key steps in the solution design result can guide the subsequent code design task, wherein the key steps describe the logical path from the starting requirements to the deliverable result; and validation of whether the solution design result and the input visual diagram of the code generation task meet the content consistency requirement.

[0067] For example, the solution design result may include a code design scheme obtained based on the input requirements. The code design scheme may be text data stored in a lightweight markup language format. The code design scheme may include the software and / or hardware modules required to generate the code, the task allocation and workload of the software and / or hardware modules, and the logical path (key steps) from the initial requirements to the deliverable result.

[0068] For example, checking for missing requirements in the solution design results can include verifying whether the code generation solution includes the input requirements, in order to avoid missing requirements.

[0069] For example, verifying the requirement deviation of the solution design result can include verifying whether there is a deviation between the code-generated solution and the input requirement points.

[0070] For example, over-design verification of the solution design results can include verifying whether there are unnecessary designs in the code generation solution. Unnecessary designs can be those that exceed the scope of the requirements.

[0071] For example, key steps describe the logical path from initial requirements to deliverable results. Initial requirements correspond to the input requirements; deliverable results are the runnable code data. Verifying whether the key steps in the solution design result can guide subsequent code design tasks can include verifying whether the key steps are decomposed to an appropriate granularity, such as whether each step in the logical path explicitly performs a task to ensure that each step directly corresponds to a code block or an interface. Verifying whether the key steps in the solution design result can guide subsequent code design tasks can also include verifying whether the input-output logic of each step corresponds, such as whether the output of the previous step can be directly used as the input of the next step.

[0072] For example, when the requirements include user interface requirements, the input code generation requirements may include a visual diagram, i.e., a user interface represented in image form. Verifying whether the solution design result and the input visual diagram of the code generation task meet the content consistency requirement may include verifying whether the page elements in the solution design result are consistent with the elements in the visual diagram. Specifically, this may include whether the number of page elements is consistent with the number of elements in the visual diagram, whether the interaction logic corresponding to the page elements is consistent with the interaction logic corresponding to the elements in the visual diagram, and whether the display state of the page elements is consistent with the display state of the elements in the visual diagram. The display state may include parameters such as the element's size, position, and color.

[0073] The embodiments disclosed herein, by verifying the design results and verifying the logical steps of code generation before code design, can avoid problems such as the generated code not meeting the requirements or being unexecutable due to design errors, thus ensuring the quality of code generation and improving the interpretability of the code generation process.

[0074] As an optional approach, if the preceding subtask is a code design task, the execution result of the code design task includes the code design result; the execution result of the preceding subtask is validated to obtain the validation result, including at least one of the following validations: requirement consistency validation, code quality validation, code security validation, completeness validation of exception handling logic, log observability validation, test coverage validation, and visual reproducibility validation.

[0075] For example, during the execution of code design tasks, existing code should be reused as much as possible to ensure code rationality.

[0076] For example, the code design result may include the generated code. Verifying the consistency of the code design result with requirements may include checking whether the execution logic of the generated code is consistent with the requirements, and checking whether the generated code contains any missing requirements or added functionality not included in the requirements.

[0077] For example, code quality verification of the code design results can include verifying whether the code has high readability, high cohesion, and low coupling. Readability refers to whether the code structure is clear, whether the names of variables and functions are explicit, and whether the structure is concise; cohesion refers to the degree of connection between elements within a code module; and coupling refers to the dependencies between code modules.

[0078] For example, performing code security verification on the code design results can include verifying whether there are known high-risk vulnerabilities in the code, so as to reduce security risks during code execution.

[0079] For example, performing a completeness check on the exception handling logic of the code design result can include checking whether the code has the ability to handle abnormal situations during runtime. For instance, in the event of network timeout, data error, or the presence of illegal parameters, the check can verify whether the code can execute the corresponding exception handling strategy.

[0080] For example, logging observability verification of code design results can include verifying whether the code can accurately generate a structured log containing context when it is running, performing actions, or encountering exceptions.

[0081] For example, verifying the test coverage of the code design results can include verifying whether the test cases can adequately cover the code during the process of testing the code with test cases.

[0082] For example, when the requirements include user interface requirements, visual fidelity verification of the code design results can include verifying whether the front-end page generated by the executed code is consistent with the input visual image. For example, it can verify whether the layout, font size, font spacing, color and interaction logic are consistent.

[0083] The embodiments of this disclosure, by performing one or more methods of verification on the code design task, can ensure the quality of the generated code and avoid code errors that prevent the required functions from being implemented. Verifying the code design results before verifying the code functionality avoids the problem of difficulty in determining the cause of failure after verification failure when only the code functionality is verified, thus improving the interpretability of the code generation process.

[0084] As an optional approach, if the preceding subtask is a functional acceptance task, the execution result of the functional acceptance task includes the functional acceptance result; the execution result of the preceding subtask is validated to obtain the validation result, including at least one of the following validations: functional availability validation, boundary scenario validation, error path validation, and visual fidelity validation, wherein the boundary scenario includes special running scenarios triggered when the scenario triggering conditions are in the critical threshold range.

[0085] For example, the functional acceptance results include the execution results of the functional acceptance tasks. Performing functional usability verification on the functional acceptance results can include verifying whether the code functionality meets the requirements, and can also include verifying whether the entire process of code execution from start to finish can be executed smoothly, and whether the response speed during code execution meets the requirements.

[0086] For example, boundary scenarios include special operating scenarios triggered when the scenario triggering conditions are within a critical threshold range, such as scenarios where the input data is null or located at the data boundary, or scenarios where repeated instructions are received within a preset time. Boundary scenario verification of functional acceptance results can include verifying the stability and accuracy of code execution under special operating scenarios.

[0087] For example, error path verification of functional acceptance results can include verifying whether the code can run correctly in the event of abnormal input or execution errors. For instance, if the code runs for more than a preset time threshold, it can be verified whether the code can exit the running state and generate an error message.

[0088] For example, visual fidelity verification of functional acceptance results can include verifying whether the front-end page generated by the executed code corresponds to the visual image. This includes verifying whether the text and elements on the page are consistent with the visual image, whether the layout of the text and elements on the page is consistent with the visual image, and whether the interactive effects of the page are consistent with the visual image.

[0089] The embodiments disclosed herein verify whether the code functionality is truly usable from the perspective of final delivery by verifying the functional acceptance results, thus ensuring the quality of code generation.

[0090] Figure 4 This is a schematic diagram illustrating the interaction between an agent and a knowledge base in a code generation method according to an embodiment of this disclosure.

[0091] like Figure 4As shown, during the code generation process, agent 410 can read data stored in the knowledge base 420 or write data to the knowledge base through interaction. For example, the agent can read index identification information stored in the knowledge base and call the corresponding knowledge instance based on the index identification information. The knowledge instance may include domain rules for performing a specific task, and may also include historical events generated by performing a specific task.

[0092] As an optional approach, the code generation method may further include: determining candidate knowledge instances in the code generation process based on the execution process data of each subtask, wherein the candidate knowledge instances include structured knowledge units with cross-task adaptability attributes; generating index identification information based on the candidate knowledge instances, wherein the index identification information indicates at least one of the candidate knowledge instances' applicable scenario tags, invocation constraints, and version information; and writing the index identification information of the candidate knowledge instances into a knowledge base so that in subsequent code generation tasks, the agent can invoke the corresponding knowledge instances based on the index identification messages.

[0093] In embodiments of this disclosure, candidate knowledge instances are constructed during the code generation process, enabling the agent to acquire the experience required to perform the corresponding task by retrieving the candidate knowledge instances, thereby improving the accuracy and efficiency of the agent in performing the task.

[0094] For example, each subtask can be executed by a corresponding intelligent agent. In the process of executing a specific task, the intelligent agent obtains the rules that need to be followed to execute the task by invoking the required knowledge instances.

[0095] For example, a cross-task adaptation attribute can represent a knowledge instance that includes general knowledge and / or rules, and an agent can retrieve relevant knowledge and / or rules from the knowledge instance and apply them to task execution.

[0096] For example, knowledge instances can be invoked through index identifiers in the knowledge base. An agent can invoke the corresponding knowledge instance through the index identifier information in the knowledge base. The index identifier information indicates at least one of the applicable scenario label, invocation constraints, and version information of the candidate knowledge instance, which facilitates the agent in invoking the corresponding knowledge instance based on the actual scenario, constraints, and / or version information of the subtask being executed.

[0097] As an optional approach, in response to receiving user confirmation, the index identification information of the candidate knowledge instance is written to the knowledge base. Writing the index identification information to the knowledge base upon receiving user confirmation avoids contaminating the knowledge base with incorrect information or causing data leakage by writing critical information into the knowledge base.

[0098] As an optional approach, candidate knowledge instances in the code generation process are determined based on the execution process data of each subtask, including: determining process exception events in the code generation process based on the execution process data of each subtask, wherein process exception events include at least one of execution failure events, process rollback events, and manual correction events; and performing event feature clustering on process exception events in combination with the context information of the process exception events to obtain candidate knowledge instances.

[0099] The embodiments of this disclosure record process exception events during code generation and perform event feature clustering on these exception events, enabling similar events to be grouped into the same knowledge instance. This allows the intelligent agent to retrieve and call the required knowledge instance based on the task being performed.

[0100] For example, the context information of a process exception event can include user feedback regarding the exception event. Incorporating user feedback during the clustering process can improve clustering accuracy.

[0101] As an alternative approach, knowledge instances can also be updated using self-evolving agents. These agents can summarize and generalize execution failure events, process rollback events, and manual correction events that occur during task execution, extracting general knowledge and / or rules. They can then update the corresponding knowledge instances based on the event category, enabling other agents to dynamically retrieve and apply relevant knowledge during the next subtask execution.

[0102] As an alternative approach, the code generation method may further include: for any target subtask among multiple subtasks, determining a key task node that matches the target subtask and requires manual confirmation; generating query information based on the key task node and sending the query information through human-computer interaction; and, in response to receiving response data for the query information, executing the target subtask based on the response data.

[0103] In embodiments of this disclosure, one or more intelligent agents are configured to actively pause before executing a target sub-task, generate query information based on key task nodes and trigger a manual confirmation process. After confirmation, the target sub-task is executed based on the received response data, thereby ensuring the reliability of code generation.

[0104] For example, query information based on key task nodes may include judgmental information and selection information. The response data for judgmental information may include "yes" or "no", and the response data for selection information may include one or more of a plurality of preset options.

[0105] As an optional approach, the key task nodes that match the target subtask and require manual confirmation are identified, including: determining the key task nodes of the target subtask based on preset constraints, wherein the preset constraints include at least one of the following conditions: there is ambiguity in the positioning of requirements, there is a requirement to read external files, there is a high-risk setting change, and there are preset permission sensitive nodes.

[0106] In the embodiments of this disclosure, nodes with ambiguous requirements, external file reading requirements, high-risk setting changes, and preset permission sensitive nodes in the target subtask are designated as key task nodes. Before executing the target subtask, query information is generated based on the key task nodes, and the target subtask is executed based on the received response data to the query information. This ensures the accuracy of the execution of the target subtask and improves the accuracy of code generation.

[0107] For example, requirement positioning ambiguity can mean that the agent has multiple understandings of the requirement points corresponding to the current task, and different understandings may lead to different execution results, requiring the user to manually determine the correct requirement.

[0108] For example, when there is a need to read external files, the user needs to manually select the corresponding external file to avoid errors when the agent automatically reads the file, while ensuring the security and compliance of the code generation process.

[0109] For example, in cases of high-risk setting changes, users need to manually confirm whether to make the changes in order to ensure the security and compliance of the code generation process.

[0110] For example, when the code reaches a node with preset permissions, the user needs to manually authorize the code before proceeding with subsequent operations to ensure the compliance of the code generation process.

[0111] As an alternative approach, the code generation method may further include: in response to any preceding subtask's execution result failing validity verification, generating a verification failure notification including failure attribution information; sending the verification failure notification to the corresponding first agent, so that the first agent re-executes the preceding subtask based on the verification failure notification until the execution result of the preceding subtask meets the validity judgment condition.

[0112] In embodiments of this disclosure, if validity verification fails, a verification failure notification is sent to the agent executing the subtask, causing the agent to re-execute the corresponding subtask. This enables reliable control over each subtask, ensuring that execution precedes subsequent subtasks and that earlier subtasks have been successfully executed. This guarantees code generation accuracy and avoids being misled by seemingly correct outputs from agents, preventing errors from escalating throughout the process. Furthermore, by verifying the execution process of each subtask, in the event of an execution error, it is not necessary to re-execute all subtasks from the beginning; instead, it is sufficient to roll back to the necessary stage and re-execute, improving code generation efficiency.

[0113] For example, the verification failure notification includes attribution information, which can be generated by the verification agent based on the verification result, enabling the first agent to analyze the cause of the error based on the attribution information and thereby correct the execution process.

[0114] As an optional approach, the code generation method may also include: for any target subtask among multiple subtasks, in the event of a workflow interruption during the execution of the target subtask, obtaining persistent task data matching the target subtask; and based on the persistent task data, restoring the workflow breakpoint of the target subtask so as to continue executing the target subtask.

[0115] In embodiments of this disclosure, when the workflow is interrupted during the execution of a target subtask, persistent task data of the target subtask is stored. This persistent task data may include the task progress of the agent executing the target subtask and the task data generated during the execution of the target subtask. The persistent task data can be stored in a non-volatile storage medium to prevent data loss. This allows the target subtask to be resumed during execution recovery based on the persistent task data, eliminating the need to repeat completed steps and improving task execution efficiency.

[0116] For example, workflow interruption can include both user-manual interruption and system-automatic interruption. In the case of user-manual interruption, in response to receiving an interruption command, persistent task data matching the current execution process of the target subtask is stored. In the case of system-automatic interruption, in response to the triggering of a predetermined interruption condition, persistent task data matching the current execution process of the target subtask is stored. The predetermined interruption condition may include conditions such as insufficient hardware resources or computer hibernation.

[0117] As an alternative approach, the code generation method may further include: for any adjacent subtasks among multiple subtasks, the first and second agents corresponding to the adjacent subtasks share the same global constraints, wherein the global constraints include general constraints applicable to each agent in the multi-agent collaborative process.

[0118] In the embodiments of this disclosure, during the code generation process, each agent is configured to share the same global constraints to support centralized management and dynamic updates of these constraints. Centralized management of global constraints enables the configuration and scheduling of each agent, improving scheduling efficiency for multiple agents. Furthermore, this approach avoids the problem of excessive constraints being input into agent prompts, which could lead to a decrease in agent command compliance.

[0119] For example, global constraints can be stored independently in a dedicated constraint file, which is decoupled from the prompt word files of each agent. This allows the iterative updates and centralized management of global constraints to be completed independently without intruding on or altering the business logic of the agents.

[0120] As an optional approach, the code generation method may further include: a first agent writing the execution result of a preceding subtask into a communication message queue, the execution result including a scheduling instruction for a second agent; and, if a verification result indicates that the execution result of the preceding subtask is valid, invoking a second agent that matches the subsequent subtask in an adjacent subtask to execute the subsequent subtask, including: in response to the second agent reading the execution result from the communication message queue, and if the execution result is confirmed to be valid, the second agent executing the subsequent subtask based on the scheduling instruction in the execution result. Wherein, a valid execution result indicates that the scheduling instruction for the second agent is valid.

[0121] In the embodiments of this disclosure, each intelligent agent can achieve asynchronous communication and decoupling through a communication message queue, enabling each intelligent agent to operate independently without unified scheduling. This is suitable for large-scale deployment scenarios and improves the flexibility of intelligent agent scheduling.

[0122] For example, the second agent can read the execution result of the first agent from the communication message queue according to its own task execution status. After reading the execution result and confirming that the execution result is valid, the second agent can execute the sub-task corresponding to the second agent based on the execution result.

[0123] Alternatively, the execution order of agents can also be defined using a state diagram. A state diagram can include multiple state nodes and directed edges connecting the state nodes. Each state node can correspond to an agent or a subtask, and the directed edges represent the execution order relationships between agents or subtasks. Defining the execution order of agents using a state diagram improves the flexibility of agent control.

[0124] As an optional approach, the code generation method may also include: standardizing and uniformly summarizing the execution process data and execution result data of each subtask in the code generation process through an archiving agent.

[0125] The embodiments of this disclosure, through the archiving agent, can summarize and organize the documents and reports generated during the code generation process, and generate a standardized execution report to clearly show the complete execution process of the task and the execution results of each step, thus ensuring the interpretability of the code generation process.

[0126] Figure 5 This is a block diagram of an agent-based code generation apparatus according to an embodiment of the present disclosure.

[0127] like Figure 5 As shown, the code generation device 500 includes: a splitting module 510, a first execution module 520, a verification module 530, a second execution module 540, and an output module 550. The splitting module 510, in response to receiving a code generation task, splits the code generation task into a sequence of subtasks with chained dependencies. The first execution module 520, for any adjacent subtask in the subtask sequence, calls a first agent matching the preceding subtask in the adjacent subtask sequence to execute the preceding subtask, obtaining the execution result of the preceding subtask. The verification module 530, for validating the execution result of the preceding subtask, obtains a verification result. The second execution module 540, if the verification result indicates that the execution result of the preceding subtask is valid, calls a second agent matching the following subtask in the adjacent subtask sequence to execute the following subtask. The output module 550, in response to the valid execution result of the last subtask in the subtask sequence, obtains the code generation result.

[0128] In one optional implementation, when the preceding subtask is a requirements analysis task, the execution result of the requirements analysis task includes the requirements analysis results. The verification module is also used to perform at least one of the following verifications on the requirements analysis results to obtain a verification result: verifying the completeness, clarity, feasibility, and acceptability of the requirements analysis results; verifying whether the requirements analysis results include complete state routing description data; and verifying whether the requirements analysis results meet the preset audit compliance requirements.

[0129] In an optional implementation, when the preceding subtask is a solution design task, the execution result of the solution design task includes the solution design result. The verification module is also used to perform at least one of the following verifications on the solution design result to obtain a verification result: verifying the solution design result for missing requirements, requirement deviations, and over-design; verifying whether the key steps in the solution design result can guide subsequent code design tasks, wherein the key steps describe the logical path from the initial requirements to the deliverable result; and verifying whether the solution design result and the input visual diagram of the code generation task meet the content consistency requirement.

[0130] In one optional implementation, when the preceding subtask is a code design task, the execution result of the code design task includes the code design result. The verification module is also used to perform at least one of the following verifications on the code design result: requirement consistency verification, code quality verification, code security verification, completeness verification of exception handling logic, log observability verification, test coverage verification, and visual fidelity verification.

[0131] In one optional implementation, when the preceding subtask is a functional acceptance task, the execution result of the functional acceptance task includes the functional acceptance result. The verification module is also used to perform at least one of the following verifications on the functional acceptance result: functional availability verification, boundary scenario verification, error path verification, and visual fidelity verification, wherein the boundary scenario includes special operating scenarios triggered when the scenario triggering conditions are within a critical threshold range.

[0132] In an optional implementation, the device further includes a knowledge invocation module, which is used to determine candidate knowledge instances in the code generation process based on the execution process data of each subtask. The candidate knowledge instances include structured knowledge units with cross-task adaptability attributes. The knowledge invocation module generates index identification information based on the candidate knowledge instances. The index identification information indicates at least one of the applicable scenario label, invocation constraints, and version information of the candidate knowledge instances. The index identification information of the candidate knowledge instances is written into a knowledge base so that in subsequent code generation tasks, the agent can invoke the corresponding knowledge instances based on the index identification information.

[0133] In an optional implementation, the knowledge invocation module is further configured to determine process exception events in the code generation process based on the execution process data of each subtask. The process exception events include at least one of execution failure events, process rollback events, and manual correction events. Combined with the context information of the process exception events, the module performs event feature clustering on the process exception events to obtain candidate knowledge instances.

[0134] In one optional implementation, the device further includes a confirmation module, which is used to determine, for any target subtask among multiple subtasks, a key task node that matches the target subtask and needs to be manually confirmed; generate inquiry information based on the key task node and send the inquiry information through human-computer interaction; and, in response to receiving response data for the inquiry information, execute the target subtask based on the response data.

[0135] In an optional implementation, the confirmation module is further configured to determine the key task nodes of the target subtask based on preset constraints, wherein the preset constraints include at least one of the following conditions: there is ambiguity in the location of the requirement, there is a requirement to read external files, there is a high-risk setting change, and there are preset permission sensitive nodes.

[0136] In an optional implementation, the device further includes a third execution module, which is further configured to generate a verification failure notification including failure attribution information in response to any previous subtask's execution result failing the validity check; and send the verification failure notification to the corresponding first agent, so that the first agent re-executes the previous subtask based on the verification failure notification until the execution result of the previous subtask meets the validity determination condition.

[0137] In one optional implementation, the device further includes a recovery module, which is used to acquire persistent task data matching the target subtask in the event of a workflow interruption during the execution of any target subtask among multiple subtasks; and to restore the workflow breakpoint of the target subtask based on the persistent task data so as to continue the execution of the target subtask.

[0138] In one optional embodiment, the device further includes a global constraint module, which is used to provide the same global constraint conditions for any adjacent subtasks among multiple subtasks, where the first and second agents corresponding to the adjacent subtasks share the same global constraint conditions. The global constraint conditions include general constraint conditions applicable to each agent in the multi-agent collaborative process.

[0139] In an optional embodiment, the device further includes a message queue module, which is used by a first agent to write the execution result of a preceding subtask into a communication message queue, the execution result including a scheduling instruction for a second agent; and, if the verification result indicates that the execution result of the preceding subtask is valid, to invoke a second agent that matches the subsequent subtask in the adjacent subtasks to execute the subsequent subtask, including: in response to the second agent reading the execution result from the communication message queue, and if the execution result is confirmed to be valid, the second agent executes the subsequent subtask based on the scheduling instruction in the execution result; wherein, the validity of the execution result indicates that the scheduling instruction for the second agent is valid.

[0140] In one optional implementation, the device further includes an archiving module, which is used to standardize and uniformly summarize the execution process data and execution result data of each subtask in the code generation process through an archiving agent.

[0141] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0142] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0143] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0144] like Figure 6 As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0145] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0146] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as task execution methods. For example, in some embodiments, the task execution method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the task execution method described above may be performed. Alternatively, in other embodiments, computing unit 601 may be configured to perform inference task processing methods by any other suitable means (e.g., by means of firmware).

[0147] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard parts (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0148] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0149] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory (EPROM) or flash memory, optical fiber, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0150] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a cathode ray tube (CRT) monitor or a liquid crystal display (LCD)); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0151] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0152] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.

[0153] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.

[0154] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A code generation method based on intelligent agents, comprising: In response to receiving a code generation task, the code generation task is split into a sequence of subtasks with chained dependencies; For any adjacent subtask in the subtask sequence, call the first agent that matches the preceding subtask in the adjacent subtask to execute the preceding subtask, and obtain the execution result of the preceding subtask; The validity of the execution result of the preceding subtask is verified to obtain the verification result; If the verification result indicates that the execution result of the preceding subtask is valid, a second agent matching the subsequent subtask in the adjacent subtask is invoked to execute the subsequent subtask. as well as The code generation result is obtained in response to the valid execution result of the last subtask in the subtask sequence.

2. The method according to claim 1, wherein, In the case where the preceding subtask is a requirements analysis task, the execution result of the requirements analysis task includes the requirements analysis results; The validity verification of the execution result of the preceding subtask, to obtain the verification result, includes: The requirements analysis results are validated by at least one of the following methods to obtain the validation results: The requirements analysis results are then verified for completeness, clarity, feasibility, and acceptability. Verify whether the requirements analysis results include complete state routing description data; Verify whether the results of the requirements analysis meet the preset traceability compliance requirements.

3. The method according to claim 1, wherein, In the case where the preceding subtask is a scheme design task, the execution result of the scheme design task includes the scheme design result; The validity verification of the execution result of the preceding subtask, to obtain the verification result, includes: The design results of the proposed scheme are verified by performing at least one of the following checks to obtain the verification results: The design results of the proposed scheme are checked for missing requirements, deviations in requirements, and over-design. Verify whether the key steps in the solution design result can guide the subsequent code design task. The key steps describe the logical path from the initial requirements to the deliverable result. Verify whether the design result of the proposed solution and the input visual diagram of the code generation task meet the content consistency requirement.

4. The method according to claim 1, wherein, In the case where the preceding subtask is a code design task, the execution result of the code design task includes the code design result; The validity verification of the execution result of the preceding subtask, to obtain the verification result, includes: The code design results shall be verified by at least one of the following: requirement consistency verification, code quality verification, code security verification, completeness verification of exception handling logic, log observability verification, test coverage verification, and visual fidelity verification.

5. The method according to claim 1, wherein, In the case where the preceding subtask is a functional acceptance task, the execution result of the functional acceptance task includes the functional acceptance result; The validity verification of the execution result of the preceding subtask, to obtain the verification result, includes: The functional acceptance results shall be verified by at least one of the following: functional availability verification, boundary scene verification, error path verification, and visual fidelity verification. The boundary scenarios include special operating scenarios triggered when the scenario triggering conditions are within the critical threshold range.

6. The method according to any one of claims 1 to 5, further comprising: Based on the execution process data of each subtask, candidate knowledge instances in the code generation process are determined, and the candidate knowledge instances include structured knowledge units with cross-task adaptability attributes. Generate index identification information based on the candidate knowledge instance, wherein the index identification information indicates at least one of the applicable scenario label, invocation constraints, and version information of the candidate knowledge instance; as well as The index identification information of the candidate knowledge instances is written into the knowledge base so that the agent can call the corresponding knowledge instances based on the index identification information in subsequent code generation tasks.

7. The method according to claim 6, wherein, The process of determining candidate knowledge instances in the code generation process based on the execution process data of each sub-task includes: Based on the execution process data of each subtask, process exception events during code generation are determined, including at least one of execution failure events, process rollback events, and manual correction events; and By combining the context information of the process exception events, event feature clustering is performed on the process exception events to obtain the candidate knowledge instances.

8. The method according to any one of claims 1 to 5, further comprising: For any target subtask in the subtask sequence, identify the key task node that matches the target subtask and needs to be manually confirmed. Generate query information based on the key task nodes and send the query information through human-computer interaction; as well as In response to receiving response data for the query information, the target subtask is executed based on the response data.

9. The method according to claim 8, wherein, The process of determining the key task nodes that match the target sub-task and require manual confirmation includes: Based on preset constraints, the key task nodes of the target subtask are determined. The preset constraint conditions include at least one of the following conditions: There are ambiguities in the definition of the demand, there is a need to read external files, there are high-risk settings changes and sensitive nodes with preset permissions.

10. The method according to any one of claims 1 to 9, further comprising: In response to any preceding subtask failing the validity check, a validation failure notification including failure attribution information is generated. The verification failure notification is sent to the corresponding first agent, so that the first agent re-executes the preceding sub-task based on the verification failure notification until the execution result of the preceding sub-task meets the validity determination condition.

11. The method according to any one of claims 1 to 9, further comprising: For any target subtask in the subtask sequence, if the workflow is interrupted during the execution of the target subtask, persistent task data matching the target subtask is obtained. as well as Based on the persistent task data, the workflow breakpoint of the target subtask is restored so that the target subtask can continue to be executed.

12. The method according to any one of claims 1 to 9, further comprising: For any adjacent subtasks in the subtask sequence, the first agent and the second agent corresponding to the adjacent subtasks share the same global constraints. The global constraints include general constraints applicable to all agents in a multi-agent collaborative process.

13. The method according to any one of claims 1 to 9, further comprising: The first intelligent agent writes the execution result of the preceding subtask into the communication message queue, and the execution result includes scheduling instructions for the second intelligent agent; The step of invoking a second agent that matches the subsequent subtask in the adjacent subtasks to execute the subsequent subtask when the verification result indicates that the execution result of the preceding subtask is valid includes: In response to the second agent reading the execution result from the communication message queue, and upon confirming that the execution result is valid, the second agent executes the subsequent subtask based on the scheduling instruction in the execution result; The execution result indicates that the scheduling instruction for the second agent is valid.

14. The method according to any one of claims 1 to 9, further comprising: The archiving agent standardizes and unifies the execution process data and execution result data of each subtask in the code generation process.

15. A code generation device based on an intelligent agent, comprising: A splitting module is used to split the code generation task into a sequence of subtasks with chained dependencies in response to receiving the code generation task. The first execution module is used to, for any adjacent subtask in the subtask sequence, call a first agent that matches the preceding subtask in the adjacent subtask to execute the preceding subtask, and obtain the execution result of the preceding subtask; The verification module is used to verify the validity of the execution results of the preceding sub-tasks and obtain the verification results. The second execution module is used to, when the verification result indicates that the execution result of the preceding subtask is valid, call a second agent that matches the subsequent subtask in the adjacent subtask to execute the subsequent subtask; as well as The output module is used to obtain the code generation result in response to the valid execution result of the last subtask in the subtask sequence.

16. An electronic device comprising: 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 to enable the at least one processor to perform the method of any one of claims 1 to 14.

17. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 14.

18. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 14.