Code intelligent agent construction system, construction method thereof and code generation method

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

Patent Information

Application Number
CN202511165957.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2026-10-09
Estimated Expiration
2045-08-19

AI Technical Summary

Technical Problem

[0002]当前主流零代码开发平台主要采用三种技术路径:(1)图形化流程配置:通过拖拽组件实现基础逻辑,但复杂业务需大量人工编排;(2)静态模板驱动:依赖预置模板填充参数,缺乏分层架构导致复用性差;(3)端到端大语言模型(Large Language Model,LLM)生成:直接生成代码但需反复调试,存在部署成功率低与人工介入频繁问题

Benefits of technology

[0012] By adopting the scheme disclosed herein, the scenario adaptability and development efficiency of code agents are significantly improved through collaborative reasoning and generation of multi-granularity templates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121168498B_ABST
    Figure CN121168498B_ABST
Patent Text Reader

Abstract

The disclosure provides a code intelligent agent construction system and a construction method and a code generation method thereof, and relates to the technical field of computers, in particular to the technical field of artificial intelligence such as large models. The specific implementation scheme is as follows: the code intelligent agent construction system comprises an intelligent collaboration engine, a hierarchical template library, a semantic understanding and hierarchical retrieval system, a T-RAG generation and optimization system, and a closed-loop verification system; wherein the hierarchical template library comprises a project-level template, a function-level template, and an API-level template; the semantic understanding and hierarchical retrieval system is configured to: generate an intent vector by analyzing user requirements through a natural language understanding module, and sequentially execute three-stage progressive template retrieval of the project level, the function level, and the API level; the T-RAG generation and optimization system is configured to: inject the hierarchical retrieval result into a large language model prompt word to generate deployable code containing front-end and back-end logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to the field of artificial intelligence technology such as large models, specifically to code intelligent agent construction systems and construction methods, code generation methods, devices, electronic devices and computer storage media. Background Technology

[0002] The current mainstream no-code development platforms mainly adopt three technical paths: (1) Graphical process configuration: basic logic is implemented by dragging and dropping components, but complex business requires a lot of manual arrangement; (2) Static template driven: parameters are filled by pre-set templates, and the lack of layered architecture leads to poor reusability; (3) End-to-end large language model (LLM) generation: code is generated directly but repeated debugging is required, resulting in low deployment success rate and frequent manual intervention. Summary of the Invention

[0003] This disclosure provides a code-based intelligent agent construction system and its construction method, code generation method, apparatus, electronic device, and computer storage medium.

[0004] According to a first aspect of this disclosure, a code intelligence agent construction system is provided, comprising: an intelligent collaboration engine, a hierarchical template library, a semantic understanding and hierarchical retrieval system, a template retrieval-augmented generation (T-RAG) generation and optimization system, and a closed-loop verification system; wherein, the intelligent collaboration engine includes planning tools, retrieval tools, development tools, and quality inspection tools, which are connected to form a closed loop through data flow pipelines; the hierarchical template library includes project-level templates, functional-level templates, and application programming interface (API)-level templates; the semantic understanding and hierarchical retrieval system is configured to: parse user requirements through a natural language understanding module to generate intent vectors, and sequentially perform three-level progressive template retrieval at the project level, functional level, and API level; the T-RAG generation and optimization system is configured to: inject hierarchical retrieval results into prompt words of a large language model to generate deployable code containing front-end and back-end logic; the closed-loop verification system is configured to: perform static structure verification and dynamic behavior simulation in a sandbox environment, and trigger the evolution and update of the template library and the weight optimization of the retrieval strategy based on verification error logs.

[0005] According to a second aspect of this disclosure, a method for constructing a code-based intelligent agent is provided, comprising: responding to user needs, parsing natural language text input by the user, and generating an intent vector and a context dependency graph; sequentially performing a three-level progressive template retrieval at the project level, function level, and API level; wherein, the project-level retrieval includes: matching a project blueprint based on the cosine similarity of the intent vector; the function-level retrieval includes: filtering function templates based on the context dependency graph; the API-level retrieval includes: verifying parameter structure compatibility; constructing enhanced prompt words with template constraints based on the hierarchical retrieval results; calling a large language model to generate deployable code; performing static structure verification and dynamic user interface behavior simulation on the deployable code in a sandbox environment to obtain a verification error log; updating the template library based on the verification error log, and optimizing the semantic ranking coefficient of the retrieval strategy.

[0006] According to a third aspect of this disclosure, a code generation method based on a code intelligence construction system is provided, comprising: generating enhanced prompt words by integrating cross-framework dependency constraint rules and pre-set exception handling examples based on hierarchical retrieval results from a semantic understanding and hierarchical retrieval system; inputting the enhanced prompt words into a large language model to generate original code; performing reference chain completion based on topological sorting on the original code through a dependency parser in a T-RAG generation and optimization system to output a code package that can be directly deployed; and inputting the code package into a closed-loop verification system, so that the closed-loop verification system can dynamically adjust the construction strategy of the enhanced prompt words based on verification error logs.

[0007] According to a fourth aspect of this disclosure, a code agent construction apparatus is provided, comprising: a vector generation module for responding to user needs by parsing natural language text input by the user and generating an intent vector and a context dependency graph; a progressive retrieval module for sequentially performing three-level progressive template retrieval at the project level, function level, and API level; wherein, the project-level retrieval includes: matching project blueprints based on the cosine similarity of the intent vector; the function-level retrieval includes: filtering function templates based on the context dependency graph; and the API-level retrieval includes: verifying parameter structure compatibility; a code generation module for constructing enhanced prompt words with template constraints based on the hierarchical retrieval results; and calling a large language model to generate deployable code; a dual-state verification module for performing static structure verification and dynamic user interface behavior simulation on the deployable code in a sandbox environment to obtain verification error logs; a template library update module for updating the template library based on the verification error logs; and a retrieval strategy optimization module for optimizing the semantic ranking coefficient of the retrieval strategy based on the verification error logs.

[0008] According to the fifth aspect of this disclosure, a code generation apparatus based on a code intelligence agent construction system is provided, comprising: a prompt word generation module, used to generate enhanced prompt words based on the hierarchical retrieval results of a semantic understanding and hierarchical retrieval system, integrating cross-framework dependency constraint rules and pre-set exception handling examples; a raw code generation module, used to input the enhanced prompt words into a large language model to generate raw code; a code package generation module, used to perform reference chain completion based on topological sorting on the raw code through a dependency parser in a T-RAG generation and optimization system, and output a code package that can be directly deployed; and a code verification module, used to input the code package into a closed-loop verification system, so that the closed-loop verification system can dynamically adjust the construction strategy of the enhanced prompt words based on verification error logs.

[0009] According to a sixth aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform any of the methods described in the embodiments of this disclosure.

[0010] According to a seventh aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform any of the methods according to embodiments of this disclosure.

[0011] According to an eighth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements any of the methods according to embodiments of this disclosure.

[0012] By adopting the scheme disclosed herein, the scenario adaptability and development efficiency of code agents are significantly improved through collaborative reasoning and generation of multi-granularity templates.

[0013] 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

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

[0015] Figure 1 This is a schematic diagram of the structure of a code-based intelligent agent construction system according to an embodiment of the present disclosure;

[0016] Figure 2 This is another structural schematic diagram of a code-based intelligent agent construction system according to embodiments of the present disclosure;

[0017] Figure 3This is a schematic diagram of the architecture of a zero-code framework according to an embodiment of the present disclosure;

[0018] Figure 4 This is a flowchart illustrating a code-based intelligent agent construction method according to an embodiment of the present disclosure;

[0019] Figure 5 This is a flowchart illustrating a code generation method for a code-based intelligent agent construction system according to an embodiment of the present disclosure;

[0020] Figure 6 This is a flowchart generated from code based on an embodiment of the present disclosure;

[0021] Figure 7 This is a schematic diagram of the structure of a code-based intelligent agent construction apparatus according to an embodiment of the present disclosure;

[0022] Figure 8 This is a schematic diagram of the structure of a code generation device for a code-based intelligent agent construction system according to an embodiment of the present disclosure;

[0023] Figure 9 This is a structural diagram of an electronic device used to implement the code agent construction method and / or the code generation method based on the code agent construction system of the present disclosure embodiments. Detailed Implementation

[0024] 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 of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0025] In this document, the term "and / or" merely describes the relationship between related objects, indicating that three relationships can exist. For example, E and / or F can represent three cases: E alone, E and F simultaneously, and F alone. The term "at least one" in this document indicates any combination of at least two of a plurality of elements. For example, including at least one of E, F, and G can mean including any one or more elements selected from the set consisting of E, F, and G. The terms "first" and "second" in this document refer to and distinguish between multiple similar technical terms, not to restrict the order or to limit there to only two. For example, "first feature" and "second feature" refer to two categories / two features; the first feature can be one or more, and the second feature can also be one or more.

[0026] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.

[0027] Before introducing the technical solutions of the embodiments of this disclosure, the technical terms that may be used in this disclosure will be further explained:

[0028] No-Code Development Platform: A technology platform that allows users to build software applications through a visual interface and configurable operations without writing traditional programming code.

[0029] Current mainstream no-code development platform technologies suffer from three major drawbacks: rigid template systems: single-layer templates cannot adapt to multi-granularity business scenarios, leading to the failure of complex logic combinations; low generation efficiency: graphical configuration takes an average of 3.5 hours per functional module, and LLM generation requires 2.8 manual corrections per module; and intelligent gaps: key links (such as interface compatibility verification) still rely on developer experience, which violates the core value of no-code.

[0030] To at least partially address one or more of the aforementioned problems and other potential issues, this disclosure proposes a code intelligence agent construction system. By integrating a three-level dynamic template layering mechanism, template-driven retrieval-enhanced generation, and a closed-loop feedback self-optimization system, it achieves near-zero human intervention in the automated development of complex applications, improving code generation efficiency. This disclosed solution is particularly suitable for: agile development and business iteration of mobile applications (APPs), enabling minute-level response to requirement changes; automated construction of cross-platform software systems, supporting collaborative generation across different operating systems; and zero-code implementation of complex enterprise-level business logic, covering highly complex scenarios such as e-commerce transactions, intelligent customer service, and financial risk control.

[0031] This disclosure provides a code-based intelligent agent construction system, such as... Figure 1As shown, the code intelligence agent construction system may include: an intelligent collaboration engine 101, a hierarchical template library 102, a semantic understanding and hierarchical retrieval system 103, a T-RAG generation and optimization system 104, and a closed-loop verification system 105. The intelligent collaboration engine 101 includes planning tools, retrieval tools, development tools, and quality control tools, which are connected via data flow pipelines to form a closed loop. The hierarchical template library 102 contains a three-layer storage structure of project-level templates, functional-level templates, and API-level templates. The semantic understanding and hierarchical retrieval system 103 is configured to: parse user needs through a natural language understanding module to generate intent vectors, and sequentially execute three-level progressive template retrieval at the project, functional, and API levels. The T-RAG generation and optimization system 104 is configured to: inject hierarchical retrieval results into large language model prompts to generate deployable code containing front-end and back-end logic. The closed-loop verification system 105 is configured to: perform static structure verification and dynamic behavior simulation in a sandbox environment, and trigger the evolution and update of the template library and the weight optimization of the retrieval strategy based on verification error logs.

[0032] In this embodiment of the disclosure, a project-level template refers to a digital asset with a pre-built system architecture blueprint, defining the overall framework of the application. For example, an e-commerce platform template includes a front-end framework and a back-end database structure.

[0033] In this embodiment of the disclosure, a functional-level template refers to a reusable unit that encapsulates independent functional modules, including interface specifications and a state machine. For example, a user login template includes a mobile phone number verification interface, an authentication state machine, and a failure lockout strategy.

[0034] In this embodiment of the disclosure, an API-level template refers to an external service encapsulation based on a service interface description specification, defining parameter structures and exception handling. For example, a payment template includes transaction amount parameters, asynchronous notification callbacks, and a timeout exception code mapping table.

[0035] In this embodiment, the three-level progressive retrieval refers to a hierarchical semantic matching mechanism: progressive filtering from item to function to API. For example, 1. Match the "e-commerce platform" blueprint; 2. Filter the "shopping cart" function; 3. Bind the "payment" API.

[0036] In this embodiment of the disclosure, the intent vector refers to a multi-dimensional floating-point array encoded by a context-aware semantic encoder for natural language requirements, representing semantic features. For example, the requirement "User registration requires SMS verification" → vector [-0.23, 0.76, ..., 0.18].

[0037] In this embodiment of the disclosure, T-RAG generation refers to a template-enhanced retrieval generation technology: injecting hierarchical templates into LLM prompt word guidance code generation. For example, the prompt words include: "Payment gateway architecture compliant with PaymentCardIndustry Data Security Standard (PCI-DSS)" (project-level template) + "Token authentication using the Spring Security framework" (functional template) + "Payment Software Development Kit" (API template).

[0038] In this embodiment of the disclosure, the closed-loop verification system refers to a sandbox-based automated testing-feedback optimization joint system. Exemplarily, it executes: interface static analysis → containerized deployment → user interface (UI) automated testing → error log feedback.

[0039] Taking the e-commerce order module generation example, the user requirement is: "Automatically send an SMS notification after the user makes a payment." Implementation process: Project-level search → Match "e-commerce platform" blueprint; Function-level search → Bind "payment callback" template; API-level search → Integrate "cloud SMS API".

[0040] The code agent construction system in this embodiment dynamically combines project-level, function-level, and API-level templates. Hierarchical retrieval decouples system complexity and improves template reusability. The T-RAG generation and optimization system injects hierarchical retrieval results into LLM prompts and uses template constraints to suppress unfounded LLM generation, ensuring consistency between the front-end and back-end logic chains and thus improving code generation pass rate. The closed-loop verification system drives dynamic and static dual-state verification and self-optimization, and utilizes a sandbox verification-template evolution closed loop to shorten the response time to requirements.

[0041] In some embodiments, the planning tool is configured to: dynamically reconstruct task execution paths through a reflexive mechanism, which includes a subtask priority reordering module and an abnormal path rollback trigger; the retrieval tool has a built-in template association graph engine that calculates the dependency weights between functional templates and API templates in real time; the development tool is configured to integrate user requirements, retrieval results, and predefined rules to output modular and directly deployable code. The quality inspection tool integrates at least the following components: a static analyzer configured to perform syntax checking and interface definition verification; an automated testing engine configured to simulate UI interaction behavior; and a security module configured to perform dependency vulnerability scanning.

[0042] In this embodiment of the disclosure, the reflection mechanism is a dynamic decision-making system based on runtime feedback. For example, when the payment module malfunctions, it automatically degrades to balance payment and triggers an alarm.

[0043] In this embodiment, the priority reordering module is an algorithmic component that dynamically adjusts the execution sequence based on task urgency. For example, in an e-commerce order scenario: payment task priority > logistics query task.

[0044] In this embodiment of the disclosure, the abnormal path fallback trigger refers to a fault-tolerant device that automatically switches the execution path under preset abnormal conditions. For example, API call timeout → automatic switching to a backup service provider (first payment method → ​​second payment method).

[0045] In this embodiment of the disclosure, the template association graph engine is a graph neural network model that calculates the dependency relationships between functional templates and API templates. For example, a dependency chain of [User Login]-[Payment Function]-[SMS API] is constructed with a weight of 0.82.

[0046] In this embodiment of the disclosure, the modular deployable code is a complete delivery package that conforms to the continuous integration standard.

[0047] In this embodiment of the disclosure, the interface definition verification is a syntax compliance check based on the service interface description specification.

[0048] In this embodiment of the disclosure, UI interaction behavior simulation refers to the technique of simulating user operations through automated scripts. For example, a cross-platform web page automation testing tool (such as Selenium WebDriver) is used to perform sandbox testing: simulating user operations and verifying interface rendering results; capturing API response exceptions and generating error logs.

[0049] In some implementations, the priority reordering module is used to: 1. collect task characteristics: latency sensitivity / resource consumption; 2. calculate priority scores; 3. refresh the task queue in real time.

[0050] In some implementations, the abnormal path fallback trigger is used to: 1. preset abnormal rules: timeout / error code; 2. maintain an alternative path mapping table; 3. generate a security detection log when triggering path switching.

[0051] In some implementations, the template association graph engine is used to: 1. construct a template knowledge graph: vertex = template, edge = dependency; 2. calculate dependency weights; 3. update the graph in real time.

[0052] In some implementations, the static analyzer is used to: analyze based on the Abstract Syntax Tree (AST): interface parameter compliance; cross-module call chain integrity; exception handling coverage.

[0053] In some implementations, UI interaction behavior simulation includes: 1. Recording user operation sequences → converting them into scripts; 2. Injecting abnormal events: network jitter / invalid input; 3. Verifying the consistency of interface response.

[0054] In some implementations, a security module is used to dynamically detect security risks in the generated code. The security module includes: 1. Common Vulnerabilities and Exposures (CVE) database matching; 2. Dependency license scanning; 3. Sensitive information disclosure detection (regular expression matching).

[0055] The technical solutions of this disclosure can improve the success rate of task execution through the reordering module; improve the speed of exception recovery through the exception path rollback trigger; improve the accuracy of dependency management through the graph engine; and improve code reliability through three-layer quality inspection.

[0056] In some embodiments, the three-level progressive template retrieval includes: project-level coarse inspection: based on the cosine similarity calculation of intent vectors, the top K (Top-K) project blueprints are selected, where K is a positive integer; function-level fine inspection: the dependency inference engine is invoked to parse the data flow logic relationship between function templates; and API-level fine matching: parameter structure compatibility verification and anomaly capture strategy matching are performed.

[0057] In this embodiment of the disclosure, the intent vector can be a fixed-dimensional numerical representation of user needs generated by natural language processing.

[0058] In this embodiment of the disclosure, cosine similarity calculation is a mathematical method for measuring the similarity of the angle between two vectors in space.

[0059] In this embodiment of the disclosure, the dependency inference engine is a computational module based on graph neural network analysis of the logical relationships between functional templates. For example, it is deduced that the "payment function" must depend on the "user authentication" template (dependency weight = 0.93).

[0060] In this embodiment of the disclosure, the data flow logical association is the transmission relationship of input and output parameters between functional modules. For example, the output of the user login template → the input of the payment template.

[0061] In this embodiment of the disclosure, exception capture strategy matching is used to verify whether the exception handling mechanism preset in the API template covers the required scenario.

[0062] In some implementations, project-level coarse checking includes: 1. calculating the Sim_{cos} of the requirement vector and all project template vectors; 2. selecting the top-3 candidates; 3. caching candidate blueprint metadata.

[0063] In some implementations, functional-level fine-tuning includes: 1. constructing a requirement-functional dependency graph; 2. using a graph neural network (GNN) to calculate the structural similarity between the user requirement graph and the template library graph. Specifically, the GNN is configured to: encode functional modules and their data flow relationships into graph embedding vectors; filter matching templates based on the similarity of the embedding vectors; 3. filter functional templates with a similarity > 0.7.

[0064] In some implementations, API-level fine-tuning includes: 1. Extracting the requirement parameter structure {name, type, range}, where name represents the unique identifier of the parameter and is used for naming code variables; type represents the data type specification of the parameter; range represents the valid value range or enumeration set of the parameter; 2. Verifying compatibility with the API template: type consistency; range inclusion (requirement max = 100 ≤ template max = 200); 3. Verifying exception policy coverage.

[0065] The technical solutions of this disclosure, through hierarchical retrieval, can not only improve retrieval accuracy but also improve parameter compatibility coverage; through automatic matching of abnormal strategies, they can improve the abnormal strategy matching rate.

[0066] In some embodiments, functional-level fine-tuning is implemented by a dependency inference engine and an anomaly-tolerant matcher.

[0067] Among them, the dependency reasoning engine constructs a functional template dependency graph, where vertices represent functional modules and edges represent data flow relationships.

[0068] Among them, the anomaly-tolerant matcher enables a fuzzy matching algorithm for missing parameters.

[0069] In this embodiment of the disclosure, the functional template dependency graph is a knowledge representation model that uses a directed graph structure to represent the data flow dependencies between functional modules. For example, vertex V: ["User Login", "Payment", "Order Generation"]; edge E: ("User Login" → "Payment" transmission token).

[0070] In this embodiment of the disclosure, the data flow relationship is the constraint on the transmission of input and output parameters between functional modules.

[0071] In this embodiment of the disclosure, the anomaly-tolerant matcher is an algorithmic component that performs fault-tolerant mapping based on string similarity when parameters do not match perfectly. For example, the requirement parameter "user's mobile number" is matched with the fuzzy template parameter "mobile".

[0072] In some implementations, the graph construction process includes: parsing the functional template; extracting input and output parameters; identifying parameter dependencies; constructing vertices V and establishing directed edges E; and generating the graph G = V, E.

[0073] Thus, dependency graphs can improve the accuracy of matching functional modules; fuzzy matching algorithms can improve parameter tolerance coverage; and combining dependency graphs and fuzzy matching algorithms can improve the detection rate of dependency conflicts and reduce the amount of code refactoring work caused by requirement changes.

[0074] In some embodiments, project-level templates encapsulate system architecture blueprints and front-end and back-end framework structures; functional-level templates define interface boundary behaviors and state machine control logic; API-level templates encapsulate external service calls based on service interface description specifications; the layered template library also includes a dynamic evolution module, configured to automatically generate patch templates based on verification error logs through a feedback data-driven mechanism.

[0075] In this embodiment of the disclosure, the system architecture blueprint is a design specification that defines the overall technology stack and module relationships of the application. For example, a microservice architecture with a front-end and back-end database separation design.

[0076] In this embodiment of the disclosure, the interface boundary behavior refers to the input / output contract and exception response rules of the functional module. For example, the user login interface: Input: {phone number, password}; Output: {token, expiration date}; Exception: {1001: incorrect password}.

[0077] In this embodiment of the disclosure, the state machine control logic is a finite state automaton that describes the rules for business state transitions. For example, the order state machine is: Pending payment → In payment → Paid; In payment → Timeout → Closed.

[0078] In this embodiment of the disclosure, the service interface description specification encapsulates a machine-readable definition of the API based on a certain standard.

[0079] In this embodiment of the disclosure, the feedback data-driven mechanism is a closed-loop system that automatically triggers template optimization using verification error logs. For example, when payment timeout errors exceed 10 times, a patch template is automatically generated.

[0080] In this embodiment of the disclosure, the patch template is an incremental update template unit used to fix specific problems.

[0081] Thus, by including architectural blueprints at the project level, state machine definitions at the functional level, and service interface description specifications at the API level, template reusability can be improved. Automatic patch generation based on error logs, and non-overwrite incremental updates, can reduce the time required to fix problems.

[0082] In some embodiments, the dynamic evolution module includes: an open extension interface that supports developers injecting custom templates; and a compatibility verification tool that performs version semantic compatibility verification and dependency conflict matrix analysis.

[0083] In this embodiment of the disclosure, the open extension interface is a standardized access point that allows developers to inject custom templates and supports protocol-independent data transmission.

[0084] In this embodiment of the disclosure, the custom template is a user-developed functional unit that conforms to specifications and can be recognized and scheduled by the system. For example, a risk control rule template includes: Input: {transaction amount, user level}; Output: {risk level, interception suggestion}.

[0085] In this embodiment of the disclosure, the version semantic compatibility check is based on the binary compatibility of the template version upgrade based on the specification. For example, it checks whether v1.2.0→v1.3.0 satisfies: the major version is the same + the minor version is added + no API is removed.

[0086] In this embodiment of the disclosure, dependency conflict matrix analysis detects resource conflicts when multiple templates are combined using a dependency graph. For example, it analyzes the database driver conflict between the payment template and the log template.

[0087] Thus, by supporting automated template injection, the efficiency of template extension is improved, and the success rate of version upgrades is increased; by intercepting during the build, the rate of dependency conflict prevention is improved.

[0088] In some embodiments, the semantic understanding and hierarchical retrieval system includes:

[0089] The natural language understanding module uses a contextual attention mechanism to generate requirement vectors;

[0090] A semantically enhanced sorter applies a dynamic weight formula to rearrange search results.

[0091] The dynamic weight formula is as follows:

[0092] Where α and β are adjustable weight coefficients, α represents the relevance weight; β represents the resource efficiency weight, used to quantify the contribution of template resource efficiency to scheduling priority, reflecting the system's trade-off between resource consumption and functional matching; Priority represents the dynamic weight; Sim cos Represents the cosine similarity (0-1) between the demand vector and the template vector; Resource cost This indicates the estimated resource consumption for template execution.

[0093] In this embodiment of the disclosure, the context attention mechanism is an algorithm that dynamically focuses key semantic segments through neural network weights. For example, the requirement "cross-border payment requires currency conversion" → focuses on {"cross-border":"weight 0.8","currency conversion":"weight 0.9"}.

[0094] In this embodiment of the disclosure, the demand vector is a fixed-dimensional numerical representation of the demand text generated by encoding. For example, a 512-dimensional vector: [-0.24, 0.76, ..., 0.18].

[0095] In this embodiment of the disclosure, the semantic enhancement sorter is a decision module that integrates multi-dimensional features to optimize retrieval results.

[0096] In this embodiment of the disclosure, the template execution resource consumption estimate is a quantitative indicator that predicts the computing resources required for template execution.

[0097] In this way, developers only need to submit templates, and validation, injection, and conflict resolution are all handled automatically. A contextual attention mechanism is used to generate requirement vectors, enabling precise parsing of requirement semantics; complexity weighting improves resource sensitivity, thereby increasing retrieval accuracy.

[0098] In some embodiments, the T-RAG generation and optimization system includes:

[0099] The suggestion word engineering module constructs enhanced suggestions that include hierarchical search results, cross-frame dependency constraints, and exception handling examples;

[0100] A cross-language dependency resolver that automatically completes module reference chains through topological sorting based on dependency relationships.

[0101] In this embodiment of the disclosure, the enhanced prompt is an LLM instruction template that injects hierarchical search results and engineering constraints.

[0102] In this embodiment of the disclosure, cross-framework dependency constraints are rules that restrict the compatibility of components from different technology stacks.

[0103] In this embodiment of the disclosure, the exception handling example is a pre-defined error handling code snippet.

[0104] In this embodiment of the disclosure, topological sorting is a linear sequence generation algorithm based on a directed acyclic graph (DAG). For example, the dependency relationship is: A→B→C→Sorting result: [A,B,C].

[0105] In this embodiment of the disclosure, the module reference chain is the complete path of import relationships between code files.

[0106] In this way, by injecting project / function / API-level templates through layered engineering prompts, including cross-framework constraint declarations, the code deployability rate is improved; and reference chain completion based on topological sorting automatically repairs unresolved symbols, reducing the dependency missing rate.

[0107] In some embodiments, the closed-loop verification system includes: a static verification module that verifies the consistency of interface definitions based on an abstract syntax tree; a sandbox simulator that performs UI behavior simulation and performance bottleneck detection in a containerized environment; and a feedback learner that maps verification errors to template weight update instructions.

[0108] In this embodiment of the disclosure, the abstract syntax tree is a tree-like data structure that represents the source code in a structured way, while preserving the syntactic logic relationships.

[0109] In this embodiment of the disclosure, interface definition consistency is the degree of matching between the verification code implementation and the design contract (such as the Open API specification (OpenAPI)).

[0110] In this embodiment of the disclosure, the containerized environment is an isolated execution space based on operating system-level virtualization.

[0111] In this embodiment of the disclosure, UI behavior simulation is achieved by automatically executing a sequence of user operations through a program.

[0112] In this embodiment of the disclosure, performance bottleneck detection is to identify hotspots of system resource consumption and critical load thresholds.

[0113] In this embodiment of the disclosure, the template weight update instruction is a control signal that dynamically adjusts the template priority according to the error type.

[0114] Thus, by implementing full AST verification through a closed-loop verification system, the contract drift problem can be eliminated, and the accuracy of deployable code can be improved.

[0115] Figure 2 A schematic diagram of a zero-code intelligent agent building framework is shown, such as... Figure 2 As shown, to achieve automated and intelligent construction of complex applications and improve development efficiency and system adaptability, this framework integrates a multi-level template-driven T-RAG strategy, combining multi-tool collaboration, semantic retrieval, template engineering, RAG generation, and a feedback closed-loop optimization mechanism, forming a complete "understanding → matching → generation → verification" technology chain. Figure 2 As shown, the intelligent agent construction framework includes an intelligent collaboration engine, multi-level dynamic templates and collaborative reasoning, semantic understanding and hierarchical retrieval system, dynamic matching and rearrangement mechanism, T-RAG-based end-to-end generation and optimization system, and closed-loop verification and feedback optimization system.

[0116] I. Intelligent Collaboration Engine

[0117] Build standardized toolchain collaboration protocols to form a dynamic and self-consistent closed loop.

[0118] 1. Planning tools: Task analysis, decomposition, and prioritization, combined with a reflective mechanism to dynamically adjust the execution route. Supports goal-based subtask generation and path replanning.

[0119] 2. Search Tool: Intelligent retrieval of the template asset library, hierarchically scheduling project-level, function-level, and API-level templates. Deeply integrated with the generator, achieving a seamless transition from retrieval to generation to optimization.

[0120] 3. Development Tools: Integrates user requirements, search results, and pre-defined rules to generate structured, modular, and directly deployable system code. Supports customized generation under multiple objectives (such as front-end / back-end generation, security enhancement).

[0121] 4. Quality control tools: integrate static analysis, automated functional testing (UI interactive verification and testing), and security testing (such as dependency vulnerability scanning).

[0122] II. Multi-level Dynamic Templates and Collaborative Reasoning

[0123] Construct an evolvable hierarchical template ecosystem and integrate it closely with the reasoning mechanism:

[0124] 1. Template system layering

[0125] a) Project-Level Templates: Define system-level architecture blueprints and specific implementations, such as e-commerce platforms and library systems, encapsulating front-end and back-end framework structures, databases, and overall code logic.

[0126] b) Function-Level Templates: These are designed for functional modules and implement specific tools such as interfaces, boundary behaviors, and state machine control, including user login, permission verification, payment processing, and search sorting.

[0127] c) API-Level Templates: These encapsulate external service calls, defining parameter structures, authentication methods, and exception handling strategies based on standard API description languages, such as implementing SMS services and map APIs.

[0128] 2. Template dynamic evolution mechanism

[0129] a) Template Data Flywheel: Based on runtime feedback and user interaction data, the template quality is analyzed through the evaluation engine, and patch templates are automatically generated and pushed to achieve continuous evolution.

[0130] b) Open template extension interface: Provides developers with a programmable interface for custom template access, and also provides compatibility verification tools to implement version semantic verification, dependency conflict detection and rollback mechanism.

[0131] III. Semantic Understanding and Hierarchical Retrieval System

[0132] Construct a multi-level retrieval framework based on natural language understanding and semantic vectorization to create an efficient and accurate multi-level semantic retrieval and matching system:

[0133] 1. Natural Language Understanding and Vectorization

[0134] a) Based on a large model, perform intent parsing and multi-dimensional vector encoding of user needs.

[0135] b) Introduce context modeling and historical interaction injection to resolve ambiguity in requirements and improve retrieval accuracy.

[0136] 2. Hierarchical retrieval strategy

[0137] a) Project-level coarse inspection (Recall Layer 1): Vector similarity retrieval to quickly locate the Top-K project blueprint.

[0138] b) Functional-level fine-grained review (Recall Layer 2): Dependency reasoning and fine-grained functional screening.

[0139] c) API-level interface fine-tuning (Recall Layer 3): Retrieve external API encapsulation templates as needed to ensure interface specifications and functional integrity.

[0140] 3. Dynamic matching and rearrangement mechanism

[0141] We introduce semantically enhanced ranking, combining relevance scoring and execution difficulty prediction to optimize template selection priority.

[0142] IV. Generation and Optimization System: End-to-End Generation Based on T-RAG

[0143] By deepening the integration of retrieval and generation through the Template-RAG system, the accuracy and executability of the code are significantly improved.

[0144] 1. Template-RAG Enhanced Generation: Based on hierarchical semantic retrieval results, it calls the LLM model with the enhanced Prompt as input and outputs executable system code (including backend logic, frontend view, configuration files, etc.).

[0145] 2. Automated Dependency Resolution and Repair: Analyzes code structure and dependencies, automatically completes missing libraries, file structures, and module references, ensuring the integrity and consistency of the system build. Supports cross-language and cross-framework dependency reasoning.

[0146] V. Closed-Loop Verification and Feedback Optimization System

[0147] Build an intelligent closed loop of "verification-feedback-optimization" to improve system reliability and continuous evolution capabilities.

[0148] 1. Static structure verification: Syntax checking, interface definition and call chain verification to ensure the generated code is compliant in terms of structure and semantics.

[0149] 2. Dynamic Sandbox Simulation: Automated deployment of generated code to a simulation environment for interactive testing, performance monitoring, and UI behavior simulation to quickly identify problems.

[0150] 3. Data Acquisition and Feedback Learning: Capture error logs, performance bottlenecks, and user interaction behaviors, and input them into the feedback learner. Based on the feedback results, dynamically adjust retrieval weights, optimize template design, and RAG inference strategies to achieve continuous self-evolution of the system.

[0151] The above-mentioned technical solutions introduce a multi-level template-driven retrieval enhancement generation strategy in the field of zero-code development. By combining semantic retrieval with large language model generation, the automation and intelligence level of intelligent agent construction is significantly improved, and the technical threshold for the development of artificial intelligence (AI) applications is reduced.

[0152] It should be understood that Figure 2 The schematic diagrams shown are merely illustrative and not limiting, and are scalable; those skilled in the art can use them as a basis. Figure 2 Even with various obvious changes and / or substitutions to the examples, the resulting technical solutions still fall within the scope of this disclosure.

[0153] Figure 3 The diagram illustrates the architecture of the zero-code framework, as shown below. Figure 3 As shown, the zero-code framework includes a multi-level template system, a hierarchical search engine, a RAG generator, and a quality control and verification engine. The multi-level template system includes an NLU parser, vector embedding, hierarchical search, and a dependency tree builder. The RAG generator includes RAG templates, a dependency parser, and a code generator. The quality control and verification engine includes a static analyzer, a sandbox simulator, a feedback analyzer, and a patch generator. The multi-level template system includes project-level templates, functional-level templates, and API-level templates, and may also include dynamic evolution and extension interfaces.

[0154] Through the aforementioned technical system, efficient, accurate, and sustainable automatic construction of intelligent agents has been achieved, providing scientific and comprehensive technical support for zero-code development.

[0155] It should be understood that Figure 3 The schematic diagrams shown are merely illustrative and not limiting, and are scalable; those skilled in the art can use them as a basis. Figure 3 Even with various obvious changes and / or substitutions to the examples, the resulting technical solutions still fall within the scope of this disclosure.

[0156] This disclosure provides a method for constructing a code-based intelligent agent. Figure 4 This is a flowchart illustrating a code-based intelligent agent construction method according to an embodiment of the present disclosure. This method can be applied to a code-based intelligent agent construction device. The device is located in an electronic device. This electronic device includes, but is not limited to, fixed devices and / or mobile devices. For example, fixed devices include, but are not limited to, servers, which can be cloud servers or ordinary servers. Mobile devices include, but are not limited to, mobile phones and tablets. In some possible implementations, the code-based intelligent agent construction method can also be implemented by a processor calling computer-readable instructions stored in memory. Figure 4 As shown, the code-based intelligent agent construction method includes:

[0157] S401: Responding to user needs, it parses the natural language text input by the user and generates an intent vector and a context dependency graph;

[0158] S402: Perform a three-level progressive template retrieval process sequentially at the project level, function level, and API level; among which, project-level retrieval includes: matching project blueprints based on cosine similarity of intent vectors; function-level retrieval includes: filtering function templates based on context dependency graphs; and API-level retrieval includes: verifying parameter structure compatibility.

[0159] S403: Construct enhanced prompt words with template constraints based on hierarchical retrieval results; call the large language model to generate deployable code;

[0160] S404: Perform static structure verification and dynamic user interface behavior simulation on deployable code in a sandbox environment to obtain verification error logs;

[0161] S405: Update the template library based on the verification error log and optimize the semantic ranking coefficient of the retrieval strategy.

[0162] In this embodiment of the disclosure, the context dependency graph is a topological network that represents the logical relationships between functional modules using a directed graph structure, where vertices are functional points and edges are execution dependencies.

[0163] In this embodiment of the disclosure, the three-level progressive template retrieval includes:

[0164] Project-level search: Matching system-level architectures (such as e-commerce platforms and intelligent customer service systems).

[0165] Functional search: Filter individual functional modules (such as user login, order generation).

[0166] API-level search: Connecting to external service interfaces (such as payment APIs).

[0167] In this embodiment of the disclosure, the enhanced prompt word containing template constraints refers to the large language model instruction injected with three-level template rules to limit the generation boundary.

[0168] In this embodiment of the disclosure, containerized sandbox verification includes: performing static and dynamic dual-state tests based on an isolated environment. Static verification includes AST syntax tree analysis interface compliance; dynamic simulation includes simulating a user click process.

[0169] The technical solution of this disclosure adopts a three-level progressive retrieval method, namely coarse screening with cosine similarity, fine adjustment with graph matching, and parameter compatibility verification, which can improve the accuracy of template retrieval; it improves the code deployability rate by generating code based on template constraint injection and topology dependency completion; and it improves the intelligence of the system by using containerized sandbox full-stack verification and automatic patch generation.

[0170] In some embodiments, generating deployable code based on hierarchical search results includes:

[0171] Enhanced prompts are constructed using the prompt engineering module, containing the following elements: an architecture description for project-level templates; interface specifications for functional-level templates; and exception handling strategies for API-level templates.

[0172] The large language model is invoked to generate code containing the following: front-end and back-end interaction logic; external dependency declaration files; and containerized deployment configuration files.

[0173] In this embodiment, the prompt word engineering module is a conversion engine that transforms hierarchical search results into commands recognizable by a large language model. The project architecture description, functional interface specifications, and API exception policies are input into the prompt word engineering module, which then outputs structured prompt text (including technical constraints and examples).

[0174] In this embodiment of the disclosure, the project-level architecture description includes the overall system technology stack and module relationships.

[0175] In this embodiment of the disclosure, the functional interface specification is the protocol standard for interaction between modules.

[0176] In this embodiment of the disclosure, the API-level exception handling strategy is a pre-defined error capture and recovery mechanism.

[0177] In this embodiment of the disclosure, the containerized deployment configuration file is a declarative definition of the application runtime environment.

[0178] In this way, through precise element injection (architecture / interface / exception), multi-language dependency adaptation, and production-ready configuration generation, the entire chain of automation from requirements to deployment is achieved.

[0179] In some embodiments, filtering feature templates based on a context dependency graph includes:

[0180] (i) Match the demand dependency graph with the pre-stored template dependency graph using the subgraph isomorphism algorithm;

[0181] (ii) Calculate the matching degree for parameters of unmatched functional interfaces:

[0182] (iii) When the matching degree is greater than the preset threshold, the matching result is adopted.

[0183] In this embodiment, the subgraph isomorphism algorithm is a mathematical method for determining whether a demand dependency graph and a template dependency graph have the same topological structure. The input is a demand graph and a template graph, and the output isomorphic mapping is a given. For example, the demand graph is: [Register] → [Login] → [Payment]; the template graph is: [User Creation] → [Authentication] → [Transaction]; and the isomorphic mapping is: Registration → User Creation, Login → Authentication, Payment → Transaction.

[0184] The subgraph isomorphism algorithm ensures the correctness of dependencies; when the matching degree is greater than the preset threshold, the matching result is adopted, which avoids low-quality matching; when the matching degree is lower than the preset threshold, the fuzzy inference engine is triggered, which helps to ensure the availability of the adopted template in the production environment.

[0185] In some embodiments, the subgraph isomorphism algorithm includes: constructing a requirement dependency graph based on user requirement function points; loading a template dependency graph from a template library; and executing a graph isomorphism matching algorithm to calculate the maximum common subgraph.

[0186] In this embodiment of the disclosure, the requirement dependency graph is a directed graph structure derived from user requirements, where vertices represent functional modules and edges represent execution dependencies between modules.

[0187] In this embodiment of the disclosure, the template dependency graph is a functional relation knowledge base pre-stored in the template library and persisted in the form of an adjacency matrix.

[0188] In this embodiment, the graph isomorphic matching algorithm based on state space search reduces computational complexity through pruning strategies. Domain knowledge pruning prioritizes matching high-weight vertices (e.g., payment function weight = 0.9); incremental matching only recalculates locally when a new vertex is added to the demand graph.

[0189] In this way, incremental computation solves the real-time matching problem for dynamic demand scenarios; sparse matrix + pruning strategy breaks through the scale bottleneck of traditional graph isomorphism algorithms; and business semantic constraints ensure the integrity of the functional chain.

[0190] In some embodiments, the enhancement of prompt word construction includes: injecting template descriptions for hierarchical retrieval; embedding cross-framework dependency constraint rules; and adding exception handling example code snippets.

[0191] In this embodiment of the disclosure, hierarchical retrieval template description refers to converting project-level, function-level, and API-level features in the hierarchical template library into natural language instructions.

[0192] In this embodiment of the disclosure, the cross-framework dependency constraint rule is a mandatory specification that restricts the interaction between components of different technology stacks.

[0193] In this embodiment of the disclosure, the exception handling example is a pre-defined high-frequency error solution code snippet.

[0194] In this way, the architecture deviation problem is solved by layered instruction injection; cross-stack security is ensured by constraint-based code embedding; high-frequency errors are eliminated by example-driven pitfall avoidance; and precise control from requirements to production code is achieved through structured template fusion, executable constraint embedding, and scenario-based example binding.

[0195] In some embodiments, generating deployable code includes: resolving cross-language dependencies through topological sorting; and automatically completing missing module reference chains.

[0196] In this embodiment of the disclosure, topological sorting is a linear sorting of the vertices of the DAG, such that the starting point of any edge appears before the ending point. For example, the dependency relationship is: Order Service → Payment Service → Notification Service; the topological sequence is: [Order Service, Payment Service, Notification Service].

[0197] In this embodiment of the disclosure, cross-language dependency is a call chain between modules of different programming languages.

[0198] In this embodiment of the disclosure, module reference chain completion automatically corrects missing import declarations.

[0199] Thus, topological sorting solves the compilation order problem; proxy stub isolation eliminates cross-language call coupling; and intelligent import ensures the integrity of the reference chain. Through cross-language dependency resolution, runtime isolation technology, and compile-time self-healing, not only can reference integrity be improved, but the first-time compilation success rate of cross-language systems can also be increased.

[0200] In some embodiments, updating the template library based on verification error logs includes: triggering automatic generation of template patches when the verification error rate is greater than a preset error rate threshold; and performing dependency conflict matrix analysis.

[0201] In this embodiment of the disclosure, the formula for calculating the verification error rate is:

[0202] Among them, Error rate Indicates the verification error rate; F critcal Indicates the number of critical errors (such as crashes, data corruption); F total This indicates the total number of validation test cases.

[0203] In this embodiment of the disclosure, the error rate threshold can be dynamically set according to the template complexity. The formula for calculating the error rate threshold is: θ = 0.5% + 0.2 × Complexity; where θ represents the error rate threshold and Complexity represents the template complexity (a measure of the structural complexity of the template itself).

[0204] In this embodiment, dependency conflict matrix analysis is used to quantitatively evaluate the compatibility of the new template with the existing library. The patch template's declaration file is parsed to extract dependencies; resource usage such as ports / configuration files is checked based on conflict detection algorithms (version compatibility calculation, resource conflict detection).

[0205] In this embodiment of the disclosure, the conflict resolution strategy includes: automatic downgrading: the dependent version is rolled back to the inventory compatible version; resource isolation: exclusive resource domains (such as independent configuration file directories) are allocated.

[0206] Thus, over-fixing is avoided through a dynamic threshold model; repairs are minimized through precise patch location; and global system compatibility is ensured through a conflict prevention system. The template library achieves self-evolution capabilities through error rate assessment, semantic-level patch generation, and dependency ecosystem governance.

[0207] In some embodiments, optimizing the semantic ranking coefficient of the retrieval strategy based on verification error logs includes:

[0208] Adjust the adjustable weight coefficients in the dynamic weight formula;

[0209] The estimated resource consumption for template execution is revised based on user interaction data.

[0210] In this embodiment of the disclosure, the dynamic weighting formula is used to balance the decision model between semantic relevance and execution cost.

[0211] Thus, through dynamic weight adjustment, performance and accuracy are adaptively balanced; through multi-source data fusion, the true execution cost is accurately reflected; and through resource-aware sorting, system overload is prevented from the source. Through a closed-loop feedback mechanism, multi-dimensional data fusion, and real-time sorting decisions, sorting accuracy and resource utilization are improved.

[0212] This disclosure provides a code generation method for a code-based intelligent agent construction system. Figure 5This is a flowchart illustrating a code generation method for a code-based intelligent agent construction system according to an embodiment of the present disclosure. This code generation method can be applied to a code generation device for a code-based intelligent agent construction system. The code generation device is located in an electronic device. This electronic device includes, but is not limited to, fixed devices and / or mobile devices. For example, fixed devices include, but are not limited to, servers, which can be cloud servers or ordinary servers. Mobile devices include, but are not limited to, mobile phones and tablets. In some possible implementations, the code generation method for the code-based intelligent agent construction system can also be implemented by a processor calling computer-readable instructions stored in memory. Figure 5 As shown, the code generation method for this code-based intelligent agent construction system includes:

[0213] S501. Based on the hierarchical retrieval results of the semantic understanding and hierarchical retrieval system, and integrating cross-frame dependency constraint rules and pre-set anomaly handling examples, enhanced prompt words are generated.

[0214] S502. Input the enhanced prompt words into the large language model to generate the original code;

[0215] S503. The dependency resolver in the T-RAG generation and optimization system performs reference chain completion based on topological sorting on the original code and outputs a code package that can be directly deployed.

[0216] S504. Input the code package into the closed-loop verification system and dynamically adjust the construction strategy of the enhanced prompt words based on the sandbox verification error log.

[0217] In this embodiment of the disclosure, S501 to S504 can be specifically executed by the T-RAG generation and optimization system of the code agent construction system.

[0218] In this embodiment of the disclosure, the semantic understanding and hierarchical retrieval system is a matching system that uses natural language processing technology to parse the semantics of user needs and combines it with hierarchical retrieval of knowledge graphs (such as framework library → component library → API interface library).

[0219] In this embodiment of the disclosure, the cross-framework dependency constraint rules are a rule base that defines the compatibility relationships between different technical frameworks (such as a component not being able to directly call a certain API).

[0220] In this embodiment, the closed-loop verification system is an iterative system that executes code in a sandbox environment, captures error logs, and dynamically feeds them back to the prompt word generation module. For example, if the sandbox execution reports an error "undefined function," the system adds relevant function library constraints to subsequent prompt words.

[0221] In some implementations, generating enhanced prompts includes: using a model to parse user needs and generate intent vectors; a first-level matching technology framework (e.g., front-end / back-end); a second-level matching component (e.g., database selection); and a third-level compatibility check via a rule engine. A pre-defined example library is retrieved, and pre-defined processing templates are inserted for high-frequency anomalies (e.g., null pointer exceptions, timeouts); finally, structured prompts are output.

[0222] In some implementations, the large language model generates the original code, including: enhancing prompts; and invoking the large language model to generate the original code based on the enhanced prompts. The enhanced prompts include: injecting context: appending similar case code snippets; and making constraints explicit: converting dependency rules into natural language instructions.

[0223] In some implementations, the parser workflow is dependent on, including:

[0224] Constructing a dependency graph: Parsing undefined symbols in the original code and extracting them as graph nodes;

[0225] Topological sorting and completion: Identify missing nodes: Undeclared nodes are detected; Search dependency libraries: Match toolkits containing the function in the knowledge base; Insert in dependency order: Insert first, then complete the calling code.

[0226] Output code package: Generates an image or compressed package with complete dependencies.

[0227] In some implementations, closed-loop verification and dynamic adjustment include:

[0228] Sandbox verification: Execute code packages in a containerized environment; monitor error logs and capture runtime exceptions.

[0229] Iterative prompting strategy: categorize logs as "dependency missing" or "logic error"; if it is a dependency missing, increase the dependency library retrieval weight in S501; if it is a logic error, add exception handling examples to the prompting words.

[0230] The technical solution of this disclosure addresses the dependency missing problem (such as missing library files) in LLM-generated code through T-RAG topology completion, improving the usability of the generated code. Dependency constraint rule base pre-detection technology conflicts prevents incompatible library version combinations. An intelligent exception handling mechanism, combined with a pre-built example library, avoids repetitive errors and achieves automated coverage of key exception types (such as concurrency races). Error feedback-driven incremental optimization based on a sandbox environment significantly improves the first-run success rate of the code through multiple iterations. It supports users with zero-code background to generate production-ready deployable code, effectively shortening the development cycle of complex systems.

[0231] In some embodiments, the code generation method for building a system based on code intelligence agents further includes: extracting the following elements from a hierarchical template library to construct prompt words: system architecture blueprint for project-level templates, state machine control logic for functional-level templates, and service interface parameter definitions for API-level templates; wherein the format of cross-framework dependency constraints is: {front-end framework} components are prohibited from directly accessing the {back-end framework} service layer.

[0232] In some implementations, the hierarchical template library includes:

[0233] Project-level template: System overall architecture design diagram (such as microservice communication topology);

[0234] Functional template: State machine model of core business logic (such as order status: pending payment → shipped → completed);

[0235] API-level templates: Interface definition templates that conform to the service interface description specifications.

[0236] For example, when a user creates a "payment system", a project-level template (payment gateway + database read / write separation architecture diagram) is automatically injected.

[0237] In some implementations, an architecture blueprint is semantically matched based on user needs (e.g., "high-concurrency system" → microservice architecture template); an architecture description is inserted into the prompt.

[0238] In this way, project-level templates ensure system architecture consistency; functional-level templates cover the entire state path, reducing the omission of business logic; and OpenAPI templates standardize the generated interfaces, improving the efficiency of connecting to downstream systems.

[0239] In some embodiments, the code package is input into the closed-loop verification system, and the construction strategy of the enhanced prompt words is dynamically adjusted based on the verification error log. This includes: when the closed-loop verification system detects an interface definition inconsistency error, the weight of the project-level architecture description is strengthened in the subsequent prompt words; when a cross-framework call exception is detected, a runtime isolation strategy is added to the dependency constraint section.

[0240] In this embodiment of the disclosure, the interface definition inconsistency error is a conflict between the API implementation of the generated code and the preset specification (such as OpenAPI), including missing parameters, incorrect paths, or incorrect response formats.

[0241] In this embodiment of the disclosure, the runtime isolation strategy is a technical solution that inserts a proxy layer or process boundary between cross-framework calls to prevent direct memory access.

[0242] In this way, after weight adjustment, the generated API is consistent with the OpenAPI definition, improving the interface specification compliance rate; and mandatory project-level template injection avoids architectural deviations caused by iteration.

[0243] Figure 6 This is a flowchart generated from code according to an embodiment of the present disclosure, such as... Figure 6 As shown, the process includes:

[0244] S601: User input natural language requirements;

[0245] S602: The system performs semantic vectorization processing;

[0246] S603: LLM generates enhanced semantic embeddings;

[0247] S603: The system sends a hierarchical template retrieval request to the template database;

[0248] S604: The template database returns a three-level template combination to the system;

[0249] S605: The system sends a RAG enhancement generation request to the LLM;

[0250] S606: LLM outputs executable code;

[0251] S607: Execution dependency resolution and dynamic completion;

[0252] S608: The system delivers a deployable system to the user;

[0253] S609: The system performs closed-loop verification of executable code;

[0254] S610: Collect user feedback logs;

[0255] S611: The system generates patch templates based on user feedback logs;

[0256] S612: Complete template version iteration.

[0257] The system is based on a user natural language command intelligent matching and combination module to achieve automated generation of intelligent agents; through a multi-level template system and dynamic combination mechanism, it achieves efficient reuse of modules; it supports cross-domain agent development (such as e-commerce, customer service, data analysis, etc.); it automates key development steps, significantly shortening the development cycle; and users without coding background can build complex applications through simple descriptions, greatly expanding the developer community.

[0258] It should be understood that Figure 6 The schematic diagrams shown are merely illustrative and not limiting, and are scalable; those skilled in the art can use them as a basis. Figure 6 Even with various obvious changes and / or substitutions to the examples, the resulting technical solutions still fall within the scope of this disclosure.

[0259] This disclosure provides a code-based intelligent agent construction apparatus, such as... Figure 7 As shown, the device may include: a vector generation module 701, used to parse natural language text input by the user in response to user needs, and generate intent vectors and context dependency graphs; a progressive retrieval module 702, used to sequentially perform three-level progressive template retrieval at the project level, function level, and API level; wherein, the project level retrieval includes: matching project blueprints based on cosine similarity of intent vectors; the function level retrieval includes: filtering function templates based on context dependency graphs; and the API level retrieval includes: verifying parameter structure compatibility; a code generation module 703, used to construct enhanced prompt words with template constraints based on the hierarchical retrieval results; and call a large language model to generate deployable code; a dual-state verification module 704, used to perform static structure verification and dynamic user interface behavior simulation on the deployable code in a sandbox environment, and obtain verification error logs; a template library update module 705, used to update the template library based on the verification error logs; and a retrieval strategy optimization module 706, used to optimize the semantic ranking coefficients of the retrieval strategy based on the verification error logs.

[0260] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.

[0261] This disclosure provides a code generation apparatus based on a code intelligence agent construction system, executed by the T-RAG generation and optimization system of the code intelligence agent construction system, such as... Figure 8 As shown, the device may include: a prompt word generation module 801, used to generate enhanced prompt words based on the hierarchical retrieval results of the semantic understanding and hierarchical retrieval system, integrating cross-frame dependency constraint rules and pre-set exception handling examples; a raw code generation module 802, used to input the enhanced prompt words into a large language model to generate raw code; a code package generation module 803, used to perform reference chain completion based on topological sorting on the raw code through the dependency parser in the T-RAG generation and optimization system, and output a code package that can be directly deployed; and a code verification module 804, used to input the code package into a closed-loop verification system, so that the closed-loop verification system can dynamically adjust the construction strategy of the enhanced prompt words based on the verification error log.

[0262] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.

[0263] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

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

[0265] Figure 9 A schematic block diagram of an example electronic device 900 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 assistants, 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.

[0266] like Figure 9 As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 902 or a computer program loaded from storage unit 908 into random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.

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

[0268] The computing unit 901 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 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, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as code agent construction methods and / or code generation methods based on code agent construction systems. For example, in some embodiments, the code agent construction methods and / or code generation methods based on code agent construction systems can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by computing unit 901, one or more steps of the code agent construction method and / or code generation method based on the code agent construction system described above can be performed. Alternatively, in other embodiments, computing unit 901 can be configured to execute the code agent construction method and / or code generation method based on the code agent construction system by any other suitable means (e.g., by means of firmware).

[0269] 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-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

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

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

[0272] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) or liquid crystal display (LCD) monitor) for displaying information to the user; 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).

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

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

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

[0276] 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 principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A code-based intelligent agent construction system, comprising: The system includes an intelligent collaboration engine, a hierarchical template library, a semantic understanding and hierarchical retrieval system, a template retrieval-enhanced T-RAG generation and optimization system, and a closed-loop verification system; among these components... The intelligent collaboration engine includes planning tools, retrieval tools, development tools, and quality inspection tools, which are connected through data flow pipelines to form a closed loop. The planning tool is configured to dynamically reconstruct task execution paths through a reflection mechanism, which includes a subtask priority reordering module and an abnormal path rollback trigger. The retrieval tool has a built-in template association graph engine that calculates the dependency weights between functional templates and API templates in real time. The development tool is configured to integrate user requirements, retrieval results, and pre-defined rules to output modular and directly deployable code. The quality inspection tool integrates at least the following components: a static analyzer configured to perform syntax checking and interface definition verification; an automated testing engine configured to simulate user interface interaction behavior; and a security module configured to perform dependency vulnerability scanning. The hierarchical template library includes project-level templates, function-level templates, and application programming interface (API) level templates. The semantic understanding and hierarchical retrieval system is configured as follows: the natural language understanding module parses user needs to generate intent vectors, and then performs a three-level progressive template retrieval at the project level, function level, and API level in sequence; The T-RAG generation and optimization system is configured to: inject hierarchical retrieval results into prompt words of a large language model, and generate deployable code containing front-end and back-end logic; The closed-loop verification system is configured to perform static structure verification and dynamic behavior simulation in a sandbox environment, and trigger the evolution and update of the template library and the weight optimization of the retrieval strategy based on the verification error log.

2. The system according to claim 1, wherein, The three-level progressive template retrieval includes: Project-level preliminary screening: Based on the cosine similarity calculation of intent vectors, the top K project blueprints are selected, where K is a positive integer; Functional-level detailed inspection: Invoke the dependency reasoning engine to parse the data flow logic relationships between functional templates; API-level fine-tuning: Execution parameter structure compatibility verification and exception handling strategy matching.

3. The system according to claim 2, wherein, The functional-level detailed inspection includes: Dependency reasoning engine: Constructs a functional template dependency graph, where vertices represent functional modules and edges represent data flow relationships; Anomaly-tolerant matcher: Enables fuzzy matching algorithm for missing parameters.

4. The system according to claim 1, wherein, The project-level template encapsulation system architecture blueprint and front-end and back-end framework structure; The functional-level template defines the interface boundary behavior and state machine control logic; The API-level template encapsulates external service calls based on the service interface description specification. The hierarchical template library also includes: The dynamic evolution module is configured to automatically generate patch templates based on verification error logs through a feedback data-driven mechanism.

5. The system according to claim 4, wherein, The dynamic evolution module includes: An open extension interface is configured to support developers injecting custom templates. The compatibility verification tool is configured to perform version semantic compatibility verification and dependency conflict matrix analysis.

6. The system according to claim 1, wherein, The semantic understanding and hierarchical retrieval system includes: The natural language understanding module is configured to use a contextual attention mechanism to generate requirement vectors. A semantically enhanced ranking algorithm is configured to reorder search results using a dynamic weighting formula; the dynamic weighting formula is as follows: Where α and β are adjustable weight coefficients, α represents the relevance weight, and β represents the resource efficiency weight; Indicates dynamic weights; This represents the cosine similarity between the demand vector and the template vector. This indicates the estimated resource consumption for template execution.

7. The system according to claim 1, wherein, The T-RAG generation and optimization system includes: The suggestion word engineering module is configured to construct enhanced suggestions that include hierarchical search results, cross-frame dependency constraints, and exception handling examples; A cross-language dependency resolver configured to automatically complete module reference chains through topological sorting based on dependencies.

8. The system according to claim 1, wherein, The closed-loop verification system includes: The static validation module is configured to validate the consistency of interface definitions based on the abstract syntax tree. A sandbox emulator configured to perform user interface behavior simulation and performance bottleneck detection in a containerized environment; The feedback learner maps validation errors to template weight update instructions.

9. A method for constructing a code-based intelligent agent, used in the code-based intelligent agent construction system as described in claim 1, the method comprising: In response to user needs, the system parses the natural language text input by the user and generates intent vectors and context dependency graphs. The system performs a three-level progressive template retrieval process: project-level, function-level, and API-level. Project-level retrieval includes matching project blueprints based on the cosine similarity of the intent vector. Function-level retrieval includes filtering function templates based on the context dependency graph. API-level retrieval includes verifying parameter structure compatibility. Enhanced prompt words with template constraints are constructed based on hierarchical search results; deployable code is generated by calling a large language model; Static structure verification and dynamic user interface behavior simulation are performed on the deployable code in a sandbox environment to obtain verification error logs. The template library is updated based on the verification error logs, and the semantic ranking coefficient of the retrieval strategy is optimized.

10. The method according to claim 9, wherein, The generation of deployable code based on hierarchical search results includes: Enhanced prompts are constructed using the prompt engineering module, containing the following elements: an architecture description for project-level templates; interface specifications for functional-level templates; and exception handling strategies for API-level templates. The large language model is invoked to generate code containing the following: front-end and back-end interaction logic; external dependency declaration files; and containerized deployment configuration files.

11. The method according to claim 9, wherein, Construct enhanced prompt words with template constraints, including: Inject a template description for hierarchical retrieval; Embed cross-framework dependency constraint rules; Add an example code snippet for exception handling.

12. The method according to claim 9, wherein, Generate deployable code, including: Resolve cross-language dependencies using topological sorting; Automatically complete missing module reference chains.

13. The method according to claim 9, wherein, The step of updating the template library based on the verification error log includes: When the verification error rate exceeds the preset error rate threshold, the template patch is automatically generated. Execution dependency conflict matrix analysis.

14. The method according to claim 9, wherein, Optimize the semantic ranking coefficient of the retrieval strategy, including: Adjust the adjustable weight coefficients in the dynamic weight formula; wherein, the dynamic weight formula is: Where α and β are adjustable weight coefficients, α represents the relevance weight, and β represents the resource efficiency weight; Indicates dynamic weights; This represents the cosine similarity between the demand vector and the template vector. This indicates the estimated resource consumption for template execution.

15. A code generation method based on a code agent construction system, used in the code agent construction system as described in claim 1, the method comprising: Based on the hierarchical retrieval results of semantic understanding and hierarchical retrieval system, enhanced prompt words are generated by integrating cross-frame dependency constraint rules and pre-set anomaly handling examples. The enhanced prompt words are input into a large language model to generate the original code; The dependency resolver in the T-RAG generation and optimization system performs reference chain completion based on topological sorting on the original code, and outputs a code package that can be directly deployed. The code package is input into the closed-loop verification system, which then dynamically adjusts the construction strategy of the enhanced prompt words based on the verification error log.

16. The method according to claim 15, wherein, The hierarchical retrieval results include: system architecture blueprints for project-level templates, state machine control logic for functional-level templates, and service interface parameter definitions for API-level templates; wherein, the format of the cross-framework dependency constraint is: {front-end framework} components are prohibited from directly accessing the {back-end framework} service layer.

17. The method according to claim 15, wherein, The step of inputting the code package into the closed-loop verification system, so that the closed-loop verification system can dynamically adjust the construction strategy of the enhanced prompt words based on the verification error log, includes: When the closed-loop verification system detects an interface definition inconsistency error, it strengthens the weight of the project-level architecture description in the subsequent prompts; when it detects a cross-framework call exception, it adds a runtime isolation strategy to the dependency constraint section.

18. A code agent construction apparatus for use in the code agent construction system of claim 1, the apparatus comprising: The vector generation module is used to respond to user needs, parse the natural language text input by the user, and generate intent vectors and context dependency graphs. The progressive retrieval module is used to sequentially perform three levels of progressive template retrieval: project-level, function-level, and API-level. Among them, project-level retrieval includes: matching project blueprints based on the cosine similarity of the intent vector; function-level retrieval includes: filtering function templates according to the context dependency graph; and API-level retrieval includes: verifying parameter structure compatibility. The code generation module is used to construct enhanced prompt words with template constraints based on hierarchical retrieval results; and to call a large language model to generate deployable code. The dual-state verification module is used to perform static structure verification and dynamic user interface behavior simulation on the deployable code in a sandbox environment to obtain verification error logs; The template library update module is used to update the template library based on the verification error log; The retrieval strategy optimization module is used to optimize the semantic ranking coefficient of the retrieval strategy based on the verification error log.

19. A code generation apparatus based on a code agent construction system, used in the code agent construction system as described in claim 1, the apparatus comprising: The prompt word generation module is used to generate enhanced prompt words by integrating cross-frame dependency constraint rules and pre-set exception handling examples with the hierarchical search results based on semantic understanding and hierarchical retrieval system. The original code generation module is used to input the enhanced prompt words into the large language model and generate the original code; The code package generation module is used to perform reference chain completion based on topological sorting on the original code by using the dependency resolver in the T-RAG generation and optimization system, and output a code package that can be directly deployed. The code verification module is used to input the code package into the closed-loop verification system, so that the closed-loop verification system can dynamically adjust the construction strategy of the enhanced prompt words based on the verification error log.

20. An electronic device, comprising: At least one processor; as well as A memory that is communicatively connected to at least one processor; wherein, The memory stores instructions that can be executed by at least one processor to enable the at least one processor to perform the method of any one of claims 9-17.

21. A non-transitory computer-readable storage medium storing computer instructions, wherein, Computer instructions are used to cause a computer to perform the method according to any one of claims 9-17.

22. A computer program product comprising a computer program stored on a storage medium, wherein the computer program, when executed by a processor, implements the method according to any one of claims 9-17.

Citation Information

Patent Citations

  • Method for generating and constructing database test knowledge base based on open source large language model and retrieval enhancement

    CN120338073A

  • PLC high-interaction honeypot system based on multi-agent task splitting and RAG enhancement

    CN120433955A