Automatic program repairing method based on double-layer context and repairing intention

By employing a two-layer context and repair intent approach, the problem of insufficient accuracy and interpretability in existing automatic program repair technologies is solved, achieving high-quality program repair results.

CN121833475APending Publication Date: 2026-04-10SOUTHWEST UNIVERSITY FOR NATIONALITIES
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing automatic program repair technologies rely on fine-grained fault location information and lack targeted global context selection, making it difficult to generate correct patches in complex real-world scenarios. Furthermore, patches generated by large language models lack interpretability and accuracy.

Method used

We employ a two-layer context and repair intent-based approach, which constructs a conversational program repair framework through local context completion, intent reasoning, global information candidate library construction, and repair learning, and generates and verifies repair patches.

Benefits of technology

It improves the accuracy and interpretability of large language models in program repair, reduces the reliance on fine-grained fault localization, and generates high-quality repair patches.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833475A_ABST
    Figure CN121833475A_ABST
Patent Text Reader

Abstract

The invention provides an automatic program repairing method based on a double-layer context and a repairing intention, and belongs to the technical field of automatic program repairing. The method comprises the following steps: repairing a data set based on an automatic program, and complementing extracted local context information; according to the complemented local context information, constructing an intention reasoning prompt, and analyzing the purpose of the failed test case to obtain a repair intention; constructing a global information candidate library, updating the global information candidate library, and selecting to obtain global context information; constructing a dialogue type program repair framework, generating repair patches, testing the repair patches, setting a verification loop, and taking the repair patches meeting conditions as candidate reasonable patches; the candidate reasonable patches are confirmed, and automatic program repair is carried out; the problem that correct patches are difficult to generate in a complex actual scene due to the fact that repair performance depends on fine-grained defect positioning information and targeted global context selection is lacked in an existing automatic program repair technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of automatic program repair technology, and particularly relates to an automatic program repair method based on a two-layer context and repair intent. Background Technology

[0002] Existing technologies have proposed many APR (Automatic Program Repair) methods, with template-based APR being widely used and considered the most advanced. However, template-based tools are limited by the underlying repair template in terms of the types of defects they can repair, making it difficult to generalize to defects beyond the predefined template. Inspired by advances in deep learning (DL), existing technologies have proposed deep learning-based APR techniques to address the problems of traditional program repair methods. These techniques typically model program repair problems as neural machine translation (NMT) problems, i.e., by training an NMT model, defective code snippets are translated into correct code snippets, thus improving repair capabilities to some extent. However, existing deep learning-based techniques are still limited by the quality of training data (e.g., low-quality training data may contain noise) and the limited historical repair data, which prevents NMT models from generalizing to more types of defects.

[0003] Automated program repair aims to automatically fix software defects and plays a crucial role in software development and maintenance. To address the time-consuming and costly nature of manual defect repair by developers, researchers have proposed various automated program repair methods. However, existing automated program repair methods rely on fine-grained fault location information and lack targeted context selection, making it difficult to accurately repair complex defects in real-world application scenarios.

[0004] Existing technologies such as Large Language Models (LLMs) have achieved remarkable results in code-related tasks and software engineering. Existing technologies using LLMs for automatic program repair demonstrate their ability to solve program repair problems; however, these technologies still have the following shortcomings: 1. Performance depends on fine-grained fault location information; most method evaluations are based on the assumption of fine-grained (e.g., line-level) fault location; however, in real-world complex code scenarios, obtaining fine-grained fault location is very difficult, and incorrect location information may mislead large language models, resulting in the generation of inaccurate fix patches. 2. Ignoring the relationship between failure tests and program logic: Existing automated program repair methods have initially analyzed the causes of defects from failed test information and used failed tests for defect repair. For example, adding failed test code directly to repair prompts has proven beneficial for program repair. However, such automated program repair methods are limited by a lack of understanding of the underlying program repair logic, leading to inaccurate patches generated by large language models; furthermore, the decision-making process of large language models is opaque, resulting in a lack of interpretability in the generated patches. Therefore, fully analyzing the causes of defects and constructing the relationship between failed tests and repair logic through reasoning is crucial for guiding large language models in defect repair. 3. Lack of targeted global context selection; global context can improve the performance of program repair; existing repair frameworks extract relevant global context information based on code dependencies, effectively guiding pre-trained large language models to generate correct patches; however, this extraction still lacks targeting, which may lead to the extracted context failing to help program repair, or even introducing irrelevant information, distracting the repair process and generating invalid patches. Summary of the Invention

[0005] To address the aforementioned shortcomings in existing technologies, this invention provides an automatic program repair method based on a dual-layer context and repair intent. This method solves the problem that existing automatic program repair technologies rely on fine-grained defect location information for repair performance and lack targeted global context selection, making it difficult to generate correct patches in complex real-world scenarios.

[0006] To achieve the above objectives, the technical solution adopted by this invention is: an automatic program repair method based on a two-layer context and repair intent, comprising the following steps: S1. Based on the automatic program repair dataset, extract the local context information containing defects and complete it to obtain the completed local context information; S2. Based on the completed local context information, construct intent reasoning prompts and analyze the purpose of the failed test cases to obtain the repair intent; S3. Construct a global information candidate library, update the global information candidate library using an abstract syntax tree and a category-based preprocessing mechanism, and select global context information using the updated global information candidate library and the repair intent. S4, select repair learning, construct a dialogic program repair framework based on repair intention and repair learning, generate repair patches, test the repair patches, and set a verification loop to determine whether the repair patches meet the preset conditions. If so, output the repair patches that meet the conditions as candidate reasonable patches; otherwise, get the failed test and return to S2. S5. Confirm the candidate reasonable patches and use the confirmed reasonable patches to perform automatic program repair.

[0007] The beneficial effects of this invention are as follows: by making full use of failed test information, this invention explores a dialogic program repair method that combines repair intent with context information, thereby improving the program repair effect of large language models; and by using a two-layer context composed of local and global contexts, it improves the accuracy of repair patches; and by constructing a dialogic program repair framework guided by repair intent based on repair intent, it achieves accurate and reliable defect repair.

[0008] Further, S1 includes the following steps: S101. Based on the automatic program repair dataset, extract the core code statements containing defects to obtain local context information; S102. Using the source code file, complete the prefix and suffix codes of a specific area surrounding the local context information to obtain the completed local context information.

[0009] The beneficial effects of the above-mentioned further solutions are as follows: By extracting local context information containing defects and completing prefix and suffix codes, the present invention improves the compileability of patches, realizes the acquisition of fault location information that does not depend on fine-grained details, and reduces the dependence of automatic program repair on defect location information.

[0010] Furthermore, S2 includes the following steps: S201. Based on the completed local context information, align the system information with the current task to obtain the first system role; S202. Construct the first user instruction using the task description, expected response format, and placeholders. Combine the first system role and the first user instruction to construct an intent reasoning prompt. S203. Analyze failed test cases, track test execution information, and locate the fault-triggered statements; S204. Fill the placeholders with the fault trigger statement, the failed test case code, and the completed local context information to obtain the intent reasoning; S205. Analyze the testing objectives of failure test cases using a large language model, and use intent reasoning to process the testing objectives of failure test cases to obtain the repair logic for reasoning defects. S206. Summarize the repair logic and obtain the repair intention.

[0011] The beneficial effects of the above-mentioned further solutions are as follows: The present invention uses system roles in the reasoning prompt construction, which reduces the number of attempts in the repair patch construction process, and uses user instructions to explicitly guide the repair patch construction to meet the requirements, thereby improving the quality and consistency of the repair patch; and by analyzing the test purpose and repair logic from the failure information to extract the repair intent, construct the association between failure testing and program repair, deeply understand the underlying program repair logic, and improve the accuracy and interpretability of generating repair patches.

[0012] Furthermore, step S3 includes the following steps: S301. Construct a global information candidate library, obtain the second system role and the second user instruction, and construct an initial global context selection prompt template based on the second system role and the second user instruction; S302. Analyze the structural information of the source code file using an abstract syntax tree and store different categories of code blocks in key-value format; S303. Based on the stored code blocks, construct candidate libraries for classes, functions, and methods using a category-based preprocessing mechanism. S304. Update the global information candidate library using the class candidate library, function candidate library, and method candidate library. Fill the initial global context selection prompt template using the repair intent and the completed local context information. S305. Using the repair intent, the large language model, and the already filled global context, select the prompt template to obtain the global context information.

[0013] The beneficial effects of the above-mentioned further solutions are as follows: This invention performs program repair by selecting globally relevant contexts guided by the repair intent, providing accurate context for the large language model, and helps the large language model generate more accurate repair patches by considering global information; and improves the effectiveness of repair patches by utilizing correlation filtering rules.

[0014] Furthermore, step S4 includes the following steps: S401. Set up third system roles and third user commands, and build a patch generation prompt template; S402. Based on the patch generation prompt template, use the completed local context information, repair intent and global context information to construct the patch generation prompt, and use the large language model to generate the repair patch. S403. Define a verification feedback mechanism to learn and correct information generated by faulty patches during the patch generation process. S404. Test the patch and set a verification loop. If the patch fails to compile in the patch test results, use the knowledge module in the current dialog to analyze the reason for the compilation error. S405. In response to a new test case error triggered by a patch during testing, the current patch is used as local context information to re-execute the automatic program fix in the next dialog window. S406. Determine whether the number of times the repair patch has been generated has reached the preset number or whether the repair patch has passed all test cases. If so, mark the repair patch as a candidate reasonable patch. Otherwise, obtain the failed test and return to step S2 to regenerate the repair patch.

[0015] Furthermore, the complete repair process can be represented as follows: ; in, This indicates an automatic program repair function. This indicates a fix patch. This indicates the fault trigger statement. This indicates the code for a failed test case. This indicates the completed local context information. Represents the global information candidate database. This represents the modeling of the process of generating repair patches. This represents a dialog-based patch generation task function. Indicates the intention to repair. This indicates global context information selected based on the repair intent. This represents a model of the process of repairing intent through intent reasoning. This indicates the function for repairing intent reasoning. This represents the modeling of the process of selecting the global context. This represents the updated global information candidate database. This indicates that the task function is selected using the global context. This indicates that the information is based on the completed local context. Global information candidate database The process of filtering and updating.

[0016] The beneficial effects of the above-mentioned further solutions are as follows: This invention explores the key elements contained in intent reasoning, mines the two-layer context composed of local and global contexts, and constructs a prompt construction method for repairing program intentions. Combined with an iterative correction mechanism, it guides the large language model to achieve high-quality program repair that does not rely on fine-grained fault location information. This invention retains the powerful generation capabilities of the large language model and combines program analysis technology to make up for its shortcomings in accuracy and interpretability, providing a new perspective for automatic program repair. Attached Figure Description

[0017] Figure 1This is a flowchart of the method of the present invention.

[0018] Figure 2 This is a roadmap for the automatic program repair technology in this embodiment.

[0019] Figure 3 This is an example diagram for local context completion in this embodiment.

[0020] Figure 4 The following is a sample diagram illustrating the entire process of this embodiment.

[0021] Figure 5 This is a diagram illustrating the construction of the global information candidate library in this embodiment. Detailed Implementation

[0022] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.

[0023] Before describing this embodiment, the following terms will be explained: APR: Automatic Program Repair; NMT: Neural Machine Translation; LLMs: Large Language Models; AST: Abstract Syntax Tree; Defects4J: A version control library for projects containing defects; QuixBugs: A benchmark dataset containing common programming errors; Token: a token used to represent a person or object.

[0024] Example like Figure 1 As shown, this invention provides an automatic program repair method based on a two-layer context and repair intent, the implementation method of which is as follows: S1. Based on the automatic program repair dataset, extract the local context information containing defects and complete it to obtain the completed local context information. The specific steps are as follows: S101. Based on the automatic program repair dataset, extract the core code statements containing defects to obtain local context information; S102. Using the source code file, complete the prefix and suffix codes of a specific area surrounding the local context information to obtain the completed local context information.

[0025] In this embodiment, as Figure 2As shown, local context completion is performed. Local context completion aims to use necessary information to complete the defective code, obtain the complete defective code block, and provide defect-related code for program repair. The prefix and suffix codes of fault-triggered statements can provide key contextual information, improving the compileability of patches; extract the core code statements containing defects from the automatic program repair dataset, and complete the prefix and suffix codes of specific areas around the core code statements containing defects based on the source code files. The specific areas around the defects usually cover the declaration and implementation of the entire function or method, resulting in the completed local context; use the completed local context as input for automatic program repair. like Figure 3 As shown, this embodiment uses the Defects4J v1.2 dataset. Figure 3 It displays the local context information after completion for defect number Char-12, including local context information and prefix and suffix codes, without relying on fine-grained fault location.

[0026] S2. Based on the completed local context information, construct intent reasoning prompts and analyze the purpose of the failed test cases to obtain the repair intent. The specific steps are as follows: S201. Based on the completed local context information, align the system information with the current task to obtain the first system role; S202. Construct the first user instruction using the task description, expected response format, and placeholders. Combine the first system role and the first user instruction to construct an intent reasoning prompt. S203. Analyze failed test cases, track test execution information, and locate the fault-triggered statements; S204. Fill the placeholders with the fault trigger statement, the failed test case code, and the completed local context information to obtain the intent reasoning; S205. Analyze the testing objectives of failure test cases using a large language model, and use intent reasoning to process the testing objectives of failure test cases to obtain the repair logic for reasoning defects. S206. Summarize the repair logic and obtain the repair intention.

[0027] In this embodiment, as Figure 2 As shown, in the analysis of test objectives and repair logic, targeted intent reasoning prompts are designed by combining local context information, analyzing the test objectives of failed test cases and the repair logic of the code, and summarizing the repair intent to better guide the large language model for innovative repairs; it mainly includes two core steps: constructing reasoning prompts and reasoning repair intent. Reasoning hint construction, such as Figure 4As shown, an intent reasoning prompt template is constructed, including a first system role and a first user instruction. The system role aligns system messages with the current task, enabling it to quickly understand the task that needs to be solved. This helps the large language model obtain reasonable results faster with fewer attempts. The user instruction consists of a task description, the expected response format, and placeholders, which explicitly guide the large language model to generate output that meets the requirements. This guides the large language model to respond in a standardized manner, improving the quality and consistency of the output. The repair intent reasoning process involves tracing test execution information to locate the fault-triggered statement. This statement, along with the failed test case code and the completed local context information, is then used to fill in placeholders, resulting in the intent reasoning. A pre-trained big oracle model is used to analyze the purpose of the failed test, and the defect repair logic is inferred based on the test purpose, leading to a summary of the repair intent. The problem of analyzing the test purpose and repair logic can be modeled as follows: ; in, Indicates the intention to repair. This represents a function for repairing intent reasoning tasks implemented using a large language model. This indicates the fault trigger statement. This indicates the code for a failed test case. This indicates the local context information after completion.

[0028] S3. Construct a global information candidate library, update the global information candidate library using an abstract syntax tree and a category-based preprocessing mechanism, and select global context information using the updated global information candidate library and the repair intent. The specific steps are as follows: S301. Construct a global information candidate library, obtain the second system role and the second user instruction, and construct an initial global context selection prompt template based on the second system role and the second user instruction; S302. Analyze the structural information of the source code file using an abstract syntax tree and store different categories of code blocks in key-value format; S303. Based on the stored code blocks, construct candidate libraries for classes, functions, and methods using a category-based preprocessing mechanism. S304. Update the global information candidate library using the class candidate library, function candidate library, and method candidate library. Fill the initial global context selection prompt template using the repair intent and the completed local context information. S305. Using the repair intent, the large language model, and the already filled global context, select the prompt template to obtain the global context information.

[0029] In this embodiment, as Figure 2As shown, the global context selection is guided by the repair intent. By constructing a global information candidate library, a prompt for global context selection based on the repair intent is designed to achieve the active selection of relevant global contexts. The candidate library construction is specifically as follows: Figure 4 As shown, a global context selection prompt template is constructed, including the second system role and the second user instruction. The structural information of the source code file is analyzed by AST, and the code blocks of different categories are stored in the form of key-value pairs of <signature, code body>. Multiple candidate libraries are constructed using a category-based preprocessing mechanism. like Figure 5 As shown, taking Java code as an example, candidate libraries for classes, functions, and methods are constructed. The specific steps for constructing each candidate library are as follows: For the class candidate library, the code body of the class is simplified, retaining only the structural information of the class, including the class attribute declarations, methods, and the signatures of the constructor (method names and parameter types, etc.), filtering out the specific implementation code and detailed internal implementation logic of methods and constructors; For the function candidate library, the complete source code of the constructor appearing in the context is retained in the code body; For the method candidate library, based on the abstract syntax tree of the completed local context, token fields carrying code semantic information (including variable names and method names, etc.) are collected; and according to the semantic and naming convention strategies in the code writing process (variable names and method names usually follow specific naming conventions), relevance filtering rules are set to exclude method candidates with low relevance or redundancy in the global information candidate library, thereby improving the accuracy and effectiveness of generating repair patches from the large language model; The global context selection process specifically involves: updating the global information candidate library using candidate libraries for constructors, functions, and methods; filling the global context selection prompt template based on the updated global information candidate library, the repair intent, and the completed local context information to obtain global context selection prompts; and, guided by the repair intent, using a pre-trained large language model to select global context information that is helpful for program repair from the global perspective of classes, constructors, and methods. The global context selection guided by the repair intent can be modeled as follows: ; in, This indicates global context information selected based on the repair intent. This represents a function that implements global context selection using a large language model. Represents the global information candidate database. This indicates that the information is based on the completed local context. Global information candidate database The process of filtering and updating, This represents the updated global information candidate database.

[0030] S4. Select repair learning, construct a dialogic program repair framework based on the repair intention and repair learning, generate repair patches, test the repair patches, and set a verification loop to determine whether the repair patches meet the preset conditions. If so, output the repair patches that meet the conditions as candidate reasonable patches; otherwise, get the failed test and return to S2. The specific steps are as follows: S401. Set up third system roles and third user commands, and build a patch generation prompt template; S402. Based on the patch generation prompt template, use the completed local context information, repair intent and global context information to construct the patch generation prompt, and use the large language model to generate the repair patch. S403. Define a verification feedback mechanism to learn and correct information generated by faulty patches during the patch generation process. S404. Test the patch and set a verification loop. If the patch fails to compile in the patch test results, use the knowledge module in the current dialog to analyze the reason for the compilation error. S405. In response to a new test case error triggered by a patch during testing, the current patch is used as local context information to re-execute the automatic program fix in the next dialog window. S406. Determine whether the number of times the repair patch has been generated has reached the preset number or whether the repair patch has passed all test cases. If so, mark the repair patch as a candidate reasonable patch. Otherwise, obtain the failed test and return to step S2 to regenerate the repair patch.

[0031] In this embodiment, as Figure 2 As shown, a conversational program repair framework is implemented. Based on the repair intent and actively selected repair learning, combined with patch generation and patch verification, a conversational program repair framework is constructed, specifically as follows: Patch generation: such as Figure 4 As shown, by constructing a patch generation prompt template and setting third-party system roles and user specifications, for each program defect, a patch generation prompt is constructed based on the completed local context information, the repair intent, and the global context information, guiding the large language model to generate a patch to fix the current defect; wherein, the conversational patch generation can be modeled as: ; in, This indicates a fix patch; Therefore, the complete repair process can be represented as follows: ; in, This indicates an automatic program repair function. It is defined as; Verification Loop: Define a verification feedback mechanism and set up a verification loop. Specifically: Test the patch; based on the patch test results, instruct the verification feedback mechanism to learn and correct information generated by erroneous patches during patch generation; if the patch fails to compile, analyze the specific reasons for the compilation error through the knowledge module within the current dialogue and regenerate the patch; due to the limited context window of the large language model, the program repair method may still have problems such as forgetting or generating fictitious content. Therefore, set a preset number of times to repeatedly generate the patch based on the size of the context window of the large language model; if the patch triggers a new test case error during testing, use the existing patch as local context information and re-execute the repair process in the next dialogue window; if the number of times the patch is repeatedly generated reaches the preset number or the patch passes all test cases, mark the patch as a candidate reasonable patch and wait for further confirmation; otherwise, continue to regenerate the patch.

[0032] S5. Confirm the candidate reasonable patches and use the confirmed reasonable patches to perform automatic program repair.

[0033] In this embodiment, by confirming the candidate reasonable patches, the confirmed reasonable patches are obtained, and the confirmed reasonable patches are used for automatic program repair.

[0034] In this embodiment, evaluations on the widely used Defects4J (versions v1.2 and v2.0) and QuixBugs datasets show that the automatic program repair method of this invention, while generating only a small number of patches per defect (as low as 10 patches, compared to 100 or more patches per bug for other methods), still outperforms state-of-the-art baseline methods, fixing 24 and 30 unique bugs on Defects4J v1.2 and Defects4J v2.0, respectively. The automatic program repair method of this invention successfully repaired 68 bugs on the QuixBugs dataset (achieving an 85% repair rate), demonstrating its good generalization across different datasets and programming languages. The automatic re-repair method of this invention improves upon the underlying LLMs, increasing the number of correct patches on Defects4J v1.2 by 377% (GPT-3.5) and 268% (GPT-4).

Claims

1. A method for automatic program repair based on double-layer context and repair intention, characterized in that, Includes the following steps: S1. Based on the automatic program repair dataset, extract the local context information containing defects and complete it to obtain the completed local context information; S2. Based on the completed local context information, construct intent reasoning prompts and analyze the purpose of failed test cases to obtain the repair intent; S3. Construct a global information candidate library, update the global information candidate library using an abstract syntax tree and a category-based preprocessing mechanism, and select global context information using the updated global information candidate library and the repair intent. S4. Select repair learning, construct a dialogic program repair framework based on repair intention and repair learning, generate repair patches, test the repair patches, and set a verification loop to determine whether the repair patches meet the preset conditions. If so, output the repair patches that meet the conditions as candidate reasonable patches; otherwise, get the failed test and return to S2. S5. Confirm the candidate reasonable patches and use the confirmed reasonable patches to perform automatic program repair.

2. The method of claim 1, wherein the method further comprises: S1 includes the following steps: S101. Based on the automatic program repair dataset, extract the core code statements containing defects to obtain local context information; S102. Using the source code file, complete the prefix and suffix codes of a specific area surrounding the local context information to obtain the completed local context information.

3. The method of claim 2, wherein the method further comprises: S2 includes the following steps: S201. Based on the completed local context information, align the system information with the current task to obtain the first system role; S202. Construct the first user instruction using the task description, expected response format, and placeholders. Combine the first system role and the first user instruction to construct an intent reasoning prompt. S203. Analyze failed test cases, track test execution information, and locate the fault-triggered statements; S204. Fill the placeholders with the fault trigger statement, the failed test case code, and the completed local context information to obtain the intent reasoning; S205. Analyze the testing objectives of failure test cases using a large language model, and use intent reasoning to process the testing objectives of failure test cases to obtain the repair logic for reasoning defects. S206. Summarize the repair logic and obtain the repair intention.

4. The method of claim 3, wherein the method further comprises: S3 includes the following steps: S301. Construct a global information candidate library, obtain the second system role and the second user instruction, and construct an initial global context selection prompt template based on the second system role and the second user instruction; S302. Analyze the structural information of the source code file using an abstract syntax tree and store different categories of code blocks in key-value format; S303. Based on the stored code blocks, construct candidate libraries for classes, functions, and methods using a category-based preprocessing mechanism. S304. Update the global information candidate library using the class candidate library, function candidate library, and method candidate library. Fill the initial global context selection prompt template using the repair intent and the completed local context information. S305. Using the repair intent, the large language model, and the already filled global context, select the prompt template to obtain the global context information.

5. The method of claim 4, wherein, S4 includes the following steps: S401. Set up third system roles and third user commands, and build a patch generation prompt template; S402. Based on the patch generation prompt template, use the completed local context information, repair intent and global context information to construct the patch generation prompt, and use the large language model to generate the repair patch. S403. Define a verification feedback mechanism to learn and correct information generated by faulty patches during the patch generation process. S404. Test the patch and set a verification loop. If the patch fails to compile in the patch test results, use the knowledge module in the current dialog to analyze the reason for the compilation error. S405. In response to a new test case error triggered by a patch during testing, the current patch is used as local context information to re-execute the automatic program fix in the next dialog window. S406. Determine whether the number of times the repair patch has been generated has reached the preset number or whether the repair patch has passed all test cases. If so, mark the repair patch as a candidate reasonable patch. Otherwise, obtain the failed test and return to step S2 to regenerate the repair patch.

6. The method of claim 5, wherein the method further comprises: The complete repair process can be represented as follows: wherein, represents an automatic program repair function, represents a repair patch, represents a fault-triggering statement, represents a failed test case code, represents the completed local context information, represents a global information candidate library, represents modeling of the repair patch generation process, represents a conversational patch generation task function, represents a repair intent, represents global context information selected based on the repair intent, represents modeling of the repair intent inference process, represents a repair intent inference task function, represents modeling of the global context selection process, represents an updated global information candidate library, represents a global context selection task function, represents the process of filtering and updating the global information candidate library according to the completed local context information the global information candidate library .