Code generation method and system based on multi-agent cooperation, device, and medium

By employing a multi-agent collaborative code generation method, leveraging centrally scheduled agents and knowledge graphs, the inefficiency and consistency challenges in software development are addressed. This enables automated conversion from natural language requirements to multi-platform code, improving code quality and delivery speed, and systematically reusing enterprise knowledge.

CN122152289APending Publication Date: 2026-06-05BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
Filing Date
2026-01-23
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies in software development suffer from low development efficiency, difficulty in ensuring code consistency, inability to systematically reuse enterprise knowledge assets, inability of traditional tools to deeply understand unstructured requirement documents, and lack of a unified multi-terminal code generation and synchronization mechanism, resulting in unstable code quality and limited delivery speed.

Method used

A code generation method based on multi-agent collaboration is adopted, which coordinates the agents for requirement analysis, knowledge retrieval and code generation through a central scheduling agent, and uses a knowledge graph to store enterprise-level knowledge assets to realize an automated conversion process from natural language requirements to multi-terminal code.

Benefits of technology

It improves code generation efficiency, ensures that generated code meets enterprise standards, enhances code quality and delivery speed, supports logical consistency across multiple platforms, and systematically reuses enterprise knowledge assets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152289A_ABST
    Figure CN122152289A_ABST
Patent Text Reader

Abstract

The disclosure provides a multi-agent cooperation-based code generation method and system, device and medium, relates to the technical field of artificial intelligence, and in particular to the technical field of agents, knowledge graphs and the like. The specific implementation scheme is as follows: the original requirement is issued to a central scheduling agent, the central scheduling agent is configured to operate in accordance with a preset main cooperation process; the central scheduling agent is controlled to respond to the original requirement and execute the main cooperation process according to the original requirement: calling a requirement analysis agent, performing semantic analysis and structural processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, calling a knowledge retrieval agent, retrieving and returning associated code assets from a pre-constructed knowledge graph; distributing the requirement specification description and the associated code assets to at least one code generation agent to generate and return target code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the fields of intelligent agents and knowledge graphs. Specifically, this disclosure relates to a code generation method and system based on multi-agent collaboration, an electronic device, and a computer-readable storage medium. Background Technology

[0002] With the acceleration of digital transformation, the iteration frequency of software projects continues to increase, especially with the frequent changes in requirements such as cloud control configuration and interface development, which places higher demands on development efficiency and delivery quality.

[0003] In current software development practices, the transformation process from product requirements to final code delivery still faces significant efficiency bottlenecks and quality risks. Taking mobile application development as an example, a typical cloud-controlled configuration requirement (such as adjusting client function switches or parameters) usually requires the product manager to write a requirements document, which is then interpreted, manually coded, and coordinated by backend developers, Android developers, and iOS developers, and finally delivered only after code review. This process is not only time-consuming and labor-intensive, but also prone to inconsistencies in logic and interface mismatches when implemented across platforms, affecting product experience and iteration speed. Summary of the Invention

[0004] This disclosure provides a code generation method and system based on multi-agent collaboration, an electronic device, and a computer-readable storage medium.

[0005] According to a first aspect of this disclosure, a code generation method based on multi-agent cooperation is provided, the method comprising: Receive the original request; The original requirements are sent to the central scheduling agent, which is configured to run according to a preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the requirement parsing agent, the knowledge retrieval agent, and at least one code generation agent. The central scheduling agent responds to the original request and executes according to the main collaboration process: The requirement parsing agent is invoked to perform semantic parsing and structuring processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, the knowledge retrieval agent is invoked to retrieve and return associated code assets from a pre-built knowledge graph; the requirement specification description and the associated code assets are distributed to at least one code generation agent to generate and return target code. Receive the code and generate the target code returned by the intelligent agent.

[0006] According to a second aspect of this disclosure, a code generation system based on multi-agent collaboration is provided, the system comprising: a central scheduling agent, a requirement parsing agent, a knowledge retrieval agent, and at least one code generation agent; and The interaction interface is used to receive the original requirements; The requirement processing module is used to send the original requirement to the central scheduling agent. The central scheduling agent is configured to run according to a preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the requirement parsing agent, the knowledge retrieval agent, and at least one code generation agent. The central scheduling agent responds to the original request and executes according to the main collaboration process: The requirement parsing agent is invoked to perform semantic parsing and structuring processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, the knowledge retrieval agent is invoked to retrieve and return associated code assets from a pre-built knowledge graph; the requirement specification description and the associated code assets are distributed to at least one code generation agent to generate and return target code. The code receiving module is used to receive the target code returned by the code generating agent.

[0007] According to a third aspect of this disclosure, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to at least one of the aforementioned processors; wherein, The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to execute the code generation method based on multi-agent cooperation.

[0008] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to execute the above-described code generation method based on multi-agent cooperation.

[0009] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the above-described code generation method based on multi-agent cooperation.

[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: Figure 1 This is a flowchart illustrating a code generation method based on multi-agent collaboration provided in an embodiment of this disclosure; Figure 2 This is a flowchart illustrating some steps of another code generation method based on multi-agent collaboration provided in this embodiment of the disclosure; Figure 3 This is a flowchart illustrating some steps of another code generation method based on multi-agent collaboration provided in this embodiment of the disclosure; Figure 4 This is a flowchart illustrating some steps of another code generation method based on multi-agent collaboration provided in this embodiment of the disclosure; Figure 5 This is a flowchart illustrating some steps of another code generation method based on multi-agent collaboration provided in this embodiment of the disclosure; Figure 6 This is a schematic diagram of a specific embodiment of another code generation method based on multi-agent collaboration provided in this disclosure; Figure 7 This is a schematic diagram of the structure of a code generation system based on multi-agent collaboration provided in an embodiment of this disclosure; Figure 8 This is a block diagram of an electronic device used to implement the code generation method based on multi-agent cooperation in the embodiments of this disclosure. Detailed Implementation

[0012] 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.

[0013] In some related technologies, code frameworks can be quickly generated using predefined templates. However, these tools are essentially parameterized text replacements, lacking the ability to understand the semantics of business requirements and thus unable to handle complex business logic.

[0014] In some related technologies, low-code / no-code platforms can be used to lower the development threshold through visual configuration. However, the applications generated by these platforms are usually tied to specific platforms, posing a "platform lock-in" risk. They are also difficult to integrate deeply with existing complex enterprise technology stacks, and their flexibility and ability to handle complex business logic are limited.

[0015] In some related technologies, AI-based assisted programming tools can be used to provide code completion or generation suggestions to developers using large language models. These tools are mainly aimed at individual developers and lack a systematic mechanism for the accumulation and reuse of enterprise-level knowledge assets (such as internal coding standards, architectural patterns, and historical successful solutions).

[0016] More importantly, existing AI (artificial intelligence) tools lack specific support for multi-terminal collaborative development scenarios, and cannot generate and ensure the consistency of code on the server, Android and iOS sides simultaneously from a single requirement.

[0017] In summary, the relevant technical solutions generally suffer from the following core defects: 1. The valuable development standards, best practices and historical experience accumulated by enterprises are scattered in documents and in the minds of personnel, and cannot be systematically accumulated, reused and iterated, resulting in unstable quality of AI-generated code that is difficult to meet enterprise standards.

[0018] 2. Traditional tools cannot deeply understand unstructured requirements documents. Although AI tools have a certain understanding ability, they lack the ability to accurately extract structured business information and configuration data from requirements documents.

[0019] 3. The lack of a unified and automated multi-platform code generation and synchronization mechanism leads to the need for repeated development of the same requirements on different platforms, resulting in low efficiency and difficulty in ensuring consistency.

[0020] 4. There are multiple human intervention points in the entire chain from requirement identification, code generation, quality verification to code submission, which fails to achieve end-to-end automated closed loop, resulting in limited overall delivery speed and easy errors.

[0021] This disclosure provides a code generation method and system based on multi-agent collaboration, an electronic device, and a computer-readable storage medium, which aim to solve at least one of the above-mentioned technical problems in the prior art.

[0022] The code generation method based on multi-agent cooperation provided in this disclosure can be executed by electronic devices such as terminal devices or servers. Terminal devices can be in-vehicle devices, user equipment (UE), mobile devices, user terminals, terminals, cellular phones, cordless phones, personal digital assistants (PDAs), handheld devices, computing devices, in-vehicle devices, wearable devices, etc. The method can be implemented by a processor calling computer-readable program instructions stored in memory. Alternatively, the method can be executed by a server.

[0023] Figure 1A flowchart illustrating the code generation method based on multi-agent collaboration provided in an embodiment of this disclosure is shown. Figure 1 As shown, it may include the following steps: S110, Receive the original request.

[0024] Original requirements are feature development requests submitted by users or product managers, expressed in natural language or semi-structured documents (such as requirement cards). For example, "Add an A / B test switch to the product details page to control the display of the old and new UIs."

[0025] In some possible implementations, the original requirements can be received through an interactive interface.

[0026] Interaction interfaces are channels for exchanging requirement data with users or external systems, including but not limited to APIs (Application Programming Interfaces) of requirement management platforms, visual web interfaces, and integration interfaces of enterprise instant messaging tools. They support receiving raw requirements in various forms, such as natural language documents, structured requirement cards, and tabular data.

[0027] After the deployment of the multi-agent collaborative code generation system, which implements the multi-agent collaborative code generation method provided in this embodiment, its interaction interface is in a listening state.

[0028] The interactive interface supports two core access modes: One is the proactive pull mode, where the central scheduling agent periodically obtains requirement cards with statuses of "pending development" or "reviewed" by polling or listening to the open API of the external requirement management platform, and automatically extracts the text description, configuration table, attachments and other contents from the cards as the original requirements.

[0029] The second is the passive receiving mode, where users can directly upload original requirements in the form of natural language documents, Excel configuration sheets, requirement prototype diagrams, etc., through the system's visual interface, instant messaging tools, or API interfaces.

[0030] In some possible implementations, after obtaining the original requirements, the original requirements can be preprocessed, such as filtering invalid characters, unifying the data encoding format, identifying the type of requirements, such as configuration class, interface class, UI (interactive interface) component class, and assigning a unique identifier to each original requirement for subsequent process tracking and data association.

[0031] S120. The original requirements are sent to the central scheduling agent. The central scheduling agent is configured to run according to the preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the requirement parsing agent, the knowledge retrieval agent, and at least one code generation agent.

[0032] Among them, the central scheduling agent, as the core scheduling unit of the code generation system based on multi-agent collaboration, is a software agent with state management and process scheduling capabilities. As the execution carrier of the preset main collaborative process, it does not directly handle business logic, but is responsible for receiving original requirements, scheduling other functional agents, maintaining process status, handling data flow and abnormal situations, and ensuring that the entire process proceeds in an orderly manner according to the established rules.

[0033] The main collaboration process refers to a workflow defined in the form of executable code or configuration that describes a fixed collaboration mode among multiple agents. It clarifies the calling order (e.g., "requirement analysis - knowledge retrieval - code generation"), data flow path (e.g., the result of requirement analysis is passed to the knowledge retrieval agent), data input and output format, triggering conditions, and collaboration boundaries among the requirement analysis agent, knowledge retrieval agent, and code generation agent. It can be flexibly adjusted through configuration files or rule engines.

[0034] The requirement parsing agent is a functional agent focused on natural language understanding and information extraction. Its core function is to transform unstructured raw requirements into standardized requirement specifications that can be recognized and processed by machines through technologies such as semantic analysis, entity recognition, and relation extraction.

[0035] The knowledge retrieval agent is a functional agent focused on knowledge query and reasoning. It is responsible for interacting with enterprise-level knowledge graphs and has the capabilities of graph query, semantic matching, and related asset extraction. Based on the requirement specification description, it can accurately locate and return the appropriate code-related knowledge assets from the structured knowledge graph.

[0036] The code generation agent is a functional agent used to generate target code. It receives a requirements specification description and associated code assets, and generates and outputs target code that meets the requirements by constructing prompt words to invoke an LLM (Large Language Model) or based on a template. It supports single-platform or multi-platform, such as simultaneous code generation on server, Android, and iOS devices.

[0037] In some possible implementations, the interaction interface, upon receiving the original request, immediately creates a new task instance and sends it to the task queue of the central scheduling agent.

[0038] The central scheduling agent retrieves the task from the queue, marks it as "in progress," and loads the pre-defined main collaboration process configuration. This configuration defines the agent invocation order, the execution chain of "requirements analysis -> knowledge retrieval -> code generation," data flow rules (the output of requirements analysis serves as the input for knowledge retrieval, and the requirements specification description and associated code assets serve as the input for code generation), and exception handling strategies, using structured formats such as DAG (Directed Acyclic Graph) and JSON (JavaScript Object Notation). Subsequently, the central scheduling agent begins to schedule subsequent agents step by step according to this process.

[0039] S130, The control center schedules the intelligent agent to respond to the original request and execute according to the main collaborative process: The system invokes a requirement parsing agent to perform semantic parsing and structuring processing on the original requirements, generating and returning a requirement specification description. Based on the requirement specification description, it invokes a knowledge retrieval agent to retrieve and return associated code assets from a pre-built knowledge graph. The requirement specification description and associated code assets are then distributed to at least one code generation agent to generate and return the target code.

[0040] The requirement specification description is a structured representation of requirements output by the requirement parsing agent. It is usually in JSON or XML (Extensible Markup Language) format and includes, but is not limited to, key attributes such as requirement identifiers, function definitions, configuration parameters, target platforms (e.g., Server / Android / iOS), and non-functional requirements.

[0041] A requirement identifier is a string encoding that uniquely identifies a specific development requirement. It typically originates directly from the requirements management platform and serves as the core link between the automated processes of this disclosure's embodiments and external project management systems.

[0042] Function definition refers to the core, structured description of the software functions to be implemented by the requirements. It has been semantically refined by the requirements parsing agent, removing ambiguity and embellishment from natural language, and transformed into an "operation instruction" that can be precisely executed by the machine.

[0043] Configuration parameters refer to the specific, configurable set of input values ​​or options required to implement a function. These parameters are usually derived from configuration tables or detailed input instructions in product requirements documents, and represent the concretization and instantiation of the function.

[0044] The target platform refers to one or more specific technology stacks or runtime environments where the requirement needs to be implemented. It clarifies the final output format and technical constraints of the generated code.

[0045] Knowledge graphs are enterprise-level structured knowledge storage carriers built on graph databases. Through predefined entity types and semantic relationships, they systematically store core development knowledge such as business domain knowledge, development specifications, code templates, and configuration examples, supporting efficient retrieval and reasoning.

[0046] Associated code assets are collections of knowledge retrieved from a knowledge graph that are relevant to the current requirement. It is a structured data package that includes, but is not limited to, code templates, development standards, configuration examples, best practices, and guidelines for avoiding typical errors.

[0047] Target code refers to executable code or code framework generated by the code generation agent based on requirements and knowledge assets, which conforms to the enterprise's development specifications and functional requirements. It can be used directly for software development or put into use after minor adjustments.

[0048] Figure 2 The diagram illustrates the execution process of the central scheduling agent following the main collaborative flow, as shown below. Figure 2 As shown, the following steps may be included: S210. Invoke the requirement parsing agent to perform semantic parsing and structured processing on the original requirements, and generate and return the requirement specification description.

[0049] The central scheduling agent sends a call request containing the original requirement and a unique requirement identifier to the requirement parsing agent. After receiving the call request, the requirement parsing agent performs the following operations: Semantic parsing: A pre-trained natural language processing model is used to perform semantic analysis on the text content of the original requirements, extract key information such as core functional points, constraints, and business scenarios, identify ambiguous expressions or points of ambiguity in the requirements, and if there is ambiguity, the user can be asked to clarify through the interactive interface to supplement the complete information.

[0050] Structured processing: The semantic parsing results are integrated with the extracted configuration parameters (such as field names, value ranges, and associated modules extracted from tables) to generate a requirement specification description according to a preset template. The format is preferably JSON and includes, but is not limited to, the following core fields: requirement identifier, function definition, target platform list, configuration parameter set, business domain identifier, priority, and responsible person information.

[0051] Specifically, if the original requirement is an HTML-formatted requirement card, the page content is parsed using tools to locate the configuration information table; the configuration information table is then converted to a different format to extract the requirement identifier, R&D lead, version information, and target platform list; based on the focus of the target platform list, redundant configuration information is trimmed and reorganized into the aforementioned requirement specification description.

[0052] The requirement parsing agent returns the generated requirement specification description to the central scheduling agent. The central scheduling agent updates the process node to "requirement parsing completed" and stores the requirement specification description for subsequent steps.

[0053] S220. Based on the requirements specification description, invoke the knowledge retrieval agent to retrieve and return related code assets from the pre-built knowledge graph.

[0054] The central scheduling agent uses the requirement specification description as a query condition to invoke the knowledge retrieval agent.

[0055] The knowledge retrieval agent translates query conditions into a graph query language and performs retrieval within the knowledge graph. The retrieved entities, their attributes, and associated documents are then organized into a structured data package, i.e., associated code assets.

[0056] S230. Distribute the requirement specification description and associated code assets to at least one code generation agent to generate and return the target code.

[0057] The central scheduling agent determines the code generation agent to be called based on the "target platform list" in the requirements specification. For example, if the target platform is Server+Android+iOS, then the server-specific code generation agent, the Android-specific code generation agent, and the iOS-specific code generation agent are called simultaneously.

[0058] The central scheduling agent adopts a concurrent distribution mechanism to synchronously send the requirement specification description, associated code assets, and unique requirement identifier to the corresponding code generation agent, ensuring synchronous code generation across multiple platforms and improving efficiency.

[0059] After receiving the data, each code-generating agent executes its generation logic to ultimately generate the target code for the platform.

[0060] Each code generation agent returns the generated target code (including code files and configuration instructions) to the central scheduling agent, which then updates the process node to "code generation complete".

[0061] S140, Receive the target code returned by the code generation agent.

[0062] The central scheduling agent collects the target code returned by all code generation agents, updates the task status to "generation complete", classifies and stores it according to the unique identifier of the requirement and the target platform, and generates a code delivery list (including code file name, storage path, generation time, and corresponding requirement link).

[0063] The entire code generation process can be completed by pushing notifications to users or relevant R&D personnel through the interactive interface.

[0064] It can also be fed into a subsequent automated workflow engine to perform automatic submission, compilation, testing, and other operations to complete the entire code generation process.

[0065] In the code generation method based on multi-agent collaboration provided in this disclosure, by having specialized agents undertake the three core steps of requirement analysis, knowledge retrieval, and code generation, and by having a central scheduling agent coordinate them serially, a complete automated transformation process from natural language requirements to deliverable code is realized. This avoids efficiency loss and error risk caused by the fragmentation of steps, improves code generation efficiency, and shortens the code delivery cycle.

[0066] Among them, requirement parsing ensures the accuracy of intent understanding; knowledge retrieval provides a channel for enterprise-level specifications and quality requirements to intervene in the generation process; and the collaborative division of labor among multiple agents lays the foundation for in-depth optimization of each link, ensuring that the generated target code strictly follows enterprise standards, effectively reducing the probability of syntax errors, specification deviations and other problems. Compared with the method of directly generating code by a single model, the code generated by the embodiments of this disclosure is of higher quality.

[0067] Furthermore, by introducing knowledge retrieval agents and knowledge graphs as a necessary part of the process, the retrieval and utilization of enterprise knowledge assets are forcibly embedded into every code generation process, enabling the systematic and routine reuse of scattered development standards and best practices, effectively making up for the shortcomings of existing AI tools in enterprise knowledge reuse.

[0068] The design, using agents as modules and processes as chains, also makes the system easily scalable. For example, to support a new platform, simply add a new platform-specific code generation agent and modify the configuration of the main collaboration process. Simultaneously, multiple code generation agents can process the same requirement in parallel, naturally supporting collaborative code generation across multiple platforms and improving logical consistency.

[0069] The code generation method based on multi-agent cooperation provided in the embodiments of this disclosure will be described in detail below.

[0070] As described above, the knowledge graph is the foundation for the code generation method based on multi-agent collaboration provided in the embodiments of this disclosure.

[0071] The knowledge graph used in this embodiment is an enterprise-level semantic knowledge network built to support intelligent code generation. It organizes discrete development knowledge elements (entities) into a knowledge network that can be understood and reasoned about by machines, using a graph structure.

[0072] In a knowledge graph, an entity is the most basic unit of information carrying, representing an object in the real world or the conceptual world. This invention discloses six core entity types that form the skeleton of the knowledge graph: Business Entity: Represents an independent business domain or product module, used for categorizing requirements within a business context. Core attributes include "Entity ID, Business Name, Business Description, Department, and Creation Time."

[0073] Platform entity: Represents a specific technology stack or runtime environment, specifying the technical context in which code generation and specifications apply. Core attributes include "entity ID, platform name, technology stack, compatible version, and development tools".

[0074] Capability: Represents a reusable technical capability or feature, serving as a bridge connecting business requirements and technical implementation. Core attributes include "Entity ID, Capability Name, Capability Description, Application Scenarios, and Dependent Components".

[0075] Specification: Stores specific, mandatory development constraints and quality requirements, existing in the form of document links or structured rules. Core attributes include "Entity ID, Specification Name, Specification Type, Applicable Platform, Specific Clauses, and Update Time".

[0076] Code Template Entity (CodeTemplate): Stores validated best practice code snippets or file templates for specific scenarios. Core attributes include "Entity ID, Template Name, Adaptability, Adaptable Platforms, Template Content, and Usage Instructions".

[0077] Configuration Entity: Stores reusable knowledge related to various configurations during enterprise software development. The core carriers are configuration examples and best practices. It is a key knowledge asset that supports the rapid generation of compliant code for configuration-related requirements. Core attributes include "entity ID, configuration name, applicable scenarios, associated platforms, associated capabilities, configuration examples, best practices, update time, and maintainer".

[0078] Predefined semantic relation types refer to directed connections that are pre-designed and named to accurately express specific business or technical logic between entities. The embodiments disclosed in this invention include the following three core relation types, which provide clear path guidance for knowledge retrieval: BELONGS_TO (Business Hierarchy): Used to describe hierarchical relationships. For example, capability entity: "Cloud Control Configuration" -- [BELONGS_TO] --> business domain entity: "Marketing System". This means that the "Cloud Control Configuration" capability belongs to the "Marketing System" business domain.

[0079] SUPPORTS_PLATFORM (Capability Support Platform Relationship): This describes the compatibility between a capability and a platform. For example, capability entity: "Cloud Control Configuration" -- [SUPPORTS_PLATFORM] --> platform entity: "Server (Java)". This means that the "Cloud Control Configuration" capability is available on the Server (Java) platform.

[0080] SPECIFIES (specificational constraints): Used to describe the constraints and guidelines that specifications impose on entities. For example, specification entity: "Java Code Specification v2.1" -- [SPECIFIES] --> platform entity: "Server (Java)". This means that the specification applies to development on all Server (Java) platforms.

[0081] HAS_CAPABILITY (Business Capability Relationship): Used to describe the semantic relationship from a business domain entity to a capability entity. It explicitly declares the specific technical capabilities that a business domain or product module possesses, depends on, or requires. For example, business domain entity: "E-commerce Transaction System" -- [HAS_CAPABILITY] --> capability entity: "Payment Gateway Integration". This means that the "E-commerce Transaction System" business domain possesses or depends on the technical capability of "Payment Gateway Integration".

[0082] INHERITS_FROM (Child Capability Inheritance Relationship): Used to describe the semantic relationship established between capability entities, representing generalization and specialization. It points to the parent capability (general capability), indicating that the current capability is a subclass or specialized version of it. For example: Capability entity: "OAuth 2.0 Social Login" --[INHERITS_FROM]--> Capability entity: "User Authentication". This means that "OAuth 2.0 Social Login" is a special form of "User Authentication" capability, which inherits the general attributes and constraints of "User Authentication".

[0083] GENERATES_CODE (Code Generation Relationship): This describes the semantic relationship between a code template entity and a platform entity or specific code file. It describes the platform on which a template generates code, or records the template source upon which a successful code generation was based. For example: Static design phase: Code template entity: "SpringBoot RESTController template" -- [GENERATES_CODE {language: "Java"}] --> Platform entity: "Server (Java / SpringBoot)".

[0084] Each semantic relation is stored in the form of a "triple" (source entity ID - relation type - target entity ID), and relation attributes (such as "constraint strength" and "effective time" for canonical constraint relations) can be attached.

[0085] The structure design of the knowledge graph is accomplished through an initial "graph schema definition" configuration file.

[0086] System administrators or architects write a configuration file in YAML or JSON format to explicitly define the aforementioned entity types and their attribute fields, as well as various core relationship types and their attributes.

[0087] When the system starts, the knowledge graph management module reads the configuration file, creates corresponding node labels and relationship types in the graph database, and establishes the graph's metadata framework. Subsequently, existing structured or semi-structured data such as enterprise development specification documents, code template libraries, platform technology stack lists, and business capability matrices are transformed into entity and relationship instances conforming to the above pattern through ETL (Extract, Transform, Load) tools or dedicated import programs, and then imported into the graph database in batches.

[0088] By clearly defining core entities and key semantic relationships, the system achieves structured and systematic storage of development knowledge, organically integrating scattered business knowledge, technical specifications, and code templates into a semantically coherent knowledge network. The clear definition of entities and relationships enables the knowledge retrieval agent to locate target knowledge based on semantic associations, effectively overcoming the problem of traditional keyword retrieval being easily affected by lexical ambiguity or differences in expression. For example, for the query "cloud control configuration capability," it accurately matches the corresponding capability entity and related platform, specification, and other entities, significantly improving the relevance and accuracy of the retrieval results. Furthermore, the standardized definition of entities and relationships allows for the addition of new business domains, technology platforms, or functional capabilities simply by adding entities and relationships according to the rules, without needing to reconstruct the entire knowledge graph, thus efficiently adapting to the rapidly iterating business development needs of enterprises.

[0089] In some possible implementations, the data quality needs to be verified during the import of data into the knowledge graph to ensure the quality and consistency of the knowledge graph. The verification operation includes at least one of the following: Entity integrity verification: Verifies the required fields, data types, and value ranges of an entity; Relationship validity verification: Verify whether the relationship type is valid and confirm that both the source entity and the target entity it connects exist; Uniqueness constraint validation: Ensures the uniqueness of a specific field within a collection of entities of the same type; Circular reference detection: Detects relationships with hierarchical or dependency properties to ensure that there are no circular reference paths.

[0090] Entity integrity verification is used to verify whether the data of a single entity is complete and conforms to the format requirements by checking required fields, data types, format specifications, and enumeration value constraints.

[0091] Relationship validity verification is used to verify whether the relationships established between entities conform to the business logic and graph schema definition, as well as the integrity of entity references and the correctness of relationship attributes.

[0092] Uniqueness constraint verification is used to ensure that key business identifiers (such as entity IDs and canonical codes) are unique throughout the entire graph, avoiding data redundancy and query ambiguity.

[0093] Circular reference detection uses a depth-first search algorithm to detect circular references in hierarchical relationships. In graph structures, it specifically refers to detecting circular paths formed between entities through relationships. For example, if entity A belongs to B, B belongs to C, and C belongs to A, this is illegal in business hierarchy relationships and will lead to logical errors and infinite retrieval loops.

[0094] It can also include content integrity verification, which is used to check the format and citation correctness of extended content such as specification documents and configuration examples.

[0095] In some specific implementations, entity integrity verification involves checking the existence and non-nullability of required attributes for each entity to be imported; checking the data type; and checking the enumeration values.

[0096] Relationship validity verification checks whether the entity IDs connected at both ends of the relationship actually exist in the current batch or graph. It also checks whether the relationship type is allowed to connect these two entity types (e.g., can a canonical entity directly connect to a business domain entity? This needs to be determined based on the schema definition).

[0097] Uniqueness constraint verification maintains a hash set in memory, recording the key IDs of processed entities. When processing a new entity, it checks if its ID already exists in the set. For entities already present in the graph, unique index constraints from the database are used to ensure uniqueness.

[0098] Circular reference detection is performed on hierarchical relationships such as BELONGS_TO using a depth-first search (DFS) algorithm. Starting from any entity node, the algorithm traverses downwards along the BELONGS_TO relationship, recording the access path. If a node is visited a second time during the traversal, it proves that a circular reference exists, the verification fails, the import process is aborted, and an error path is reported.

[0099] Through rigorous automated verification, the introduction of dirty data and erroneous associations is prevented from the source, ensuring the authority and credibility of the knowledge graph as the system's "brain." This mechanism transforms the traditional data quality assurance process, which relies on manual review, into rule-based automated verification, significantly reducing the cost and error risk of knowledge graph construction and subsequent maintenance. A high-quality knowledge graph is the foundation for accurate retrieval and generation by the code-generating agent. The aforementioned verification steps effectively avoid code generation failures or low-quality issues caused by errors in the knowledge source.

[0100] In some possible implementations, the knowledge graph used in this disclosure is constructed based on graph database technology and persistently stores entities, semantic relationships and their attributes.

[0101] Graph database technology is a type of non-relational database specifically designed for storing and processing graph-structured data. It stores data as nodes (entities), edges (relationships), and attributes, and provides efficient graph traversal and relation query capabilities.

[0102] Persistent storage refers to permanently storing data on non-volatile storage media (such as hard drives) to ensure that data is not lost after a system restart. It is the opposite of memory storage.

[0103] Specifically, choose a mature graph database product, such as Neo4j. Deploy a Neo4j database instance on the server and configure it with the necessary storage space, memory, and access permissions. Integrate the official Neo4j driver into the "Knowledge Retrieval Agent" and "Knowledge Graph Management Module".

[0104] Through the driver, the system interacts with the database using a query language to perform operations such as creating, querying, updating, and deleting entities and relationships, thereby achieving persistent storage and dynamic updates of knowledge.

[0105] Graph databases have been deeply optimized for multi-hop relationship queries such as SUPPORTS_PLATFORM and BELONGS_TO, offering performance several orders of magnitude higher than traditional relational database multi-table JOIN operations, thus meeting the real-time knowledge retrieval requirements of code generation scenarios. Furthermore, graph databases offer relatively flexible schemas, easily allowing the addition of new entity or relationship types as business grows without complex table structure changes, adapting to the continuous accumulation and evolution of enterprise knowledge. Their storage method is highly consistent with the logical model of knowledge graphs, making data maintenance, understanding, and visualization more intuitive and efficient.

[0106] In some possible implementations, after the knowledge graph is constructed, the knowledge retrieval agent is configured to perform the following operations: Based on the target platform identifier and function definition in the requirements specification description, perform association retrieval in the knowledge graph to locate and return the specification entities and code template entities associated with the target platform and functions; the set of located entities constitutes the associated code assets.

[0107] Specifically, the knowledge retrieval agent converts the input parameters (target platform identifiers and functional definitions from the requirements specification) into parameterized query statements, which are then executed via a graph database. The database engine efficiently traverses the graph to find all entities that meet the criteria.

[0108] First, locate the business domain entities in the knowledge graph based on the "business domain identifier", and then associate them with the corresponding capability entities and specification entities through the "business hierarchy relationship". Then, by combining the target platform identifiers in the "Target Platform List", code template entities and configuration examples adapted to the platform can be filtered out through the "Capability Platform Support Relationship". Finally, based on the semantic similarity of the "functional definition", relevant best practices and error avoidance guidelines are matched to form a set of related code assets.

[0109] The knowledge retrieval agent filters and sorts the associated code assets, returns the results to the central scheduling agent, updates the process node to "knowledge retrieval completed", and associates the storage requirement specification description with the corresponding associated code assets.

[0110] The entire retrieval process is closely integrated with the platform and functional context of the current requirements, ensuring that the returned "specifications" and "templates" are highly relevant to the current task and avoiding interference from irrelevant knowledge. By mapping requirements to queries for specific entities and relationships in the graph, the fuzzy search that originally required keyword matching is transformed into a precise search based on explicit logic, significantly improving the accuracy and efficiency of the retrieval. The returned "related code assets" are the core input for constructing prompts for the subsequent code generation agent, and their quality directly determines the performance of the final generated code in terms of specification compliance, context adaptability, and practical usability.

[0111] In some possible implementations, the code generation agent generates target code based on a large language model.

[0112] Figure 3 A flowchart illustrating one implementation method for generating target code based on a large language model is shown, such as... Figure 3 As shown, the following steps may be included: S310. Construct prompt information. The prompt information integrates the associated code assets returned from the knowledge retrieval agent, as well as the function definition and target platform identifier generated based on the requirement specification description.

[0113] The prompts are carefully crafted input text designed to guide the large language model in generating specific code. They are a structured context package that integrates diverse information such as task descriptions, constraints, and reference examples.

[0114] The function definition is the core description of "what to do" extracted from the "requirements specification". It is usually a verb-object phrase or a specific pattern name, such as "create FeatureToggle configuration class" or "implement user pagination query interface".

[0115] The target platform identifier is an identifier extracted from the "requirements specification" that explicitly specifies the code's runtime environment or technology stack.

[0116] Large language models refer to pre-trained deep learning models that have been trained on large amounts of code and text, possessing powerful code understanding and generation capabilities, such as GPT-4, Claude, and CodeLlama. This invention interacts with these models through their APIs.

[0117] S320. Input the prompt information into the large language model and obtain the initial code generated by the large language model.

[0118] The initial code refers to the original code output generated directly by the large language model based on the prompt information, without subsequent verification and processing by this system.

[0119] Once the code generation agent receives the "requirement specification" and "associated code assets" from the central scheduling agent, it performs the following operations: The functional definitions and target platform identifiers are extracted from the "Requirements Specification Description".

[0120] Extract key code templates and specification points from "Associated Code Assets".

[0121] Organize the above information into a coherent and clear prompt text, following a predefined template. A simplified template example is as follows: You are a senior {target platform identifier} development engineer. Please strictly follow the requirements below to generate code.

[0122] Task: {Function Definition} Rules that must be followed: 1. {Normative Point 1 extracted from assets} 2. {Normative points 2 extracted from assets} Reference example: {Target Platform Identifier} {Example code snippet extracted from assets} Please generate complete, compileable code.

[0123] The constructed prompt message is sent to the configured large language model API endpoint. The text response returned by the API is received; this response is the generated initial code.

[0124] By using structured prompts, vague natural language requirements are transformed into machine-readable instructions containing specific context, constraints, and examples, significantly improving the accuracy and relevance of code generated by large language models. Prompts are the core carrier for the "associative code assets" to function. By embedding knowledge such as specifications and templates into the prompts, the generated "initial code" can maintain consistency with existing enterprise practices in terms of architectural style, coding standards, and business logic, solving the problem of uncontrollable code quality generated by general AI tools.

[0125] In some possible implementations, associated code assets include code templates, development specifications, and configuration examples; The notification message also includes at least one of the following elements: Development specifications extracted from associated code assets and marked as mandatory constraints; Code templates extracted from associated code assets and validated by enterprise practices; Typical error patterns or avoidance guidelines based on a historical problem database and relevant to the current task scenario.

[0126] Mandatory constraints refer to rules extracted from enterprise development specifications that must be followed unconditionally. They typically involve security, performance, core architecture, or team agreements, and are marked with strong words such as "must," "prohibited," or "absolutely required" in the warning message, such as "Do not connect to the database in a loop."

[0127] A code template validated by enterprise practice refers to a structured code snippet or document framework that has been verified through multiple projects within an enterprise and is recognized as a best practice. It is not only syntactically correct, but also the "gold standard" that conforms to the specific business context and technology selection of the enterprise.

[0128] Typical error patterns and avoidance guidelines are common error types and their prevention or correction methods summarized based on historical code review records, online defect analysis, and other data. For example, "Update UI in asynchronous callback without switching back to the main thread".

[0129] In some possible implementations, mandatory constraints are automatically identified and extracted by parsing the title, emphasis formatting (such as bold, red highlighting), or predefined tags of the specification document.

[0130] Validated templates retrieve their content directly from the "Code Template Entity".

[0131] Error patterns are retrieved from a separate "Error Pattern Knowledge Base" based on the functional keywords of the current task.

[0132] Insert these elements into the relevant sections of the prompts in a structured manner. For example, list mandatory constraints in the "Required Standards" section; paste template code in the "Reference Examples" section; and add a new "Notes" section at the end to list error patterns and avoidance guidelines.

[0133] By proactively highlighting "mandatory constraints" and "common errors," the model can avoid known pitfalls during the generation process, reducing security vulnerabilities and logical flaws at the source. Using validated templates as direct references guides the model to automatically align with enterprise best practices in design patterns and code structure, which not only reduces code maintenance costs but also significantly improves code quality.

[0134] In some possible implementations, the prompts may also include code formatting specifications, integrity requirements, etc., for checking and verifying the code generated from the large model. For example, based on the formatting specifications, analysis tools can check the code's syntax correctness, style consistency, and compliance with specific rules without running the code.

[0135] In some possible implementations, the code generation agent supports multiple large language models and can be flexibly switched according to the characteristics of the task.

[0136] Figure 4 The flowchart illustrates one implementation of selecting a large language model to generate target code, such as... Figure 4 As shown, the following steps may be included: S410. Select the target large language model from multiple pre-configured large language models based on the complexity of the target platform identifier and / or function definition.

[0137] Among these, the target large language model is the optimal or most suitable model instance selected from multiple available models for the current specific code generation task.

[0138] In some possible implementations, the code-generating agent pre-sets model selection rules and makes dynamic decisions based on task characteristics: Choose based on functional complexity: When the functional definition contains complex business logic (such as multi-condition branching, distributed transactions, and high-concurrency processing), prioritize the large language model with strong logical consistency; when the functional is a simple configuration class with high repetition (such as basic parameter configuration), choose the large language model with low cost and high speed. Based on the target platform: For complex interface development, prioritize large language models that generate high-quality code; for simple component development, prioritize large language models with good cross-platform compatibility; for large-scale configuration requirements (such as batch generation of cloud-controlled switch code), prioritize large language models that are efficient and low-cost.

[0139] S420: Call the application programming interface of the target large language model and pass in the prompt information adjusted according to the characteristics of the target model's large language.

[0140] Application programming interfaces (APIs) refer to standardized network interfaces provided by large language model service providers for calling models.

[0141] Adjust the parameter format and content details of the prompt messages according to the characteristics of different large language models: Context length adaptation: If the target model supports long contexts, retain the complete code template and specification clauses; if it does not support long contexts, simplify the core logic of the template and extract the specification keywords; for more specialized large language models, more rigorous technical language should be used; for large language models with a wide range of applications, the expression can be appropriately simplified, highlighting the functions and constraints. In some possible implementations, it is possible to uniformly require the large language model to begin with "language type", such as "java [code content]", to facilitate the automatic extraction of code snippets later.

[0142] By dynamically selecting models based on task characteristics, it is possible to ensure the quality of complex task generation while using more economical models for simple tasks, thus achieving optimal resource allocation.

[0143] In some possible implementations, the calling parameters of multiple pre-configured large language models are managed through a unified model configuration file; the model configuration file defines at least the application programming interface key, context length, and temperature parameters for each large language model.

[0144] The model configuration file is a centralized, non-code configuration file (such as YAML, JSON, or environment variables) used to uniformly manage the connection parameters, performance parameters, and business rules of all available large language models. All sensitive information in the configuration file (such as API keys) is stored encrypted and dynamically retrieved by the decryption module when the code-generated agent invokes the system, ensuring information security.

[0145] Context length is the maximum text length limit that a large language model can process, which directly affects the completeness of the prompt information and the complexity of code generation.

[0146] Temperature is a parameter that controls the randomness of the generated results of large language models. The lower the value, the more stable and controllable the generated results; the higher the value, the more creative the results.

[0147] During system initialization, the code generation agent automatically loads the model configuration file, parses and caches all model parameter information, and generates a "model name - parameter" mapping table. The configuration file supports hot updates; modifications do not require a system restart. The code generation agent checks for configuration file changes every 30 seconds, and if updates are found, it automatically reloads the cache to ensure parameters take effect in real time.

[0148] When a model needs to be invoked, the code generation agent quickly retrieves the corresponding API key, context length, and other parameters from the mapping table based on the selected target model name, without having to repeatedly parse the configuration file.

[0149] The code generation agent calls the API of the target large language model via HTTP / HTTPS protocol, passing in the following core parameters: Authentication parameters: API key (read from the model configuration file); Core input parameters: Adjusted prompt message; Generation control parameters: temperature parameter, maximum number of tokens generated; After the call, receive the JSON format response returned by the model, parse the fields to obtain the code content, i.e., the target code.

[0150] By centrally managing sensitive API keys and volatile model parameters in a configuration file and decoupling them from business logic, configuration and logic are separated. When it is necessary to change models, upgrade APIs, or adjust parameters, there is no need to modify and redeploy code; only the configuration file needs to be updated, significantly improving operational efficiency and security.

[0151] In some possible implementations, the code generation agent supports dynamically switching the selected target large language model at runtime based on updates to the model configuration file or a preset load balancing strategy.

[0152] Among them, runtime dynamic switching automatically changes the currently used large language model based on preset conditions without stopping the system, without requiring manual service restart.

[0153] Load balancing strategies are rules used to distribute the call pressure of multiple large language models, such as "distribute tasks according to the current concurrency of the model" to avoid overloading a single model.

[0154] In some possible implementations, when an administrator modifies the model configuration file (such as adding a new model, updating the API key, or adjusting the applicable scenarios), the code generation agent detects the configuration change and automatically triggers the dynamic switching logic.

[0155] Alternatively, the system can monitor the call status (concurrency, response time, success rate) of each pre-configured model in real time. When the concurrency of a certain model exceeds the threshold or the response time exceeds the preset time, the load balancing strategy is triggered to allocate new tasks to the model with the lower current load.

[0156] Alternatively, if the target model fails to be called multiple times in a row (e.g., API key expires, service is unavailable), the code generation agent will automatically select a backup model from the list of models that are suitable for the current task.

[0157] The execution flow of dynamic switching may include the following steps: 1. The code generation agent monitors the model call status and configuration file changes in real time. Once the switching condition is triggered, the current model call task is immediately paused. 2. Based on the task's functional definition and target platform identifier, select candidate backup models from the "Adapted Platform" and "Applicable Scenarios" fields in the model configuration file, and sort them by "Load from Low to High"; 3. Extract parameter information of candidate models (such as API keys, temperature parameters, etc.) and update the current call context synchronously (such as incomplete prompts and task progress). 4. Re-initiate the call using the parameters of the backup model to ensure seamless task continuity without manual intervention; 5. Record the switching process (triggering conditions, original model, target model, switching time) to facilitate subsequent operation and maintenance analysis.

[0158] Through the above process, when a large language model service becomes unavailable due to temporary failures, network fluctuations, or quota exhaustion, the system can automatically switch to a backup model, ensuring the continuous availability of the code generation service and achieving "degradation without interruption." Simultaneously, model resources can be dynamically allocated based on task load, avoiding situations where some models are idle while others are overloaded, thus improving the overall utilization efficiency and scheduling flexibility of model resources.

[0159] In some possible implementations, after obtaining the initial code generated by the large language model, it is also necessary to perform static syntax checks and specification compliance verification on the initial code.

[0160] Static syntax checking involves using code checking tools to validate the syntax rules of the initial code, detecting syntax errors, code redundancy, and potential syntax risks.

[0161] Specification compliance verification involves comparing the initial code with the associated specification entities in the knowledge graph to check whether it conforms to the enterprise's development specifications (such as naming conventions, code structure specifications, and security specifications).

[0162] Specifically, after obtaining the "initial code," the code generation agent uses customized analysis tools to perform specification compliance checks to verify whether the code conforms to the "mandatory constraints" retrieved from the knowledge graph. It then calls tools such as Lint to perform static analysis on the initial code, detecting code redundancy, potential performance issues, and security vulnerabilities. If the requirements specification includes functional verification standards, it performs automated functional testing based on those standards to verify the functional compliance of the initial code. Verification is considered successful only when syntax checking, specification compliance verification, static analysis, and functional testing all pass.

[0163] If the verification passes, the process ends and the final code, i.e., the target code, is output.

[0164] If the verification fails, the error diagnosis report generated by the verification is used to reconstruct the prompt message, embedding a correction guidance module containing specific error entries and modification requirements into the prompt message, and then calling the large language model again to generate correction code.

[0165] The error diagnosis report is a structured report generated after static syntax checking and specification compliance verification. It contains core information such as error type, error location, error description, and modification suggestions.

[0166] The correction guidance module is a precise correction instruction embedded in the post-reconstruction prompts, targeting the error diagnosis report. It clearly informs the large language model of the error items that need to be modified and the specific requirements.

[0167] In other words, if verification fails, the code generation agent extracts the core error entries from the error diagnosis report, generates specific correction requirements for each error entry, adds a "Correction Guidance Module" to the original prompt information, embeds the above correction requirements, and adds the explanation "Please optimize the initial code based on the following error correction requirements to ensure that there are no syntax errors and that it conforms to all specifications." The refactored prompt information is then re-entered into the target large language model, triggering the code correction process, generating corrected code, and performing static syntax checks and specification compliance verification on the corrected code again. If errors still exist, the above process is repeated until verification passes, and the final target code is output.

[0168] If the error still fails to meet the requirements after multiple corrections, a manual intervention notification can be triggered, pushing an error report to the R&D manager.

[0169] By closely integrating the "generation" capability of large language models with the "verification" capability of static analysis, the system uses the verification results to accurately guide the model to self-correct. Even if the initial generation results of the model are inadequate, the system can continuously optimize through an automated iterative mechanism, significantly improving the reliability and maturity of the final output code, making it reach or approach the level that can be directly merged into the codebase.

[0170] In some possible implementations, at least one code generation agent includes multiple platform-specific agents; the requirement specification description and associated code assets are distributed to at least one code generation agent, including: concurrently distributing the requirement specification description and associated code assets to multiple platform-specific agents to synchronously generate code implementations suitable for different technology platforms.

[0171] Platform-specific agents refer to code generation agents specifically optimized for a particular technology stack or runtime environment. Each such agent deeply embeds the platform's unique coding standards, framework knowledge, best practices, and targeted suggestion strategies for interacting with large language models. For example: AndroidCodeAgent: Proficient in Kotlin / Java syntax, Android SDK, Jetpack components, and mobile-specific constraints.

[0172] IOSCodeAgent: Proficient in Swift syntax, iOS SDK, UIKit / SwiftUI, and Apple review guidelines.

[0173] ServerCodeAgent: May be further subdivided into JavaSpringAgent, GoAgent, etc., proficient in backend API design, database interaction, concurrency processing and microservice architecture.

[0174] When multiple target platforms are specified in the requirements specification, the central scheduling agent issues code generation instructions to multiple platform-specific agents simultaneously within the same processing cycle, rather than executing them sequentially. This is a parallel processing mode.

[0175] The central scheduling agent, based on the target platform identifier list, searches for and activates the corresponding platform-specific agent instance in the registry. It then copies the same requirement specification and associated code assets multiple times and sends them to all relevant platform-specific agents almost simultaneously via asynchronous messaging. This process does not wait for any single agent to complete, thus achieving concurrent distribution.

[0176] After receiving the task data, each platform-specific agent independently and simultaneously runs its internal generation process (as described above). Each agent uses its platform-specific prompt word templates and model configurations to generate code implementations adapted to its platform.

[0177] After each platform-specific agent completes its generation, it asynchronously returns the results (code files and possible metadata) to the central scheduling agent. The central scheduling agent collects all results and combines them into a project structure containing multi-platform code.

[0178] Although the distribution is concurrent, the core meaning of "synchronization" here refers to driving multiple agents to work in parallel for the same requirement specification description and associated code assets, ultimately producing a set of code implementations that are consistent in business logic, match interfaces, and are cross-platform.

[0179] By "distributing" the data, the multi-platform adaptation work, which originally required a sequential process, is transformed into an automated process executed in parallel by multiple platform-specific intelligent agents, significantly improving development efficiency. Simultaneously, since all platform intelligent agents are generated based on the same authoritative requirements specification and knowledge assets, issues such as logical inconsistencies and API mismatches caused by inconsistent understanding, communication deviations, or asynchronous implementation paces are eliminated at the source, greatly improving product quality and integration efficiency. When supporting a new platform, only a new "platform-specific intelligent agent" needs to be developed and registered, without modifying the core collaboration process. This makes the method provided in this disclosure particularly suitable for requirements such as configuration changes, function switches, and basic data models that require multi-platform synchronization.

[0180] In some possible implementations, after receiving the target code returned by the code generation agent and passing quality verification (the specific verification is completed as described above), the target code is automatically committed to the specified branch of the code repository.

[0181] Specifically, it reads the target code repository address and authentication information (such as deployment keys) specified in the configuration. It executes the `git clone` command in the temporary working directory to completely clone the remote repository to the local machine. Based on the requirement identifiers and feature definitions in the requirement specification, it generates branch names according to preset specifications. In the local repository, it first switches to the main branch, then creates and switches to the new feature branch. If necessary, it creates or modifies specific configuration files in this branch according to templates or rules.

[0182] Write the verified target code to the corresponding directory in the local repository according to the project structure requirements. Generate commit messages according to the standardized template and push the local branch to the remote code repository.

[0183] Construct an HTTP request to call the code review platform's API. The request includes: the source branch (feature branch), the target branch (main branch), the title, the description (an automatically generated detailed description including a link to the requirement card), and a list of assigned reviewers. The list of reviewers can be automatically determined based on the "Responsible Person" field in the requirement specification description, the "Code Owner" rule in the code path, or a preset list. After a successful API call, the platform returns a merge request link (i.e., a code change link).

[0184] Generate rich text notification messages based on the template. The content typically includes: notification title: such as "New code review is ready"; key information: requirement identifier, feature summary, submitter (system account); important links: code change link (merge request URL) and requirement details link (requirement card URL); reviewers: @mention the relevant reviewers.

[0185] Call the API provided by the enterprise communication tool to send the above message to the specified group or channel, so that relevant personnel can review the code on the code review platform and merge it into the main branch after confirming the code quality.

[0186] In some possible implementations, the knowledge graph is continuously updated and the prompts are optimized based on code review feedback and actual usage results to improve the generation quality.

[0187] Figure 5 This diagram illustrates a process for continuously updating the knowledge graph and optimizing prompts based on code review feedback and actual usage. Figure 5 As shown, the following steps may be included: S510. Collect code review comments on the generated and submitted target code, and / or data on the actual usage effect of the target code in the runtime environment as feedback data.

[0188] Code review comments refer to the modification suggestions, approval conclusions, or discussion content raised by reviewers on the code review platform regarding the code automatically generated and submitted by the system. This represents the quality feedback of the generated code at the "design / implementation level."

[0189] Actual usage performance data refers to runtime metrics, logs, and business data collected by a monitoring system after the generated code is deployed to a runtime environment (such as a test environment or production environment). This is the quality feedback of the generated code at the "runtime / value level," including but not limited to: Performance metrics: API response time, memory usage, and error rate.

[0190] Business metrics: the effectiveness of function switches and the effect of configuration parameter adjustments.

[0191] Stability data: Whether new crashes or anomalies have been introduced.

[0192] In some possible implementations, a merge request event is subscribed to from a code review platform. When the event is triggered, the collector parses the event payload and extracts information such as the merge request ID, comment content, review result (approval / rejection), and reviewer. The feedback is then precisely linked back to the original "requirement specification description" and the generation task through the requirement identifier embedded in the merge request title or description.

[0193] Unstructured comments undergo keyword extraction and sentiment analysis (simple analysis such as "good", "needs modification", "there is a bug here"), are transformed into structured records, and stored in the feedback database.

[0194] Configure a log aggregation system or application performance monitoring system to tag the deployed generated code and predefine key monitoring metrics for different types of generated code. For example, monitor the loading success rate and parameter reading frequency of generated "configuration classes"; monitor the call volume and latency of generated "API interfaces". Periodically (e.g., hourly), pull relevant metric data from the monitoring system, compare it with the baseline, identify performance regressions, abnormal fluctuations, or business value achievement, and obtain data on actual usage effects.

[0195] S520. Update the knowledge graph based on the success patterns or common problems identified in the feedback data.

[0196] The core logic of updating knowledge graphs is to learn patterns from successes and draw lessons from problems.

[0197] When generated code receives high praise during review (e.g., a comment like "perfect implementation") or performs exceptionally well in actual operation, locate the "code template entity" and "associated code assets" used to generate the code. Improve the confidence score or usage frequency attribute of the "code template entity" to rank it higher in future searches. Alternatively, link the successful "code file entity" to its source "code template entity" as a success story.

[0198] If a success pattern is universal, it can be abstracted into a new "configuration example" entity or "code template snippet" entity and added to the knowledge graph.

[0199] When multiple generation tasks receive similar modification suggestions during code review, or encounter similar errors during runtime, cluster analysis can be used to summarize common defect patterns from the feedback data. In the corresponding "standard entity," mandatory rule entries targeting these defects can be explicitly added.

[0200] Under the relevant "Capability Entity" or "Platform Entity," associate it with a newly created "Typical Error Pattern" entity, describing the problem and its fix in detail. If a "Code Template" frequently causes problems, reduce its weight or add a "Needs Optimization" tag.

[0201] S530. Based on feedback data, adjust the strategies or element weights used by the code generation agent when constructing prompt information.

[0202] In some possible implementations, feedback data is analyzed to identify which types of constraints or examples are frequently followed and which are ignored when generating high-quality code. The "emphasis" of different elements in the hint template is dynamically adjusted. For example, if feedback indicates that "mandatory constraints" are frequently ignored by the model, the optimizer will embed these constraints in a more prominent format (e.g., "Required") or by repeating them multiple times when building hints. Conversely, the descriptions of elements that are consistently followed correctly can be simplified.

[0203] Different suggestion strategies (Strategy A and Strategy B) can be used to generate code for similar tasks, and their merits can be judged by subsequent review adoption rates or runtime metrics. The winning strategy and its corresponding model selection, temperature parameters, and other configurations will be recorded and prioritized, forming an evolutionary cycle of "generation—validation—optimization".

[0204] Analyze the final prompts (including iterative revisions) used in generated tasks that received positive feedback, and extract their structural and linguistic features. Update the system's prompt template library with more effective prompt structures for use in subsequent tasks.

[0205] By transforming human review feedback and real-world operational data into training data, the system continuously improves its enterprise-specific performance without retraining the underlying large model. The knowledge graph and suggestion strategies act as the system's "experience" and "methodology," working synergistically and iteratively to continuously refine the system's overall capabilities over time, gradually improving code generation quality.

[0206] In some possible implementations, the central scheduling agent also maintains global execution status and context information, specifically including a unique identifier for the requirement delivery, the execution status of each functional agent (pending execution / in execution / completed / abnormal), the cache address of output data, the identifier of the current process node, and the execution timestamp, ensuring full traceability. When any agent experiences an execution timeout, returns an error response, or fails verification, a retry mechanism is automatically triggered. The retry interval adopts an exponential backoff strategy, and the number of retries strictly does not exceed a preset threshold. If the retry still fails, the current requirement delivery process is immediately suspended, and an abnormal alarm is pushed to the system administrator. In addition to the error type and the identifier of the abnormal agent, the alarm information also includes an abnormal log summary and a quick location link, facilitating the administrator to quickly troubleshoot the problem.

[0207] The following is a simple and specific embodiment to illustrate the code generation method based on multi-agent collaboration provided by this disclosure. Figure 6 A schematic diagram of the process is shown, such as Figure 6 As shown, it may include the following steps: 1. Listen for task requests and obtain requirement cards, which include a requirement description. Upon receiving the requirement card for the task request, the central scheduling agent automatically triggers subsequent processes.

[0208] 2. The requirement parsing agent parses the original requirements, i.e., requirement cards (unstructured text), and extracts key information: function name, cloud control type (switch), applicable platform, expected parameters (such as default switch value, effective version, etc.) to generate a requirement specification description.

[0209] 3. Invoke the knowledge graph, automatically retrieve the corresponding R&D rules and examples from the knowledge graph based on the requirement specification description, and send them to the code generation agent.

[0210] 4. The code generation intelligent agent system automatically generates and pushes target code to the corresponding platform, and developers can directly integrate the generated target code.

[0211] Based on and Figure 1 The method shown follows the same principle. Figure 7 This illustration shows a schematic diagram of the structure of a code generation system based on multi-agent cooperation provided in an embodiment of this disclosure, such as... Figure 7As shown, the code generation system 70 based on multi-agent collaboration may include: A central scheduling agent, a demand analysis agent, a knowledge retrieval agent, and at least one code generation agent; and Interaction interface 710 is used to receive raw requests; The demand processing module 720 is used to send the original demand to the central scheduling agent. The central scheduling agent is configured to run according to a preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the demand parsing agent, the knowledge retrieval agent, and at least one code generation agent. The central scheduling agent responds to the original request and executes according to the main collaboration process: The requirement parsing agent is invoked to perform semantic parsing and structuring processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, the knowledge retrieval agent is invoked to retrieve and return associated code assets from a pre-built knowledge graph; the requirement specification description and the associated code assets are distributed to at least one code generation agent to generate and return target code. The code receiving module 730 is used to receive the target code returned by the code generating agent.

[0212] In the multi-agent collaborative code generation system provided in this disclosure, by assigning specialized agents to the three core stages of requirement analysis, knowledge retrieval, and code generation, and coordinating them serially by a central scheduling agent, a complete automated transformation process from natural language requirements to deliverable code is achieved. This avoids efficiency losses and error risks caused by fragmented processes, improves code generation efficiency, and shortens the code delivery cycle. Requirement analysis ensures the accuracy of intent understanding; knowledge retrieval provides a channel for enterprise-level specifications and quality requirements to intervene in the generation process; and the collaborative division of labor among multiple agents lays the foundation for in-depth optimization of each stage, ensuring that the generated target code strictly adheres to enterprise standards and effectively reduces the probability of syntax errors, specification deviations, and other problems. Compared to the method of directly generating code using a single model, the code generated in this disclosure embodiment is of higher quality.

[0213] In some possible implementations, the code generation agent is used to: construct prompts that integrate associated code assets returned from the knowledge retrieval agent, as well as functional definitions and target platform identifiers generated based on the requirements specification description; input the prompts into a large language model to obtain the initial code generated by the large language model.

[0214] In some possible implementations, associated code assets include code templates, development specifications, and configuration examples; the prompt information also includes at least one of the following elements: development specifications extracted from associated code assets and marked as mandatory constraints; code templates extracted from associated code assets and validated by enterprise practices; and typical error patterns or avoidance guidelines based on a historical issue database and relevant to the current task scenario.

[0215] In some possible implementations, the code generation agent is used to: select a target large language model from multiple pre-configured large language models based on the target platform identifier and / or the complexity of the function definition; call the application programming interface of the target large language model and pass in prompts adjusted according to the large language characteristics of the target model.

[0216] In some possible implementations, the calling parameters of multiple pre-configured large language models are managed through a unified model configuration file; the model configuration file defines at least the application programming interface key, context length, and temperature parameters for each large language model.

[0217] In some possible implementations, the code generation agent supports dynamically switching the selected target large language model at runtime based on updates to the model configuration file or a preset load balancing strategy.

[0218] In some possible implementations, the code generation agent is also used to: perform static syntax checking and specification compliance verification on the initial code; if the verification fails, reconstruct the prompt information based on the error diagnosis report generated by the verification, embed a correction guidance module containing specific error entries and modification requirements in the prompt information, and call the large language model again to generate corrected code.

[0219] In some possible implementations, at least one code generation agent includes multiple platform-specific agents; a central scheduling agent is used to concurrently distribute the requirement specification description and associated code assets to multiple platform-specific agents to synchronously generate code implementations suitable for different technology platforms.

[0220] In some possible implementations, the knowledge graph connects various entities through predefined semantic relationship types; entity types include: business domain entities, platform entities, capability entities, specification entities, and code template entities; semantic relationship types include at least: business hierarchy relationships representing business affiliation, capability platform support relationships, and specification constraint relationships.

[0221] In some possible implementations, the knowledge retrieval agent is used for: entity integrity verification: verifying the required fields, data types, and value ranges of an entity; relation validity verification: verifying whether the relation type is valid and confirming that both the source and target entities connected to it exist; uniqueness constraint verification: ensuring the uniqueness of a specific field in a set of entities of the same type; and circular reference detection: detecting relations with hierarchical or dependent properties to ensure that there are no circular reference paths.

[0222] In some possible implementations, knowledge graphs are built on graph database technology, which is used to persistently store entities, semantic relationships, and their attributes.

[0223] In some possible implementations, the knowledge retrieval agent is used to: perform association retrieval in the knowledge graph based on the target platform identifier and function definition in the requirements specification description, so as to locate and return the specification entities and code template entities associated with the target platform and functions; the set of located entities constitutes the associated code assets.

[0224] In some possible implementations, the system also includes a feedback module for: collecting code review comments on the generated and submitted target code, and / or data on the actual usage effect of the target code in the runtime environment as feedback data; updating the knowledge graph based on success patterns or common problems identified in the feedback data; and adjusting the strategies or element weights used by the code generation agent when constructing prompt information based on the feedback data.

[0225] In some possible implementations, the requirement specification is described as JSON or XML format data that includes requirement identifiers, function definitions, configuration parameters, and target platform information.

[0226] It is understood that the above-mentioned modules of the code generation system based on multi-agent cooperation in the embodiments of this disclosure have implementation... Figure 1 The embodiments shown illustrate the functionality of corresponding steps in the code generation method based on multi-agent collaboration. This functionality can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described functions. These modules can be software and / or hardware, and each module can be implemented individually or integrated from multiple modules. For a detailed description of the functions of each module in the above-described code generation system based on multi-agent collaboration, please refer to [link to relevant documentation]. Figure 1 The corresponding descriptions of the code generation methods based on multi-agent collaboration in the embodiments shown are not repeated here.

[0227] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of users' personal information comply with the provisions of relevant laws and regulations, necessary measures have been taken, and there is no violation of public order and good morals.

[0228] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.

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

[0230] The electronic device includes: 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 the code generation method based on multi-agent cooperation as provided in the embodiments of this disclosure.

[0231] Compared to existing technologies, this electronic device achieves a complete automated transformation process from natural language requirements to deliverable code by assigning dedicated intelligent agents to the three core stages of requirement analysis, knowledge retrieval, and code generation, and coordinating them serially through a central scheduling agent. This avoids efficiency losses and error risks caused by fragmented processes, improves code generation efficiency, and shortens the code delivery cycle. Requirement analysis ensures the accuracy of intent understanding; knowledge retrieval provides a channel for enterprise-level specifications and quality requirements to intervene in the generation process; and the collaborative division of labor among multiple intelligent agents lays the foundation for in-depth optimization of each stage, ensuring that the generated target code strictly adheres to enterprise standards and effectively reduces the probability of syntax errors, specification deviations, and other problems. Compared to methods that directly generate code using a single model, the code generated by this embodiment is of higher quality. The readable storage medium is a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the code generation method based on multi-agent cooperation as provided in the embodiments of this disclosure.

[0232] Compared to existing technologies, this readable storage medium achieves a complete automated transformation process from natural language requirements to deliverable code by assigning dedicated intelligent agents to the three core stages of requirement parsing, knowledge retrieval, and code generation, and coordinating them serially through a central scheduling agent. This avoids efficiency losses and error risks caused by fragmented processes, improves code generation efficiency, and shortens the code delivery cycle. Requirement parsing ensures the accuracy of intent understanding; knowledge retrieval provides a channel for enterprise-level specifications and quality requirements to intervene in the generation process; and the collaborative division of labor among multiple intelligent agents lays the foundation for in-depth optimization of each stage, ensuring that the generated target code strictly adheres to enterprise standards and effectively reduces the probability of syntax errors, specification deviations, and other problems. Compared to methods that directly generate code using a single model, the code generated by this embodiment is of higher quality.

[0233] The computer program product includes a computer program that, when executed by a processor, implements the code generation method based on multi-agent cooperation as provided in the embodiments of this disclosure.

[0234] Compared to existing technologies, this computer program product achieves a complete automated transformation process from natural language requirements to deliverable code by assigning specialized intelligent agents to the three core stages of requirement analysis, knowledge retrieval, and code generation, and coordinating them serially through a central scheduling agent. This avoids efficiency losses and error risks caused by fragmented processes, improves code generation efficiency, and shortens the code delivery cycle. Requirement analysis ensures the accuracy of intent understanding; knowledge retrieval provides a channel for enterprise-level specifications and quality requirements to intervene in the generation process; and the collaborative division of labor among multiple intelligent agents lays the foundation for in-depth optimization of each stage, ensuring that the generated target code strictly adheres to enterprise standards and effectively reduces the probability of syntax errors, specification deviations, and other problems. Compared to methods that directly generate code using a single model, the code generated by this embodiment is of higher quality.

[0235] Figure 8 A schematic block diagram of an example electronic device 800 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.

[0236] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

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

[0238] The computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 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 801 performs the various methods and processes described above, such as a code generation method based on multi-agent cooperation. For example, in some embodiments, the code generation method based on multi-agent cooperation can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the code generation method based on multi-agent cooperation described above can be performed. Alternatively, in other embodiments, computing unit 801 may be configured by any other suitable means (e.g., by means of firmware) to perform a code generation method based on multi-agent cooperation.

[0239] 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 products (ASSPs), systems-on-a-chip (SoCs), payload-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.

[0240] 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.

[0241] 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 (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0242] 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 CRT (cathode ray tube) or LCD (liquid crystal display) monitor); 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).

[0243] 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.

[0244] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0245] 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 disclosed in this disclosure can be achieved, and this is not limited herein.

[0246] 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 multi-agent cooperation, comprising: Receive the original request; The original requirements are sent to the central scheduling agent, which is configured to run according to a preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the requirement parsing agent, the knowledge retrieval agent, and at least one code generation agent. The central scheduling agent responds to the original request and executes according to the main collaboration process: The requirement parsing agent is invoked to perform semantic parsing and structural processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, the knowledge retrieval agent is invoked to retrieve and return associated code assets from the pre-built knowledge graph; The requirement specification description and the associated code assets are distributed to at least one code generation agent to generate and return the target code; Receive the code and generate the target code returned by the intelligent agent.

2. The method according to claim 1, wherein, The code generation agent generates target code, including: Construct a prompt message, which integrates the associated code assets returned from the knowledge retrieval agent, as well as the function definition and target platform identifier generated based on the requirement specification description; Input the prompt information into the large language model to obtain the initial code generated by the large language model.

3. The method according to claim 2, wherein, The associated code assets include code templates, development specifications, and configuration examples; the prompt information also includes at least one of the following elements: Development specifications extracted from the associated code assets and marked as mandatory constraints; Code templates extracted from the associated code assets and validated through enterprise practice; Typical error patterns or avoidance guidelines based on a historical problem database and relevant to the current task scenario.

4. The method according to claim 2, wherein, The step of inputting the prompt information into the large language model includes: Based on the target platform identifier and / or the complexity of the function definition, select a target large language model from multiple pre-configured large language models; Call the application programming interface of the target large language model and pass in the prompt information adjusted according to the large language characteristics of the target model.

5. The method according to claim 4, wherein, The calling parameters of the multiple pre-configured large language models are managed through a unified model configuration file; the model configuration file defines at least the application programming interface key, context length, and temperature parameter for each large language model.

6. The method according to claim 5, wherein, The code generation agent supports dynamically switching the selected target large language model at runtime based on updates to the model configuration file or a preset load balancing strategy.

7. The method according to claim 2, wherein, After obtaining the initial code generated by the large language model, the following is also included: Perform static syntax checking and specification compliance verification on the initial code; If the verification fails, the prompt information is reconstructed based on the error diagnosis report generated by the verification. A correction guidance module containing specific error entries and modification requirements is embedded in the prompt information, and the large language model is called again to generate correction code.

8. The method according to claim 1, wherein, The at least one code generation agent includes multiple platform-specific agents; The step of distributing the requirement specification description and the associated code assets to at least one code generation agent includes: The requirement specification description and associated code assets are concurrently distributed to the multiple platform-specific intelligent agents to synchronously generate code implementations suitable for different technology platforms.

9. The method according to claim 1, wherein, The knowledge graph connects various entities through predefined semantic relationship types; The entity types include: business domain entities, platform entities, capability entities, specification entities, and code template entities; The semantic relationship types include at least: business hierarchy relationships representing business affiliation, capability platform support relationships, and normative constraint relationships.

10. The method according to claim 9, wherein, The data import process for the knowledge graph includes a data quality verification step, which includes at least one of the following operations: Entity integrity verification: Verifies the required fields, data types, and value ranges of an entity; Relationship validity verification: Verify whether the relationship type is valid and confirm that both the source entity and the target entity it connects exist; Uniqueness constraint validation: Ensures the uniqueness of a specific field within a collection of entities of the same type; Circular reference detection: Detects relationships with hierarchical or dependency properties to ensure that there are no circular reference paths.

11. The method according to claim 9, wherein, The knowledge graph is built based on graph database technology, and the graph database is used to persistently store the entities, semantic relationships and their attributes.

12. The method according to claim 9, wherein, The knowledge retrieval agent is configured to perform the following operations: Based on the target platform identifier and function definition in the requirement specification description, an association retrieval is performed in the knowledge graph to locate and return the specification entities and code template entities associated with the target platform and function; the set of located entities constitutes the associated code assets.

13. The method according to claim 1, further comprising: Collect code review comments on the generated and submitted target code, and / or data on the actual usage effect of the target code in the runtime environment as feedback data; The knowledge graph is updated based on the success patterns or common problems identified in the feedback data. Based on the feedback data, the strategy or element weights used by the code-generating agent when constructing prompt information are adjusted.

14. The method according to claim 1, wherein, The requirement specification description includes requirement identifiers, function definitions, configuration parameters, and target platform data in JSON or XML format.

15. A code generation system based on multi-agent cooperation, comprising: The system includes a central scheduling agent, a demand parsing agent, a knowledge retrieval agent, and at least one code generation agent. as well as The interaction interface is used to receive the original requirements; The requirement processing module is used to send the original requirement to the central scheduling agent. The central scheduling agent is configured to run according to a preset main collaboration process. The main collaboration process defines the calling order and data flow relationship between the requirement parsing agent, the knowledge retrieval agent, and at least one code generation agent. The central scheduling agent responds to the original request and executes according to the main collaboration process: The requirement parsing agent is invoked to perform semantic parsing and structural processing on the original requirement, generating and returning a requirement specification description; based on the requirement specification description, the knowledge retrieval agent is invoked to retrieve and return associated code assets from the pre-built knowledge graph; The requirement specification description and the associated code assets are distributed to at least one code generation agent to generate and return the target code; The code receiving module is used to receive the target code returned by the code generating agent.

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-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-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-14.