Code automatic debugging and optimizing system and method based on AI intelligent agent

By using an AI-based automated code debugging and optimization system, the shortcomings of AI programming tools in terms of context awareness, automated testing, and environment adaptation are addressed. This enables efficient and automated code generation and deployment, improving code quality and development efficiency.

CN121116263APending Publication Date: 2025-12-12CHONGQING KAIYUAN GONGCHUANG TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511653382.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

Existing AI programming tools have limited context awareness and memory capabilities in multi-round interactions, low efficiency in automated testing and verification, and insufficient automation in environment adaptation and deployment, resulting in poor code generation consistency and a heavy burden on developers.

Method used

An AI-based automated code debugging and optimization system is adopted, including a coordinator module, a plan generation module, a code generation module, a test verification module, a deployment and operation module, a project summary module, and a context management module. It realizes context awareness of multi-turn dialogue, automated task execution and code generation, testing, and deployment, and provides a project summary report.

Benefits of technology

It improves the accuracy and quality of code generation, reduces human intervention, ensures code stability and reliability, simplifies the development process, and improves task processing efficiency and environment adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121116263A_ABST
    Figure CN121116263A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic code debugging and optimizing system and method based on an AI agent, and relates to the technical field of artificial intelligence and automatic programming, the system comprises a coordinator module, a plan generation module, a code generation module, a test verification module, a deployment operation module, a project summary module, a language model module and a context management module; the coordinator module supports to select and call an Agent for specific task execution according to the current task process, and the plan generation module is configured to automatically generate a development task plan according to the requirements of a user and transmit a task list to the code generation module. Through the exception retry mechanism and the task backtracking mechanism, the system can automatically detect errors in the code generation process and repair the errors, and the tedious process of traditional manual debugging is avoided. The system optimizes the code generation process by backtracking the historical task and adjusting the generation strategy, and the quality of the final code is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and automated programming technology, and in particular to a system and method for automatic code debugging and optimization based on AI intelligent agents. Background Technology

[0002] With the rapid development of artificial intelligence and large-scale model technology, large pre-trained models based on deep learning have become important tools for automated programming and code optimization. These models can perform tasks such as code generation, auto-completion, refactoring, debugging, and testing to a certain extent, providing new solutions for the intelligent and automated development of software.

[0003] However, existing AI programming tools typically have the following problems: Limited context awareness and memory: Existing large models have weak context tracking and memory management capabilities in multi-turn interactions, resulting in generated content that cannot maintain consistency with previous dialogues or tasks, and even duplicate or irrelevant outputs.

[0004] Low efficiency of automated testing and verification: After the code is generated, the correctness and functionality of the code often rely on manual testing, lacking an efficient and automated testing mechanism, and the verification process is cumbersome.

[0005] Insufficient automation in environment adaptation and deployment: Although large models can generate code, this code often cannot be automatically adapted to different runtime environments. It must be manually configured and deployed, which increases the burden on developers. Summary of the Invention

[0006] The purpose of this invention is to address the shortcomings of existing technologies by proposing an AI-based automatic code debugging and optimization system and method that can automatically parse user requirements, generate development plans, write code, execute automated tests, support one-click operation, and provide project summary reports.

[0007] The system has context awareness capabilities for multi-turn dialogues and can automatically execute development tasks by intelligently selecting tool functions.

[0008] Firstly, to address the aforementioned technical problems, this application adopts the following technical solution: an AI-based automatic code debugging and optimization system. The system includes a coordinator module, a plan generation module, a code generation module, a testing and verification module, a deployment and execution module, a project summary module, a language model module, and a context management module. The coordinator module supports selecting and calling the agent for specific task execution based on the current task flow. The plan generation module is configured to automatically generate development task plans according to user needs and pass the task list to the code generation module. The code generation module generates corresponding code according to the task plan and handles any exceptions that occur during the generation process. The testing and verification module verifies the generated code through automated testing and evaluates the code quality. The deployment and execution module automatically deploys and runs the code based on the generated code and test results. After code generation, testing, and deployment are completed, the project summary module generates a project summary report to help users understand the project. The language model module supports intelligent invocation of utility functions to complete tasks and supports task backtracking. The context management module maintains task consistency and coherence in multi-turn dialogues and manages user sessions and historical information.

[0009] More preferably, the coordinator module supports selecting the Agent to invoke for specific task execution based on the current task flow, specifically including: When a user submits a task request, the coordinator module first performs the initialization of the large model; The coordinator module calls the corresponding Agent module according to the type of task; After the system completes the task, the coordinator module will feed back the collected progress information to the front-end user. The task invocation formula is as follows: Let the task set be Each task has an execution time. and dependent task set Scheduling requires satisfying task dependencies, and the scheduling algorithm is expressed as follows: ; in: For the task The dependency set; For dependent tasks Completion time; For the task Execution time; The types of tasks include plan generation, code generation, test verification, deployment and execution, project summary, language modeling, and context management; The progress information includes task execution status, generated plan lists, and created or modified code files. The coordinator module provides real-time feedback on the task execution progress, which is calculated as: progress. Used to represent a task The completion status, with a value ranging from 0 to 1, is calculated using the following formula: ; in: :Task At any moment Progress; :Task At any moment The execution time already completed; :Task Total estimated execution time.

[0010] More preferably, the plan generation module is configured to automatically generate a development task plan based on user needs and pass the task list to the code generation module, specifically including: The plan generation module first parses the user's input requirements, constructs system prompt words, and calls the large model to generate a development task plan. The generated development task plan will undergo content checking. If the generated plan is abnormal or empty, the task plan will be regenerated. After the task list is generated, the generated plan list is transmitted to the calling end in real time through SSE streaming output. The SSE streaming output formula is as follows: Let the generated task list be The task list will be divided into multiple parts and transmitted in real time. The transmission of each part is represented by the following formula: ; in: At any moment The task list sent to the client It is a moment The generated task list.

[0011] More preferably, the code generation module generates corresponding code according to the task plan and handles abnormal situations that occur during the generation process, specifically including: After the plan generation module completes the task list, the code generation module reads and updates the status of the task list; The code generation module calls the large model to generate code, producing corresponding code files based on user needs and the requirements in the task list. The formula for calling the large model to generate code is: Let the large model be User needs are The task list is The generated code is The process of generating code can be represented as follows: ; in: Code generated from a large model; The system transforms user input into development tasks. A task list that indicates the steps and functional requirements needed to generate code; If problems are encountered during code generation, the code generation module will re-execute the task. The formula for the exception retry mechanism is as follows: Set a task The generation state is If the task fails, a retry mechanism will be triggered, with a retry count of [number missing]. and retry interval The formula is as follows: ; in: :Task The status after the retry; :Task The number of retries; : The time interval between each retry; Retry is a function of the retry process, indicating that if the task fails, the system will increase the number of retries and start generating the task again; Once the code is generated, it will be aggregated and output, and returned in the format of Action instructions.

[0012] More preferably, the test verification module verifies the generated code through automated testing and evaluates the code quality, specifically including: The test verification module parses the functional functions in the generated code file and calls the large model to automatically generate corresponding unit test framework test cases; The generated test cases are combined with the functional functions to form a complete test script; Use the unit test framework to execute test scripts and perform modular functional testing; The test results will be fed back to the coordinator module, which will also provide an automatic repair function.

[0013] More preferably, the deployment and execution module automatically deploys and runs the code based on the generated code and test results, specifically including: The deployment and runtime module will automatically select the corresponding runtime environment based on the language of the generated code; The deployment and runtime module provides a runtime environment for different programming languages ​​through pre-configured Docker images; The deployment and operation module will limit resources within the Docker container and system resources to prevent anomalies; The running status and results are returned and fed back to the coordinator module and the user.

[0014] More preferably, after code generation, testing, and deployment are completed, the project summary module generates a project summary report to help users understand the project, specifically including: After the deployment and operation module completes its tasks, the project summary module calls the large model to generate a project summary report. The project summary module returns a report to the user to help them understand the project's implementation and deployment process.

[0015] More preferably, the language model module supports intelligent invocation of utility functions to complete tasks and supports task backtracking, specifically including: The test and verification module executes the code and reports errors; The language model module reviews historical tasks, analyzes errors, and optimizes the generation strategy. Explore new development paths based on historical actions and automatically generate optimal solution code in subsequent tasks.

[0016] More preferably, the context management module maintains task consistency and coherence across multiple rounds of dialogue, and manages user sessions and historical information, specifically including: When a user engages in multiple rounds of dialogue with the system, the context management module stores the user's historical messages and session state in Redis.

[0017] When a conversation needs to be interrupted, the context management module uses the `Interrupt()` function to pause the conversation and resumes it from the interrupted point using the `Command` primitive when the user restarts the conversation. Let the current task state be... The operation when a task is interrupted is represented by the algorithm formula for pausing the dialogue using the Interrupt() function: ; in: This is the current status of the task; It is the current context state; It is an interrupt operation function that saves the current task state and context and suspends the execution of the task.

[0018] Secondly, to solve the aforementioned technical problems, another technical solution adopted in this application is: an AI-based automatic code debugging and optimization method, applied to the aforementioned AI-based automatic code debugging and optimization system, comprising the following steps: S1. Obtain user input requirements and generate a structured task list through semantic parsing; analyze user input requirements based on natural language processing models or pre-trained large models and transform the requirements into a development plan to be executed by the system; S2. Based on the generated task list, the AI ​​agent is invoked to process each task and automatically generate code. If code errors or anomalies are detected during the generation process, the system will automatically retry the generation process according to the preset error handling mechanism. S3. Automatically generate test cases that match the code functionality and use unit test scripts to test the code. If problems are found during the test, the system will automatically backtrack to historical tasks, identify errors, and fix them. S4. Based on the generated code language, automatically select the appropriate Docker image and run the code in an isolated container environment. The execution environment provided by Docker containers ensures that the code can run stably in different operating systems and environments. S5. After code generation, testing, and deployment are completed, a project summary report is automatically generated. The report includes a project description, feature implementation, usage methods, and deployment plan.

[0019] Advantages of this invention: This invention can automatically generate code that meets user input requirements, eliminating the need for manually writing large amounts of code. Through large models such as the DeepSeek API, the system can intelligently call utility functions, generation functions, and methods, thereby reducing manual intervention and improving the accuracy and quality of code generation. This invention utilizes an exception retry mechanism and a task backtracking mechanism, enabling the system to automatically detect and fix errors during code generation, thus avoiding the tedious process of traditional manual debugging. The system optimizes the code generation process by backtracking historical tasks and adjusting generation strategies, ensuring the quality of the final code.

[0020] This invention automatically tests and verifies the generated code using a unit test framework, ensuring the code is error-free during runtime. If a test fails, the system can automatically backtrack and fix the error, significantly improving the stability and reliability of the code.

[0021] This invention can intelligently analyze the dependencies between tasks and execute tasks according to the dependency order. For tasks without dependencies, the system can achieve parallel scheduling, reducing execution time and improving task processing efficiency. This invention utilizes technologies such as Lang Graph and Redis to enable the system to manage and persist user sessions, task states, and graph states, ensuring the consistency and continuity of tasks in multi-turn dialogues. This invention can interrupt a task at any time and resume it when needed, thereby ensuring that the task can continue as planned and avoiding unexpected interruptions or loss of context information during task execution. This invention can automatically select a suitable Docker image environment based on the code language and execute the code. Through the isolated container environment, the system can prevent potential malicious code from affecting the main system and ensure the stable operation of the code in various environments.

[0022] This invention automatically generates project summary reports, helping users understand the project's implementation status, usage methods, deployment plans, and other information, simplifying documentation work in the later stages of development. Attached Figure Description To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a schematic diagram of the structure of the AI-based automatic code debugging and optimization system of the present invention; Figure 2 This is a flowchart illustrating the method of Embodiment 2 of the present invention; Detailed Implementation The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] Figure 1 This is a flowchart illustrating an AI-based automatic code debugging and optimization system according to an embodiment of the present invention. It should be noted that if substantially the same result is achieved, the method of this application is not necessarily identical. Figure 1 The sequence of processes shown is limited.

[0025] Example 1 like Figure 1This document describes an AI-based automated code debugging and optimization system, comprising: a coordinator module, a plan generation module, a code generation module, a testing and verification module, a deployment and execution module, a project summary module, a language model module, and a context management module. The coordinator module supports selecting and invoking an agent to execute specific tasks based on the current task flow. The plan generation module is configured to automatically generate development task plans according to user needs and pass the task list to the code generation module. The code generation module generates corresponding code according to the task plan and handles exceptions that occur during the generation process. The testing and verification module verifies the generated code through automated testing and evaluates the code quality. The deployment and execution module automatically deploys and runs the code based on the generated code and test results. The project summary module generates a project summary report after code generation, testing, and deployment are completed to help users understand the project. The language model module supports intelligent invocation of utility functions to complete tasks and supports task backtracking. The context management module maintains task consistency and coherence in multi-turn dialogues and manages user sessions and historical information.

[0026] In this embodiment, specifically: The coordinator module is the core control unit of the system. It is responsible for managing the execution of task flows, coordinating the interaction between various modules, and scheduling tasks. Its main function is to receive user requests and, based on the requirements, call different functional modules to execute tasks. When a user submits a task request, the coordinator module first initializes the large model to ensure the system can use the latest large model for task processing. Based on the task type (e.g., plan generation, code generation, test verification, etc.), the coordinator module calls the corresponding Agent module. For example, when a user requests to generate a development plan, the coordinator calls the plan generation module; when code generation is required, the coordinator calls the code generation module. After each module completes its task, the coordinator feeds back the collected progress information to the front-end user, including task execution status, the generated plan list, and created or modified code files, ensuring the user can track the system's execution status in real time.

[0027] For example: a user requests code generation, and the coordinator initializes the large model.

[0028] The coordinator calls the plan generation module to generate a task list.

[0029] The coordinator continues to call the code generation module to generate code and obtain the code generation results.

[0030] After the code generation is complete, the coordinator calls the test and verification module to perform automated testing.

[0031] After the test is completed, the coordinator calls the deployment and execution module to execute the code and provide the running status.

[0032] The core purpose of task scheduling is to ensure that each module is executed in the correct order based on task dependencies and priorities, and to be able to dynamically adjust according to the current system state.

[0033] Suppose the system has multiple tasks (such as plan generation, code generation, test verification, etc.), and each task has a priority. The task set is Each task has an execution time. and dependent task set Scheduling requires satisfying task dependencies, and the scheduling algorithm is expressed as follows: Each task i needs to meet the following conditions: ; in: For the task The dependency set; For dependent tasks Completion time; For the task Execution time; The earliest start time for task i is when it must wait for all its preceding dependent tasks. Let be the completion time of task i.

[0034] Task dependency detection: The system parses the input / output parameters of each task in the task description file (or user input); If task The input parameters depend on the task. The output result is then determined. ; Dependency graph construction: The system constructs a directed acyclic graph based on the dependencies of all tasks: ; This graph can ensure the correct scheduling order through topological sorting; Dynamic update mechanism: When the task status changes (e.g., a task fails or is re-executed), the system updates the dependency graph in real time. Update rules: ; And recalculate the scheduling time: ; In actual task scheduling, the coordinator module needs to adjust the execution order of tasks according to their dependencies to ensure that tasks are executed in the order of their dependencies, without any premature execution.

[0035] The coordinator module also needs to provide real-time task progress feedback to the user.

[0036] Progress update feedback mechanism: Progress feedback needs to be displayed in real time through dynamic updates. For example, the system updates every [time period]. The task progress is updated periodically. ; in: The progress of task i at the next moment; : The current progress of task i; : The change in the task progress at the current moment.

[0037] Exception handling and retry mechanism: During task execution, situations such as task failure or timeout may occur, requiring exception handling and automatic retry.

[0038] The retry mechanism in this invention is used to automatically retries multiple times when a task fails, so as to ensure that the task is completed within the maximum allowed execution time.

[0039] Specifically, define the task The start time is The execution time per session is The retry interval after a task failure is The maximum allowed execution time is The current cumulative retry time is .

[0040] When a task fails, the system waits for a certain period of time. Then execute again and update the cumulative retry time: ; like The system will re-execute the task; if If the task fails, the execution will be terminated and the failure status will be recorded. Upon successful completion, the completion time will be calculated as follows: ; in, Task start time Execution time; : Cumulative retry time; Maximum tolerance duration; Task completion time.

[0041] In this way, the system can dynamically manage task retries within the maximum time constraint, ensuring the stability and robustness of system execution.

[0042] If the test verification module finds an error during testing, the system can determine whether to automatically fix the bug using the following formula: Fix=ErrorDetectedANDAuto-FixFlag; If Auto-FixFlag is enabled, the system will automatically fix errors; otherwise, manual intervention is required.

[0043] Feedback and status update after task completion: After the task is completed, the coordinator module needs to update the task status and provide feedback on the task results to the user.

[0044] Assume the state of task i is determined by Statu The completion status can be updated using the following formula: Task completion status formula: ; The coordinator module will adjust according to the task progress. Determine if the task is complete. If the progress has been reached... If the task is completed, the coordinator will perform a final status update.

[0045] The large model initialization algorithm is the first step when the coordinator module starts up, ensuring that the system loads and prepares the latest large model. The core of this algorithm is to ensure that all relevant modules can start smoothly and initialize shared resources.

[0046] Formula description: The core of model initialization is loading the model's weights and configuration: ; in: Indicates at time The model after initialization.

[0047] Load(Pretrained Model, Latest Checkpoint) means loading the latest pretrained model and checkpoint.

[0048] During initialization, the coordinator loads different sub-models based on different task types to ensure that it can support different functions in the task flow (such as plan generation, code generation, etc.).

[0049] The coordinator module schedules different functional modules (such as task generation, code generation, and test verification) based on the task type. The key to task scheduling lies in managing the execution order and scheduling mechanism of tasks.

[0050] The coordinator module schedules tasks sequentially based on their dependencies and ensures that no task is executed prematurely.

[0051] In task scheduling, task priority Based on the urgency of the task and execution time Calculation, where It is quantified through task deadlines and user-defined priorities: ; The formula for task priority is: ; in, and These are weighting coefficients set based on task type and execution duration. To assess the urgency of the task; This refers to the task execution time.

[0052] In this invention, the urgency of the task It is calculated based on the task's deadline and the priority weights entered by the user: The value reflects the urgency of the task; the closer to the deadline, the higher the urgency. Weighting coefficient and The impact of urgency and execution time on task priority can be controlled separately, and can be configured according to task type and execution duration.

[0053] The plan generation module is responsible for automatically generating development task plans based on user needs and passing the task list to subsequent modules for execution.

[0054] The plan generation module first parses the user's input requirements, constructs system prompts, and calls the large model to generate a development task plan.

[0055] The generated plan will undergo content checks. If the generated plan is abnormal or empty, the task plan will be regenerated to ensure that each task list item is executable.

[0056] After the task list is generated, the generated plan list is transmitted to the calling end in real time via SSE (Server-SentEvents) streaming output. For example: When a user submits a request, the plan generation module receives the task and generates a plan.

[0057] The task generation module passes the generated task list to the coordinator module, which then schedules subsequent code generation and testing / verification modules based on the task list.

[0058] If the task list generation fails, the plan generation module will regenerate the list and return it to the coordinator until the list content meets the requirements.

[0059] The key to parsing user requirements is to transform the user's natural language input into development tasks that the system can understand. To achieve this, models from Natural Language Processing (NLP) can be used for requirement parsing, converting user needs into specific tasks.

[0060] User Input Requirement Analysis: Assume the user's requirement is a string. The NLP model transforms this data into structured data that the system can understand. (Task list), Algorithm formula for parsing user needs: ; in: It is the user's input requirement (natural language string). It is a list of tasks (structured data) output by the parser, such as tasks like plan generation, code writing, and test verification.

[0061] Once the requirements are parsed into structured tasks, the system generates a detailed development task plan by calling the large model.

[0062] The user requirement parser NLPParser in this invention is based on a deep learning-based natural language processing model.

[0063] The main structure of this model includes: 1. Word embedding layer: Converts the input user request text into word vectors; 2. Transformer encoder: Captures contextual features in user requirements; 3. Decoder: Generates a task list based on the encoded features.

[0064] The model is trained through supervised learning and uses a large number of labeled datasets to optimize model parameters, ensuring that it can accurately parse user needs and generate structured task lists.

[0065] The analytical formula is: ; in, It is a natural language processor based on deep learning, and the model structure and training process are as described above.

[0066] Training data types: It contains code requirement corpora from multiple fields, such as natural language requirements and corresponding task lists for scenarios like web development, data analysis, and mobile applications, with a total sample size of no less than 100,000 entries. The sources include requirement posts from public technical forums and historical development requirement databases within enterprises.

[0067] Labeling method: Semantic segmentation and task type labeling are employed; Logic: First, divide the natural language requirements into sub-requirements according to functional modules, and then label the task type and dependencies for each sub-requirement.

[0068] For example, the requirement "develop a user management system, including registration and login" can be divided into three tasks: "develop the main framework of the user management system", "implement the registration function", and "implement the login function", and marked with "main task - sub-task" dependency.

[0069] Label Studio was used as the annotation tool, and the annotation consistency was no less than 0.85 after cross-validation.

[0070] Quantitative indicators for optimization objectives: Using F1 score as the core metric, it must achieve F1 ≥ 0.9 on a test set containing 10,000 unseen requirements.

[0071] At the same time, precision and recall are taken into account to ensure the model's universality on public datasets and enterprise-customized datasets.

[0072] Assume the system has an internal model The task generation formula is: ; in: It is a development plan generated from the model (containing detailed steps and priorities for each task).

[0073] The task plan generator Mplan in this invention is a natural language processing model based on deep learning, using a Transformer or RNN structure.

[0074] The input to the model is a list of tasks, including information such as task name, priority, and time limit.

[0075] The specific generation steps are as follows: 1. Task Information Extraction: Extract key information for each task from the input task list; 2. Encoder: Extracts the relationships and context between tasks using a Transformer or RNN encoder. 3. Decoder: Generates a task plan (Pplan) corresponding to the task list, and optimizes the execution order of tasks based on task priority and dependencies; 4. Output layer: Generates the final task plan.

[0076] The model is trained through supervised learning, using a list of labeled tasks and corresponding plans as training data, and updating the model parameters through optimization algorithms (such as the Adam optimizer).

[0077] To ensure the completeness and feasibility of the task plan, the system needs to check whether the generated task list meets the predetermined conditions. If a task in the plan is missing a necessary step or there is a conflict, the system will regenerate the task plan.

[0078] Assuming the generated task plan is The validity of the task list can be verified through a function. To verify, the formula is as follows: ; in: This is a check function that verifies the validity of the task list; if If the return value is True, the task schedule is valid; if the return value is False, the task schedule has a problem and needs to be regenerated.

[0079] Task list validity check: In this invention This function is used to validate the task list (TaskList). The specific implementation steps are as follows: 1. Step Completeness Check: Check whether each task contains all the necessary steps (such as initialization, execution, and completion). A task missing any necessary steps will be considered invalid.

[0080] 2. Dependency check: Verify that the dependencies between tasks are correct to avoid circular dependencies or missing dependent tasks in the task chain.

[0081] 3. Overall task list check: Determine the validity of the task list by checking the steps and dependencies of all tasks.

[0082] Returns True if all tasks are valid, otherwise returns False.

[0083] The required steps are based on task type and business scenario, defining a minimum set of required steps for different types of task lists; specifically including: It must include the steps of "requirements decomposition, code generation, unit testing, and deployment verification"; It must include the steps of "data acquisition, cleaning, analysis, and result output"; The "Required Steps Template Library" was compiled by statistical analysis of domain expert annotations and historical valid task lists.

[0084] The steps in the task list to be checked are matched element by element with the corresponding templates in the "Required Steps Template Library". If a step marked "Required" is missing in the template, the steps are considered incomplete. The core logic of the task list validity check function includes the following checks: Task dependency check: Confirms whether the prerequisite tasks for a given task have been completed.

[0085] Step integrity check: Verify that each step in the task plan is complete and that no critical operations are missing.

[0086] Time and resource constraint check: Confirm whether the execution time and resources for each task are reasonable.

[0087] If the task plan is invalid, regenerate the plan using the following formula: ; This will invoke the natural language parser again to regenerate the task plan.

[0088] Once the task list is generated, the system needs to transmit the task plan to the calling client in real time. SSE (Server-SentEvents) is a one-way communication protocol based on HTTP that allows the server to send real-time updates to the browser.

[0089] The system uses SSE streaming output to progressively transmit the task schedule to the client.

[0090] Let the generated task list be The task list will be divided into multiple parts for real-time transmission. The transmission of each part is represented by the following formula: SSE streaming output formula: ; in: At any moment The task list sent to the client It is a moment The generated task list.

[0091] After each part of the task plan is generated, the system transmits it to the client via SSE, and the client can display the progress of the task list in real time.

[0092] SSE's streaming output is achieved through the following process: ; Each part will be transmitted gradually as the generation progresses, and the connection will be maintained until all task lists have been transmitted.

[0093] The code generation module is responsible for generating the corresponding code according to the task plan and handling any exceptions that occur during the generation process.

[0094] Task status update and execution: After the plan generation module completes the task list, the code generation module reads and updates the status of the task list to ensure that the code generation tasks are consistent with the plan.

[0095] Call the large model to generate code: The code generation module will call the large model to generate code, and generate the corresponding code files according to the user's needs and the requirements in the task list.

[0096] Retrying in case of exceptions: If problems are encountered during code generation, the code generation module will re-execute the task to ensure that the final output code meets the expected requirements.

[0097] Summarizing and Outputting: After the code generation is complete, the generated code will be summarized and output, and returned in the format of Action instructions for use by other modules.

[0098] For example: The plan generation module generates a task list, and the code generation module generates code based on the task list.

[0099] If an exception occurs during the code generation process, the code generation module will re-execute the generation task.

[0100] After the code generation is complete, the code generation module returns the generated code and Action instructions to the coordinator module, ready for testing and verification. After receiving the task list, the code generation module needs to continuously track the task status and update it based on the task execution progress to ensure that the generated code matches the plan. This process requires monitoring and feedback on the task execution status to ensure that the generated code meets the expected requirements and specifications.

[0101] Assuming the task list is The task execution status of the code generation module is... The state update for each task is represented by the following formula: ; in: :Task In time The state. :Task At the previous point in time The state. : Task list, containing all tasks for which code needs to be generated. : Current task execution time, indicating the actual progress of the task.

[0102] Assuming a task The generation state is If the task fails, a retry mechanism will be triggered, with a retry count of [number missing]. and retry interval The formula is as follows: ; in: :Task The status after the retry; :Task The number of retries; : The time interval between each retry; Retry is a function of the retry process, indicating that if the task fails, the system will increase the number of retries and start generating the task again.

[0103] If a task fails on the first attempt, the system will automatically retry until the maximum number of retries is reached or the task succeeds.

[0104] Assume the large model is User needs are The task list is The generated code is The code generation process can be represented as calling the formula for generating code from the large model: ; in: Code generated from a large model; The system transforms user input into development tasks. : A task list that indicates the steps and functional requirements needed to generate code.

[0105] Task plan generation model : In this invention The model is a deep learning-based task plan generator. The model's input includes user requirements. and task list The output is the generated task plan. .

[0106] Select a pre-trained base model, including: Multilingual code generation model, encoder-decoder architecture model, and large model API fine-tuning; The training data selection criteria include: web development, data analysis, mobile applications, and backend services. Model structure: Input layer: handles user requests and task lists; Encoder: Extracts dependencies between tasks based on Transformer or RNN structures; Decoder: Generates specific task execution plans, taking into account factors such as task priority and time constraints; Output layer: Generates the final task plan .

[0107] Training methods: Supervised learning: Training is performed on a large amount of labeled data, and the cross-entropy loss function is used to minimize the difference between the generated plan and the actual plan; Algorithm optimization: The Adam optimizer is used to optimize the model's parameters to ensure the accuracy of the generated plan.

[0108] The large model generates corresponding code based on these inputs, enabling automated and intelligent code generation.

[0109] The testing and verification module is responsible for verifying the generated code through automated testing and evaluating the code quality.

[0110] Parse code files and generate test cases: The test verification module parses the functional functions in the generated code files and calls the large model to automatically generate the corresponding unit test framework test cases.

[0111] Concatenate test scripts: Combine the generated test cases with the functional functions to form a complete test script, ensuring that the test covers all functional points.

[0112] Execute unit tests: Use the unit test framework to execute test scripts and perform modular functional tests.

[0113] Test Feedback: If an error is detected during the test, the system will return an error message and provide an automatic repair function.

[0114] Test case generation process: The test case generation process in this invention includes the following steps: 1. Function Parsing: First, the function files in the code file are parsed. An Abstract Syntax Tree (AST) is used to parse the code and extract key information such as the name, parameters, return type, and function body of each function. The parsed function metadata will serve as the basis for generating test cases.

[0115] 2. Generate unit test cases by calling the large model: Based on the extracted functional information, the large model is called to automatically generate unit test cases, ensuring that the test covers a variety of situations such as valid input, invalid input, and boundary conditions.

[0116] 3. Ensure test coverage and boundary conditions: After test cases are generated, use code coverage analysis tools to ensure that the tests cover all paths of the code and generate boundary condition test cases, such as maximum value, minimum value, empty input, etc.

[0117] For example: After the task plan generation module completes code generation, the test verification module parses the generated code and automatically generates test cases.

[0118] The test verification module executes the generated test scripts and checks whether the code functions correctly using the unit test framework.

[0119] The test results will be fed back to the coordinator module, which will provide automatic repair functionality when necessary.

[0120] The deployment and execution module is responsible for automatically deploying and running the code based on the generated code and test results.

[0121] Automatic code language recognition: The deployment module will automatically select the corresponding runtime environment based on the language of the generated code.

[0122] Calling pre-configured Docker images: The deployment module provides a runtime environment for different programming languages ​​through pre-configured Docker images, ensuring that the code can be executed smoothly in the container.

[0123] Limiting system resources: To prevent malicious code from affecting the main system, the deployment module limits resources (such as CPU, memory, IO, and network) in the Docker container.

[0124] Return running status and results: The deployment module will return the running status, results and error messages of the code to ensure that users can understand the code execution status in a timely manner.

[0125] For example: After the testing and verification module completes the testing, the deployment and execution module automatically selects a suitable Docker image based on the code language.

[0126] The deployment module runs code in a Docker environment and limits system resources to prevent exceptions.

[0127] The running status and results are returned and fed back to the coordinator module and the user.

[0128] The project summary module is responsible for generating a project summary report after code generation, testing, and deployment are completed, to help users understand the project.

[0129] The project summary module generates a project summary report by calling the large model based on the project's execution status. The report covers information such as project description, feature implementation, usage, and deployment.

[0130] Formatted output report: The summary report is output in a specified format to ensure that the content of the report is easy to understand and can provide a reference for subsequent work.

[0131] Project Summary Module: The project summary module in this invention automatically generates project summary reports by calling a large model. The report generation process is as follows: 1. Input data processing: Project data, including project name, function description, deployment plan and other information, will be structured and passed to the large model.

[0132] 2. Large Model Report Generation: The large model receives project data and generates a project summary report, which includes a project overview, functional implementation, usage methods, deployment plan, etc.

[0133] 3. Report Formatting: The generated report is formatted according to a preset template to produce a final readable project summary report for users to view.

[0134] For example: After the deployment and operation module completes its tasks, the project summary module calls the large model to generate a project summary report.

[0135] The project summary module returns a report to the user, helping them quickly understand the project's implementation and deployment process.

[0136] The language model module is the intelligent hub of the system, responsible for generating code and handling development tasks. To ensure that the language model module works efficiently with other modules, it is necessary to clearly define the data flow, task transfer, and interaction mechanisms between the modules.

[0137] User Requirement Analysis: When a user submits a task request (e.g., requesting the generation of a code module or the design of a system function), the plan generation module calls the language model module to perform semantic analysis of the user's requirements. The language model module analyzes the task details based on the user's requirements and generates a structured development plan, ensuring that the generated task list can be used in subsequent task execution.

[0138] After a user submits a requirement, the plan is to generate a module to parse the requirement.

[0139] The language model module transforms requirements into structured tasks through semantic parsing.

[0140] Structured tasks are passed to the coordinator module as a task list.

[0141] Upon receiving the development plan, the task plan generation module passes the task list to the language model module, which then calls the corresponding utility functions (such as the DeepSeek API) to write the code. The language model module automatically generates code based on the development plan and historical task data, and intelligently calls utility functions during this process to ensure the code meets the requirements.

[0142] The Language Model Module (LMM) is built on the DeepSeek API framework, adopts a multi-layer Transformer architecture, and combines reinforcement learning strategies to achieve task action prediction.

[0143] The module mainly includes an input processing layer, a semantic understanding layer, an action decision layer, a tool invocation layer, and an output generation layer.

[0144] In its implementation, LMM receives user request vectors. Historical dialogue context Previous action and utility function set As input, the optimal action is predicted through the policy network. : ; when When dealing with a specific utility function, the system uses an action mapping matrix. Trigger the corresponding tool call.

[0145] The training process for the language model module includes: (1) Use large-scale code corpus for semantic understanding pre-training; (2) Supervised fine-tuning using manually labeled samples; (3) Improve the accuracy and stability of task execution by optimizing reinforcement learning based on human feedback.

[0146] Ultimately, this module can automatically select the appropriate Action based on the task context and call utility functions to complete tasks such as code generation, debugging, and summarization.

[0147] Reward function design: It quantifies the task execution accuracy and task execution stability from two dimensions, integrates intermediate step rewards and final rewards, and trains the reward model based on comparative learning of human preferences.

[0148] Policy network structure: A pre-trained model from the code domain is selected, with a 12-layer Transformer encoder, a 6-layer decoder, 12 attention heads, a hidden layer dimension of 768, a feed-forward dimension of 3072, and a newly added tool type embedding layer and decision layer to adapt to tool invocation decisions.

[0149] Policy optimization: The PPO algorithm is adopted, with the Actor-Critic architecture in collaboration. It combines the reward signal output by the reward model and updates the policy network through a loss function with KL divergence penalty to optimize the tool calling decision.

[0150] The plan generation module generates a task list and passes it to the code generation module.

[0151] The code generation module calls the language model module to write code.

[0152] The language model module automatically calls the corresponding utility functions and returns code based on the development plan.

[0153] The generated code is passed to the test and verification module for verification.

[0154] When the testing and verification module verifies the generated code, if errors are found, the language model module will backtrack and execute historical tasks to identify and correct the causes of the errors. By backtracking historical data, the language model module can identify problems in the code generation process and automatically optimize the generation strategy to avoid repeating errors.

[0155] Specifically: The algorithm for analyzing the root causes of errors is as follows: First, the errors output by the test and verification module are classified into types, including syntax errors, logic errors, and missing dependencies. Then, the execution history data stored in the context management module is retrieved. This execution history data includes requirement parsing results, task lists, code generation parameters, and tool call records. By calculating the correlation between error features and historical task steps, which involves matching error logs with the output features of corresponding task stages based on cosine similarity, the specific task link where the error occurred can be located, including requirement decomposition deviations, misuse of code generation templates, and errors in tool call parameters, thereby pinpointing the root cause.

[0156] The specific method for optimizing the generation strategy is as follows: Dynamically adjust the generation strategy based on the identified root cause of the error. If the discrepancy stems from a misunderstanding of the requirements, the semantic alignment between historical sessions and current requirements in the context management module should be strengthened. If the problem stems from a flaw in the code generation logic, update the generation parameters of the language model module; if the problem is from an error in tool invocation, correct the decision weights for tool selection.

[0157] Meanwhile, error cases and corresponding remediation strategies are stored in the experience base. During subsequent generation, the avoidance rules are invoked first through case matching to avoid repeating errors.

[0158] The test and verification module executes the code and reports errors.

[0159] The language model module reviews historical tasks, analyzes errors, and optimizes generation strategies.

[0160] Explore new development paths based on historical actions and automatically generate better code in subsequent tasks.

[0161] The language model module is not only responsible for generating code, but also for generating the configurations required to execute tasks. For example, when the deployment and running module needs to support different programming languages, the language model module intelligently selects appropriate utility functions and configurations (such as Docker images) based on historical data and task requirements to ensure that the code can execute smoothly.

[0162] After the code is generated, the language model module provides the deployment module with the configuration information required for execution.

[0163] The deployment and execution module executes code based on these configurations and returns the execution results.

[0164] In multi-turn dialogues, the language model module not only handles the current task but also maintains its connection with historical tasks. The context management module ensures that the language model can generate coherent code based on historical dialogues and task backtracking, avoiding repetitive or erroneous task execution.

[0165] The context management module stores historical conversations and task states.

[0166] The language model module maintains task continuity by backtracking through historical task data and generates code that meets user needs.

[0167] Through Lang Graph, the context management module ensures the execution order and task recovery of multi-turn dialogues.

[0168] The context management module is responsible for maintaining the consistency and coherence of tasks in multi-turn dialogues and managing user sessions and historical information.

[0169] The context management module uses Lang Graph and Redis to store the user's session state, ensuring that each round of dialogue can rely on the previous context to make the correct decisions.

[0170] During a conversation, users can pause the current conversation using Lang Graph's Interrupt() function and resume execution later, ensuring the task proceeds smoothly.

[0171] All session history, message state, and graph state are persistently stored for subsequent task backtracking and recovery.

[0172] For example: When a user engages in multiple rounds of dialogue with the system, the context management module stores the user's historical messages and session state in Redis.

[0173] When a conversation needs to be interrupted, the module uses the Interrupt() function to pause the conversation and resumes it from the interrupted point using the Command primitive when the user restarts the conversation.

[0174] When the system receives an interrupt command, the current task is paused, and its state (including dialog context, task state, etc.) is saved. Assuming the current task state is... The operation when a task is interrupted can be expressed as the core algorithm formula for task interruption: ; in: This is the current status of the task; It is the current context state; Interrupt is an interrupt operation function that saves the current task state and context and suspends the execution of the task.

[0175] The core algorithm formula for task recovery: When the system resumes a task, it recovers from the previously interrupted task state and context. Assume the task's interrupted state is... and context The recovery process can be represented as: ; in: This is the task status after recovery. It represents the context state saved at the time of the interruption. Restore is the restore function that loads the task state and context saved at the time of the interruption back into the system, allowing the task to continue execution.

[0176] Session history and task status can be accessed through Alternatively, it can be stored in a persistent storage system. The formula for persistence can be expressed as: ; in: This refers to the task's status information. Persist_Store is a persistent storage operation that saves the task status to a database or cache.

[0177] When a task needs to be restored, the system can retrieve the task status from storage using the following formula: ; Storage graph status: For graph state (such as the graph state of Lang Graph), a similar persistence method is used: ; in: This refers to the graph state. Graph_Persist_Store saves the graph state to persistent storage.

[0178] When it is necessary to restore the graph state, you can use: ; Example 2 like Figure 2 Another technical solution provided for the embodiments of this disclosure is: an AI-based automatic code debugging and optimization method, applied to the above-mentioned AI-based automatic code debugging and optimization system, comprising the following steps: S1. Obtain user input requirements and generate a structured task list through semantic parsing; analyze user input requirements based on natural language processing models or pre-trained large models and transform the requirements into a development plan to be executed by the system; S2. Based on the generated task list, the AI ​​agent is invoked to process each task and automatically generate code. If code errors or anomalies are detected during the generation process, the system will automatically retry the generation process according to the preset error handling mechanism. S3. Automatically generate test cases that match the code functionality and use unit test scripts to test the code. If problems are found during the test, the system will automatically backtrack to historical tasks, identify errors, and fix them. S4. Based on the generated code language, automatically select the appropriate Docker image and run the code in an isolated container environment. The execution environment provided by Docker containers ensures that the code can run stably in different operating systems and environments. S5. After code generation, testing, and deployment are completed, a project summary report is automatically generated. The report includes a project description, feature implementation, usage methods, and deployment plan.

[0179] Specifically, in this embodiment, user requests are received, and semantic parsing of task requirements is performed through a large model to generate an executable task list. Based on historical dialogues and task generation rules, each task is assigned a priority, and the execution order is automatically arranged according to dependencies.

[0180] In this embodiment, the step of generating code and automatically handling exceptions further includes the following sub-steps: Generate code by calling the DeepSeek API or similar tools; During the generation process, if the system detects code anomalies (such as logical errors, formatting issues, etc.), it will automatically trigger the exception handling mechanism to regenerate the code or perform repairs.

[0181] In this embodiment, the step of using a unit test script for automated testing further includes the following sub-steps: Automatically generate the corresponding unit test framework based on the generated code; If the test results do not meet expectations during the test run, the system will automatically optimize and adjust the test cases until all tests pass. In this embodiment, the step of calling the Docker environment according to the code language and supporting one-click execution further includes the following sub-steps: Select the appropriate Docker image based on the code language type (such as Python, Java, etc.); Automatically configure the runtime environment, execute code, and limit resource usage to prevent impact on the main system; Specifically, in this embodiment, the step of generating a project summary report further includes the following sub-steps: Collect and organize important information during the project development process (such as function implementation, usage methods, deployment steps, etc.) and automatically generate a summary report; Natural language generation technology is used to generate project summary documents, ensuring that the report content is concise and clear, and easy to use and maintain in the future.

[0182] Specifically, in this embodiment, the method further includes: Using a task backtracking mechanism, when errors or deviations are detected during task execution, historical task records are backtracked, and task execution strategies are adjusted to ensure the accurate execution of the final task. Specifically, in this embodiment, the method further includes: Task dependency analysis automatically analyzes the dependencies between tasks after the task list is generated, and optimizes the task execution order based on the dependencies to ensure that tasks are executed according to the predetermined process. Specifically in this embodiment, when a problem occurs during task execution (such as logical errors in the generated code or failure of automated tests), the backtracking mechanism can identify and correct the problem through the following steps: By analyzing historical execution status, the root cause of the error can be found.

[0183] Adjust generation strategy: Based on historical data and the context of task execution, readjust the task generation process or method to optimize the code generation strategy.

[0184] In this embodiment, the specific repair mechanism formula is as follows: ; in: Indicates the degree of error detected (e.g., logical errors or missing functionality in the generated code); Fix This is the automatic repair flag. If automatic repair is enabled, repair will be performed. This is the repair action, indicating whether to repair errors and re-execute the task.

[0185] Error severity measurement mechanism: This invention quantifies the degree of error in generated code by comprehensively measuring the detection results at the grammatical, logical, and functional levels.

[0186] Error types include syntax errors (detected by the compiler), logic errors (verified by unit tests), and missing functionality (analyzed by project requirements).

[0187] The system calculates the error severity value based on the following formula: ; in, The number of errors in each of the three categories. These are the weight parameters.

[0188] when When this happens, the system automatically triggers the repair module. Threshold Dynamically adjust to adapt to different code quality standards, defined as: ; Through this mechanism, the system can achieve quantitative assessment of code errors and adaptive repair triggering, improving the accuracy and stability of automated debugging.

[0189] Formula for constructing a task dependency graph: Assume there is One task, task With the task There are dependencies between them, and these dependencies can be represented by a graph. It means that, among them: It is a set of tasks Each task is a node.

[0190] It is a set of dependencies between tasks, representing the relationships between tasks. To the mission Dependencies (i.e., tasks) Must be in the task (Completed previously).

[0191] ; The goal of task scheduling optimization is to ensure that tasks are executed in the order of their dependencies. Assume the execution time of a task is... And the task Task-dependent Execution, task start time It should satisfy: ; in: It is a task The start time of execution. It is a task Execution time. Indicates task Dependency Task implement.

[0192] Task parallelism analysis can optimize scheduling by identifying the dependency-free relationships between tasks, assuming tasks and It is independent (i.e.) If they can be executed in parallel: ; This indicates that if the task and It has no dependencies and can be executed in parallel, thereby reducing the overall task execution time.

[0193] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A code automatic debugging and optimization system based on AI intelligent agents, characterized in that, The system includes a coordinator module, a plan generation module, a code generation module, a testing and verification module, a deployment and operation module, a project summary module, a language model module, and a context management module. The coordinator module supports selecting the agent to execute specific tasks based on the current task flow. The plan generation module is configured to automatically generate development task plans according to user needs and pass the task list to the code generation module. The code generation module generates corresponding code according to the task plan and handles exceptions that occur during the generation process. The test verification module verifies the generated code through automated testing and evaluates the code quality. The deployment and run module automatically deploys and runs the code based on the generated code and test results. After code generation, testing, and deployment are completed, the project summary module generates a project summary report to help users understand the project. The language model module supports intelligent invocation of utility functions to complete tasks and supports task backtracking. The context management module maintains the consistency and coherence of tasks in multi-turn dialogues and manages user sessions and historical information.

2. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The coordinator module supports selecting the Agent to execute a specific task based on the current task flow, specifically including: When a user submits a task request, the coordinator module first performs the initialization of the large model; The coordinator module calls the corresponding Agent module according to the type of task; After the system completes the task, the coordinator module will feed back the collected progress information to the front-end user. The task invocation formula is as follows: Let the task set be Each task has an execution time. and dependent task set Scheduling requires satisfying task dependencies, and the scheduling algorithm is expressed as follows: ; in: For the task The dependency set; For dependent tasks Completion time; For the task Execution time; The earliest start time for task i is when it must wait for all its preceding dependent tasks. Let i be the completion time of task i; The types of tasks include plan generation, code generation, test verification, deployment and execution, project summary, language modeling, and context management; The progress information includes task execution status, generated plan lists, and created or modified code files. The coordinator module provides real-time feedback on the task execution progress, which is calculated as: progress. Used to represent a task The completion status, with a value ranging from 0 to 1, is calculated using the following formula: ; in: :Task At any moment Progress; :Task At any moment Time elapsed since execution; :Task Total estimated execution time.

3. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The plan generation module is configured to automatically generate a development task plan based on user needs and pass the task list to the code generation module, specifically including: The plan generation module first parses the user's input requirements, constructs system prompt words, and calls the large model to generate a development task plan. The generated development task plan will undergo content checking. If the generated plan is abnormal or empty, the task plan will be regenerated. After the task list is generated, the generated plan list is transmitted to the calling end in real time through SSE streaming output. The SSE streaming output formula is as follows: Let the generated task list be The task list will be divided into multiple parts and transmitted in real time. The transmission of each part is represented by the following formula: ; in: At any moment The task list sent to the client It is a moment The generated task list.

4. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The code generation module generates corresponding code according to the task plan and handles exceptions that occur during the generation process, specifically including: After the plan generation module completes the task list, the code generation module reads and updates the status of the task list; The code generation module calls the large model to generate code, producing corresponding code files based on user needs and the requirements in the task list. The formula for calling the large model to generate code is: Let the large model be User needs are The task list is The generated code is The process of generating code can be represented as follows: ; in: Code generated from a large model; The system transforms user input into development tasks. A task list that indicates the steps and functional requirements needed to generate code; If problems are encountered during code generation, the code generation module will re-execute the task. The formula for the exception retry mechanism is as follows: Set a task The generation state is If the task fails, a retry mechanism will be triggered, with a retry count of [number missing]. and retry interval The formula is as follows: ; in: :Task The status after the retry; :Task The number of retries; : The time interval between each retry; Retry is a function of the retry process, indicating that if the task fails, the system will increase the number of retries and start generating the task again; Once the code is generated, it will be aggregated and output, and returned in the format of Action instructions.

5. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The testing and verification module verifies the generated code through automated testing and evaluates the code quality, specifically including: The test verification module parses the functional functions in the generated code file and calls the large model to automatically generate corresponding unit test framework test cases; The generated test cases are combined with the functional functions to form a complete test script; Use the unit test framework to execute test scripts and perform modular functional testing; The test results will be fed back to the coordinator module, which will also provide an automatic repair function.

6. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The deployment and execution module automatically deploys and runs the code based on the generated code and test results, specifically including: The deployment and runtime module will automatically select the corresponding runtime environment based on the language of the generated code; The deployment and runtime module provides a runtime environment for different programming languages ​​through pre-configured Docker images; The deployment and execution module will limit resources within the Docker container and also limit system resources; The running status and results are returned and fed back to the coordinator module and the user.

7. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The project summary module generates a project summary report after code generation, testing, and deployment are completed to help users understand the project. Specifically, it includes: After the deployment and operation module completes its tasks, the project summary module calls the large model to generate a project summary report. The project summary module returns a report to the user to help them understand the project's implementation and deployment process.

8. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The language model module supports intelligent invocation of utility functions to complete tasks and supports task backtracking, specifically including: The test and verification module executes the code and reports errors; The language model module reviews historical tasks, analyzes errors, and optimizes the generation strategy. Explore new development paths based on historical actions and automatically generate optimal solution code in subsequent tasks.

9. The AI-based automatic code debugging and optimization system according to claim 1, characterized in that, The context management module maintains task consistency and coherence across multiple rounds of dialogue, and manages user sessions and historical information, specifically including: When a user engages in multiple rounds of dialogue with the system, the context management module stores the user's historical messages and session state in Redis. When a conversation needs to be interrupted, the context management module uses the `Interrupt()` function to pause the conversation and resumes it from the interrupted point using the `Command` primitive when the user restarts the conversation. Let the current task state be... The operation when a task is interrupted is represented by the algorithm formula for pausing the dialogue using the Interrupt() function: ; in: This is the current task status; It is the current context state; It is an interrupt operation function that saves the current task state and context and suspends the execution of the task.

10. A method for automatic code debugging and optimization based on AI intelligent agents, characterized in that, To implement the AI-based automatic code debugging and optimization system according to any one of claims 1-9, the system includes the following steps: S1. Obtain user input requirements and generate a structured task list through semantic parsing; analyze user input requirements based on natural language processing models or pre-trained large models and transform the requirements into a development plan to be executed by the system; S2. Based on the generated task list, the AI ​​agent is invoked to process each task and automatically generate code. If code errors or anomalies are detected during the generation process, the system will automatically retry the generation process according to the preset error handling mechanism. S3. Automatically generate test cases that match the code functionality and use unit test scripts to test the code. If problems are found during the test, the system will automatically backtrack to historical tasks, identify errors, and fix them. S4. Based on the generated code language, automatically select the appropriate Docker image and run the code in an isolated container environment. The execution environment provided by Docker containers ensures that the code can run stably in different operating systems and environments. S5. After code generation, testing, and deployment are completed, a project summary report is automatically generated. The report includes a project description, feature implementation, usage methods, and deployment plan.

Citation Information

Cited By

  • High-reliability optical storage integrated controller based on domestic chip and real-time operating system

    CN122092516A

  • Multi-role intelligent agent cooperation automatic software development method, system and equipment and medium

    CN122219895A