Method and device for automatically generating a restricted agent-driven financial services modeling code

By employing a restricted agent-driven code generation method for financial business modeling, and utilizing a sandbox environment and pre-built toolsets, this approach addresses the issues of uncontrollability and security compliance in existing code generation technologies. It achieves high accuracy and automated quality self-correction, meeting the high standards required in the financial sector.

CN122431665APending Publication Date: 2026-07-21DIGITAL CHINA SYST INTEGRATION SERVICE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DIGITAL CHINA SYST INTEGRATION SERVICE
Filing Date
2026-04-03
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing technologies for code generation in financial business modeling scenarios suffer from uncontrollability, insufficient accuracy, high costs of iterative repair, inadequate unit test coverage, and security and compliance risks, making it difficult to meet the high standards required in the financial sector.

Method used

By adopting a restricted agent-driven approach, a sandbox environment is built, structured prompts are generated, and restricted agents are invoked. Combined with a pre-built toolset, code generation and iterative repair are performed to ensure that the code complies with business specifications and security requirements.

Benefits of technology

It achieves high accuracy, high controllability, and automated quality self-correction in financial business modeling code, reduces iterative repair costs, and meets the trustworthiness and compliance requirements of financial institutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122431665A_ABST
    Figure CN122431665A_ABST
Patent Text Reader

Abstract

A method and device for automatically generating a restricted agent-driven financial business modeling code, the method comprising: receiving a structured data file, generating a modeling task of a plurality of atomized business steps; each step being associated with a business specification; constructing a sandbox environment isolated from a main project for each business step; pre-generating a business object class and a process boundary component interface in each sandbox environment according to the business specification, and extracting a method signature of a rule class and an entity operation service on which the current business step depends; packaging the business object class, the process boundary component interface and the method signature into structured prompt information; calling a code generation agent running under the constraint of a pre-set tool set, generating initial implementation code and unit test code according to the prompt information, and automatically performing compilation and unit testing, and performing local correction on the code by using the tool set according to error logs of the compilation or testing failure; iteratively executing; and writing back the code files in the sandbox environment in a controlled manner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for automatically generating financial business modeling code driven by a restricted agent. Background Technology

[0002] Automated code generation, based on natural language prompts, automatically generates corresponding program code by understanding the developer's intent. Current technologies primarily rely on general-purpose Large Language Model (LLM) platforms (such as Trae and Codex) for automated code generation, offering high flexibility and broad code coverage, thus improving software development efficiency. However, existing automated code generation is a purely free-form generation model. When facing financial business modeling scenarios with extremely high requirements for code quality, stability, and compliance, this model suffers from a series of insurmountable objective drawbacks: 1. Code uncontrollability and accuracy issues: The lack of structured constraints and guidance makes it difficult for generated code to fully conform to pre-set specifications in terms of style, interface contracts, and subtle implementations of business logic. In scenarios that require adherence to strict financial regulations and business logic (such as the complex steps of a deposit account system), a large amount of unexpected code is often generated, leading to a significant amount of subsequent manual rework and fixing work, severely impacting code accuracy.

[0003] 2. High Iterative Fix Costs and Low Efficiency: When generated code has defects (whether compilation errors or logical flaws), existing technologies often require manual intervention for complex debugging and refactoring, or require the model to regenerate large blocks of code. This fix process lacks precision and specificity, resulting in long iterative fix cycles, high costs, and difficulty in supporting the requirements of rapid customization and agile iteration.

[0004] 3. Insufficient Unit Test Coverage and Lack of Quality Assurance: Existing large-scale model platforms struggle to automatically generate high-quality, high-coverage unit tests, thus lacking the ability to automatically ensure the quality of generated business logic. In the financial sector, code must undergo rigorous verification before deployment. Current technologies cannot establish automated quality gates, resulting in low code credibility and an inability to meet the high standards required by financial scenarios.

[0005] 4. Significant Security and Compliance Risks: Generative AI services are inherently vulnerable to attacks, such as input injection attacks, where attackers could manipulate input to bypass security measures or gain unauthorized access to files. Within financial institutions, any code flaws or security vulnerabilities can pose significant risks, including data breaches and legal compliance issues. The "black box" nature of the purely free-form generation model results in extremely poor code auditability and traceability, contradicting the transparency and accountability requirements of financial regulations. Summary of the Invention

[0006] To address the shortcomings of the existing technologies, this invention provides a method, apparatus, device, and medium for automatically generating financial business modeling code driven by a restricted agent, employing the following technical solution: Firstly, a method for automatically generating code for financial business modeling driven by restricted agents is provided, including: Receive a structured data file containing business modeling information and generate a modeling task with multiple atomic business steps; each step is associated with a corresponding business specification; For each business step, a sandbox environment isolated from the main project is built; the sandbox environment is configured as a code generation and testing space. According to the business specifications, business object classes and process boundary component interfaces are pre-generated in each sandbox environment, and the rule classes and entity operation service method signatures that the current business step depends on are extracted; the business object classes, process boundary component interfaces and method signatures are packaged into structured prompt information for passing to the code generation Agent. The code generation agent, which runs under the constraints of a pre-defined toolset, is invoked to generate initial implementation code and unit test code based on the prompts. The code is then automatically compiled and tested. Based on the error logs of compilation or test failures, the targeted repair tools in the toolset are used to make local corrections to the code. The code is iteratively executed until all unit tests pass or the preset number of iterations is reached. The code files that have passed compilation and unit test verification in the sandbox environment are written back in a controlled manner.

[0007] Secondly, a device for automatically generating financial business modeling code driven by a restricted agent is provided, comprising: The business step parsing module is used to receive structured data files containing business modeling information and generate modeling tasks with multiple atomic business steps; each step is associated with a corresponding business specification. The sandbox environment building module is used to build a sandbox environment isolated from the main project for each business step; the sandbox environment is configured as a code generation and testing space. The prompt message generation module is used to pre-generate business object classes and process boundary component interfaces in each sandbox environment according to the business specifications, and extract the rule classes and entity operation service method signatures that the current business step depends on; package the business object classes, process boundary component interfaces and method signatures into structured prompt messages for passing to the code generation Agent; The code generation agent module is used to call the code generation agent running under the constraints of a pre-set toolset. Based on the prompt information, it generates initial implementation code and unit test code, and automatically executes compilation and unit tests. Based on the error logs of compilation or test failures, it uses the targeted repair tools in the toolset to locally correct the code. It iterates until all unit tests pass or the preset number of iterations is reached. The code files that have passed compilation and unit test verification in the sandbox environment are written back in a controlled manner.

[0008] Thirdly, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, performs the steps of the method as described in the first aspect.

[0009] Fourthly, a readable storage medium is provided, on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method as described in the first aspect. Attached Figure Description

[0010] Figure 1 A schematic flowchart illustrating a restricted agent-driven method for automatically generating financial business modeling code, provided in an embodiment of this application; Figure 2 A schematic flowchart illustrating another method for automatically generating code for financial business modeling driven by a restricted agent, provided in an embodiment of this application. Detailed Implementation

[0011] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the technical solutions in the embodiments of this application are clearly described. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art are within the scope of protection of this application.

[0012] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0013] The steps described in this application and the flowcharts in the accompanying drawings are not necessarily strictly executed according to the step numbers; the execution order of the steps can be changed. Furthermore, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be broken down into multiple steps.

[0014] This specification provides a method for automatically generating financial business modeling code driven by restricted agents, and also relates to an apparatus for automatically generating financial business modeling code driven by restricted agents, a computer device, and a computer-readable storage medium. The following describes each item in detail with reference to the accompanying drawings and preferred embodiments.

[0015] While existing free code generation technologies based on general-purpose large language models have shown some potential in the field of general software development, their fundamental shortcomings in code controllability, accuracy, iterative repair efficiency, and financial-grade security make them difficult to directly or stably apply to automated code generation tasks for financial business modeling. This application aims to provide an innovative code generation technology that overcomes the core challenges faced by existing technologies in financial business modeling code generation—namely, uncontrollable code, low iterative repair efficiency, weak quality assurance mechanisms, and high compliance risks—by combining a hybrid paradigm of a "restricted code generation agent" and a "manual design workflow." This application strives to achieve high accuracy, high controllability, and automated quality self-correction of financial-grade code while ensuring code generation speed.

[0016] Please see Figure 1-2 This application provides a method for automatically generating code for financial business modeling driven by a restricted agent, including: Step S1: Receive a structured data file containing business modeling information and generate a modeling task with multiple atomic business steps; each step is associated with a corresponding business specification; Step S2: For each business step, build a sandbox environment isolated from the main project; the sandbox environment is configured as a code generation and testing space; Step S3: According to the business specifications, pre-generate business object classes and process boundary component interfaces in each sandbox environment, and extract the rule classes and entity operation service method signatures that the current business step depends on; package the business object classes, process boundary component interfaces and method signatures into structured prompt information for passing to the code generation Agent; Step S4: Invoke the code generation agent running under the constraints of the preset toolset, generate initial implementation code and unit test code according to the prompt information, and automatically execute compilation and unit tests. Based on the error logs of compilation or test failures, use the targeted repair tools in the toolset to locally correct the code; iterate until all unit tests pass or the preset number of iterations is reached; and controllably write back the code files that have passed the compilation and unit test verification in the sandbox environment.

[0017] The core of this application's embodiments lies in implementing a hybrid paradigm that combines a "restricted code generation agent" with a "manually designed workflow." This system decomposes complex business modeling into a series of manageable and verifiable atomic steps, and through strict tool-based constraints on agent behavior, ensures that the implementation process strictly follows the manually designed step workflow, thereby guaranteeing the quality of the generated code and the stability of the process.

[0018] The workflow execution begins with step S1. During implementation, a structured data file containing business modeling details (e.g., the JSON file output1028_batch_with_27_steps_v1_with_format_zhuan.json) is loaded. Atomic business steps are obtained by fine-grained decomposition of financial business logic, with each atomic step corresponding to an independent and verifiable business operation. The system design supports parallel processing of multiple business steps (such as ST1001, ST1002, ST016, ST159, ST168, etc.) to optimize overall generation efficiency.

[0019] Furthermore, in step S2, the construction of a sandbox environment isolated from the main project for each atomization step includes: Step S201: Create a separate sandbox directory for each atomization step; Step S202: Analyze the dependency code paths and build a streamlined Maven project tree structure; Step S203: Copy the main project files and resource configuration files to the sandbox directory.

[0020] To ensure the security of Agent operations, the core mechanism is sandbox isolation. In step S2, before processing each step, the workflow calls the `_build_sandbox` method to build a separate, isolated test sandbox directory (e.g., ` / datas / cache / ST1001`) for that step (e.g., ST1001). Subsequently, the system analyzes the dependent code paths, builds a streamlined Maven project tree structure, and copies necessary project files (such as `pom.xml` in the root directory and modules, and resource files such as `application.yml` and Mapper XML files) into the sandbox. This physical isolation ensures that even if the Agent introduces errors during generation or repair, it will not pollute the main project codebase.

[0021] Further, in step S3, the step of pre-generating business object classes and process boundary component interfaces according to the business specifications, and extracting the method signatures of rule classes and entity operation services that the current business step depends on, includes: Based on the requirements document, the bytecode or source code of the dependent business rule classes and entity operation services are parsed using the template. The signature information is obtained by retrieving the method name, parameter type list, and return value type.

[0022] In financial business modeling, ensuring that the generated code structure and interfaces conform to business specifications is crucial. In step S3, the following mechanism guides the Agent's structure: Based on the business requirements document, a template engine pre-generates Business Object (BO) classes and Process Boundary Component (PBC) interfaces conforming to project specifications, such as ST1001InputBo, ST1001OutputBo, and IST1001Pbc. These pre-generated files define explicit input-output contracts, significantly limiting the Agent's design freedom, providing a clear structure and unified specifications, and reducing the risk of biased understanding of the infrastructure. Subsequently, the system executes the `_extract_signatures` step, parsing the public method signatures of all dependent business rule classes and entity operation services, and using this precise signature information as the input context for the code generation Agent. This prevents the Agent from erroneously "guessing" or "illusory" non-existent APIs, thus ensuring high accuracy at the implementation level. For complex business dependencies (such as entity queries and service calls), the system precisely extracts the method signatures (including parameter types and return values) of the dependencies during the generation phase and explicitly passes these signatures to the Agent as part of the Prompt. This mechanism greatly reduces the possibility of the Agent generating incorrect API calls due to "illusion," ensuring the accuracy of the code at the integration level. For example, in financial business modeling, a step (such as ST042 checking product limits) may involve seven sub-steps (such as obtaining event type, obtaining retained balance, calculating total balance, etc.), relying on multiple entity queries (MbProdDefineService, MbEventPartService) and static rules (BR0017Rule). Precise signatures ensure that the Agent can correctly implement this multi-stage business logic flow.

[0023] The detailed handling of financial business modeling in this application's embodiments reflects its emphasis on the stability of merging steps and sub-steps. For example, although the ST042 (check product limits) task is complex, its business logic is manually decomposed into seven atomic sub-steps. This fine-grained decomposition ensures clear boundaries for each logical unit. The Agent's task is to stably encapsulate this logic into independent private methods within the PBC implementation class based on these clear boundaries and predefined interfaces, thereby guaranteeing the modularity and maintainability of complex business process implementation.

[0024] Furthermore, the toolset includes: FileIOTool provides a secure encapsulation for file read and write operations, forcing the code generation agent to operate on files only through FileIOTool. This tool prevents the code generation agent from arbitrarily modifying the file system at the logical level, reducing the risk of data corruption or loss due to erroneous operations and meeting the operational security requirements of financial systems. MvnTool encapsulates Maven compilation and testing commands to enforce standardized builds and automated verification of all code; this tool ensures that the generated code is compileable and testable, serving as the first quality gate in the process. StringReplaceTool, also known as the targeted repair tool, is used to search and replace strings based on error logs. This tool is dedicated to code repair, guiding the code generation agent to make local modifications instead of regenerating the entire file, which significantly improves the efficiency and stability of iterative repair. PlanningTool is used to break down code generation and repair tasks into an ordered list of subtasks.

[0025] The core design of the Restricted CodeAgent in this application is to guide the capabilities of a large language model to precise code generation and iterative repair tasks through a predefined toolset, rather than free creation, thereby meeting the stringent requirements of financial applications for stability and auditability.

[0026] The Agent receives a structured Prompt prepared by the workflow and then uses its internal Planning Tool to break down the task into a prioritized list of subtasks (such as generating implementation classes, generating unit tests, compiling, and testing). The Agent interacts with the underlying LLMClient and executes tasks by invoking its toolset according to LLM instructions. The core toolset and its constraints are as follows: Furthermore, the code generation agent that runs under the constraints of the pre-defined toolset is specifically configured as follows: Step S401: The code generation agent calls the PlanningTool to generate a list of subtasks with priority order based on the initial implementation code, unit test code, and process boundary component interface; for example, generating process boundary component implementation classes, generating corresponding unit test classes, executing Maven compilation, and executing Maven unit tests, etc. Step S402: Based on the subtask list, the code generates an Agent that calls FileIOTool to read files in the sandbox environment; Step S403: The code generation Agent calls MvnTool to execute the encapsulated mvn compile and mvn test commands; Step S404: When compilation or testing fails, the code generation agent captures the error logs output by Maven, locates the line of code containing the defect and the logical error, and calls StringReplaceTool to perform minimal string replacement repair; for example, assertion failure exceptions, null pointer exceptions, or compilation error messages; Step S405: When all tasks are completed and unit tests pass or the preset number of iterations is reached, the code generation agent calls FileIOTool to copy the code files that have passed compilation and unit test verification back to the main project directory.

[0027] In the specific implementation of step S4, a mandatory "Generate-Compile-Test-Repair" closed-loop iterative mechanism (GCTR) is introduced to ensure that all generated financial business logic code meets high-standard quality requirements before integration. This is also the key to meeting the trustworthiness requirements of financial institutions in this application embodiment. After generating the initial code and unit tests, the Agent immediately executes compilation and testing via MvnTool. If the test fails, the Agent will autonomously analyze the error logs output by Maven (such as AssertionFailedError or uncaught NullPointerException) and use StringReplaceTool for targeted modifications. Only code that has undergone sufficient testing and autonomous repair can pass the quality gate until all test cases pass. Specifically: After generating the PBC implementation class and its corresponding JUnit 5 unit tests, the Agent enters the GCTR loop. The core value of this mechanism lies in automated diagnosis and targeted remediation. 1. Initial verification: The Agent is first compiled using MvnTool to ensure that the code has no syntax errors (for example, the ST1001 task was successfully compiled in the 6th iteration).

[0028] 2. Functionality Verification and Error Feedback: Subsequently, the Agent executes unit tests. If the test fails, Maven returns detailed error logs (e.g., the ST1001 task failed on the 8th iteration, returning an AssertionFailedError and a report about a NullPointerException).

[0029] Autonomous targeted remediation: The agent analyzes these logs, pinpointing errors to specific lines of code and logical flaws, and then calls StringReplaceTool for minimal and precise remediation. For example, for the three failed use cases found in ST1001, the agent took the following remediation measures: Fix 1 (Null Input Exception): The failure of testExecute_NullInput was detected because the original code did not throw an exception. The Agent precisely added the logic of if (input == null) throw newNullPointerException at the beginning of the execute method.

[0030] Fix 2 (File Read Simulation): The testExecute_FileReadFailed failure was identified as being due to the inflexible simulation read logic in the implementation class. The Agent has modified the readBatchOpenAccountFileContent method to enable it to recognize specific filenames (such as fail_file.txt) or empty filenames and return null, thus supporting test scenarios.

[0031] This autonomous iterative repair process (for example, in the ST1001 task of checking the content of batch account opening files, the Agent found three test failures in the 8th iteration, and then precisely repaired logical defects such as empty input checks and file read failure simulations through the 9th to 11th iterations, and successfully passed all tests in the 13th iteration) quantitatively demonstrates the high robustness of the embodiments of this application and solves the pain point of traditional LLM code generation relying on manual debugging.

[0032] The final step involves strict quality gate control. Only after the Agent successfully completes all tasks and marks them as complete using TaskDoneTool will the workflow execute the _copy_files_back operation, which systematically copies the verified code files (PBC implementation classes, Input / Output BOs, PBC interfaces, and unit test files) from the sandbox back to the main project. This mechanism ensures that only code that has undergone both compilation and functional testing verification can enter the final codebase. Furthermore, all tool calls, Agent decisions, and fixes throughout the process are meticulously logged, fully meeting the auditability and traceability requirements of financial institutions for code generation processes.

[0033] The embodiments of this application can reliably handle complex financial business modeling, such as ST042 (checking product limits), which involves querying multiple entity tables and calling multiple business rules. The implementation class ST042PbcImpl must call dependencies precisely according to the business process: 1. Entity query dependency: The Agent must accurately call the query methods of the service layer, such as using MbProdDefineService.queryProdDefineByProdTypeAndEventDefault() to get the account opening event type, and using RbClientAcctRelationService.queryClientAcctRelationByClientNoAndProdType() to get the customer's associated account information.

[0034] 2. Rule chaining: The Agent needs to accurately implement complex rule logic chains: First, it summarizes the available account balance through BR0100Rule.execute(), then uses this result and the product's maximum retention balance to calculate the maximum amount allowed for this deposit through BR0016Rule.execute(), and finally calls BR0017Rule.execute() to check whether the transaction amount exceeds the limit.

[0035] By forcing the use of Mockito to mock entity services in unit tests, and using MockedStatic <classname>The pattern tests the static methods of rule classes (such as BR0017Rule) to ensure that the Agent must strictly adhere to the architectural specifications of high cohesion and low coupling, and to verify the correctness of all business branch logic.

[0036] The table below illustrates the dependency call relationships of the complex business steps in ST042, demonstrating the precise control of financial business modeling in this application's embodiments: Based on the above solution, this application precisely constrains and guides the creative capabilities of Large Language Models (LLMs) within an auditable and verifiable engineering framework, successfully resolving the "trust gap" problem in the application of LLMs in high-risk fields such as fintech. The following table summarizes the comparison between the shortcomings of existing technologies and the beneficial effects of this invention: Corresponding to the above-described embodiment of the method for automatically generating code for financial business modeling driven by restricted agents, this application embodiment provides an apparatus for automatically generating code for financial business modeling driven by restricted agents, comprising: include: The business step parsing module is used to receive structured data files containing business modeling information and generate modeling tasks with multiple atomic business steps; each step is associated with a corresponding business specification. The sandbox environment building module is used to build a sandbox environment isolated from the main project for each business step; the sandbox environment is configured as a code generation and testing space. The prompt message generation module is used to pre-generate business object classes and process boundary component interfaces in each sandbox environment according to the business specifications, and extract the rule classes and entity operation service method signatures that the current business step depends on; package the business object classes, process boundary component interfaces and method signatures into structured prompt messages for passing to the code generation Agent; The code generation agent module is used to call the code generation agent running under the constraints of a pre-set toolset. Based on the prompt information, it generates initial implementation code and unit test code, and automatically executes compilation and unit tests. Based on the error logs of compilation or test failures, it uses the targeted repair tools in the toolset to locally correct the code. It iterates until all unit tests pass or the preset number of iterations is reached. The code files that have passed compilation and unit test verification in the sandbox environment are written back in a controlled manner.

[0037] Furthermore, the toolset includes: FileIOTool is used to provide a secure encapsulation for file read and write operations, forcing the code-generated agent to operate on files only through FileIOTool; MvnTool encapsulates Maven compilation and testing commands, used to enforce that all code must undergo standardized builds and automated verification; StringReplaceTool, the targeted repair tool, is used to search and replace strings based on error logs; PlanningTool is used to break down code generation and repair tasks into an ordered list of subtasks.

[0038] Furthermore, the code generation agent that runs under the constraints of the pre-defined toolset is specifically configured as follows: The code generation agent calls the PlanningTool to generate a list of subtasks with priority order based on the initial implementation code, unit test code, and process boundary component interfaces. Based on the subtask list, the code generates an Agent that calls FileIOTool to read files in the sandbox environment; The code generation agent calls MvnTool to execute the encapsulated mvn compile and mvn test commands; When compilation or testing fails, the code generation agent captures the error logs output by Maven, locates the line of code containing the defect and the logical error, and calls StringReplaceTool to perform minimal string replacement repair. Once all tasks are completed and unit tests pass or the preset number of iterations is reached, the code generation agent calls FileIOTool to copy the code files that have passed compilation and unit test verification back to the main project directory.

[0039] Furthermore, the sandbox environment construction module is specifically used for: Create a separate sandbox directory for each atomization step; Analyze dependency code paths and build a streamlined Maven project tree structure; Copy the main project files and resource configuration files to the sandbox directory.

[0040] Furthermore, the step of pre-generating business object classes and process boundary component interfaces according to the business specifications, and extracting the method signatures of rule classes and entity operation services that the current business step depends on, includes: Based on the requirements document, the bytecode or source code of the dependent business rule classes and entity operation services are parsed using the template. The signature information is obtained by retrieving the method name, parameter type list, and return value type.

[0041] The aforementioned restricted agent-driven automated generation device for financial business modeling code implements the steps and processes of the aforementioned restricted agent-driven automated generation method for financial business modeling code, and achieves the same technical effect. To avoid repetition, these will not be described again here.

[0042] Corresponding to the above-described embodiment of the automated generation method for financial business modeling code driven by restricted agents, this application provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps and processes of the above-described embodiment of the automated generation method for financial business modeling code driven by restricted agents, and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0043] Memory can be used to store software programs and various data. Memory can primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area can store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, memory can include volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM). The memory in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.

[0044] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and applications, while the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into the processor.

[0045] Corresponding to the above-described embodiment of the method for automatically generating code for financial business modeling driven by restricted agents, this application embodiment also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the steps and processes of the above-described embodiment of the method for automatically generating code for financial business modeling driven by restricted agents, and achieve the same technical effect. To avoid repetition, these will not be described again here.

[0046] The processor is the processor in the electronic device described in the above embodiments of this application. The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.

[0047] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one…" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0048] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0049] It is understood that the embodiments of this application have been described above in conjunction with the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. As those skilled in the art will know, various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the invention. Furthermore, those skilled in the art, under the guidance or instruction of this application, can modify these features and embodiments to adapt to specific situations and materials without departing from the spirit and scope of the invention. Therefore, this invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of this invention.< / classname>

Claims

1. A method for automatically generating code for financial business modeling driven by restricted agents, characterized in that, include: Receive a structured data file containing business modeling information and generate a modeling task with multiple atomic business steps; Each step is associated with corresponding business specifications; For each business step, a sandbox environment isolated from the main project is built; the sandbox environment is configured as a code generation and testing space. According to the business specifications, business object classes and process boundary component interfaces are pre-generated in each sandbox environment, and the rule classes and entity operation service method signatures that the current business step depends on are extracted; the business object classes, process boundary component interfaces and method signatures are packaged into structured prompt information for passing to the code generation Agent. The code generation agent, which runs under the constraints of a pre-defined toolset, is invoked to generate initial implementation code and unit test code based on the prompts. The code is then automatically compiled and tested. Based on the error logs of compilation or test failures, the targeted repair tools in the toolset are used to make local corrections to the code. The code is iteratively executed until all unit tests pass or the preset number of iterations is reached. The code files that have passed the compilation and unit test verification in the sandbox environment are written back in a controlled manner.

2. The method for automatically generating financial business modeling code driven by restricted agents according to claim 1, characterized in that, The toolset includes: FileIOTool is used to provide a secure encapsulation for file read and write operations, forcing the code-generated agent to operate on files only through FileIOTool; MvnTool encapsulates Maven compilation and testing commands, used to enforce that all code must undergo standardized builds and automated verification; StringReplaceTool, the targeted repair tool, is used to search and replace strings based on error logs; PlanningTool is used to break down code generation and repair tasks into an ordered list of subtasks.

3. The method for automatically generating financial business modeling code driven by restricted agents according to claim 1, characterized in that, The code generation agent that runs under the constraints of the pre-defined toolset is specifically configured as follows: The code generation agent calls the PlanningTool to generate a list of subtasks with priority order based on the initial implementation code, unit test code, and process boundary component interfaces. Based on the subtask list, the code generates an Agent that calls FileIOTool to read files in the sandbox environment; The code generation agent calls MvnTool to execute the encapsulated mvn compile and mvn test commands; When compilation or testing fails, the code generation agent captures the error logs output by Maven, locates the line of code containing the defect and the logical error, and calls StringReplaceTool to perform minimal string replacement repair. Once all tasks are completed and unit tests pass or the preset number of iterations is reached, the code generation agent calls FileIOTool to copy the code files that have passed compilation and unit test verification back to the main project directory.

4. The method for automatically generating financial business modeling code driven by restricted agents according to claim 1, characterized in that, The aforementioned construction of a sandbox environment isolated from the main project for each atomization step includes: Create a separate sandbox directory for each atomization step; Analyze dependency code paths and build a streamlined Maven project tree structure; Copy the main project files and resource configuration files to the sandbox directory.

5. The method for automatically generating code for financial business modeling driven by restricted agents according to claim 1, characterized in that, The process of pre-generating business object classes and process boundary component interfaces according to the business specifications, and extracting the method signatures of rule classes and entity operation services that the current business step depends on, includes: Based on the requirements document, the bytecode or source code of the dependent business rule classes and entity operation services are parsed using the template. The signature information is obtained by retrieving the method name, parameter type list, and return value type.

6. A device for automatically generating code for financial business modeling driven by a restricted agent, characterized in that, include: The business step parsing module is used to receive structured data files containing business modeling information and generate modeling tasks for multiple atomic business steps. Each step is associated with corresponding business specifications; The sandbox environment building module is used to build a sandbox environment isolated from the main project for each business step; the sandbox environment is configured as a code generation and testing space. The prompt message generation module is used to pre-generate business object classes and process boundary component interfaces in each sandbox environment according to the business specifications, and extract the rule classes and entity operation service method signatures that the current business step depends on; package the business object classes, process boundary component interfaces and method signatures into structured prompt messages for passing to the code generation Agent; The code generation agent module is used to call the code generation agent running under the constraints of a pre-set toolset. Based on the prompt information, it generates initial implementation code and unit test code, and automatically executes compilation and unit tests. Based on the error logs of compilation or test failures, it uses the targeted repair tools in the toolset to locally correct the code. It iterates until all unit tests pass or the preset number of iterations is reached. The code files that have passed compilation and unit test verification in the sandbox environment are written back in a controlled manner.

7. The automated generation device for financial business modeling code driven by restricted agents according to claim 6, characterized in that, The toolset includes: FileIOTool is used to provide a secure encapsulation for file read and write operations, forcing the code-generated agent to operate on files only through FileIOTool; MvnTool encapsulates Maven compilation and testing commands, used to enforce that all code must undergo standardized builds and automated verification; StringReplaceTool, the targeted repair tool, is used to search and replace strings based on error logs; PlanningTool is used to break down code generation and repair tasks into an ordered list of subtasks.

8. The restricted agent-driven automated generation device for financial business modeling code according to claim 6, characterized in that, The code generation agent that runs under the constraints of the pre-defined toolset is specifically configured as follows: The code generation agent calls the PlanningTool to generate a list of subtasks with priority order based on the initial implementation code, unit test code, and process boundary component interfaces. Based on the subtask list, the code generates an Agent that calls FileIOTool to read files in the sandbox environment; The code generation agent calls MvnTool to execute the encapsulated mvn compile and mvn test commands; When compilation or testing fails, the code generation agent captures the error logs output by Maven, locates the line of code containing the defect and the logical error, and calls StringReplaceTool to perform minimal string replacement repair. Once all tasks are completed and unit tests pass or the preset number of iterations is reached, the code generation agent calls FileIOTool to copy the code files that have passed compilation and unit test verification back to the main project directory.

9. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, it implements the steps of the restricted agent-driven automated generation method for financial business modeling code as described in any one of claims 1 to 5.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the restricted agent-driven automated generation method for financial business modeling code as described in any one of claims 1 to 5.