Code task processing method and code repairing method

Through automated code task processing methods, the context code of the code warehouse is used to process pending code, solving the problem of time-consuming and error-prone manual processing in the prior art, and improving processing efficiency and accuracy.

CN119807017APending Publication Date: 2025-04-11ALIBABA (CHINA) CO LTD

Patent Information

Application Number
CN202510296166.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In the prior art, code processing tasks need to be executed manually, which is time-consuming and prone to human errors, affecting the processing effect.

Method used

Provides a code task processing method, which can obtain pending code, perform error analysis and operation, and retrieve context code from the code repository if it fails, and process pending code based on the context code to achieve automated processing.

Benefits of technology

Reduce manual intervention, improve the efficiency and accuracy of code task processing, and realize warehouse-level code task processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807017A_ABST
    Figure CN119807017A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a code task processing method and a code repairing method. The code task processing method comprises the steps of obtaining a to-be-processed code of a target code task; performing error analysis on the to-be-processed code, and running the to-be-processed code to obtain a running result under the condition of determining that the to-be-processed code does not comprise a code error based on an analysis result; when it is determined that the to-be-processed code fails to run based on the running result, a context code of the to-be-processed code is retrieved from a code warehouse; and processing the to-be-processed code according to the context code to obtain a code processing result. Through error analysis and operation of the to-be-processed code, the functionality of the to-be-processed code is ensured, the overall quality and stability of the to-be-processed code are further improved, warehouse-level code task processing is achieved by retrieving the context code in the code warehouse, the context code is utilized to process the to-be-processed code, automatic processing is achieved, and the processing efficiency of the to-be-processed code is improved. And the processing efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a code task processing method and a code repair method. Background Art

[0002] In the software development process, code processing is an indispensable part of ensuring software quality, performance and security. As the complexity of software systems increases, developers need to perform various operations on source code, including but not limited to formatting, refactoring, error detection and repair, dependency management, etc. These tasks are crucial to keeping the code base clean and improving code readability and maintainability.

[0003] Currently, these code processing tasks are usually performed manually by developers. However, manually performing code tasks not only takes a lot of time, but may also cause additional problems due to human errors, affecting the effect of code processing. Therefore, an efficient and accurate code task processing solution is urgently needed. Summary of the invention

[0004] In view of this, an embodiment of the present specification provides a code task processing method. One or more embodiments of the present specification also relate to a code repair method, a code task processing device, a code repair device, a computing device, an electronic device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of the present specification, a code task processing method is provided, including: obtaining a code to be processed of a target code task; performing error analysis on the code to be processed, and when it is determined based on the analysis result that the code to be processed does not include a code error, running the code to be processed to obtain a running result; when it is determined based on the running result that the code to be processed fails to run, retrieving context code of the code to be processed from a code repository; processing the code to be processed according to the context code to obtain a code processing result.

[0006] According to a second aspect of an embodiment of the present specification, a code repair method is provided, including: obtaining a code to be repaired of a code repair task; performing error analysis on the code to be repaired, and when it is determined based on the analysis result that the code to be repaired does not include a code error, running the code to be repaired to obtain an operation result; when it is determined based on the operation result that the code to be repaired fails to run, retrieving context code of the code to be repaired from a code repository; and repairing the code to be repaired according to the context code to obtain a code repair result.

[0007] According to a third aspect of the embodiments of this specification, a code task processing device is provided, including: a first acquisition module, configured to acquire a code to be processed of a target code task; a first running module, configured to perform an error analysis on the code to be processed, and when it is determined based on the analysis result that the code to be processed does not include a code error, run the code to be processed to obtain a running result; a first retrieval module, configured to retrieve context code of the code to be processed from a code repository when it is determined based on the running result that the code to be processed fails to run; and a processing module, configured to process the code to be processed according to the context code to obtain a code processing result.

[0008] According to a fourth aspect of an embodiment of the present specification, a code repair device is provided, including: a second acquisition module, configured to acquire a code to be repaired of a code repair task; a second running module, configured to perform an error analysis on the code to be repaired, and when it is determined based on the analysis result that the code to be repaired does not include a code error, run the code to be repaired to obtain a running result; a second retrieval module, configured to retrieve context code of the code to be repaired from a code repository when it is determined based on the running result that the code to be repaired fails to run; and a repair module, configured to repair the code to be repaired according to the context code to obtain a code repair result.

[0009] According to a fifth aspect of an embodiment of this specification, a computing device is provided, comprising: a memory and a processor; the memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, and the computer program / instructions, when executed by the processor, implement the steps of the method provided in the first aspect or the second aspect above.

[0010] According to the sixth aspect of the embodiments of this specification, an electronic device is provided, comprising: a memory and a processor, the memory and the processor being connected via a bus; the memory is used to store computer programs / instructions, and the processor is used to execute computer programs / instructions, and the computer program / instructions, when executed by the processor, implement the steps of the method provided in the first aspect or the second aspect above.

[0011] According to the seventh aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the method provided in the first aspect or the second aspect are implemented.

[0012] According to an eighth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the steps of the method provided in the first aspect or the second aspect above.

[0013] The code task processing method provided by an embodiment of the present specification includes: obtaining the code to be processed of the target code task; performing error analysis on the code to be processed, and running the code to be processed to obtain the running result when it is determined based on the analysis result that the code to be processed does not include a code error; retrieving the context code of the code to be processed from the code warehouse when it is determined based on the running result that the code to be processed fails to run; processing the code to be processed according to the context code to obtain the code processing result. By performing preliminary error analysis on the code to be processed, potential problems of the code to be processed, such as syntax errors, logical errors or non-compliance with coding standards, can be found to ensure the accuracy of the code to be processed. After determining that the code to be processed does not include a code error, running the code to be processed can verify whether the actual behavior of the code to be processed meets expectations, which not only ensures the functionality of the code to be processed, but also improves the overall quality and stability of the code to be processed. When the code to be processed fails to run, the background and dependencies of the code to be processed are understood by retrieving the context code in the code warehouse, which improves the coverage of the context information required for processing, enhances the processing capability of complex code tasks, and realizes warehouse-level code task processing. The code to be processed is processed according to the context code, which realizes the automatic code task processing, reduces the manual intervention, and improves the efficiency and accuracy of the code task processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 is an architecture diagram of a code task processing system provided by an embodiment of this specification; Figure 2 is a flow chart of a code task processing method provided by an embodiment of this specification; Figure 3 is a processing flow chart of a code task processing method provided by an embodiment of this specification; Figure 4 is a processing flow chart of another code task processing method provided by an embodiment of this specification; Figure 5 is a flow chart of a code repair method provided by an embodiment of this specification; Figure 6 It is a structural diagram of a code task processing device provided by an embodiment of this specification; Figure 7 It is a structural schematic diagram of a code repair device provided by an embodiment of this specification; Figure 8 is a structural block diagram of a computing device provided by one embodiment of this specification; Fig. 9 It is a structural block diagram of an electronic device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0015] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0016] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms of "one", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items. The term "at least one" in one or more embodiments of this application refers to "one or more", and "multiple" refers to "two or more". The term "including" is an open description and should be understood as "including but not limited to", and may include other content on the basis of the content already described.

[0017] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0018] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0019] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM, Large Language Model), a multi-modal pre-training model, etc.

[0020] When the big model is used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image description (IC, Image Caption), image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.

[0021] First, the terms involved in one or more embodiments of this specification are explained.

[0022] Code repair: refers to the process of repairing and improving the code through a series of operations when errors or defects are found in the code during the software development process.

[0023] Repository-level code repair: refers to the code quality improvement and error repair work for the entire code repository, rather than just focusing on a single file or module. Repository-level code repair tasks may involve multiple aspects, such as code style unification, performance optimization, security vulnerability patching, dependency updates, etc.

[0024] Static analysis: is a debugging method that checks the security, performance, and design flaws of code without executing it.

[0025] Static analysis tools: are software development tools used to analyze source code without executing it. These tools identify potential problems and improvement opportunities by parsing and checking code structure, syntax, data flow, and other information. Static analysis tools are mainly used to improve code quality, find potential errors, ensure compliance with coding standards, and enhance security.

[0026] Chain-of-Through (CoT): is a technique used in the field of NLP and artificial intelligence, especially useful in solving complex problems, reasoning tasks, and multi-step decision-making processes. CoT can prompt the model to explicitly output the intermediate step-by-step reasoning steps before outputting the final answer, which can enhance the arithmetic, common sense, and reasoning performance of large models.

[0027] Semantic search: is an information search method that aims to improve the accuracy and relevance of search results by understanding the context and meaning behind the search query.

[0028] Unit test function: referred to as "unit test function", refers to a code snippet used to verify whether the smallest testable unit (such as a function, method, or class) in a software application works as expected. Well-written unit test functions can help developers find errors early and ensure the correctness and stability of the code.

[0029] Unit testing: It is an important testing method in the software development process, which aims to verify whether the smallest testable unit (usually a function, method or class) in the software application works as expected. Unit testing is usually written and executed by developers to ensure that each unit can run normally independently and to quickly discover potential problems when the code is changed.

[0030] Agent: refers to a system that relies on a large model as the core, combines tool calls and knowledge base to complete more complex tasks.

[0031] Taking the code repair task as an example, code errors may not only affect the functional correctness of the program, but also lead to security vulnerabilities, thereby threatening the security of user data. Therefore, timely and effective identification and repair of errors in the code is crucial to maintaining the stability and reliability of the software. Traditionally, this process relies on the expertise and experience of developers, who need to carefully analyze error reports, locate problem codes, and design effective repair solutions.

[0032] However, manual bug fixing has significant limitations and challenges. First, the process is extremely time-consuming and labor-intensive, requiring developers to review potential sources of errors one by one, which greatly slows down the speed of repair, especially when faced with large-scale software projects. Second, due to the complexity and multi-level structure of software systems, accurately locating the cause of errors often requires cross-domain expertise, which increases the difficulty of repair. In addition, human errors are prone to occur during the manual repair process, resulting in the emergence of new problems or the failure to completely resolve old problems. Finally, this method is difficult to apply on a large scale and cannot meet the needs of rapid iteration and deployment.

[0033] In order to solve the above problems, the embodiments of this specification propose a method that combines static repair and dynamic repair, and integrates the context code in the code repository, so as to realize automated code task processing, reduce manual intervention, and improve the efficiency and accuracy of code task processing. Specifically, the code to be processed of the target code task is obtained; error analysis is performed on the code to be processed, and when it is determined based on the analysis result that the code to be processed does not include code errors, the code to be processed is run to obtain the running result; when it is determined based on the running result that the code to be processed fails to run, the context code of the code to be processed is retrieved from the code repository; according to the context code, the code to be processed is processed to obtain the code processing result.

[0034] In this specification, a code task processing method is provided. This specification also relates to a code repair method, a code task processing device, a code repair device, a computing device, an electronic device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0035] See also Figure 1 , Figure 1 The following is an architecture diagram of a code task processing system provided by an embodiment of the present specification. The code task processing system may include a client 100 and a server 200; The client 100 is used to send the to-be-processed code of the target code task to the server 200; The server 200 is used to perform error analysis on the code to be processed, and when it is determined based on the analysis result that the code to be processed does not include a code error, run the code to be processed to obtain a running result; when it is determined based on the running result that the code to be processed fails to run, retrieve the context code of the code to be processed from the code repository; process the code to be processed according to the context code to obtain a code processing result; and send the code processing result to the client 100; The client 100 is also used to receive the code processing result sent by the server 200.

[0036] By applying the solution of the embodiments of the present specification, the background and dependencies of the code to be processed are understood by retrieving the context code in the code repository, thereby improving the coverage of the context information required for processing, enhancing the processing capabilities of complex code tasks, and realizing warehouse-level code task processing. The code to be processed that does not include code errors and fails to run is processed according to the context code, thereby realizing automated code task processing, reducing manual intervention, and improving the efficiency and accuracy of code task processing.

[0037] In actual applications, the code task processing system may include a server 200 and multiple clients 100, wherein the client 100 may include an end-side device, and the server 200 may include a cloud-side device. A communication connection may be established between multiple clients 100 through the server 200. In the code task processing scenario, the server 200 is used to provide code task processing services between multiple clients 100. Multiple clients 100 may serve as senders or receivers, respectively, and achieve communication through the server 200. Users may interact with the server 200 through the client 100 to receive data sent by other clients 100, or send data to other clients 100, etc. In the code task processing scenario, users may publish data streams to the server 200 through the client 100, and the server 200 may generate code processing results based on the data stream, and push the code processing results to other clients that have established communication.

[0038] The client 100 and the server 200 are connected via a network. The network provides a medium for a communication link between the client 100 and the server 200. The network may include various connection types, such as wired or wireless communication links or optical fiber cables, etc. The data transmitted by the client 100 may need to be encoded, transcoded, compressed, etc. before being released to the server 200.

[0039] The client 100 can be a browser, an application (APP, Application), or a web application such as HyperText Markup Language Version 5 (H5, HyperText Markup Language5) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The client 100 can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server 200, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The client 100 can be deployed in an electronic device and needs to rely on the device to run or some APPs in the device to run. For example, the electronic device can have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, mailbox clients, social platform software, etc.

[0040] The server 200 may include servers that provide various services, such as servers that provide communication services to multiple clients, servers for background training that support models used on clients, and servers that process data sent by clients. It should be noted that the server 200 can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server of a distributed system, or a server combined with a blockchain. The server can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0041] It is worth noting that the code task processing method provided in the embodiments of this specification is generally executed by the server, but in other embodiments of this specification, the client may also have similar functions to the server, thereby executing the code task processing method provided in the embodiments of this specification. In other embodiments, the code task processing method provided in the embodiments of this specification may also be jointly executed by the client and the server. Next, taking the server executing the code task processing method proposed in the embodiments of this specification as an example, the code task processing method is described in detail.

[0042] See also Figure 2 , Figure 2 A flowchart of a code task processing method provided by an embodiment of the present specification is shown, which specifically includes the following steps: Step 202: Obtain the code to be processed of the target code task.

[0043] It should be noted that the target code task refers to the task that needs to be completed during the software development or maintenance process. The task goal of the target code task can be to add new features, fix errors, optimize performance, etc. The target code task can be different types of code tasks, such as code debugging tasks, code repair tasks, etc. The pending code refers to the source code provided to achieve the target code task. The pending code can be a code snippet or a complete source code document. The pending code can be code that is in the development stage, or it can be code extracted from the code repository and prepared for repair or review.

[0044] In practical applications, there are many ways to obtain the pending code of the target code task, which are selected according to the actual situation, and the embodiments of this specification do not limit this. In one possible implementation of this specification, the pending code sent by the user through the client can be received. In another possible implementation of this specification, the pending code can be read from the code warehouse or other data acquisition device based on the code file name and line number.

[0045] Step 204: Perform error analysis on the code to be processed, and if it is determined based on the analysis result that the code to be processed does not include a code error, run the code to be processed to obtain a running result.

[0046] It should be noted that the process of error analysis of the code to be processed can be regarded as the process of static analysis of the code to be processed. Error analysis aims to identify code errors in the code to be processed without executing the code to be processed. Code errors include but are not limited to syntax errors, logic errors, indentation errors, inconsistent coding standards, etc. The analysis result refers to the result obtained by error analysis of the code to be processed. The analysis result can be divided into two types: including code errors and excluding code errors. Optionally, when the analysis result indicates that the code to be processed includes code errors, the error message of the code to be processed can also be given in the analysis result. Running the code to be processed refers to the process of compiling and executing the code to be processed. The purpose of running the code to be processed is to check whether the function of the code to be processed can work as expected. Running the code to be processed is usually performed in a test environment to avoid affecting the running production system. The running result refers to the result obtained after running the code to be processed. The running result is used to describe whether the code to be processed runs successfully, that is, whether it includes dynamic errors. Therefore, the running result can be divided into two types: running failure and running success. If the running result indicates that the code to be processed fails to run, it means that the code to be processed cannot work as expected and the code to be processed needs to be processed. If the running result indicates that the code to be processed runs successfully, it means that the code to be processed can work as expected, and the processing of the target code task can be ended at this time.

[0047] In practical applications, there are many ways to run the code to be processed and obtain the running results, which are selected according to the actual situation. The embodiments of this specification do not limit this. In one possible implementation of this specification, the code to be processed can be saved as a file (such as script.py), and the corresponding command can be entered in the command line to execute the file (for example, for a Python script, python script.py can be used to execute) to obtain the running results. In another possible implementation of this specification, the code to be processed can be run using the test code to obtain the running results.

[0048] In an optional embodiment of the present specification, the above-mentioned error analysis of the code to be processed, when it is determined based on the analysis result that the code to be processed does not include a code error, running the code to be processed to obtain the running result may include the following steps: Perform error analysis on the code to be processed and obtain analysis results; If it is determined based on the analysis result that the code to be processed does not include a code error, obtaining a test code of the code to be processed; Use the test code to run the code to be processed and obtain the running results.

[0049] It should be noted that test code refers to test cases or test scripts written to verify and ensure the functional correctness of the code to be processed. Test code is used to check whether the code to be processed works as expected, which can help developers find and fix potential problems at an early stage. Test code includes but is not limited to different types of test cases such as unit testing, integration testing, and system testing. If the test code is a unit test function, the process of running the code to be processed using the unit test function can be regarded as the unit test process. During the unit test process, the unit test running tool can be called to run the code to be processed based on the test code to obtain the running results. For example, you can use a test framework (such as Pytest) to execute the test and use the eXtensible Markup Language (XML) format to record the error information in the analysis results. Using XML format to record the error information can not only make the data more structured and readable, but also improve the scalability and cross-platform compatibility of the data, which is convenient for subsequent automated processing and integration.

[0050] In practical applications, there are many ways to perform error analysis on the code to be processed and obtain analysis results, which can be selected according to actual conditions. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a static analysis tool (such as Pylint) can be called to perform static analysis on the code to be processed to obtain analysis results. The analysis results obtained by the static analysis tool can be recorded in JSON format, so as to clearly represent complex data structures (such as nested objects and arrays), which helps to record various information in the analysis results in detail (such as error type, location, description, etc.). In another possible implementation of this specification, error analysis rules can be configured in a code management system (such as GitHub, GitLab), and error analysis rules can be used to perform error analysis on the code to be processed to obtain analysis results.

[0051] Furthermore, there are multiple ways to obtain the test code of the code to be processed, which can be selected according to the actual situation, and the embodiments of this specification do not limit this. In one possible implementation of this specification, the test code of the code to be processed sent by the user through the client can be received. In another possible implementation of this specification, the test code of the code to be processed can be read from the test code library.

[0052] By applying the solution of the embodiments of this specification, a preliminary error analysis is performed on the code to be processed, and potential problems of the code to be processed, such as syntax errors, logic errors, or situations that do not meet coding standards, can be found to ensure the accuracy of the code to be processed. After determining that the code to be processed does not include code errors, running the code to be processed can verify whether the actual behavior of the code to be processed meets expectations, which not only ensures the functionality of the code to be processed, but also improves the overall quality and stability of the code to be processed.

[0053] In an optional embodiment of the present specification, if an error analysis is performed on the code to be processed and it is determined that the code to be processed includes a code error, the code error in the code to be processed can be modified. There are many ways to modify the code error in the code to be processed, and the specific selection is made according to the actual situation. The embodiments of the present specification do not impose any restrictions on this. In a possible implementation method of the present specification, the code error in the code to be processed can be directly modified according to the modification suggestions given by the static analysis tool to obtain a modified code to be processed, wherein the modified code to be processed does not include a code error.

[0054] In another possible implementation of the present specification, the task processing model may be used to modify code errors in the code to be processed, that is, after the error analysis of the code to be processed is performed, the following steps may be further included: In the case where it is determined based on the analysis result that the code to be processed includes a code error, constructing modification prompt information based on the analysis result and the code to be processed; The modification prompt information is input into the task processing model to obtain a modified code to be processed, wherein the modified code to be processed does not include a code error.

[0055] It should be noted that the modification prompt information refers to a piece of text or instruction (prompt) provided to the task processing model, which is used to guide the task generation model to modify the code errors of the code to be processed and generate the modified code to be processed. The task processing model refers to an algorithm model with code modification capabilities. The task processing model can be a large model in the code field, or it can be a deep learning model trained based on sample processing code, sample analysis results of sample processing code, and sample modification code. The task processing model can receive modification prompt information, and automatically modify the code to be processed according to the modification prompt information, and output the modified code to be processed. The processing goal of the task processing model is to repair the errors found by static error analysis and obtain the modified code to be processed that does not include code errors.

[0056] In practical applications, there are many ways to construct modification prompt information based on the analysis results and the code to be processed, and the specific selection is based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a modification prompt template can be obtained, and the analysis results and the code to be processed are filled into the modification prompt template to obtain the modification prompt information. The modification prompt template can be a simple text integration template, or it can be a modification prompt template based on CoT. Through the modification prompt template based on CoT, the task processing model can be guided to give a thinking process based on the modified code to be processed. In another possible implementation of this specification, since the code length is usually long, in order to ensure that the task processing model can correctly modify the code, the output format requirements of the task processing model can be additionally added to the modification prompt information, such as outputting the modification code snippet and the modification identification information of the modification code snippet, without the need to output the complete modified code to be processed, to avoid redundant and time-consuming output of the task processing model.

[0057] Furthermore, there are multiple ways to input the modification prompt information into the task processing model to obtain the modified code to be processed, and the specific selection is made according to the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the task processing model can directly output the complete modified code to be processed. Therefore, the modification prompt information can be directly input into the task processing model to obtain the modified code to be processed. In another possible implementation of this specification, the task processing model can output the modification code snippet and the modification identification information of the modification code snippet, without outputting the complete modified code to be processed. Therefore, the modification prompt information can be input into the task processing model to obtain the modification code snippet and the modification identification information of the modification code snippet, and then according to the modification identification information and the modification code snippet, the code to be processed is modified to obtain the modified code to be processed.

[0058] By applying the solution of the embodiments of this specification and using the task processing model to modify the code errors in the code to be processed, the modified code to be processed can be obtained efficiently and accurately.

[0059] In an optional embodiment of the present specification, the above-mentioned inputting the modification prompt information into the task processing model to obtain the modified code to be processed may include the following steps: Inputting the modification prompt information into the task processing model to obtain the modified code snippet and modification identification information of the modified code snippet, wherein the modification identification information is used to identify the position of the modified code snippet in the code to be processed; The code to be processed is modified according to the modification identification information and the modification code fragment to obtain the modified code to be processed.

[0060] It should be noted that, in the case where it is determined based on the analysis results that the code to be processed includes a code error, the code snippet in which the code error occurs in the code to be processed can be called an erroneous code snippet. The modified code snippet refers to a correct code snippet without a code error obtained after modifying the erroneous code snippet. The modification identification information is used to identify the position of the modified code snippet in the code to be processed. The modification identification information can be the line number, code block number, etc. of the modified code snippet in the code to be processed. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. Optionally, in order to enable the task processing model to generate the modified code snippet more accurately, the modification prompt information can also include error identification information of the erroneous code snippet, and the error identification information is used to guide the task processing model to modify the erroneous code snippet to obtain the modified code snippet.

[0061] In actual applications, there are many ways to modify the code to be processed according to the modification identification information and the modified code snippet, and obtain the modified code to be processed. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a code editing tool can be called to modify the code to be processed according to the modification identification information and the modified code snippet to obtain the modified code to be processed. Among them, the code editing tool is used to parse the modified code snippet output by the task processing model and apply it to the code to be processed based on the modification identification information. The input of the code editing tool is the start identifier and end identifier of the modified code snippet and the modified code snippet, and the output is the modified code to be processed. In another possible implementation of this specification, the code snippet to be modified can be screened out from the code to be processed according to the modification identification information; the modified code snippet is used to replace the code snippet to be modified in the code to be processed to obtain the modified code to be processed.

[0062] By applying the solution of the embodiment of this specification, the task processing model only outputs the modified code fragment and the modification identification information of the modified code fragment, avoiding the output of longer code content, shortening the processing time of the task processing model, and improving the processing efficiency.

[0063] Step 206: When it is determined based on the running result that the code to be processed fails to run, the context code of the code to be processed is retrieved from the code repository.

[0064] It should be noted that the code repository refers to a system used to store and manage code and its historical changes. Context code refers to other code parts that are associated with the code to be processed. The relationship between the context code and the code to be processed includes but is not limited to call relationships, data dependencies, and configuration dependencies. The context code helps to fully understand the working environment and dependencies of the code to be processed, so as to process the code more accurately. Retrieval refers to the operation of obtaining a specific code snippet from the code repository.

[0065] In actual applications, there are many ways to retrieve the context code of the code to be processed from the code repository, which can be selected according to the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the context code of the code to be processed can be retrieved from the code repository through the application programming interface (API, Application Programming Interface) provided by the code hosting platform. In another possible implementation of this specification, at least one target retrieval tool can be called to retrieve the context code of the code to be processed from the code repository.

[0066] In an optional embodiment of the present specification, the above-mentioned retrieving the context code of the code to be processed from the code repository may include the following steps: Selecting at least one target search tool corresponding to the code to be processed from multiple candidate search tools; At least one target retrieval tool is called to retrieve context codes of the code to be processed from the code repository.

[0067] It should be noted that multiple candidate search tools refer to a group of tools that can be used to retrieve specific code from a code repository. Multiple candidate search tools can be adapted to various scenarios. The candidate search tool can be a command line tool, an API interface, a development environment (IDE, Integrated Development Environment) plug-in or other forms of search tools. The way in which the search tool retrieves the context code from the code repository includes repository parsing, symbol search, code snippet search, semantic search, etc., which are selected according to the actual situation, and the embodiments of this specification do not impose any restrictions on this. Through symbol search, code snippet search and semantic search, the coverage of context information required for code processing can be improved, and the processing ability of complex code tasks can be enhanced. The target search tool refers to one or more search tools suitable for target code tasks selected from multiple candidate search tools. The target search tool can more efficiently retrieve the context code of the code to be processed from the code repository. If the number of target search tools is multiple, the process of retrieving the context code can be regarded as a multi-tool mixed search process.

[0068] In practical applications, there are many ways to screen out at least one target retrieval tool corresponding to the code to be processed from multiple candidate retrieval tools, and the selection is made based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, based on the specific requirements of the code to be processed, at least one target retrieval tool that can meet these requirements can be selected from multiple candidate retrieval tools. In another possible implementation of this specification, based on the retrieval performance of multiple candidate retrieval tools, at least one target retrieval tool corresponding to the code to be processed can be screened out, and the performance of at least one target retrieval tool is higher than that of other candidate retrieval tools other than the target retrieval tool.

[0069] By applying the solution of the embodiment of this specification, at least one target search tool corresponding to the code to be processed is first determined, and then the target search tool is called to search for context code, so as to ensure that the context code of the code to be processed can be efficiently and accurately retrieved from the code repository.

[0070] In an optional embodiment of the present specification, at least one target search tool may be screened out using the task processing model. That is, the above-mentioned screening out at least one target search tool corresponding to the code to be processed from multiple candidate search tools may include the following steps: Obtain tool description information of multiple candidate search tools; Construct filtering prompt information based on tool description information, code to be processed, and running results; The screening prompt information is input into the task processing model to obtain a tool screening result, wherein the tool screening result is used to indicate at least one target retrieval tool corresponding to the code to be processed.

[0071] It should be noted that the tool description information of the candidate search tool refers to a series of detailed information used to describe the candidate search tool. The tool description information includes but is not limited to the functions, characteristics, applicable scenarios, and advantages and disadvantages of the candidate search tool. The screening prompt information refers to a piece of text or instruction provided to the task processing model, which is used to guide the task generation model to screen out at least one target search tool from multiple candidate search tools. The task processing model refers to an algorithm model with text processing capabilities. The task processing model can be a large model in the code field, or a deep learning model trained based on sample target search tools, sample candidate search tools, and sample description information of sample candidate search tools. The task processing model can receive the screening prompt information and automatically generate a tool screening result based on the screening prompt information. The tool screening result can be the target tool description information, the target tool identifier, the search parameters of the target search tool, etc. If the tool screening result is the target tool description information, the candidate search tool corresponding to the target tool description information can be determined as the target search tool; if the tool screening result is the target tool identifier, the candidate search tool corresponding to the target tool identifier can be determined as the target search tool.

[0072] In actual applications, there are many ways to obtain tool description information of multiple candidate search tools, which can be selected based on actual conditions, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, tool description information of each candidate search tool sent by a user through a client can be received. In another possible implementation of this specification, the tool description information of the candidate search tool can be extracted from the tool description file of the candidate search tool.

[0073] Furthermore, there are multiple ways to construct the filtering prompt information according to the tool description information, the code to be processed and the running results, and the specific selection is made according to the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a filtering prompt template can be obtained, and the tool description information, the code to be processed and the running results can be filled into the filtering prompt template to obtain the filtering prompt information. The filtering prompt template can be a simple text integration template, or it can be a CoT-based filtering prompt template. Through the CoT-based filtering prompt template, the task processing model can be guided to give a thinking process based on the tool filtering results. In another possible implementation of this specification, description keywords can be extracted from the tool description information, and filtering prompt information can be constructed according to the description keywords, the code to be processed and the running results.

[0074] By applying the solution of the embodiments of this specification, at least one target search tool is screened out from multiple candidate search tools through a task processing model, thereby reducing manual intervention and improving the efficiency and accuracy of determining the target search tool.

[0075] In actual applications, there are many ways to call at least one target retrieval tool to retrieve the context code of the code to be processed from the code repository. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, at least one target retrieval tool can be directly called to retrieve the context code of the code to be processed from the code repository. In another possible implementation of this specification, the retrieval parameters of different target retrieval tools may be different. In order to ensure the normal operation of the target retrieval tool, at least one target retrieval tool can be called based on the retrieval parameters required by the target retrieval tool to retrieve the context code of the code to be processed from the code repository.

[0076] In an optional embodiment of the present specification, the tool screening result includes a search parameter of at least one target search tool; the above-mentioned calling at least one target search tool to retrieve the context code of the code to be processed from the code repository may include the following steps: Based on the search parameters, at least one target search tool is called to retrieve context codes of the code to be processed from the code repository.

[0077] It should be noted that the search parameters refer to various options and parameters that need to be configured and adjusted when calling at least one target search tool. By configuring the search parameters, the search behavior of the target search tool can be precisely controlled, so as to find the required context code more efficiently.

[0078] By applying the solution of the embodiment of this specification, at least one target search tool is called based on the search parameters to retrieve the context code from the code repository, thereby ensuring that the target search tool can work normally and the accuracy of the context code.

[0079] Step 208: Process the code to be processed according to the context code to obtain a code processing result.

[0080] It should be noted that the code processing result refers to the final result after the code to be processed is processed based on the context code. Processing the code to be processed involves fixing the problem that causes the operation failure, optimizing the performance of the code to be processed, and enhancing the security of the code to be processed. The code processing result obtained after the code to be processed is processed is a code without code errors and can correctly perform the expected task.

[0081] In actual applications, there are many ways to process the code to be processed according to the context code and obtain the code processing results. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the task processing model can be used to process the code to be processed based on the context code to obtain the code processing results. In another possible implementation of this specification, the automated refactoring tools (Automated Refactoring Tools) can be called to process the code to be processed according to the context code to obtain the code processing results.

[0082] By applying the scheme of the embodiments of this specification, potential problems of the code to be processed can be discovered through preliminary error analysis of the code to be processed, thereby ensuring the accuracy of the code to be processed. After determining that the code to be processed does not include code errors, the code to be processed is run to verify whether the actual behavior of the code to be processed meets expectations, which not only ensures the functionality of the code to be processed, but also improves the overall quality and stability of the code to be processed. When the code to be processed fails to run, the background and dependencies of the code to be processed are understood by retrieving the context code in the code repository, thereby improving the coverage of the context information required for processing, enhancing the processing capabilities of complex code tasks, and realizing warehouse-level code task processing. The code to be processed is processed according to the context code, thereby realizing automated code task processing, reducing manual intervention, and improving the efficiency and accuracy of code task processing.

[0083] In an optional embodiment of the present specification, the above-mentioned processing of the code to be processed according to the context code to obtain the code processing result may include the following steps: Build processing prompt information based on the code to be processed, the running results and the context code; Input the processing prompt information into the task processing model to obtain the code processing result.

[0084] It should be noted that the processing prompt information refers to a piece of text or instruction provided to the task processing model, which is used to guide the task generation model to process the code to be processed based on the running results and context code to generate a code processing result. The task processing model refers to an algorithm model with code processing capabilities. The task processing model can be a large model in the code field, or it can be a deep learning model trained based on sample code processing results, sample processing code, sample running results, and sample context code of the sample processing code. The task processing model can receive processing prompt information, and automatically process the code to be processed according to the processing prompt information, and output the code processing results. The goal of the task processing model is to fix the errors generated when the code to be processed is running, and obtain a code processing result that can be successfully run.

[0085] In practical applications, there are many ways to construct modification prompt information based on the analysis results and the code to be processed, and the specific selection is based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a modification prompt template can be obtained, and the analysis results and the code to be processed are filled into the modification prompt template to obtain the modification prompt information. The modification prompt template can be a simple text integration template, or it can be a modification prompt template based on CoT. Through the modification prompt template based on CoT, the task processing model can be guided to give a thinking process based on the modified code to be processed. In another possible implementation of this specification, since the code length is usually long, in order to ensure that the task processing model can correctly modify the code, the output format requirements of the task processing model can be additionally added to the modification prompt information, such as outputting the modification code snippet and the modification identification information of the modification code snippet, without the need to output the complete modified code to be processed, to avoid redundant and time-consuming output of the task processing model.

[0086] Furthermore, there are multiple ways to construct processing prompt information based on the code to be processed, the operation result and the context code, and the specific selection is based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a processing prompt template can be obtained, and the code to be processed, the operation result and the context code are filled into the processing prompt template to obtain processing prompt information. The processing prompt template can be a simple text integration template, or it can be a processing prompt template based on CoT. Through the processing prompt template based on CoT, the task processing model can be guided to give a thinking process based on the code processing results. In another possible implementation of this specification, the operation result keywords can be extracted from the operation results, and the processing prompt information can be constructed based on the operation result keywords, the code to be processed and the context code.

[0087] There are many ways to input the processing prompt information into the task processing model to obtain the code processing result, which can be selected according to the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the task processing model can directly output the complete code processing result. Therefore, the modification prompt information can be directly input into the task processing model to obtain the code processing result. In another possible implementation of this specification, the task processing model can output the target code fragment and the target identification information of the target code fragment after processing the code fragment in the code to be processed based on the context code, without outputting the complete code processing result. Therefore, the processing prompt information can be input into the task processing model to obtain the target code fragment and the target identification information of the target code fragment, and then the code to be processed is processed according to the target code fragment and the target identification information to obtain the code processing result.

[0088] By applying the solution of the embodiments of this specification, the code to be processed is processed based on the context code using the task processing model, and the code processing result can be obtained efficiently and accurately.

[0089] In an optional embodiment of the present specification, the above-mentioned inputting the processing prompt information into the task processing model to obtain the code processing result may include the following steps: Inputting the processing prompt information into the task processing model to obtain the target code segment and target identification information of the target code segment, wherein the target identification information is used to identify the position of the target code segment in the code to be processed; The code to be processed is processed according to the target identification information and the target code fragment to obtain a code processing result.

[0090] It should be noted that, in the case where it is determined based on the running result that the code to be processed has failed to run, the code snippet in the code to be processed that causes the running failure can be called a failed code snippet. The target code snippet refers to the correct code snippet that runs successfully after processing the failed code snippet. The processing identification information is used to identify the position of the failed code snippet in the code to be processed. The processing identification information can be the line number, code block number, etc. of the failed code snippet in the code to be processed. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. Optionally, in order to enable the task processing model to generate the target code snippet more accurately, the processing prompt information can also include failure identification information of the failed code snippet. The failure identification information is used to guide the task processing model to process the failed code snippet to obtain the target code snippet.

[0091] In practical applications, there are many ways to process the code to be processed according to the target identification information and the target code fragment, and obtain the code processing result. The specific selection is based on the actual situation, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, a code editing tool can be called to process the code to be processed according to the target identification information and the target code fragment to obtain the code processing result. In another possible implementation of this specification, the code fragment to be replaced can be screened out from the code to be processed according to the target identification information; the target code fragment is used to replace the code fragment to be replaced in the code to be processed to obtain the code processing result.

[0092] By applying the solution of the embodiments of this specification, the task processing model only outputs the target code fragment and the target identification information of the target code fragment, avoiding the output of longer code content, shortening the processing time of the task processing model, and improving the processing efficiency.

[0093] In an optional embodiment of the present specification, the above-mentioned processing of the code to be processed according to the target identification information and the target code fragment to obtain the code processing result may include the following steps: According to the target identification information, the code fragment to be replaced is selected from the code to be processed; The target code fragment is used to replace the code fragment to be replaced in the code to be processed, and a code processing result is obtained.

[0094] It should be noted that the code fragment to be replaced refers to the part of the code to be processed that needs to be replaced according to the target identification information. The target code fragment refers to the new code fragment used to replace the code fragment to be replaced, and the target code fragment is usually a modified or optimized code.

[0095] Exemplarily, if the target identification information is the starting line number and ending line number of the target code fragment, the code fragment to be replaced corresponding to the starting line number and the ending line number can be determined from the code to be processed, and the target code fragment can be used to replace the code fragment to be replaced in the code to be processed to obtain the code processing result.

[0096] By applying the solution of the embodiments of this specification, the target code fragment is used to replace the code fragment to be replaced in the code to be processed, so as to realize automatic code task processing, reduce manual intervention, and improve the efficiency and accuracy of code task processing.

[0097] In an optional embodiment of the present specification, before constructing the processing prompt information according to the code to be processed, the running result and the context code, the following steps may also be included: Acquire processing auxiliary information, wherein the processing auxiliary information includes at least one of problem description information of the code to be processed, code description information, and test code; According to the code to be processed, the running result and the context code, constructing the processing prompt information may include the following steps: Construct processing prompt information based on the code to be processed, running results, context code and processing auxiliary information.

[0098] It should be noted that processing auxiliary information refers to information additionally provided to the task processing model, which can assist the task processing model in processing the code to be processed. Problem description information refers to information that describes in detail the specific problems or defects existing in the code to be processed. Problem description information includes but is not limited to the phenomenon and possible causes of the problem. Problem description information can help the task processing model to identify the problem that needs to be processed. Code description information refers to information that describes the function, structure and logic of the code in detail. Code description information is used to describe the role, input and output parameters, dependencies, etc. of the code to be processed. Code description information can help the task processing model fully understand the working principle of the code to be processed, so as to carry out reasonable processing.

[0099] In actual applications, there are many ways to obtain processing auxiliary information, which can be selected according to actual conditions, and the embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, processing auxiliary information sent by a user through a client can be received. In another possible implementation of this specification, processing auxiliary information can be read from other data acquisition devices or databases. The implementation method of "constructing processing prompt information based on the code to be processed, the running results, the context code and the processing auxiliary information" is the same as the above-mentioned implementation method of "constructing processing prompt information based on the code to be processed, the running results and the context code", and the embodiments of this specification will not be repeated.

[0100] By applying the solution of the embodiments of this specification, by adding processing auxiliary information to the processing prompt information, the task processing model can enhance its understanding of the code to be processed and the problems existing in the code to be processed, and improve the processing performance of the task processing model.

[0101] In the embodiment of this specification, a warehouse-level code task hierarchical processing solution based on the task processing model Agent is proposed. Taking the code task as a code repair task as an example, a two-stage repair method of static analysis repair and single test operation repair can be adopted for hierarchical processing. Next, through Figure 3 The static analysis and repair process of the first phase is explained. Figure 4 This section describes the second phase of the unit test run repair process.

[0102] See also Figure 3 , Figure 3A processing flow chart of a code task processing method provided by an embodiment of the present specification is shown, which specifically includes: obtaining the code to be repaired of the code repair task. Calling a static analysis tool to perform error analysis on the code to be repaired and obtain analysis results. Based on the analysis results, determine whether the code to be repaired reports an error (that is, whether it includes static code errors). If not, enter the single test operation repair process. If so, construct modification prompt information based on the analysis results and the code to be repaired; use the task processing model to process the modification prompt information to obtain a modified code snippet and modification identification information of the modified code snippet, wherein the modification identification information is used to identify the position of the modified code snippet in the code to be repaired. Calling a code editing tool to perform static code error modification based on the modified code snippet and the modification identification information, that is, according to the modification identification information, filtering out the code snippet to be modified from the code to be repaired; using the modified code snippet, replace the code snippet to be modified in the code to be repaired to obtain the modified code to be repaired. After calling the code editing tool to modify static code errors based on the modified code snippet and the modified identification information, you can return to the step of calling the static analysis tool, perform error analysis on the code to be repaired, obtain the analysis results, and iteratively repair static code errors until the modified code to be repaired that does not include static code errors is obtained, thereby ending the static analysis and repair process.

[0103] See also Figure 4 , Figure 4A processing flow chart of another code task processing method provided by an embodiment of the present specification is shown, which specifically includes: obtaining the code to be repaired and the unit test function of the code to be repaired of the code repair task. Calling the unit test running tool, running the code to be repaired based on the unit test function, and obtaining the running result. Judging whether the code to be repaired has a running error (that is, whether it includes a dynamic code error) based on the running result. If not, the processing of the code repair task is completed. If so, obtaining the tool description information of multiple candidate search tools; constructing the screening prompt information according to the tool description information, the code to be repaired and the running result; processing the screening prompt information using the task processing model to obtain at least one target search tool corresponding to the code to be repaired and the search parameters of at least one target search tool. Based on the search parameters, calling at least one target search tool to retrieve the context code of the code to be repaired from the code repository. Constructing the processing prompt information according to the code to be repaired, the running result and the context code; processing the modification prompt information using the task processing model to obtain the target code fragment and the target identification information of the target code fragment, wherein the target identification information is used to identify the position of the target code fragment in the code to be repaired. The code editing tool is called to modify the dynamic code errors based on the target code snippet and the target identification information, that is, according to the target identification information, the code snippet to be replaced is screened out from the code to be repaired; the target code snippet is used to replace the code snippet to be replaced in the code to be repaired, and the repaired code to be processed is obtained. After the code editing tool is called to modify the dynamic code errors based on the target code snippet and the target identification information, the step of obtaining the code to be repaired and the unit test function of the code to be repaired of the code repair task can be returned to perform iterative repair of dynamic code errors until the repaired code to be processed that does not include dynamic code errors is obtained, and the unit test operation repair process ends.

[0104] The solution of the embodiment of this specification is applied to optimize the efficiency and pass rate of Agent repairing warehouse code by combining static and dynamic repair. The first stage focuses on the repair of basic errors, and the second stage solves more complex dynamic errors by extracting and retrieving unit test functions. In addition, the phased processing method allows for more refined management and repair of warehouse-level code errors, which is suitable for code repair without single testing, and improves the robustness and coverage of the overall solution. By automatically running static analysis tools and single test running tools, feedback after the code is repaired can be obtained in real time, and iterative repairs can be performed, reducing manual intervention, improving the degree of automation, significantly improving the pass rate of repairs, and providing technical support for the code repair capabilities of automatic software engineering and artificial intelligence programmers. Considering the complexity of repairing warehouse code, at least one target retrieval tool is used for retrieval enhancement to cover the retrieval needs of various contextual information. At the same time, by only outputting code snippets and identifiers, the problem of redundant and time-consuming model output is avoided.

[0105] The following combination Figure 5 , taking the application of the code task processing method provided in this specification in the code repair scenario as an example, the code task processing method is further described. Figure 5 A flowchart of a code repair method provided by an embodiment of the present specification is shown, which specifically includes the following steps: Step 502: Obtain the code to be repaired of the code repair task.

[0106] Step 504: performing error analysis on the code to be repaired, and if it is determined based on the analysis result that the code to be repaired does not contain code errors, running the code to be repaired to obtain a running result.

[0107] Step 506: When it is determined based on the running result that the code to be repaired fails to run, the context code of the code to be repaired is retrieved from the code repository.

[0108] Step 508: Repair the code to be repaired according to the context code to obtain a code repair result.

[0109] It should be noted that the code to be repaired refers to a specific code with defects or problems. The code to be repaired may contain errors, non-standard writing, potential security vulnerabilities or other areas that need improvement. The implementation of steps 502 to 508 can refer to the implementation of steps 202 to 208 above, and this specification embodiment will not be repeated.

[0110] By applying the scheme of the embodiments of this specification, potential problems in the code to be repaired can be discovered by performing a preliminary error analysis on the code to be repaired, thereby ensuring the accuracy of the code to be repaired. By running the code to be repaired after determining that the code to be repaired does not include code errors, it is possible to verify whether the actual behavior of the code to be repaired meets expectations, which not only ensures the functionality of the code to be repaired, but also improves the overall quality and stability of the code to be repaired. When the code to be repaired fails to run, the background and dependencies of the code to be repaired are understood by retrieving the context code in the code repository, thereby improving the coverage of the context information required for repair, enhancing the processing capabilities for complex code repair tasks, and realizing warehouse-level code repair. Repairing the code to be repaired according to the context code realizes automated code repair, reduces manual intervention, and improves the efficiency and accuracy of code repair.

[0111] Corresponding to the above-mentioned code task processing method embodiment, this specification also provides a code task processing device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of a code task processing device provided by an embodiment of the present specification. Figure 6 As shown, the device comprises: A first acquisition module 602 is configured to acquire the to-be-processed code of the target code task; The first running module 604 is configured to perform error analysis on the code to be processed, and if it is determined based on the analysis result that the code to be processed does not include a code error, run the code to be processed to obtain a running result; The first retrieval module 606 is configured to retrieve the context code of the code to be processed from the code repository when it is determined based on the running result that the code to be processed fails to run; The processing module 608 is configured to process the code to be processed according to the context code to obtain a code processing result.

[0112] Optionally, the first retrieval module 606 is further configured to screen out at least one target retrieval tool corresponding to the code to be processed from a plurality of candidate retrieval tools; and call at least one target retrieval tool to retrieve context code of the code to be processed from the code repository.

[0113] Optionally, the first retrieval module 606 is further configured to obtain tool description information of multiple candidate retrieval tools; construct filtering prompt information based on the tool description information, the code to be processed and the running results; input the filtering prompt information into the task processing model to obtain tool filtering results, wherein the tool filtering results are used to indicate at least one target retrieval tool corresponding to the code to be processed.

[0114] Optionally, the tool screening result includes search parameters of at least one target search tool; the first search module 606 is further configured to call at least one target search tool based on the search parameters to retrieve context code of the code to be processed from the code repository.

[0115] Optionally, the processing module 608 is further configured to construct processing prompt information according to the code to be processed, the running result and the context code; input the processing prompt information into the task processing model to obtain the code processing result.

[0116] Optionally, the processing module 608 is further configured to input the processing prompt information into the task processing model, obtain the target code fragment and the target identification information of the target code fragment, wherein the target identification information is used to identify the position of the target code fragment in the code to be processed; according to the target identification information and the target code fragment, the code to be processed is processed to obtain the code processing result.

[0117] Optionally, the processing module 608 is further configured to filter out the code fragment to be replaced from the code to be processed according to the target identification information; and replace the code fragment to be replaced in the code to be processed with the target code fragment to obtain a code processing result.

[0118] Optionally, the device also includes: a third acquisition module, configured to acquire processing auxiliary information, wherein the processing auxiliary information includes at least one of problem description information of the code to be processed, code description information and test code; the processing module 608 is further configured to construct processing prompt information based on the code to be processed, the running results, the context code and the processing auxiliary information.

[0119] Optionally, the first running module 604 is further configured to perform error analysis on the code to be processed and obtain analysis results; when it is determined based on the analysis results that the code to be processed does not include code errors, obtain test code for the code to be processed; and use the test code to run the code to be processed to obtain an operation result.

[0120] Optionally, the device also includes: a construction module, which is configured to construct modification prompt information based on the analysis results and the code to be processed when it is determined based on the analysis results that the code to be processed includes a code error; input the modification prompt information into the task processing model to obtain a modified code to be processed, wherein the modified code to be processed does not include a code error.

[0121] Optionally, the construction module is further configured to input the modification prompt information into the task processing model, obtain the modified code snippet and the modification identification information of the modified code snippet, wherein the modification identification information is used to identify the position of the modified code snippet in the code to be processed; according to the modification identification information and the modified code snippet, the code to be processed is modified to obtain the modified code to be processed.

[0122] By applying the scheme of the embodiments of this specification, potential problems of the code to be processed can be discovered through preliminary error analysis of the code to be processed, thereby ensuring the accuracy of the code to be processed. After determining that the code to be processed does not include code errors, the code to be processed is run to verify whether the actual behavior of the code to be processed meets expectations, which not only ensures the functionality of the code to be processed, but also improves the overall quality and stability of the code to be processed. When the code to be processed fails to run, the background and dependencies of the code to be processed are understood by retrieving the context code in the code repository, thereby improving the coverage of the context information required for processing, enhancing the processing capabilities of complex code tasks, and realizing warehouse-level code task processing. The code to be processed is processed according to the context code, thereby realizing automated code task processing, reducing manual intervention, and improving the efficiency and accuracy of code task processing.

[0123] The above is a schematic scheme of a code task processing device of this embodiment. It should be noted that the technical scheme of the code task processing device and the technical scheme of the above-mentioned code task processing method belong to the same concept, and the details not described in detail in the technical scheme of the code task processing device can be referred to the description of the technical scheme of the above-mentioned code task processing method.

[0124] Corresponding to the above code repair method embodiment, this specification also provides a code repair device embodiment, Figure 7 FIG. 1 is a schematic diagram showing the structure of a code repair device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises: The second acquisition module 702 is configured to acquire the code to be repaired of the code repair task; The second running module 704 is configured to perform error analysis on the code to be repaired, and if it is determined based on the analysis result that the code to be repaired does not include a code error, run the code to be repaired to obtain a running result; The second retrieval module 706 is configured to retrieve the context code of the code to be repaired from the code repository when it is determined based on the running result that the code to be repaired fails to run; The repair module 708 is configured to repair the code to be repaired according to the context code to obtain a code repair result.

[0125] By applying the scheme of the embodiments of this specification, potential problems in the code to be repaired can be discovered by performing a preliminary error analysis on the code to be repaired, thereby ensuring the accuracy of the code to be repaired. By running the code to be repaired after determining that the code to be repaired does not include code errors, it is possible to verify whether the actual behavior of the code to be repaired meets expectations, which not only ensures the functionality of the code to be repaired, but also improves the overall quality and stability of the code to be repaired. When the code to be repaired fails to run, the background and dependencies of the code to be repaired are understood by retrieving the context code in the code repository, thereby improving the coverage of the context information required for repair, enhancing the processing capabilities for complex code repair tasks, and realizing warehouse-level code repair. Repairing the code to be repaired according to the context code realizes automated code repair, reduces manual intervention, and improves the efficiency and accuracy of code repair.

[0126] The above is a schematic scheme of a code repair device of this embodiment. It should be noted that the technical scheme of the code repair device and the technical scheme of the above code repair method belong to the same concept, and the details not described in detail in the technical scheme of the code repair device can be referred to the description of the technical scheme of the above code repair method.

[0127] Figure 8 A structural block diagram of a computing device 800 provided in one embodiment of the present specification is shown.

[0128] The computing device 800 includes: Memory 810 and processor 820; The memory 810 is used to store computer programs / instructions, and the processor 820 is used to execute computer programs / instructions. When the computer program / instructions are executed by the processor 820, the steps of the above-mentioned code task processing method or code repair method are implemented.

[0129] In one or more embodiments of the present specification, the computing device may be understood as an integrated intelligent terminal, including but not limited to a server, a desktop computer, a personal computer (PC), an all-in-one model machine, a mobile phone, a tablet computer or other portable intelligent terminal, etc., and the computing device may be pre-installed with the model described in the above embodiments of the present application.

[0130] Specifically, the computing device can pre-set multiple types of models, including but not limited to models in the fields of natural language processing, visual processing, speech processing, code processing, multimodal task processing, etc., so as to provide a variety of model choices. In different product forms, the computing device can support one or more model usage methods, including but not limited to model training, model calling, model fine-tuning, model deployment, model reasoning and application, etc. In some product forms, the computing device also supports model management, including but not limited to multi-type model management (supporting the management of multiple types of models such as discriminant and generative models), model version control (supporting the control of different model versions), model evaluation (based on model evaluation tools, evaluating the performance and effect of the model), etc. In other product forms, the computing device can also create applications based on models, provide API calling capabilities, and can call models to the created applications through API interfaces, while providing application management tools to achieve management and monitoring of applications.

[0131] Furthermore, the computing device can also include data management (supporting the creation and management of model tuning data sets), a training center (providing rich training resources to help users learn and master artificial intelligence technology), and basic management and control capabilities (providing enterprise-level basic management and control capabilities to ensure the security and efficient operation of the system). Through the above functions, a comprehensive, integrated artificial intelligence development, training, deployment and application device is provided.

[0132] Fig. 9 A structural block diagram of an electronic device 900 provided according to an embodiment of the present specification is shown.

[0133] Memory 910 and processor 920, memory 910 and processor 920 are connected via bus 930; The memory 910 is used to store computer programs / instructions, and the processor 920 is used to execute computer programs / instructions. When the computer program / instructions are executed by the processor 920, the steps of the above-mentioned code task processing method or code repair method are implemented.

[0134] Specifically, the components of the electronic device 900 include but are not limited to a memory 910 and a processor 920. The processor 920 and the memory 910 may be connected via a bus 930.

[0135] The electronic device 900 may also include an access device 940, which enables the electronic device 900 to communicate with a database 950 storing data via one or more networks 960. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 940 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world microwave interconnection access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0136] In one embodiment of the present specification, the above components of the electronic device 900 and Fig. 9 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig. 9 The electronic device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0137] The electronic device 900 may be any type of stationary or mobile electronic device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable electronic device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary electronic device such as a desktop computer or a PC. The electronic device 900 may also be a mobile or stationary electronic device.

[0138] The above is a schematic scheme of an electronic device of this embodiment. It should be noted that the technical scheme of the electronic device and the technical scheme of the above-mentioned code task processing method and code repair method belong to the same concept, and the details not described in detail in the technical scheme of the electronic device can be referred to the description of the technical scheme of the above-mentioned code task processing method or code repair method.

[0139] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above-mentioned code task processing method or code repair method when executed by a processor.

[0140] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned code task processing method and code repair method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned code task processing method or code repair method.

[0141] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned code task processing method or code repair method when executed by a processor.

[0142] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the above-mentioned code task processing method and code repair method belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be referred to the description of the technical scheme of the above-mentioned code task processing method or code repair method.

[0143] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0144] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0145] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0146] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0147] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A code task processing method, comprising: Get the pending code of the target code task; Performing error analysis on the code to be processed, and if it is determined based on the analysis result that the code to be processed does not include a code error, running the code to be processed to obtain a running result; In the case where it is determined based on the running result that the code to be processed fails to run, retrieving the context code of the code to be processed from the code repository; The code to be processed is processed according to the context code to obtain a code processing result.

2. According to the method of claim 1, the retrieving the context code of the code to be processed from the code repository comprises: Selecting at least one target search tool corresponding to the code to be processed from a plurality of candidate search tools; The at least one target retrieval tool is called to retrieve context code of the code to be processed from the code repository.

3. The method according to claim 2, wherein the step of selecting at least one target search tool corresponding to the code to be processed from a plurality of candidate search tools comprises: Obtaining tool description information of the plurality of candidate search tools; Constructing screening prompt information according to the tool description information, the code to be processed and the running result; The screening prompt information is input into a task processing model to obtain a tool screening result, wherein the tool screening result is used to indicate at least one target retrieval tool corresponding to the code to be processed.

4. The method according to claim 3, wherein the tool screening result includes search parameters of the at least one target search tool; The calling of the at least one target retrieval tool to retrieve the context code of the code to be processed from the code repository includes: Based on the search parameters, the at least one target search tool is called to retrieve context code of the code to be processed from the code repository.

5. The method according to claim 1, wherein the processing of the code to be processed according to the context code to obtain a code processing result comprises: Constructing processing prompt information according to the code to be processed, the running result and the context code; The processing prompt information is input into a task processing model to obtain the code processing result.

6. The method according to claim 5, wherein the step of inputting the processing prompt information into a task processing model to obtain the code processing result comprises: Inputting the processing prompt information into the task processing model to obtain a target code segment and target identification information of the target code segment, wherein the target identification information is used to identify the position of the target code segment in the code to be processed; The code to be processed is processed according to the target identification information and the target code fragment to obtain the code processing result.

7. The method according to claim 6, wherein the processing of the code to be processed according to the target identification information and the target code fragment to obtain the code processing result comprises: According to the target identification information, filter out the code fragment to be replaced from the code to be processed; The target code segment is used to replace the code segment to be replaced in the code to be processed, so as to obtain the code processing result.

8. The method according to claim 5, before constructing the processing prompt information according to the code to be processed, the running result and the context code, further comprises: Acquire processing auxiliary information, wherein the processing auxiliary information includes at least one of problem description information of the code to be processed, code description information, and test code; The constructing processing prompt information according to the code to be processed, the running result and the context code includes: Processing prompt information is constructed according to the code to be processed, the running result, the context code and the processing auxiliary information.

9. The method according to claim 1, wherein the error analysis of the code to be processed is performed, and when it is determined based on the analysis result that the code to be processed does not include a code error, the code to be processed is run to obtain a running result, comprising: Performing error analysis on the code to be processed to obtain the analysis result; If it is determined based on the analysis result that the code to be processed does not include a code error, obtaining a test code of the code to be processed; The code to be processed is run using the test code to obtain a running result.

10. The method according to any one of claims 1 to 9, after performing error analysis on the code to be processed, further comprising: In the case where it is determined based on the analysis result that the code to be processed includes the code error, constructing modification prompt information according to the analysis result and the code to be processed; The modification prompt information is input into the task processing model to obtain a modified code to be processed, wherein the modified code to be processed does not include the code error.

11. The method according to claim 10, wherein the step of inputting the modification prompt information into the task processing model to obtain the modified code to be processed comprises: Inputting the modification prompt information into the task processing model to obtain a modified code snippet and modification identification information of the modified code snippet, wherein the modification identification information is used to identify the position of the modified code snippet in the code to be processed; The code to be processed is modified according to the modification identification information and the modification code fragment to obtain the modified code to be processed.

12. A code repair method, comprising: Get the code to be repaired of the code repair task; Performing error analysis on the code to be repaired, and if it is determined based on the analysis result that the code to be repaired does not include a code error, running the code to be repaired to obtain an operation result; In the case where it is determined based on the running result that the code to be repaired fails to run, retrieving context code of the code to be repaired from a code repository; The code to be repaired is repaired according to the context code to obtain a code repair result.

13. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 12 are implemented.

14. An electronic device comprising: A memory and a processor, wherein the memory and the processor are connected via a bus; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 12 are implemented.

15. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 12.

16. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Code processing method and code repair testing method

    CN118760612A

  • Code testing method and device and electronic equipment

    CN119179642A

Cited By

  • Code task processing method and code repair method

    WO2026188951A1