MDSplus data access code self-correction method based on execution feedback

CN122594063BActive Publication Date: 2026-10-30HEFEI INSTITUTE OF PHYSICAL SCIENCE CHINESE ACADEMY OF SCIENCES
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202611101056.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-30
Estimated Expiration
2046-07-23

AI Technical Summary

Technical Problem

仅根据通用运行错误进行代码修改,难以同时处理访问对象错误、访问流程错误和数据读取效率问题

Benefits of technology

[0018]采用上述技术方案具有以下优点:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122594063B_ABST
    Figure CN122594063B_ABST
Patent Text Reader

Abstract

The application discloses an MDSplus data access code self-repairing method based on execution feedback, and belongs to the technical field of nuclear fusion experiment scientific data access and program automatic repair. The code to be repaired and the corresponding user original request are acquired, the code is run in a controlled execution environment, and execution feedback is collected; metadata anchor failure, node path link failure, access planning failure, execution failure or performance bottleneck are identified according to the execution feedback, MDSplus metadata that can be used for code repair are retrieved from the MDSplus metadata source according to the failure type, and a structured execution feedback prompt is constructed; the prompt is input into a large language model to generate a repaired code, the feedback is collected again, and when the iteration termination condition is not met, the failure identification, feedback construction and code repair are repeated. The method can improve the pertinence and reliability of the automatic repair of the MDSplus data access code, and can keep the iteration process controllable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of scientific data access and automatic program repair technology for nuclear fusion experiments, and in particular to a self-correcting method for MDSplus data access code based on execution feedback. Background Technology

[0002] MDSplus is a data system for organizing and accessing scientific experimental data. In nuclear fusion experimental data management, it can be used to organize data objects such as experimental trees, experimental launcher numbers, and signal nodes. Researchers typically need to write Python, C / C++, or MATLAB code to open experimental trees, specify launcher numbers, read node data, read time-dimension data, and process results. With the development of large language model code generation technology, automatically generating data access code based on natural language requests has become a feasible code generation method.

[0003] For example, Chinese invention patent application CN 121478802 A (publication date: February 6, 2026) discloses a "method and system for automatically generating database execution code based on a large language model." This method decomposes query logic according to a predefined query template and generates an execution plan. Simultaneously, it collects database schema information, data distribution information, and index feature information, and then uses a large language model to generate database execution code that matches the query semantics. During code execution, errors such as compilation errors, execution failures, and incorrect execution results can be analyzed and reported, allowing the large language model to adjust or regenerate the code. For code with insufficient execution performance, performance metrics and performance bottleneck characteristics can be used as feedback information to generate performance optimization schemes and optimized execution code.

[0004] For example, Chinese invention patent application CN 121052226 A (publication date: December 2, 2025) discloses a "table data analysis method integrating a large language model and the ReAct framework," which enables the large language model to perform task parsing and code generation, and generates code through semantic calibration, code pre-checking, and logical verification. For code that fails verification, errors can be classified, and corresponding correction strategies can be fed back for semantic understanding errors, code syntax errors, and logical conflict errors before executing the verified code.

[0005] The aforementioned technologies are already capable of error analysis, verification, and feedback correction for general database execution code or tabular data analysis code. However, MDSplus data access has a specific data organization method and access process. There are specific correspondences between the experimental tree, artillery number, node path, time dimension, and data source, and the code must also be executed according to the corresponding data access process. General error types and code correction contexts cannot directly reflect the differences between access object location errors, node path mapping errors, and missing access steps. Even if the code can run, it may return results that do not meet the user's request due to mismatches in target signal, artillery number range, or time dimension.

[0006] Furthermore, high-frequency waveform data in MDSplus may involve large data read volumes. Automatically generated access code may result in issues such as reading the entire high-frequency waveform data at once, duplicate connections, duplicate node reads, or a lack of time window filtering. Modifying the code solely based on common runtime errors is insufficient to simultaneously address access object errors, access process errors, and data read efficiency issues.

[0007] Therefore, improving the automatic error correction capabilities of MDSplus data access code in terms of access object location, access process organization, actual execution, and data reading efficiency has become an urgent technical problem to be solved. Summary of the Invention

[0008] The main objective of this invention is to provide a self-correcting method for MDSplus data access code based on execution feedback, which aims to improve the automatic error correction capability of MDSplus data access code in terms of access object location, access process organization, actual execution, and data reading efficiency.

[0009] To achieve the above objectives, this invention proposes a self-correcting method for MDSplus data access code based on execution feedback, comprising the following steps: S1, Obtain the MDSplus data access code to be corrected and the original user request corresponding to the MDSplus data access code, and prepare to execute the MDSplus data access code in a controlled execution environment; S2, run the MDSplus data access code in the controlled execution environment, collect execution feedback information, including execution status; when the execution status is successful, record the return result; when the execution status is failed, record the error log; and when the pre-configured performance information collection conditions are met, record performance information. S3. Based on the execution feedback information, identify the failure type of the MDSplus data access code during the process of accessing the MDSplus system. The failure types include metadata anchoring failure, node path linking failure, access planning failure, execution failure, and performance bottleneck. S4. Based on the identified failure type, retrieve the MDSplus metadata that can be used for code correction under the failure type from the MDSplus metadata source, and fuse the MDSplus metadata retrieval results, the execution feedback information and the user's original request to construct a structured execution feedback prompt. S5, input the structured execution feedback prompt into the large language model, generate the corrected MDSplus data access code from the large language model, run the corrected MDSplus data access code in the controlled execution environment and collect execution feedback information again; if the preset iteration termination condition is not met, repeat steps S3 to S5 according to the re-collected execution feedback information until the iteration termination condition is met.

[0010] Preferably, in step S1, the MDSplus data access code to be corrected is obtained in any of the following ways: generated by the large language model based on the user's original request, uploaded by the user, or output by the preceding code generation system. Preferably, in step S1, the controlled execution environment includes a Python virtual environment, a container environment, a sandbox execution environment, a remote task execution environment, or an isolated execution environment in an integrated scientific research data platform; The execution preparation includes configuring the MDSplus client library, MDSplus server address, code execution timeout, memory usage limits, allowed data servers, log recording path, and execution result cache directory.

[0011] Preferably, step S2 includes: When the MDSplus data access code executes successfully, a data summary is recorded. The data summary includes data dimension, data length, time range, whether the data is empty, and whether the data contains outliers. When the MDSplus data access code fails to execute, the failure location and failure stage are recorded, and error logs, exception stacks, and MDSplus return information are collected. The failure stages include the connection stage, the experimental tree opening stage, the node reading stage, the time dimension reading stage, and the result processing stage. For MDSplus data access code that can be executed but whose code execution time exceeds a preset execution time threshold or whose memory usage exceeds a preset memory threshold, the performance information is collected. The performance information includes code execution time, memory usage, data read length, number of repeated connections, number of repeated node reads, whether the full waveform data is read at once, whether there is a missing time window for filtering, and whether data transformation or loop operations unrelated to the user's original request are performed.

[0012] Preferably, in step S3, the failure type is identified based on the error log, exception stack, MDSplus return information, return results, and performance information using rule matching, keyword matching, or log pattern recognition, including: When the error log or the MDSplus returned information contains a node not found message, the failure type is identified as a node path link failure. When it is detected that the MDSplus data access code performs a node read operation without performing the experimental tree open operation, the failure type is identified as an access planning failure. When the code execution time exceeds a preset execution time threshold or the memory usage exceeds a preset memory threshold, the failure type is identified as a performance bottleneck. When the returned result is empty and the MDSplus metadata in the pre-configured MDSplus metadata source indicates that the node path specified by the code exists, if the cannon number specified by the code is not within the range of available cannon numbers, or the node specified by the code is unavailable under the corresponding cannon number, then the failure type will be identified as metadata anchoring failure. When an error occurs in the MDSplus data access code during syntax parsing, runtime environment configuration, or application programming interface call, the failure type will be identified as an execution failure.

[0013] Preferably, step S3 further includes: For successfully executed MDSplus data access code, a consistency judgment is made between the returned result and the user's original request. The consistency judgment includes judging whether the returned data is empty, whether it contains the target signal, whether it has a time dimension, whether the data dimension matches the task requested by the user, whether the returned signal is consistent with the physical variable requested by the user, whether the statistical results cover the range of gun numbers specified by the user, and whether the output format meets the user's request. When the returned result is inconsistent with the user's original request, the corresponding failure type is determined according to the inconsistency, the corresponding execution result is marked as a semantic execution failure or access object error, and the process proceeds to step S4; the result status is used to record the inconsistency between the returned result and the user's original request, and is not considered as a new category of failure type in step S3.

[0014] Preferably, step S4 includes: When the failure type is node path link failure, retrieve the candidate node paths recorded in the MDSplus metadata source; When the failure type is a metadata anchoring failure caused by an experimental tree error or a gun number error, the candidate experimental tree and the range of available gun numbers are retrieved from the MDSplus metadata source; When the failure type is access planning failure and the returned result lacks the time dimension corresponding to the target node, retrieve the time dimension expression corresponding to the target node from the MDSplus metadata source; When the failure type is access planning failure, obtain the MDSplus data access process template; When the failure type is a performance bottleneck, correction suggestions such as time window filtering, downsampling, or segmented reading are generated based on the performance information.

[0015] Preferably, in step S4, the structured execution feedback prompt includes the user's original request, the MDSplus data access code to be corrected in this round, the execution stage, the error log, the failure type, the explanation of the failure reason, the code location that needs to be corrected, the MDSplus metadata corresponding to the failure type, and the correction suggestion; The structured execution feedback prompts also include the following corrective constraints: keeping the task defined by the user's original request unchanged, retaining the connection method of successfully establishing an MDSplus connection in the code, correcting erroneous node paths according to the candidate node paths recorded in the MDSplus metadata source, supplementing missing experimental tree opening operations, supplementing missing time dimension reading operations, correcting the MDSplus application programming interface calling method, and adding time window filtering, downsampling, or segmented reading operations for cases where the code execution time exceeds a preset execution time threshold, memory usage exceeds a preset memory threshold, or when a full waveform data is read at once.

[0016] Preferably, in step S5, the user's original request, the MDSplus data access code to be corrected in this round, the error log, the failure type, the MDSplus metadata, and the correction suggestion are input into the large language model, and the large language model performs code correction corresponding to the failure type. The code fixes include correcting erroneous node paths, correcting experimental tree names, correcting artillery number parameters, adding MDSplus connection statements, adding experimental tree opening operations, adding time dimension reading operations, correcting the MDSplus application programming interface call method, adding exception handling, adding time window filtering, adding downsampling processing, adopting a segmented reading method, eliminating duplicate connection operations, and eliminating duplicate node reading operations.

[0017] Preferably, the iteration termination condition includes any of the following conditions: The revised MDSplus data access code was executed successfully and returned a result that satisfied the user's original request. The number of corrections has reached the preset maximum number of corrections; During continuous correction, the same error is determined to occur repeatedly based on a preset error identity rule. The current failure type is determined to be unable to be automatically corrected through the feedback construction and code correction process in steps S4 and S5 according to the preset correctability rules; The cumulative execution time or the cost of calling a large language model calculated according to a preset measurement standard exceeds the corresponding preset threshold. Received a user-initiated termination command; When the iteration termination condition is met, the final MDSplus data access code, execution result, error reason, or manual intervention suggestion is output according to the termination reason.

[0018] The above technical solution has the following advantages: This application, by actually running MDSplus data access code in a controlled execution environment and collecting execution feedback, enables subsequent corrections to be judged based on the actual execution status, error messages, return results, and performance information, reducing the bias caused by correcting solely based on code text. By identifying metadata anchoring failures, node path linking failures, access planning failures, execution failures, and performance bottlenecks, clear subsequent processing guidelines can be formed for different failure scenarios in the MDSplus data access process. Based on the identified failure type, MDSplus metadata applicable to code correction under that failure type is retrieved from the MDSplus metadata source, and the MDSplus metadata retrieval results, execution feedback, and the user's original request are integrated into a structured execution feedback prompt, providing context for code correction corresponding to the actual access object and access status. Compared to correction methods that only feed general error logs back to the large language model, this application further combines MDSplus specific failure types and MDSplus metadata retrieval results to construct feedback prompts. Using the structured execution feedback prompts to generate corrected code and then re-executing and verifying the corrected code forms a closed-loop correction process driven by actual execution results. The system repeatedly identifies failures, constructs feedback mechanisms, and corrects code when the iteration termination condition is not met, enabling the code to undergo multiple rounds of adjustments. At the same time, the termination condition restricts the correction process, avoiding unconstrained loops and improving the controllability and stability of the automatic correction process. Attached Figure Description

[0019] The present invention will now be described in detail with reference to specific embodiments and accompanying drawings, wherein: Figure 1 A flowchart of the MDSplus data access code self-correction method based on execution feedback provided in the embodiments of this application. Detailed Implementation

[0020] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the embodiments of this application. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0021] Embodiment 1 of this application provides a self-correcting method for MDSplus data access code based on execution feedback. This method aims to address problems such as non-executable code, incorrect access paths, incomplete access planning, and low performance in the existing process of generating MDSplus data access code from large language models. By actually executing the generated code and identifying and automatically correcting errors based on the execution results, it can effectively reduce errors in the generated code at once and reduce the burden of manual code debugging for researchers. like Figure 1 As shown, the method includes steps S1 to S5.

[0022] Step S1: Obtain the MDSplus data access code to be corrected and the corresponding original user request. In this step, the MDSplus data access code to be corrected can be generated by a large language model based on the original user request, uploaded by the user, or output by the preceding code generation system. After obtaining the code and request, prepare for execution of the MDSplus data access code to be corrected in a controlled execution environment. The controlled execution environment can be a Python virtual environment, container environment, sandbox execution environment, remote task execution environment, or an isolated execution environment within an integrated scientific research data platform. Setting up a controlled execution environment provides a runnable object and a secure execution foundation for subsequent execution feedback analysis. Execution preparation includes configuring the MDSplus client library, MDSplus server address, code execution timeout, memory usage limits, allowed data servers, log recording path, and execution result cache directory. The preset execution time threshold is determined based on the code execution timeout configuration, and the preset memory threshold is determined based on the memory usage limit configuration. The pre-configured performance information collection conditions include at least code execution time exceeding a preset execution time threshold or memory usage exceeding a preset memory threshold; the preset data length threshold is determined according to the number of returned data points or the number of data bytes.

[0023] Step S2 involves running the aforementioned MDSplus data access code in a controlled execution environment and collecting execution feedback information during the process. This feedback includes the execution status. When the execution status is successful, a returned data summary is recorded, including data dimensions, data length, time range, whether the data is empty, and whether the data contains outliers. When the execution status is failed, the failure location and stage are recorded, and error logs, exception stacks, and MDSplus return information are collected. The failure stages include the connection stage, experimental tree opening stage, node reading stage, time dimension reading stage, and result processing stage. For MDSplus data access code that can be executed but whose execution time exceeds a preset execution time threshold or whose memory usage exceeds a preset memory threshold, performance information is also collected. This performance information includes code execution time, memory usage, data read length, number of repeated connections, number of repeated node reads, whether the entire waveform data is read at once, whether a time window filtering is missing, and whether data transformation or loop operations unrelated to the user's original request are performed. This step obtains real execution feedback, thus avoiding relying solely on the code text itself to determine its correctness.

[0024] Step S3: Identify the failure types of the MDSplus data access code during the MDSplus system access process based on the execution feedback information. These failure types include metadata anchoring failure, node path linking failure, access planning failure, execution failure, and performance bottleneck. Specifically, metadata anchoring failure refers to the generated code failing to correctly determine the experimental tree, firing number range, signal description, or data source information based on MDSplus metadata, resulting in an overall error in the access target; node path linking failure refers to the natural language signal name not being correctly mapped to the node path recorded in the MDSplus metadata source, or the code specifying a non-existent node path; access planning failure refers to the code not following the MDSplus data access process, missing necessary operations such as connection establishment, experimental tree opening, firing number specification, node reading, time dimension reading, or connection closure; execution failure refers to errors occurring in the code during syntax parsing, runtime environment configuration, application programming interface calls, connection establishment, experimental tree opening, firing number specification, node reading, or result processing; and performance bottleneck refers to inefficient access behaviors such as code execution time exceeding a preset execution time threshold, memory usage exceeding a preset memory threshold, full reading of high-frequency waveforms, repeated connections, repeated node readings, or lack of time window filtering, even though the code can execute. During the identification process, judgments are made based on error logs, exception stacks, MDSplus return information, return results, and performance information, using rule matching, keyword matching, or log pattern recognition methods. When the error log or MDSplus return information contains "node not found" information, the failure type is identified as node path link failure; when code is detected performing a node read operation without performing an experimental tree opening operation, the failure type is identified as access planning failure; when code execution time exceeds a preset execution time threshold or memory usage exceeds a preset memory threshold, the failure type is identified as performance bottleneck; when the return result is empty and MDSplus metadata indicates that the node path specified by the code exists, if the specified artillery number is not within the range of available artillery numbers, or the node specified by the code is unavailable under the corresponding artillery number, the failure type is identified as metadata anchoring failure; when errors occur during code syntax parsing, runtime environment configuration, or application programming interface calls, the failure type is identified as execution failure. The MDSplus metadata used in step S3 is obtained from the MDSplus metadata source pre-configured during the execution preparation phase, enabling the failure identification phase to verify the existence and availability of the experimental tree, artillery number, and node path specified by the code.

[0025] For successfully executed MDSplus data access code, a further consistency check is performed between the returned result and the user's original request. This consistency check includes determining whether the returned data is empty, whether it contains the target signal, whether it has a time dimension, whether the data dimension matches the user's requested task, whether the returned signal matches the physical variables requested by the user, whether the statistical results cover the range of gun numbers specified by the user, and whether the output format meets the user's request. When the returned result is inconsistent with the user's original request, the corresponding existing failure type is determined based on the inconsistency, and the corresponding execution result is marked as a semantic execution failure or an access object error, proceeding to step S4. The result status is only used to record inconsistencies between the returned result and the user's original request and does not constitute a new failure type beyond the five failure types described in step S3. In one implementation, when the target signal or physical variable is inconsistent with the user's request, it can be determined based on MDSplus metadata as a node path link failure or metadata anchoring failure; when the returned result lacks the time dimension corresponding to the target node, it can be determined as an access planning failure; when an anomaly occurs during result processing or output, it can be determined as an execution failure.

[0026] Step S4: Based on the identified failure type, retrieve MDSplus metadata for that failure type from the MDSplus metadata source that can be used for code correction. Then, integrate the MDSplus metadata retrieval results, execution feedback information, and the user's original request to construct a structured execution feedback prompt. The MDSplus metadata source provides metadata information such as experimental trees, available gun number ranges, node paths, signal descriptions, data source information, and time dimension expressions. During retrieval, select the corresponding retrieval object based on the failure type identified in step S3. When the failure type is a node path link failure, retrieve the candidate node paths recorded in the MDSplus metadata source; when the failure type is a metadata anchoring failure caused by an experimental tree error or a gun number error, retrieve the candidate experimental trees and available gun number ranges; when the failure type is an access planning failure and the returned result lacks the time dimension corresponding to the target node, retrieve the time dimension expression corresponding to the target node; when the failure type is an access planning failure, obtain the MDSplus data access process template; when the failure type is a performance bottleneck, formulate correction suggestions such as time window filtering, downsampling, or segmented reading based on performance information.

[0027] The MDSplus metadata source can provide metadata through metadata tables, index files, or service interfaces. In one implementation, when retrieving candidate node paths, the experimental tree, artillery number, signal name or signal description in the user's original request, and the node path specified in the code to be corrected are used as search criteria. These criteria are then matched against the experimental tree, available artillery number range, node path, and signal description in the metadata record. When multiple candidate node paths are obtained, those with available experimental trees and artillery numbers and whose existence is indicated by the metadata record are retained, while those that cannot be uniquely determined are written into the structured execution feedback prompt. If no corresponding metadata is found or the MDSplus metadata source is inaccessible, a decision is made according to preset correctability rules to determine whether to terminate automatic correction and output a suggestion for manual intervention.

[0028] The structured execution feedback includes the user's original request, the MDSplus data access code to be corrected in this round, the execution stage, error log, failure type, failure reason explanation, the code location requiring correction, MDSplus metadata retrieval results, and correction suggestions. To ensure the accuracy of the correction, the structured execution feedback also includes specific correction constraints. These constraints include keeping the task defined by the user's original request unchanged, preserving the connection method that has successfully established an MDSplus connection in the code, and correcting the erroneous node path based on the candidate node path recorded in the MDSplus metadata source; they also include supplementing missing experimental tree opening operations, supplementing missing time dimension reading operations, and correcting the MDSplus application programming interface call method. For cases where the code execution time exceeds a preset execution time threshold, memory usage exceeds a preset memory threshold, or a full waveform data read at once is detected, correction constraints include adding time window filtering, downsampling, or segmented reading operations. By combining the error log with the MDSplus metadata retrieval results for feedback construction, the original error information can be transformed into correction instructions that are understandable and executable by the large language model.

[0029] In one implementation, the structured execution feedback prompts are organized in the following order: the user's original request, the code to be corrected in this round, the execution stage, the error log, the failure type, the MDSplus metadata retrieval results, the correction suggestions, and the correction constraints. Each item is distinguished by its corresponding field name.

[0030] Step S5 involves inputting the structured execution feedback into the large language model, which then generates the corrected MDSplus data access code. This code correction is performed by the large language model based on the original user request, the MDSplus data access code to be corrected in this round, the error log, the failure type, MDSplus metadata, and correction suggestions. Specific operations for code correction include correcting error node paths, correcting experimental tree names, correcting artillery number parameters, supplementing MDSplus connection statements, supplementing experimental tree opening operations, supplementing time dimension reading operations, correcting the MDSplus application programming interface call method, adding exception handling, adding time window filtering, adding downsampling processing, adopting a segmented reading method, eliminating duplicate connection operations, and eliminating duplicate node reading operations. The large language model modifies the code content corresponding to the failure location according to the failure type and correction constraints, and outputs complete MDSplus data access code that can be re-executed in a controlled execution environment; the output code is verified through re-execution and execution feedback collection in step S5.

[0031] After generating the corrected code, the corrected MDSplus data access code is run in a controlled execution environment, and execution feedback information is collected again. At this point, it is determined whether the preset iteration termination condition is met. If the preset iteration termination condition is not met, steps S3 to S5 are repeated based on the re-collected execution feedback information. This process iterates until the iteration termination condition is met. The iteration termination conditions include several possible triggering conditions. The iteration termination condition is met when the corrected MDSplus data access code executes successfully and returns a result that satisfies the user's original request; when the number of corrections reaches the preset maximum number of corrections; when the same error is repeatedly detected during continuous corrections according to the preset error identity rule; when the current failure type is determined by the preset correctability rule to be uncorrectable through the feedback construction and code correction process described in steps S4 and S5; when the cumulative execution time or the large language model call cost calculated according to the preset measurement caliber exceeds the corresponding preset threshold; and when a user-initiated termination command is received. The preset maximum number of corrections, cumulative execution time threshold, and large language model call cost threshold are configured as iteration control parameters before execution. After the iteration termination conditions are met, the system outputs the final MDSplus data access code, execution result, error cause, or manual intervention suggestion based on the termination reason. This controllable multi-round self-correcting closed-loop design avoids the code generation process from falling into an infinite loop, ensuring the stability and reliability of the automatic code correction process. In one implementation, the preset error identity rule can be judged based on one or more of the error type, error code or error message and failure stage; the preset correctability rule can be used to determine whether MDSplus metadata corresponding to the current failure type can be obtained, form a correction suggestion and determine the executable correction operation; the cost of calling the large language model can be calculated cumulatively according to at least one pre-configured metering caliber among the number of calls, the amount of input and output data or the service billing value.

[0032] Embodiment 2 of this application provides a specific scenario example of applying the above-described MDSplus data access code self-correction method based on execution feedback. This scenario demonstrates how the system automatically identifies and corrects performance bottlenecks.

[0033] During scientific data access, the user inputs a request via natural language. Specifically, the request is to read high-frequency magnetic probe signals from a specific artillery unit over a long time interval and plot the waveform. The large language model generates initial MDSplus data access code based on this request. The logic of this initial code is to read all high-frequency waveform data at once. This initial code is then input into a controlled execution environment for execution. The system, through a performance information collection mechanism, detects that the code's execution time exceeds a preset runtime threshold, and its memory usage also exceeds a preset memory threshold. Furthermore, the system detects that the data read length exceeds a preset data length threshold. In this scenario, the controlled execution environment uses an isolated execution environment with a pre-configured MDSplus client library. The experimental tree, artillery unit, node path, and request time interval are determined by the user's original request and the MDSplus metadata source. The preset runtime threshold, preset memory threshold, and preset data length threshold are configured before execution. The data length is expressed as the number of returned data points or the number of data bytes. The initial code and the corrected code are executed in the same controlled execution environment under the same user's original request, and the code execution time, peak memory usage, and data length are recorded respectively.

[0034] Based on the performance information above, the system identifies the failure type of the current code as a performance bottleneck. Subsequently, the system constructs a corresponding structured execution feedback prompt. The failure type in the structured execution feedback prompt is a performance bottleneck, the problem description is that the current code reads all high-frequency time-series data at once, resulting in excessive runtime and memory usage. The suggested correction is to add a time window filtering operation or downsample the read results before plotting. Upon receiving this structured execution feedback prompt, the large language model generates optimized code. The optimized code adds logic for selecting a time window or downsampling the data. The system executes the optimized code again. The corrected code filters the read results according to the time interval specified by the user request, or downsamples the read results according to the sampling interval configured before execution before plotting; upon re-execution, the same performance metrics are recorded under the same environment and request conditions as the initial code. When the re-execution records show that the code's runtime and memory usage are both lower than the corresponding records of the initial code, and the returned results meet the user request, the system outputs the corrected code and visualization results.

[0035] Embodiment 3 of this application provides an MDSplus data access code self-correction system based on execution feedback. This system is used to execute the method provided in Embodiment 1 of this application. The system includes a code execution module, an execution result parsing module, a failure type identification module, a metadata auxiliary feedback construction module, a code correction module, and a re-execution module.

[0036] The code execution module receives user requests and initial code input. It runs the initial MDSplus data access code within a controlled execution environment. The execution result parsing module, connected to the code execution module, is responsible for collecting the code's execution status, error logs, return results, and performance information within the controlled execution environment. The failure type identification module, also connected to the execution result parsing module, analyzes the causes of code failures based on the collected information and categorizes them into specific failure types.

[0037] The metadata-assisted feedback construction module is connected to the failure type identification module and the MDSplus metadata source. This module retrieves relevant metadata from the MDSplus metadata source and integrates error logs, failure types, candidate nodes, and correction suggestions into a structured execution feedback prompt. The code correction module receives the structured execution feedback prompt and calls the large language model to generate the corrected code. The re-execution module receives the corrected code and re-runs it in a controlled execution environment. If the preset iteration termination condition is not met, the system returns the execution result to the execution result parsing module for a new round of parsing and correction until the preset iteration termination condition is met.

[0038] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A self-correcting method for MDSplus data access code based on execution feedback, characterized in that, Includes the following steps: S1, Obtain the MDSplus data access code to be corrected and the original user request corresponding to the MDSplus data access code, and prepare to execute the MDSplus data access code in a controlled execution environment; S2, run the MDSplus data access code in the controlled execution environment, collect execution feedback information, including execution status; when the execution status is successful, record the return result; when the execution status is failed, record the error log; and when the pre-configured performance information collection conditions are met, record performance information. S3. Based on the execution feedback information, identify the failure type of the MDSplus data access code during the process of accessing the MDSplus system. The failure types include metadata anchoring failure, node path linking failure, access planning failure, execution failure, and performance bottleneck. S4. Based on the identified failure type, retrieve MDSplus metadata for the failure type that can be used for code correction from the MDSplus metadata source. Specifically, when the failure type is a node path link failure, retrieve the candidate node paths recorded in the MDSplus metadata source; when the failure type is a metadata anchoring failure caused by an experimental tree error or a cannon number error, retrieve the candidate experimental trees and available cannon number ranges from the MDSplus metadata source; when the failure type is an access planning failure and the returned result lacks a time dimension corresponding to the target node, retrieve the time dimension expression corresponding to the target node from the MDSplus metadata source; when the failure type is an access planning failure, obtain the MDSplus data access process template; when the failure type is a performance bottleneck, form correction suggestions such as time window filtering, downsampling, or segmented reading based on the performance information; and fuse the MDSplus metadata retrieval results, the execution feedback information, and the user's original request to construct a structured execution feedback prompt. S5, input the structured execution feedback prompt into the large language model, generate the corrected MDSplus data access code from the large language model, run the corrected MDSplus data access code in the controlled execution environment and collect execution feedback information again; if the preset iteration termination condition is not met, repeat steps S3 to S5 according to the re-collected execution feedback information until the iteration termination condition is met.

2. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, In step S1, the MDSplus data access code to be corrected is obtained in any of the following ways: generated by the large language model based on the user's original request, uploaded by the user, or output by the preceding code generation system.

3. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, In step S1, the controlled execution environment includes a Python virtual environment, a container environment, a sandbox execution environment, a remote task execution environment, or an isolated execution environment in an integrated scientific research data platform; The execution preparation includes configuring the MDSplus client library, MDSplus server address, code execution timeout, memory usage limits, allowed data servers, log recording path, and execution result cache directory.

4. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, Step S2 includes: When the MDSplus data access code executes successfully, a data summary is recorded. The data summary includes data dimension, data length, time range, whether the data is empty, and whether the data contains outliers. When the MDSplus data access code fails to execute, the failure location and failure stage are recorded, and error logs, exception stacks, and MDSplus return information are collected. The failure stages include the connection stage, the experimental tree opening stage, the node reading stage, the time dimension reading stage, and the result processing stage. For MDSplus data access code that can be executed but whose code execution time exceeds a preset execution time threshold or whose memory usage exceeds a preset memory threshold, the performance information is collected. The performance information includes code execution time, memory usage, data read length, number of repeated connections, number of repeated node reads, whether the full waveform data is read at once, whether there is a missing time window for filtering, and whether data transformation or loop operations unrelated to the user's original request are performed.

5. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, In step S3, based on the error log, exception stack trace, MDSplus return information, return results, and performance information, the failure type is identified using rule matching, keyword matching, or log pattern recognition, including: When the error log or the MDSplus returned information contains a node not found message, the failure type is identified as a node path link failure. When it is detected that the MDSplus data access code performs a node read operation without performing the experimental tree open operation, the failure type is identified as an access planning failure. When the code execution time exceeds a preset execution time threshold or the memory usage exceeds a preset memory threshold, the failure type is identified as a performance bottleneck. When the returned result is empty and the MDSplus metadata in the pre-configured MDSplus metadata source indicates that the node path specified by the code exists, if the cannon number specified by the code is not within the range of available cannon numbers, or the node specified by the code is unavailable under the corresponding cannon number, then the failure type will be identified as metadata anchoring failure. When an error occurs in the MDSplus data access code during syntax parsing, runtime environment configuration, or application programming interface call, the failure type will be identified as execution failure.

6. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, Step S3 also includes: For successfully executed MDSplus data access code, a consistency judgment is made between the returned result and the user's original request. The consistency judgment includes judging whether the returned data is empty, whether it contains the target signal, whether it has a time dimension, whether the data dimension matches the task requested by the user, whether the returned signal is consistent with the physical variable requested by the user, whether the statistical results cover the range of gun numbers specified by the user, and whether the output format meets the user's request. When the returned result is inconsistent with the user's original request, the corresponding failure type is determined according to the inconsistency, the corresponding execution result is marked as a semantic execution failure or access object error, and the process proceeds to step S4; the result status is used to record the inconsistency between the returned result and the user's original request, and is not considered as a new category of failure type in step S3.

7. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, In step S4, the structured execution feedback prompt includes the user's original request, the MDSplus data access code to be corrected in this round, the execution stage, the error log, the failure type, the explanation of the failure reason, the code location that needs to be corrected, the MDSplus metadata corresponding to the failure type, and the correction suggestion; The structured execution feedback prompts also include the following corrective constraints: keeping the task defined by the user's original request unchanged, retaining the connection method of successfully establishing an MDSplus connection in the code, correcting erroneous node paths according to the candidate node paths recorded in the MDSplus metadata source, supplementing missing experimental tree opening operations, supplementing missing time dimension reading operations, correcting the MDSplus application programming interface calling method, and adding time window filtering, downsampling, or segmented reading operations for cases where the code execution time exceeds a preset execution time threshold, memory usage exceeds a preset memory threshold, or when a full waveform data is read at once.

8. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, In step S5, the user's original request, the MDSplus data access code to be corrected in this round, the error log, the failure type, the MDSplus metadata, and the correction suggestions are input into the large language model, and the large language model executes the code correction corresponding to the failure type. The code fixes include correcting erroneous node paths, correcting experimental tree names, correcting artillery number parameters, adding MDSplus connection statements, adding experimental tree opening operations, adding time dimension reading operations, correcting the MDSplus application programming interface call method, adding exception handling, adding time window filtering, adding downsampling processing, adopting a segmented reading method, eliminating duplicate connection operations, and eliminating duplicate node reading operations.

9. The MDSplus data access code self-correction method based on execution feedback according to claim 1, characterized in that, The iteration termination condition includes any of the following conditions: The revised MDSplus data access code was executed successfully and returned a result that satisfied the user's original request. The number of corrections has reached the preset maximum number of corrections; During continuous correction, the same error is determined to occur repeatedly based on a preset error identity rule. The current failure type is determined to be unable to be automatically corrected through the feedback construction and code correction process in steps S4 and S5 according to the preset correctability rules; The cumulative execution time or the cost of calling a large language model calculated according to a preset measurement standard exceeds the corresponding preset threshold. Received a user-initiated termination command; When the iteration termination condition is met, the final MDSplus data access code, execution result, error reason, or manual intervention suggestion is output according to the termination reason.

Citation Information

Patent Citations

  • Table data analysis method fusing large language model and ReAct framework

    CN121052226A

  • Database execution code automatic generation method and system based on large language model

    CN121478802A

  • Correction method and generation system for converting natural language into SQL (Structured Query Language) of large language model

    CN121786049A

  • Dynamic sandbox data analysis method and system based on large language model

    CN122197000A