A workflow template generation method and system based on Agentic AI causal reasoning

By using a three-stage causal reasoning method based on Agentic AI, a causal graph is constructed to automatically generate workflow templates, which solves the problems of lack of causal logic and unclear semantic structure in existing technologies, and realizes the traceability and execution stability of workflow templates.

CN122132026APending Publication Date: 2026-06-02KEDA ZHILING (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
KEDA ZHILING (BEIJING) TECHNOLOGY CO LTD
Filing Date
2025-12-30
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies lack the ability to model causal logic and semantic structure in the generation of automated workflow templates, resulting in templates that lack reasonable explanation, are prone to circular dependencies and parameter conflicts, and are difficult to optimize.

Method used

A three-stage causal reasoning method based on Agentic AI is adopted. By acquiring historical input text, extracting task objectives, constructing a causal graph, and automatically generating a workflow template based on the causal graph, including task objective decomposition, sequential causal reasoning, and parametric causal inference, the generated template is ensured to have causal logic and traceability.

Benefits of technology

The generated workflow templates are traceable, stable in execution, and have locatable errors. They resolve semantic fragmentation and parameter conflict issues, ensuring the semantic consistency and logical correctness of the templates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132026A_ABST
    Figure CN122132026A_ABST
Patent Text Reader

Abstract

The disclosure provides an Agentic AI causal reasoning-based workflow template generation method and system, relating to the technical field of software engineering. The method comprises: obtaining historical input text, extracting task targets from the historical input text, performing three-stage causal reasoning on the task targets, obtaining a causal graph, verifying the causal graph, obtaining a target causal graph, and automatically synthesizing an executable workflow template based on the target causal graph. Through the above method, an executable workflow template is automatically generated based on the target causal graph, so that the workflow template has traceability, execution stability and error positioning, solving the problems of semantic fragmentation, parameter conflict and unstable execution in the automatic workflow template generation process, thereby ensuring the semantic consistency and logical correctness of the workflow template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of software engineering technology, and in particular to a workflow template generation method and system based on Agentic AI causal reasoning. Background Technology

[0002] In modern software development, the configuration of automated workflows mainly relies on developers manually writing declarative configuration files such as human-readable data serialization (YAML Ain't Markup Language), or selecting and modifying them from static template libraries. To improve configuration efficiency, existing technologies mainly employ two types of automation methods: one is a static template recommendation system based on keyword matching; the other is a generation method based on clustering and statistical prediction of historical workflows, which generates configurations through trained models.

[0003] However, these existing technologies have fundamental flaws. First, by substituting statistical correlation for causality, they fail to distinguish between logically necessary dependencies and accidental contributions between tasks, resulting in a lack of reasonable explanation for the generated node order. Second, they lack a structured causal modeling mechanism; the generated templates are typically flat node sequences, failing to establish a hierarchical and traceable causal chain from "business objectives" to "node order" and then to "parameter configuration." Finally, the lack of logical closed-loop verification of the generated results easily leads to circular dependencies, parameter conflicts, or semantic fragmentation, making the template executable but uninterpretable and difficult to optimize.

[0004] In summary, existing technologies lack the ability to model the causal logic and semantic structure between tasks. Therefore, how to solve the semantic fragmentation, parameter conflicts and execution instability that occur in the process of generating automated workflow templates has become the main problem to be solved. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this disclosure provides a workflow template generation method and system based on Agentic AI causal reasoning.

[0006] According to a first aspect of the present disclosure, a workflow template generation method based on Agentic AI causal reasoning is provided, the method comprising: Retrieve historical input text; Extract the task objective from the historical input text, perform three-stage causal reasoning on the task objective, and obtain a causal graph; The causal graph is validated to obtain the target causal graph. Based on the target cause-effect graph, an executable workflow template is automatically synthesized.

[0007] In one possible design, the task objective is extracted from the historical input text, and a three-stage causal reasoning is performed on the task objective to obtain a causal graph, including: The task objective is broken down into multiple task sub-objectives, and causal identification is performed on multiple task sub-objectives to obtain the necessary node set corresponding to the task objective; Perform sequential causal reasoning analysis on each necessary node in the necessary node set to generate a sequential causal chain; Identify the key parameters of each node in the sequential causal chain, perform causal effect analysis on the key parameters of each node, and obtain a parametric causal graph; A causal graph is generated based on the necessary node set, sequential causal chain, and parametric causal graph.

[0008] In one possible design, causal identification is performed on multiple task sub-objectives to obtain the necessary node set corresponding to the task objective, including: Determine the node capability domain corresponding to each task sub-target, and based on the node capability domain corresponding to each task sub-target, select candidate nodes corresponding to each task sub-target from the preset node resource pool; Counterfactual reasoning is performed on the node capability domain of each candidate node to select the necessary node set corresponding to the task objective from each candidate node; wherein, counterfactual reasoning is a determination mechanism for whether candidate nodes, their order or key parameters constitute necessary conditions for the task objective.

[0009] In one possible design, counterfactual reasoning is performed on the capability domain of each candidate node to filter the necessary set of nodes corresponding to the task objective from each candidate node, including: For each candidate node, a removal operation is performed, and the execution status corresponding to the task objective is determined based on the node capability domain corresponding to the removed candidate node. If the execution status is successful, then the corresponding candidate node is determined to be a non-essential node; If the execution status is "execution failed", then the corresponding candidate node is determined to be a necessary node.

[0010] In one possible design, sequential causal reasoning analysis is performed on each necessary node in the necessary node set to generate a sequential causal chain, including: The necessary nodes in the necessary node set are analyzed based on data dependency rules to obtain a data flow graph. The data dependency rules include: explicit parameter reference rules, type matching rules, and data flow integrity rules. Logical execution constraints are obtained by analyzing each necessary node in the necessary node set based on logical dependency rules. The logical execution constraints include the execution order, preconditions, and failure propagation relationships of each necessary node. By integrating data flow graphs with logical execution constraints, multiple sets of sequence variants are constructed; Causal inference verification was performed on multiple sets of sequential variants to obtain sequential causal chains.

[0011] In one possible design, the key parameters for each node in the sequential causal chain are determined, including: Determine the required identifiers, template syntax identifiers, and task impact dimension identifiers in the sequential causal chain; Determine the parameter document corresponding to the sequential causal chain, and extract the key parameters corresponding to each node from the parameter document based on the required field identifier, template syntax identifier, and task impact dimension identifier.

[0012] In one possible design, a causal effect analysis is performed on the key parameters of each node to obtain a parametric causal graph, including: Set different test values ​​for the key parameters of each node; When the key parameters at each node are set for each test, the causal effect on the workflow execution behavior is determined; where execution behavior includes multiple task influence dimensions, and the causal effect characterizes the correspondence between changes in test values ​​and changes in execution behavior.

[0013] Based on causal effects, construct a parametric causal graph for each node.

[0014] In one possible design, after constructing the parametric causal graph for each node based on causal effects, it also includes: Based on the parameter constraint generation rules, key parameter analysis is performed on the parameter cause-effect graph to obtain multiple set constraints for each node. Multiple constraints are defined as causal constraints for the parameters of each node.

[0015] In one possible design, a causal graph is generated based on the necessary node set, sequential causal chains, and parametric causal graphs, including: Determine the extended node set in the sequential causal chain, and determine the parameter node set in the parametric causal graph; A comprehensive node set is generated based on the necessary node set, the extended node set, and the parameter node set. Determine the data flow graph by constructing an edge set based on the data flow direction between nodes in the sequential causal chain, the causal effects in the parametric causal graph, and the data flow graph. A causal graph is constructed based on the comprehensive node set and edge set.

[0016] In one possible design, a causal graph is constructed based on the combined node set and edge set, including: Based on the comprehensive node set and edge set, an initial causal graph is constructed; Determine the causal relationship attribute field corresponding to each edge in the initial causal graph, and determine the node state field corresponding to each node in the initial causal graph; In the initial causal graph, the causal relationship attribute field is associated with the corresponding edge, and the node state field is associated with the corresponding node to obtain the causal graph.

[0017] In one possible design, the causal graph is validated to obtain the target causal graph, including: Transform the causal graph into an adjacency list graph structure; Perform a depth-first search on unvisited nodes in the adjacency list graph structure to identify strongly connected components in the adjacency list graph structure. The causal graph is validated based on strongly connected components to obtain the target causal graph.

[0018] In one possible design, the causal graph is validated based on strongly connected components to obtain the target causal graph, including: Determine the error type corresponding to the strongly connected components in the causal graph; If the error type matches the set error type, the strongly connected components are de-looped to obtain an acyclic topology. Unreachable nodes are detected in acyclic topologies to identify unreachable nodes. If an unreachable node is a redundant node, then remove the unreachable node from the causal graph to obtain the target causal graph; If an unreachable node is a non-redundant node, then perform edge patching on the non-redundant node to obtain the target causal graph.

[0019] In one possible design, based on the target causal graph, an executable workflow template is automatically synthesized, including: Determine the node order, dependencies, and key parameters of each node from the target causal graph; Workflow templates are automatically generated based on node order, dependencies, and key parameters of each node.

[0020] According to a second aspect of the present disclosure, a workflow template generation system based on Agentic AI causal reasoning is provided, comprising: The text acquisition module is used to acquire historical input text; The causal reasoning module is used to extract the task objective from the historical input text, perform three-stage causal reasoning on the task objective, and obtain a causal graph. The graph generation module is used to perform graph verification on the causal graph to obtain the target causal graph. The template generation module is used to automatically synthesize executable workflow templates based on the target causal graph.

[0021] In one possible design, the causal reasoning module is specifically used to decompose the task objective into multiple task sub-objectives, perform causal identification on the multiple task sub-objectives to obtain the necessary node set corresponding to the task objective, perform sequential causal reasoning analysis on each necessary node in the necessary node set to generate a sequential causal chain, determine the key parameters of each node in the sequential causal chain, perform causal effect analysis on the key parameters of each node to obtain a parameter causal graph, and generate a causal spectrum based on the necessary node set, the sequential causal chain, and the parameter causal graph.

[0022] In one possible design, the causal reasoning module is also used to determine the node capability domain corresponding to each task sub-target, and based on the node capability domain corresponding to each task sub-target, to select candidate nodes corresponding to each task sub-target from a preset node resource pool, to perform counterfactual reasoning on the node capability domain of each candidate node, and to select the necessary node set corresponding to the task target from each candidate node; wherein, counterfactual reasoning is a determination mechanism for determining whether candidate nodes, order or key parameters constitute necessary conditions for the task target.

[0023] In one possible design, the causal reasoning module is also used to perform a removal operation on each candidate node and determine the execution status of the task target based on the node capability domain corresponding to the removed candidate node. If the execution status is successful, the corresponding candidate node is determined to be a non-essential node; if the execution status is failed, the corresponding candidate node is determined to be an essential node.

[0024] In one possible design, the causal reasoning module is also used to analyze each necessary node in the necessary node set based on data dependency rules to obtain a data flow graph. The data dependency rules include explicit parameter reference rules, type matching rules, and data flow integrity rules. Based on the logical dependency rules, the module analyzes each necessary node in the necessary node set to obtain logical execution constraints. The logical execution constraints include the execution order, preconditions, and failure propagation relationships of each necessary node. The data flow graph and logical execution constraints are integrated to construct multiple sets of sequence variants. Causal inference verification is performed on the multiple sets of sequence variants to obtain a sequential causal chain.

[0025] In one possible design, the causal reasoning module is also used to determine the required identifier, template syntax identifier, and task influence dimension identifier corresponding to the sequential causal chain, determine the parameter document corresponding to the sequential causal chain, and extract the key parameters corresponding to each node from the parameter document based on the required identifier, template syntax identifier, and task influence dimension identifier.

[0026] In one possible design, the causal reasoning module is also used to set different test values ​​for the key parameters of each node, and to determine the causal effect on the execution behavior of the workflow when the key parameters of each node are set to each test value; wherein, the execution behavior includes multiple task influence dimensions, the causal effect characterizes the correspondence between the change of test value and the change of execution behavior, and based on the causal effect, a parameter causal graph of each node is constructed.

[0027] In one possible design, the causal reasoning module is also used to perform key parameter analysis on the parameter causal graph based on the parameter constraint generation rules, obtain multiple set constraints for each node, and determine the multiple set constraints as the parameter causal constraints for each node.

[0028] In one possible design, the causal reasoning module is also used to determine the extended node set in the sequential causal chain and the parameter node set in the parametric causal graph. Based on the necessary node set, the extended node set, and the parameter node set, a comprehensive node set is generated, a data flow graph is determined, and an edge set is constructed based on the data flow between nodes in the sequential causal chain, the causal effects in the parametric causal graph, and the data flow graph. Based on the comprehensive node set and the edge set, a causal graph is constructed.

[0029] In one possible design, the causal reasoning module is also used to construct an initial causal graph based on the comprehensive node set and edge set, determine the causal relationship attribute field corresponding to each edge in the initial causal graph, and determine the node state field corresponding to each node in the initial causal graph. In the initial causal graph, the causal relationship attribute field is associated with the corresponding edge, and the node state field is associated with the corresponding node to obtain the causal graph.

[0030] In one possible design, the graph generation module is specifically used to transform the causal graph into an adjacency list graph structure, perform a depth-first search on the unvisited nodes in the adjacency list graph structure, identify strongly connected components in the adjacency list graph structure, and perform graph verification on the causal graph based on the strongly connected components to obtain the target causal graph.

[0031] In one possible design, the graph generation module is also used to determine the error type corresponding to the strongly connected components in the causal graph. If the error type matches the set error type, the strongly connected components are de-looped to obtain an acyclic topology. Unreachable nodes are detected in the acyclic topology to obtain unreachable nodes. If the unreachable node is a redundant node, it is deleted from the causal graph to obtain the target causal graph. If the unreachable node is a non-redundant node, it is padded with edges to obtain the target causal graph.

[0032] In one possible design, the template generation module is specifically used to determine the node order, dependencies, and key parameters of each node from the target causal graph, and automatically generate a workflow template based on the node order, dependencies, and key parameters of each node.

[0033] According to a third aspect of the present disclosure, a computer device is provided, comprising: A memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the method of the first or second aspect described above.

[0034] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, the method of the first aspect described above is implemented.

[0035] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects: In this embodiment, a three-stage causal reasoning is performed on the task objective to construct a target causal graph. Based on the target causal graph, an executable workflow template is automatically generated. The workflow template has traceability, execution stability, and error localization, solving the problems of semantic fragmentation, parameter conflict, and execution instability that occur during the generation of automated workflow templates. Furthermore, the workflow template is generated entirely based on causal logic and does not rely on any clustering prediction model, which improves the modeling ability of causal logic and semantic structure between task sub-objectives, thereby ensuring the semantic consistency and logical correctness of the workflow template.

[0036] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0037] The accompanying drawings, which are incorporated in and form part of this disclosure, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0038] Figure 1 This is a schematic diagram of a system architecture illustrated in an exemplary embodiment of this disclosure; Figure 2 This disclosure is a flowchart illustrating a workflow template generation method based on Agentic AI causal reasoning according to an exemplary embodiment. Figure 3 This disclosure is a schematic diagram illustrating a three-stage causal reasoning process for a task objective to obtain a causal graph, according to an exemplary embodiment. Figure 4 This is a schematic diagram of a three-stage causal reasoning process illustrated in this disclosure according to an exemplary embodiment; Figure 5 This is a schematic diagram illustrating the process of constructing a causal graph according to an exemplary embodiment of this disclosure; Figure 6 This disclosure is a schematic diagram illustrating the structure of a workflow template generation system based on Agentic AI causal reasoning according to an exemplary embodiment; Figure 7 This is a schematic diagram of the structure of a computer device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0039] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0040] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0041] It should be understood that although the terms first, second, third, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0042] In related technologies, the configuration of automated workflows suffers from fundamental flaws. First, it substitutes statistical correlation for causality, failing to distinguish between logically necessary dependencies and accidental contributions between tasks, resulting in a lack of reasonable explanation for the generated node order. Second, it lacks a structured causal modeling mechanism; the generated templates are typically flat node sequences, failing to establish a hierarchical and traceable causal chain from "business objectives" to "node order" and then to "parameter configuration." Finally, it lacks logical closed-loop verification of the generated results, easily leading to circular dependencies, parameter conflicts, or semantic fragmentation. This makes the template executable but uninterpretable, difficult to optimize, and lacking the ability to model the causal logic and semantic structure between tasks. Therefore, resolving the semantic fragmentation, parameter conflicts, and execution instability that occur during the generation of automated workflow templates has become a major problem to be solved.

[0043] The workflow template generation method based on Agentic Artificial Intelligence (Agentic AI) causal reasoning in this application embodiment is fundamentally based on explicitly constructing and utilizing a target causal graph as the sole basis and driving force for workflow template generation. Unlike existing methods that directly generate templates based on statistics, rules, or large language models, this application embodiment employs a three-stage causal reasoning process: "target causal identification—sequential causal reasoning—parametric causal inference." This process deconstructs user requirements into a structured sequential causal chain, forming a target causal graph. Furthermore, the workflow template synthesis module strictly follows the causal relationships within this target causal graph, rather than relying on historical template matching or black-box model output. Finally, a graph verification mechanism based on counterfactual reasoning is used to verify and reinforce the necessity of nodes and connections in the generated workflow template, ensuring that the generated workflow template is logically rigorous, its behavior is controllable, and its results are interpretable.

[0044] The workflow template generation method based on Agentic AI causal reasoning in the embodiments of this application will be described in detail below.

[0045] The system architecture diagram in this application embodiment is shown below. Figure 1 As shown, in Figure 1In this system architecture, the semantic parsing module consists of a semantic parsing module, a causal reasoning module, a template synthesis module, and a knowledge base module. The semantic parsing module performs semantic parsing on the received historical input text, which can be a human-readable data serialization (YAML Ain't MarkupLanguage, YAML) file or a lightweight data exchange (JavaScript Object Notation, JSON) file. This extracts the task objective, technology stack type, and constraints from the historical input text, and associates these elements to construct a semantic mapping framework. This framework serves as a tool for translation and connection, providing structured input for the causal reasoning module. The causal reasoning module completes causal chain modeling through three-stage reasoning, generating a causal graph. The template synthesis module automatically generates executable workflow templates based on the causal graph. The knowledge base module stores the workflow templates for reuse and retrieval.

[0046] It should be noted that the template synthesis module mentioned above does not directly rely on historical templates, statistical models, or rule sets. Instead, it takes the target causal graph as input, maps the nodes in the target causal graph to executable workflow nodes, and determines the execution order and parameter passing logic of the nodes based on the dependency relationships defined by the edges in the target causal graph, thus synthesizing the final workflow template.

[0047] The system architecture described above decouples semantic input, causal modeling, and template generation. The semantic parsing module and the causal reasoning module can communicate through the causal graph, avoiding direct dependence on specific models or algorithms and ensuring that the system has cross-language model portability and scalability.

[0048] like Figure 2 As shown, Figure 2 This disclosure is a flowchart illustrating a workflow template generation method based on Agentic AI causal reasoning according to an exemplary embodiment, comprising the following steps: In step 210, the historical input text is obtained.

[0049] To address the lack of modeling capabilities for causal logic and semantic structure between tasks in related technologies, this application requires obtaining historical input text. This historical input text includes project context, historical workflow, and task descriptions. The project context includes structured information such as code structure, code analysis tools, language and technology stack types, directory and module structure, and business style specifications. The technology stack types can be Python or JavaScript. The historical workflow records specific operation processes derived from pipeline execution logs. Historical workflows can be stored in YAML format, including node identifiers, types, key parameters, and explicit dependencies. The task description defines the requirements for each stage of the historical workflow, expressing business objectives in natural language, such as implementing a code quality inspection process or configuring automated testing for a Flask project.

[0050] The system can convert historical input text into an intermediate representation based on semantic parsing. The intermediate representation is in a unified format or a data structure that the computer can directly process, enabling efficient communication between the various modules in the system and ensuring improved efficiency in generating workflow templates.

[0051] For example, project context: The team is developing a new functional module; historical workflow: When developing a functional module, after the code is submitted, it will be executed sequentially through steps such as formatting checks, static checks, and unit tests. The execution time, tools used, and check results of each step will be recorded and stored; task description: Perform formatting checks, static checks, and unit tests on the submitted Python code and output risk warnings.

[0052] By using the methods described above, historical input text can be identified, ensuring its accuracy and improving the efficiency of automated workflow template generation.

[0053] In step 220, the task objective is extracted from the historical input text, and a three-stage causal reasoning is performed on the task objective to obtain a causal graph.

[0054] Semantic parsing is performed on historical input text, and task objectives, technology stack features, and constraints are extracted from the historical input text. Technology stack features describe the programming languages ​​used in the project or target task, and constraints are derived from historical workflows. Constraints can be automatically mapped to the default settings of the target task, such as default mirroring, default timeout, etc., or constraints can be used to form confidence scores to provide probabilities or weights for automatic decision-making.

[0055] In step 220, the system explicitly constructs the core data structure driving the workflow template generation—a causal graph—by performing three-stage causal reasoning on the task objectives (objective, sequence, and parameters). In this embodiment, the workflow template is not directly generated but synthesized based on the causal relationships contained in the causal graph. The three-stage causal reasoning on the task objectives yields a flowchart of the causal graph, as shown below. Figure 3 As shown, the specific process is as follows: In step 310, the task objective is broken down into multiple task sub-objectives, and causal identification is performed on the multiple task sub-objectives to obtain the necessary node set corresponding to the task objective.

[0056] Step 310 aims to solve the problem of how to identify indispensable execution units from fuzzy task objectives. The system decomposes the task objective into multiple logical sub-objectives and associates each sub-objective with a candidate node with a node capability domain through semantic mapping. The key is that the system does not simply list candidate nodes, but uses causal necessity analysis, such as counterfactual reasoning, to select the necessary node set that constitutes the minimum sufficient condition for the task objective from the candidate nodes. The necessary node set lays the node foundation of the causal graph.

[0057] The task objective is broken down into multiple task sub-objectives, and the node capability domain corresponding to each task sub-objective is determined. The node capability domain is the range of various situations that a node can handle in the system. For example, the node responsible for data acquisition has a node capability domain that includes: acquiring different types of data such as temperature, humidity, and pressure, as well as adjusting the acquisition frequency and filtering data anomalies.

[0058] This application embodiment establishes a semantic mapping between task sub-goals and node capability domains based on the Large Language Model (LLM). For example, if the task goal is to ensure code maintainability, the task goal can be divided into two task sub-goals: detecting complexity and checking naming conventions. Detecting complexity corresponds to the complexity_checker node, and checking naming conventions corresponds to the naming_linter node.

[0059] Based on the node capability domain corresponding to each task sub-target, candidate nodes corresponding to each task sub-target are selected from the preset node resource pool. The preset node resource pool is a set of nodes with independent functions that are pre-built and stored during the system initialization phase according to standards such as function type, technical specifications, and performance parameters. These nodes are uniformly encapsulated, contain complete input and output interfaces and configurable parameters, and can be dynamically called and combined based on workflow requirements, ensuring that the efficiency and standardization of workflow template generation can be improved. Each task sub-target corresponds to at least one candidate node.

[0060] For example, candidate nodes could be: flake8, black, pytest, bandit, and mypy.

[0061] To distinguish between causal relationships and accidental relationships, this application embodiment requires counterfactual reasoning for the node capability domain of each candidate node. Counterfactual reasoning is a mechanism to determine whether a candidate node, sequence, or key parameter constitutes a necessary condition for the task objective. A set of necessary nodes corresponding to the task objective is selected from each candidate node. The necessary nodes in the set of necessary nodes have a causal mapping with the task sub-objectives. Based on this, a removal operation is performed on each candidate node, and the execution status corresponding to the task objective is determined based on the node capability domain corresponding to the removed candidate node. If the execution status is successful, the corresponding candidate node is determined to be a non-necessary node; if the execution status is failed, the corresponding candidate node is determined to be a necessary node.

[0062] Specifically, the above counterfactual reasoning method is as follows: under the premise of keeping other conditions unchanged, remove a candidate node, construct a counterfactual workflow, and analyze the execution difference between the counterfactual workflow and the original workflow without removing the candidate node based on the LLM model, and output an execution difference report. The execution difference report includes: a list of failed candidate nodes, data flow interruption points, and unachievable task objectives. If removing a candidate node causes the task objective to be impossible to complete and there is no alternative candidate node, then the candidate node is determined as a necessary node.

[0063] For example, if A and B occur simultaneously, it may be just a coincidence, or it may be that A causes B. Counterfactual reasoning can determine whether B would have occurred if A had not occurred, thereby distinguishing between causal relationships and accidental relationships.

[0064] The counterfactual reasoning method described above can also remove the downstream dependent nodes corresponding to a candidate node, which is beneficial for evaluating the importance of the candidate node. The counterfactual reasoning method described above can be repeated, so it will not be explained again here.

[0065] The original workflow mentioned above can be a historical workflow. The original workflow can be adjusted and replaced based on the actual software development scenario. The task objective mentioned above can be replaced with task sub-objectives. Since the necessary nodes for determining the task sub-objectives are the same as the necessary nodes for determining the task objective, they will not be repeated here.

[0066] Based on the above method, by introducing counterfactual reasoning as a causal necessity determination mechanism, the embodiments of this application can effectively filter out false correlations or accidental associations in historical data, ensuring that the constructed causal graph and the final generated workflow template only contain logically necessary candidate nodes and sequences, thereby improving the accuracy and reliability of the workflow template.

[0067] For example, removing the flake8 node prevents the system from performing syntax and static checks, removing the black node prevents the code format from meeting team standards, and removing the pytest node prevents the execution of unit tests. Therefore, the flake8 node, black node, and pytest node are all determined to be necessary nodes.

[0068] Optionally, embodiments of this application may also filter the necessary node set corresponding to the task objective from each candidate node based on functional dependency rules, as follows: If the task objective or sub-objective requires key technical capabilities, then candidate nodes with key technical capabilities are matched from the candidate node set. The resource utilization rate corresponding to the matched candidate nodes is then determined. The candidate node with the lowest resource utilization rate is determined as the optimal node for achieving the key technical capabilities. Thus, the selected optimal node is determined as the necessary node. Necessary nodes can be presented based on the data exchange format (JavaScript Object Notation, JSON) to ensure the structured organization of data and cross-system compatibility.

[0069] In real-world software development scenarios, the necessary node set can be determined based on at least one of the above methods, which will not be elaborated on here.

[0070] For example, a flowchart illustrating the three-stage causal reasoning process in this application embodiment is shown below. Figure 4 As shown, in Figure 4 The process consists of three phases: Phase 1 is the identification of business objective causality, which includes: identifying task objectives and sub-objectives, determining candidate node sets, performing counterfactual reasoning on candidate nodes, and outputting the necessary node set; Phase 2 is sequential causal chain reasoning, which includes: determining the necessary node set, applying data dependency rules, applying logical dependency rules, and generating a sequential causal chain; Phase 3 is parametric causal inference, which includes: identifying key parameters of nodes, constructing scenarios for LLM model inference, extracting causal effects, and generating a parametric causal graph, with the scenario determined based on key parameters and test values.

[0071] The three-stage outputs together form a causal graph, which clearly expresses the hierarchical structure of business objectives, node logic, and parameter dependencies. The causal graph is the only input source for the template synthesis module, fundamentally ensuring the logical closed loop and traceability of the generated results.

[0072] By using the above method, causal identification is performed on multiple task sub-objectives to obtain the necessary node set corresponding to the task objective. This ensures that the necessary node set can support the achievement of the task objective and guarantees the accuracy of the necessary node set. During the workflow template generation process, the functional stability and operational efficiency of the necessary nodes can be specifically enhanced.

[0073] In step 320, sequential causal reasoning analysis is performed on each necessary node in the necessary node set to generate a sequential causal chain.

[0074] Step 320 aims to address the problem of determining the non-arbitrarily interchangeable execution logical order among necessary nodes. The system analyzes the inherent constraints between necessary nodes from two dimensions: data dependency and logical dependency, generating the execution order. To reinforce the causal necessity of the order, rather than merely empirical correlation, this embodiment introduces counterfactual reasoning as the core verification mechanism. Specifically, the system proactively adjusts the execution order among necessary nodes using variations and deduces their consequences. If the variation leads to a logical error, it indicates that the dependencies in the original order are causally necessary, thus establishing a verified and stable sequential relationship as a sequential causal chain. This sequential causal chain defines the main topological structure between nodes in the causal graph.

[0075] Due to the lack of a structured causal modeling mechanism, the generated workflow templates are usually flat node sequences, failing to establish a hierarchical and traceable causal chain from "business objectives" to "node order" and then to "parameter configuration". Therefore, this application embodiment analyzes the node order corresponding to the necessary node set from two dimensions: data dependency and logical dependency. The specific process is as follows: Based on the data dependency rules, each necessary node in the necessary node set is analyzed to obtain the data flow graph. The data dependency rules include: explicit parameter reference rules, type matching rules, and data flow integrity rules.

[0076] Furthermore, based on explicit parameter reference rules, each necessary node is detected. The explicit parameter reference rules determine the data dependency reference fields corresponding to the necessary nodes, thereby determining the data flow graph corresponding to the set of necessary nodes.

[0077] For example, the data dependency reference field corresponding to the necessary node B is nodes.A.output.xxx, where xxx is the specific content provided by the necessary node A to the necessary node B. The necessary node B needs A to provide xxx to work properly. Therefore, the data flow is from A to B.

[0078] The type matching results are obtained by detecting the input and output data types of each necessary node based on the type matching rules.

[0079] Furthermore, taking each necessary node as the center, if the data type output by the upstream node is consistent with the data type received or processed by the downstream node, it means that the upstream node and the downstream node are matched, and data can be directly transmitted between the upstream node and the downstream node; if the data type output by the upstream node is inconsistent with the data type received and processed by the downstream node, it means that the upstream node and the downstream node are not matched, and the upstream node or the downstream node needs to be converted or adjusted.

[0080] When an upstream node matches a downstream node, and only one upstream node can generate the data type that the downstream node can receive or process, it means that there is an implicit dependency between the upstream and downstream nodes.

[0081] For example: if the data input type of necessary node B needs to be provided by the data output type of necessary node A, and only necessary node A can produce this data input type in the current workflow, then it is inferred that there is an implicit dependency between necessary nodes A and B, and the data flow is from A to B.

[0082] Based on the above method, it can be ensured that the data type output by the upstream node is consistent with the data type received by the downstream node, thus avoiding data parsing errors caused by type mismatch.

[0083] Based on the data flow integrity rules, each necessary node in the necessary node set is analyzed. If the data required by the downstream node must be processed by the upstream node before it can be used, then a necessary path is formed between the necessary nodes, and a data flow diagram is generated based on the necessary path.

[0084] For example, the code fixed by lint is a prerequisite for the execution of the test node, the code fixed by lint is the output of the upstream node, and the execution of the test node is the operation of the downstream node. Only when the upstream code is fixed can the downstream test begin.

[0085] To ensure semantic consistency in the workflow, it is necessary to analyze the logical dependencies between necessary nodes. Logical dependencies are reflected in semantics or preconditions. Therefore, this embodiment of the application needs to analyze each necessary node in the necessary node set based on logical dependency rules to obtain logical execution constraints. The logical execution constraints include: the execution order of each necessary node, preconditions, and failure propagation relationships.

[0086] Specifically, if the execution of a downstream node is contingent upon the successful completion of an upstream node, then the upstream node is determined to be a prerequisite for the downstream node, and a logical dependency is formed between the upstream and downstream nodes.

[0087] If the failure of an upstream node inevitably leads to the downstream node becoming meaningless or failing, and the failure includes errors in code, system failures, data format errors, etc., then it is determined that there is a failure propagation relationship between the upstream and downstream nodes, and the upstream and downstream nodes constitute a logical dependency.

[0088] If the semantics of necessary nodes have a semantic sequence relationship, such as "Get Changes" before "Analyze Changes", then the semantics of necessary nodes are identified based on the LLM model, and the necessary nodes are semantically sorted to obtain the execution order of necessary nodes.

[0089] Based on the above process, after determining the data flow diagram and logical execution constraints, in order to address the shortcomings of the single perspective of the data flow diagram and the lack of a global perspective on data flow in the logical execution constraints, this application embodiment needs to integrate the data flow diagram and logical execution constraints to construct a fused node sequence, thereby ensuring the correctness of the data path and ensuring that necessary nodes are executed in an orderly manner according to logic.

[0090] To avoid unnecessary sequence constraints in the workflow, this embodiment of the application verifies the necessity of the sequence by exchanging the node order in the fusion node sequence and analyzing the consequences. The specific process is as follows: The node order of the fusion nodes is adjusted to obtain multiple sets of adjusted sequence variants. Causal inference verification is performed on the multiple sets of sequence variants to detect whether there are logical errors in the multiple sets of sequence variants. If there are no logical errors, the corresponding sequence variant is determined as a sequential causal chain; if there are logical errors, the location of the logical error is located and the sequence variant is corrected.

[0091] Specifically, each set of sequential variants is input into the LLM model, and a detection report corresponding to each set of sequential variants is output. If the detection report is a normal report, it means that there is no logical error in the sequential variant. If the detection report is an abnormal report, the abnormal report includes: missing data, execution failure, or inconsistency with logical dependencies, which means that there is a logical error. It is necessary to determine the degree of impact of each set of sequential variants on the workflow based on the abnormal report. If the degree of impact is greater than the degree of impact threshold, it is determined that the node order of the corresponding sequential variant cannot be changed, and the sequential variant is marked with the necessary causal label.

[0092] For example, the node order is analyzed from two dimensions: data dependency and logical dependency. Data dependency analysis is based on the input-output relationship of the nodes: the output of black is the formatted source code, and the inputs of flake8 and pytest are both source code. The business style specification of the historical workflow is "formatting takes precedence over static testing". Logical dependency analysis further determines that static testing should be executed before unit testing. Based on the above rules, the system obtains the sequential causal chain: black→flake8→pytest, thereby ensuring that the generated process is logically interpretable and conforms to actual engineering experience.

[0093] Based on the above method, it is possible to identify sequential variants without logical errors, thereby improving the stability and efficiency of the workflow, as well as the accuracy of the sequential causal chain, which provides a topological order basis for the generation of workflow templates.

[0094] In step 330, the key parameters of each node in the sequential causal chain are determined, and the causal effect analysis of the key parameters of each node is performed to obtain the parameter causal graph.

[0095] Step 330 aims to address the independent technical problem of ensuring that node parameter configuration does not cause the workflow template behavior to deviate from expectations. This technical problem is as important as the determination of nodes and their order. The system first identifies the key parameters for each node. Then, through causal effect analysis of these key parameters—for example, setting default values, extreme values, and missing values, and observing their impact on the workflow template's execution path, performance, results, and quality—a parametric causal graph describing the causal relationship between parameter values ​​and workflow behavior is constructed. Based on the parametric causal graph, parametric causal constraints are derived. These constraints are integrated as attribute information into the causal graph, thereby ensuring that the generated workflow template is controllable and conforms to causal expectations at the parameter level.

[0096] To precisely control the behavior and outcome of a workflow, it is necessary to determine the causal impact of changes in key parameters at each node on the workflow's behavior. First, it is necessary to determine the key parameters of each node in the sequential causal chain. The specific process is as follows: The required identifiers, template syntax identifiers, and task impact dimension identifiers in the sequential causal chain are determined. The parameter document corresponding to the sequential causal chain is determined. The parameter document records the detailed information of all parameters in each node of the sequential causal chain. Based on the required identifiers, template syntax identifiers, and task impact dimension identifiers, the key parameters corresponding to each node are extracted from the parameter document.

[0097] The required field identifier can be "required", the template syntax identifier is "{{}}", "{{}}" represents cross-node data reference, and the task impact dimension identifier can be execution logic, performance dimension, or result quality dimension, etc.

[0098] The required field identifiers, template syntax identifiers, and task impact dimension identifiers mentioned above can all be adjusted based on the actual software development scenario; this is just an example.

[0099] Secondly, in order to determine the causal impact of changes in key parameters at each node on the workflow's behavioral state, a causal effect analysis of the key parameters at each node is needed to obtain a parameter cause-effect graph. The specific process is as follows: Different test values ​​are set for the key parameters of each node. The test values ​​can be default values, extreme values, and missing values. When the key parameters of each node are set for each test value, the causal effect on the execution behavior of the workflow is determined. This execution behavior includes multiple task impact dimensions, such as execution path, performance, quality, and failure probability. The causal effect characterizes the correspondence between the change of test value and the change of execution behavior. Based on the causal effect, a parameter causal graph of each node is constructed.

[0100] Optionally, the key parameters of each node and each test value can be input into the LLM model to output the causal effect under different test values.

[0101] During workflow execution, the lack of clear constraints between key parameters can lead to contradictory combinations and unreasonable values, resulting in workflow failure, inefficiency, or unexpected results. Therefore, to ensure the rationality of parameter configuration and the stable operation of the workflow, it is necessary to determine the causal constraints of parameters at each node. The specific process is as follows: Based on the parameter constraint generation rules, key parameter analysis is performed on the parameter cause-effect graph to obtain multiple set constraints for each node, and these multiple set constraints are determined as the parameter cause-effect constraints for each node.

[0102] Specifically, the parameter constraint generation rules include: necessity constraints, dependency constraints, value range constraints, and consistency constraints. Necessity constraints require the removal of a key parameter from a node in the parameter cause-effect graph to simulate the situation where a key parameter is missing, and then start the node to run. If the node fails to execute, the constraint condition is set to make the removed key parameter a necessary parameter; otherwise, the constraint condition is set to make the removed key parameter a non-necessary parameter.

[0103] The aforementioned dependency constraint is that the key parameters of a downstream node in the parametric cause-effect graph depend on the output of an upstream node. Therefore, a binding expression is generated for the downstream node, and this binding expression is used as the setting constraint condition for the downstream node. For example: P = {{nodes.Q.output.xxx}}, where "{{}}" is a value reference. The key parameters of P need to be determined based on the output xxx of the upstream node Q. That is, the key parameters of P are bound to the output of Q.

[0104] The above-mentioned value range constraint is to replace the key parameters of each node with test values, where the test values ​​are extreme values, thereby determining the value range of the key parameters of each node. Then, the default value and parameter type corresponding to the key parameters of each node are determined, and the setting constraint conditions of each node are generated based on the value range, default value and parameter type.

[0105] The aforementioned consistency constraint determines multiple key parameter combinations in the parameter cause-effect graph. If multiple key parameter combinations have mutually exclusive or cooperative relationships, a cross-parameter consistency definition is generated, and the consistency definition is used as the setting constraint condition.

[0106] For example, when starting the cache, a cache path must be provided. The combination of multiple key parameters corresponding to "starting the cache" and "cache path" forms a collaborative relationship. Therefore, in the cross-parameter consistency definition, it is explicitly stipulated that when the key parameter corresponding to "starting the cache" is "yes", the key parameter corresponding to "cache path" must be filled with a valid path value, thereby avoiding logical errors.

[0107] Based on the above method, determining the parameter cause-effect graph and the parameter cause-effect constraints of each node can ensure that the generated workflow template is correct and executable.

[0108] In step 340, a causal graph is generated based on the necessary node set, the sequential causal chain, and the parametric causal graph.

[0109] Step 340 involves the structured integration of the three-stage reasoning results. The system unifies the necessary nodes and node relationships in the sequential causal chain, as well as the parametric causal constraints and causal effects contained in the parametric causal graph, into a complete and computable data structure—the causal graph. In the causal graph, nodes represent necessary task units, and task units represent verified data, logical dependencies, or causal effects. Causal relationship attributes can be attached to edges. The causal graph will serve as the sole input to the subsequent workflow template synthesis module, guiding the synthesis of workflow templates, thereby completely eliminating reliance on historical template libraries or statistical rules and achieving truly causal logic-driven workflow template construction.

[0110] To ensure a clearer structure and more coherent logic in the causal graph, this embodiment of the application needs to determine the necessary node set, the extended node set in the sequential causal chain, and the parameter node set in the parametric causal graph. Then, based on the necessary node set, the extended node set, and the parameter node set, a comprehensive node set is generated. Next, based on the data flow direction between nodes in the sequential causal chain, the causal effect in the parametric causal graph, and the data flow graph, an edge set is constructed. Finally, based on the comprehensive node set and the edge set, a causal graph is constructed.

[0111] The aforementioned extended node set includes: parallel nodes and auxiliary nodes in the sequential causal chain. Auxiliary nodes are nodes that support, supplement, or regulate the main workflow. Auxiliary nodes do not directly participate in the core causal logic. For example, in the sequential causal chain of data processing, the main nodes are data acquisition and data analysis, while the auxiliary nodes are data backup. The parameter nodes in the aforementioned parameter node set are attached to the corresponding task nodes as attributes, rather than being separately split into nodes in the causal graph. This avoids node redundancy and ensures the simplicity and logic of the causal graph.

[0112] By extracting the data flow direction between nodes from the sequential causal chain, the data flow direction graph corresponding to the data dependency rule is determined. Then, the data type and data name are marked in the edge attributes between nodes in the data flow direction graph, and the causal effect is determined as the edge attribute attached to the corresponding node or edge, which improves the completeness and accuracy of the causal graph.

[0113] In one possible design, to improve the practicality of the causal graph, it is necessary to construct an initial causal graph based on the comprehensive node set and edge set, then determine the causal relationship attribute field corresponding to each edge in the initial causal graph, and determine the node state field corresponding to each node in the initial causal graph. Then, in the initial causal graph, the causal relationship attribute field is associated with the corresponding edge, and the node state field is associated with the corresponding node to obtain the causal graph.

[0114] The aforementioned causal relationship attribute fields include: data type, logical type, confidence level, source stage, etc., and the aforementioned node status fields include: necessity identifier, non-necessity identifier, fault impact level, etc.

[0115] For example, a schematic diagram of the causal graph construction process in this application embodiment is shown below. Figure 5 As shown, in Figure 5 In this process, the necessary node set, extended node set, and parameter node set are determined. Based on these, a comprehensive node set is generated. An edge set is constructed based on sequential dependencies (data flow graph) and data dependencies (data flow, causal effect). Causal relationship attribute fields and node state fields are determined. Based on the comprehensive node set, edge set, causal relationship attribute fields, and node state fields, a causal graph is constructed. Then, the Tarjan algorithm is run to detect strongly connected components in the causal graph and determine whether a cycle exists. If not, the current causal graph is determined as the final causal graph. If a cycle exists, logical cycles and data cycles in the strongly connected components are classified and processed to resolve the cycles. Finally, the validity of the causal graph is determined.

[0116] Using the methods described above, a comprehensive node set is generated based on the necessary node set, the extended node set, and the parameter node set. This ensures that the core nodes of the system are covered and that the causal graph is complete. Furthermore, an edge set is constructed based on the data flow between nodes in the sequential causal chain, the causal effects in the parameter causal graph, and the data flow graph. This ensures that the relationships between nodes can be accurately described from multiple dimensions, making the causal graph more precise, avoiding biases caused by single node relationships, and improving the accuracy and practicality of the causal graph.

[0117] In step 230, the causal graph is validated to obtain the target causal graph.

[0118] To ensure that all causal relationships in the causal graph constructed from the preceding causal inference are true, necessary, and logically consistent, they need to be refined and verified to obtain the target causal graph for the final driving template synthesis. This step goes beyond traditional graph structure checks and incorporates closed-loop verification of causal necessity determination. The specific process is as follows: The causal graph is transformed into an adjacency list graph structure, which is a graph structure stored in the form of an adjacency list. A depth-first search is performed on unvisited nodes in the adjacency list. Then, index and lowlink values ​​are maintained to mark nodes. The index records the order in which nodes are visited, and the lowlink records the index of the earliest visited node that can be traced back from the current node. To temporarily store nodes whose strongly connected components have not yet been determined, a stack is used to record the current search path. When the index and lowlink values ​​of a node are equal, it means that all nodes from that node to the top of the stack form a strongly connected component. The strongly connected component is popped from the stack, thus determining all strongly connected components. The number of nodes in a strongly connected component is greater than 1. Finally, the causal graph is validated based on the strongly connected components to obtain the target causal graph.

[0119] It should be noted that for a single node that has a self-loop, it is marked as a self-referencing error.

[0120] Graph verification of causal graphs can be performed based on the Tarjan algorithm, which will not be discussed in detail here.

[0121] Since the circular dependencies of nodes in strongly connected components have logical contradictions, this application embodiment needs to determine the error type corresponding to the strongly connected components in the causal graph. If the error type matches the set error type, the error type is set as a repairable error type. Then, the strongly connected components are de-looped to obtain an acyclic topology. Finally, unreachable nodes are detected in the acyclic topology to obtain unreachable nodes.

[0122] Specifically, when the error type is that the strongly connected component consists only of logical dependencies and the data flow allows for refactoring, the execution order between nodes in the strongly connected component is adjusted to eliminate circular dependencies; when the error type is that the strongly connected component consists only of hard data dependencies, the hard data dependencies can be that key parameters must come from downstream nodes, the local design corresponding to the strongly connected component is marked as an unrepairable structural error, and a prompt is made that the local design needs to be manually refactored.

[0123] In this application, embodiments can select the edge with the least impact on the task objective in strongly connected components based on the principle of least disruption, and disconnect or redirect it. Alternatively, a repair scheme corresponding to the strongly connected components can be generated based on the LLM model, such as splitting a certain aggregation node into a pre-processing node and a post-summary node, or changing some key parameters to come from the external context rather than the downstream node.

[0124] Unreachable node detection in acyclic topology is based on reverse traversal to check whether all nodes are reachable from the starting node. This means that starting from the starting node, can a path be found to reach the target node by following the directed edges between nodes? If so, the node is reachable from the starting node; otherwise, it is determined to be unreachable.

[0125] If an unreachable node is a redundant node, it is removed from the causal graph to obtain the target causal graph; if an unreachable node is a non-redundant node, it is padded with edges to obtain the target causal graph.

[0126] The aforementioned target causal graph decouples semantic parsing from template generation, ensuring that the system can be transferred across models and algorithms.

[0127] By using the above methods, the causal graph is verified to obtain the target causal graph, ensuring the logical accuracy of the target causal graph, solving the problems of circular dependencies and isolated nodes in the causal graph, and ensuring the reliability of the target causal graph.

[0128] In step 240, an executable workflow template is automatically synthesized based on the target causal graph.

[0129] The template synthesis module relies solely on the target causal graph generated in step 230 for synthesis, rather than retrieving components or imitating historical templates. This ensures that the generated workflow template is a direct reflection of causal logic, possessing high interpretability and consistency. The specific synthesis process is as follows: In order to achieve the automatic transformation from abstract causal logic to workflow, this application embodiment needs to determine the node order, dependency relationship and key parameters of each node from the target causal graph, and automatically generate a workflow template based on the node order, dependency relationship and key parameters of each node. The workflow template includes: purpose description, node definition, dependency structure and parameter constraints. The workflow template can be in YAML format.

[0130] To illustrate the feasibility of the causal reasoning mechanism of this application embodiment in actual engineering scenarios, "Python code review" is used as an example to demonstrate the entire process of the system performing three-stage causal reasoning on node selection, node order and parameter configuration under real task conditions.

[0131] The "Python code review" is based on the project's historical corpus and contextual information. It gradually obtains a structured causal graph through causal modeling and finally generates a workflow template that can be directly executed. This demonstrates the advantages of the embodiments of this application in terms of logical consistency, traceability and engineering feasibility.

[0132] The historical input text consists of three parts: project context, historical workflow records, and task description. The project context includes the code structure (directories such as src / and tests / ), code analysis tools (black, flake8, pytest), and business style guidelines. The historical workflow records come from the pipeline execution log, and the task description is: "Perform formatting checks, static analysis, and unit tests on the submitted Python code and output risk warnings."

[0133] The above information, after being processed by the semantic parsing module, serves as the input to the causal reasoning module.

[0134] Phase 1: Identifying the Causes and Effects of Business Objectives

[0135] The system establishes a candidate node set based on the task objectives. The candidate node set includes nodes such as flake8, black, pytest, bandit, and mypy. Then, based on the requirements of the business objectives, the necessity of each candidate node is determined through counterfactual reasoning.

[0136] For example, removing flake8 prevents the system from performing syntax and static analysis, removing black prevents the code format from meeting team standards, and removing pytest prevents unit tests from running. Therefore, flake8, black, and pytest are all considered necessary nodes. bandit and mypy are not required in the task objective and are therefore classified as non-necessary nodes.

[0137] The output of Phase 1 is the set of necessary nodes and their causal mapping with business objectives, which is used for sequential reasoning in subsequent phases.

[0138] Phase Two: Node Sequence Causal Reasoning.

[0139] In Phase Two, the system analyzes the node order from two dimensions: data dependency and logical dependency. The data dependency analysis is based on the input-output relationship of the nodes: the output of black is the formatted source code, and the inputs of flake8 and pytest are both source code. The business style specification is "formatting takes precedence over static checking". The logical dependency analysis further determines that static checking should be executed before unit testing.

[0140] Based on the above rules, the system obtains the sequential causal chain: black→flake8→pytest. This sequential causal chain reflects the data processing order and the team's usual execution strategy, ensuring that the generated process is logically interpretable and conforms to actual engineering experience.

[0141] Phase 3: Parameter Causal Inference.

[0142] In Phase 3, the system performs causal effect analysis on key parameters of necessary nodes. First, it identifies multiple key parameter combinations for flake8, pytest, and black, focusing on key parameters that have a real impact on execution behavior, such as flake8's max-line-length, pytest's exitfirst, and black's line-length. Then, it constructs default, extreme, and standard scenarios to compare the differences in process behavior under different test values.

[0143] For example, a smaller max-line-length will increase the number of warnings and errors in the lint phase, exitfirst will cause the unit test phase to terminate early, and line-length will affect the scope of formatting changes. The system extracts causal effects based on these differences and forms a parameter causal graph, providing a clear parameter configuration basis for the template generation module.

[0144] Based on the necessary node set, sequential causal chain, and parametric causal graph obtained from the three-stage causal reasoning, a YAML template is synthesized.

[0145] The output of the three-stage causal reasoning is synthesized into a causal graph, which is verified by the Tarjan algorithm and no circular dependencies are found. The data flow starts from git_diff and forms a topological closed path through static inspection, testing and reporting. Thus, the target causal graph is determined.

[0146] Furthermore, the YAML template automatically synthesized based on the target causal graph differs significantly from the template generated based on clustering prediction methods in terms of node selection, order rationality, and parameter configuration. The differences are shown in Table 1. Table 1 This case study vividly demonstrates the advantages of the Agentic AI-based workflow template generation method over traditional clustering prediction methods in terms of causal interpretability, structural stability, and parameter controllability.

[0147] The YAML template for automatically synthesizing target causal graphs realizes intelligent template generation with causal reasoning as its core. Through the coupling mechanism of semantic parsing and causal reasoning, natural language descriptions can be directly transformed into causal graphs. At the logical level, it completes the unified mapping of "semantics → causality → structure", which greatly reduces manual configuration and syntax errors. Through the logical closed loop of "semantic understanding - causal modeling - template synthesis", it realizes the leap from relevance matching to causal reasoning.

[0148] The embodiments of this application fundamentally solve the problems of causal logic rationality and structural controllability of workflow templates during the generation stage. Further quality verification, precise problem location and automated iterative optimization of the generated workflow templates belong to an independent post-processing governance stage, which can be completed by an independent system. Together, the two constitute a solution covering the entire life cycle of workflow templates, which will not be described in the embodiments of this application.

[0149] Using the above method, a three-stage causal reasoning is performed on the task objective to construct a target causal graph. Based on the target causal graph, an executable workflow template is automatically generated. The workflow template has traceability, execution stability, and error localization, solving the problems of semantic fragmentation, parameter conflict, and execution instability that occur in the process of automated workflow template generation. Furthermore, the workflow template is generated entirely based on causal logic and does not rely on any clustering prediction model, which improves the modeling ability of causal logic and semantic structure between task sub-objectives, thereby ensuring the semantic consistency and logical correctness of the workflow template.

[0150] like Figure 6 The diagram shown is a schematic representation of a workflow template generation system based on Agentic AI causal reasoning, according to an exemplary embodiment, comprising the following steps: Text acquisition module 601 is used to acquire historical input text; Causal reasoning module 602 is used to extract task objectives from the historical input text, perform three-stage causal reasoning on the task objectives, and obtain a causal graph. The graph generation module 603 is used to perform graph verification on the causal graph to obtain the target causal graph. The template generation module 604 is used to automatically synthesize an executable workflow template based on the target causal graph.

[0151] In one possible design, the causal reasoning module 602 is specifically used to decompose the task objective into multiple task sub-objectives, perform causal identification on the multiple task sub-objectives to obtain a set of necessary nodes corresponding to the task objective, perform sequential causal reasoning analysis on each necessary node in the set of necessary nodes to generate a sequential causal chain, determine the key parameters of each node in the sequential causal chain, perform causal effect analysis on the key parameters of each node to obtain a parameter causal graph, and generate the causal graph based on the set of necessary nodes, the sequential causal chain, and the parameter causal graph.

[0152] In one possible design, the causal reasoning module 602 is further configured to determine the node capability domain corresponding to each task sub-target, and based on the node capability domain corresponding to each task sub-target, filter candidate nodes corresponding to each task sub-target from a preset node resource pool, perform counterfactual reasoning on the node capability domain of each candidate node, and filter the necessary node set corresponding to the task target from each candidate node; wherein, the counterfactual reasoning is a determination mechanism for determining whether candidate nodes, their order, or key parameters constitute necessary conditions for the task target.

[0153] In one possible design, the causal reasoning module 602 is further configured to perform a removal operation on each candidate node, and determine the execution status corresponding to the task target based on the node capability domain corresponding to the removed candidate node. If the execution status is successful, the corresponding candidate node is determined to be a non-essential node; if the execution status is failed, the corresponding candidate node is determined to be the essential node.

[0154] In one possible design, the causal reasoning module 602 is further configured to analyze each necessary node in the necessary node set based on data dependency rules to obtain a data flow graph; the data dependency rules include: explicit parameter reference rules, type matching rules, and data flow integrity rules; and to analyze each necessary node in the necessary node set based on logical dependency rules to obtain logical execution constraints; the logical execution constraints include: the execution order, preconditions, and failure propagation relationships of each necessary node; the data flow graph and the logical execution constraints are fused to construct multiple sets of sequence variants; and causal inference verification processing is performed on the multiple sets of sequence variants to obtain the sequential causal chain.

[0155] In one possible design, the causal reasoning module 602 is further configured to determine the required identifier, template syntax identifier, and task influence dimension identifier corresponding to the sequential causal chain, determine the parameter document corresponding to the sequential causal chain, and extract the key parameters corresponding to each node from the parameter document based on the required identifier, the template syntax identifier, and the task influence dimension identifier.

[0156] In one possible design, the causal reasoning module 602 is further configured to set different test values ​​for the key parameters of each node, and determine the causal effect on the execution behavior of the workflow when the key parameters of each node are each test value; wherein the execution behavior includes multiple task influence dimensions, the causal effect characterizes the correspondence between the change of test value and the change of execution behavior, and based on the causal effect, construct the parameter causal graph of each node.

[0157] In one possible design, the causal reasoning module 602 is further used to perform key parameter analysis on the parameter causal graph based on parameter constraint generation rules, obtain multiple set constraints for each node, and determine the multiple set constraints as parameter causal constraints for each node.

[0158] In one possible design, the causal reasoning module 602 is further configured to determine the extended node set in the sequential causal chain and the parameter node set in the parameter causal graph; generate a comprehensive node set based on the necessary node set, the extended node set, and the parameter node set; determine a data flow graph; construct an edge set based on the data flow direction between nodes in the sequential causal chain, the causal effects in the parameter causal graph, and the data flow graph; and construct the causal graph based on the comprehensive node set and the edge set.

[0159] In one possible design, the causal reasoning module 602 is further configured to construct an initial causal graph based on the comprehensive node set and the edge set, determine the causal relationship attribute field corresponding to each edge in the initial causal graph, and determine the node state field corresponding to each node in the initial causal graph. In the initial causal graph, the causal relationship attribute field is associated with the corresponding edge, and the node state field is associated with the corresponding node to obtain the causal graph.

[0160] In one possible design, the graph generation module 603 is specifically used to convert the causal graph into an adjacency list graph structure, perform a depth-first search on the unvisited nodes in the adjacency list graph structure, identify the strongly connected components in the adjacency list graph structure, and perform graph verification on the causal graph based on the strongly connected components to obtain the target causal graph.

[0161] In one possible design, the graph generation module 603 is further configured to determine the error type corresponding to the strongly connected component in the causal graph. If the error type matches a set error type, the strongly connected component is de-looped to obtain an acyclic topology. Unreachable nodes are detected in the acyclic topology to obtain unreachable nodes. If the unreachable node is a redundant node, it is deleted from the causal graph to obtain the target causal graph. If the unreachable node is a non-redundant node, it is padded with edges to obtain the target causal graph.

[0162] In one possible design, the template generation module 604 is specifically used to determine the node order, dependencies, and key parameters of each node from the target causal graph, and automatically generate the workflow template based on the node order, dependencies, and key parameters of each node.

[0163] This disclosure provides a computer device, including: A memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the method of any of the above embodiments.

[0164] This specification describes an embodiment of a workflow template generation method based on Agentic AI causal reasoning, which can be applied to computer devices, such as servers or terminal devices. The device embodiment can be implemented in software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by a processor that processes the file, reading the corresponding computer program instructions from non-volatile memory into memory and executing them. From a hardware perspective, such as... Figure 7 The diagram shown is a structural schematic of a computer device used in an embodiment of this specification to generate a workflow template based on Agentic AI causal reasoning. (Except for...) Figure 7 In addition to the processor 710, memory 730, network interface 720, and non-volatile memory 740 shown, other hardware may also be included depending on the actual function, which will not be described in detail here.

[0165] This disclosure provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the methods of any of the above embodiments. The execution method and beneficial effects are similar, and will not be described again here.

[0166] The aforementioned computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0167] The computer program described above can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer device, partially on the user's device, as a standalone software package, partially on the user's computer device and partially on a remote computer device, or entirely on a remote computer device or server.

[0168] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0169] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0170] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A workflow template generation method based on Agentic AI causal reasoning, characterized in that, include: Retrieve historical input text; The task objective is extracted from the historical input text, and a three-stage causal reasoning is performed on the task objective to obtain a causal graph. The causal graph is validated to obtain the target causal graph; Based on the target causal graph, an executable workflow template is automatically synthesized.

2. The method according to claim 1, characterized in that, The process of extracting the task objective from the historical input text, performing three-stage causal reasoning on the task objective, and obtaining a causal graph includes: The task objective is broken down into multiple task sub-objectives, and causal identification is performed on the multiple task sub-objectives to obtain the necessary node set corresponding to the task objective; Perform sequential causal reasoning analysis on each necessary node in the set of necessary nodes to generate a sequential causal chain; The key parameters of each node in the sequential causal chain are determined, and the causal effect analysis of the key parameters of each node is performed to obtain a parameter causal graph. The causal graph is generated based on the necessary node set, the sequential causal chain, and the parameter causal graph.

3. The method according to claim 2, characterized in that, The step of performing causal identification on the multiple task sub-objectives to obtain the necessary node set corresponding to the task objective includes: Determine the node capability domain corresponding to each task sub-target, and based on the node capability domain corresponding to each task sub-target, filter candidate nodes corresponding to each task sub-target from a preset node resource pool; Counterfactual reasoning is performed on the node capability domain of each candidate node to filter the necessary node set corresponding to the task objective from each candidate node; wherein, the counterfactual reasoning is a determination mechanism for whether the candidate node, its order, or key parameters constitute necessary conditions for the task objective.

4. The method according to claim 3, characterized in that, The step of performing counterfactual reasoning on the node capability domain of each candidate node to filter the necessary node set corresponding to the task objective from each candidate node includes: For each candidate node, a removal operation is performed, and the execution status corresponding to the task objective is determined based on the node capability domain corresponding to the removed candidate node. If the execution status is successful, then the corresponding candidate node is determined to be a non-essential node; If the execution status is "execution failed", then the corresponding candidate node is determined as the necessary node.

5. The method according to claim 2, characterized in that, The step of performing sequential causal reasoning analysis on each necessary node in the necessary node set to generate a sequential causal chain includes: The necessary nodes in the necessary node set are analyzed based on data dependency rules to obtain a data flow graph; the data dependency rules include: explicit parameter reference rules, type matching rules, and data flow integrity rules; Logical execution constraints are obtained by analyzing each necessary node in the necessary node set based on logical dependency rules. The logical execution constraints include the execution order, preconditions, and failure propagation relationships of each necessary node. The data flow diagram is integrated with the logical execution constraints to construct multiple sets of sequence variants; The causal inference verification process is performed on the multiple sets of sequential variants to obtain the sequential causal chain.

6. The method according to claim 2, characterized in that, Determining the key parameters of each node in the sequential causal chain includes: Determine the required identifiers, template syntax identifiers, and task impact dimension identifiers corresponding to the sequential causal chain; Determine the parameter document corresponding to the sequential causal chain, and extract the key parameters corresponding to each node from the parameter document based on the required field identifier, the template syntax identifier, and the task influence dimension identifier.

7. The method according to claim 2, characterized in that, The causal effect analysis of the key parameters of each node to obtain a parameter causal graph includes: Different test values ​​are set for the key parameters of each node; When the key parameters of each node are set to values ​​for each test, the causal effect on the execution behavior of the workflow is determined; wherein, the execution behavior includes multiple task influence dimensions, and the causal effect characterizes the correspondence between changes in test values ​​and changes in execution behavior; Based on the causal effect, the parameter causal graph of each node is constructed.

8. The method according to claim 7, characterized in that, After constructing the parameter causal graph for each node based on the causal effect, the method further includes: Based on the parameter constraint generation rules, key parameter analysis is performed on the parameter cause-effect graph to obtain multiple set constraints for each node. Multiple constraints are defined as causal constraints for the parameters of each node.

9. The method according to claim 2, characterized in that, The process of generating the causal graph based on the necessary node set, the sequential causal chain, and the parametric causal graph includes: Determine the extended node set in the sequential causal chain, and determine the parameter node set in the parameter causal graph; Based on the necessary node set, the extended node set, and the parameter node set, a comprehensive node set is generated; Determine the data flow graph, and construct an edge set based on the data flow direction between nodes in the sequential causal chain, the causal effects in the parametric causal graph, and the data flow graph; The causal graph is constructed based on the comprehensive node set and the edge set.

10. The method according to claim 9, characterized in that, The construction of the causal graph based on the integrated node set and the edge set includes: Based on the integrated node set and the edge set, an initial causal graph is constructed; Determine the causal relationship attribute field corresponding to each edge in the initial causal graph, and determine the node state field corresponding to each node in the initial causal graph; In the initial causal graph, the causal relationship attribute field is associated with the corresponding edge, and the node state field is associated with the corresponding node to obtain the causal graph.

11. The method according to claim 1, characterized in that, The step of performing graph verification on the causal graph to obtain the target causal graph includes: The causal graph is transformed into an adjacency list graph structure; A depth-first search is performed on the unvisited nodes in the adjacency list graph structure to identify the strongly connected components in the adjacency list graph structure. The causal graph is validated based on the strongly connected components to obtain the target causal graph.

12. The method according to claim 11, characterized in that, The step of performing graph verification on the causal graph based on the strongly connected components to obtain the target causal graph includes: Determine the error type corresponding to the strongly connected component in the causal graph; If the error type matches the set error type, the strongly connected components are de-looped to obtain an acyclic topology. Unreachable nodes are detected in the acyclic topology to obtain the unreachable nodes; If the unreachable node is a redundant node, then the unreachable node is deleted from the causal graph to obtain the target causal graph; If the unreachable node is a non-redundant node, then the non-redundant node is padded with edges to obtain the target causal graph.

13. The method according to claim 1, characterized in that, The automatic synthesis of an executable workflow template based on the target causal graph includes: Determine the node order, dependencies, and key parameters of each node from the target causal graph; The workflow template is automatically generated based on the node order, dependencies, and key parameters of each node.

14. A workflow template generation system based on Agentic AI causal reasoning, characterized in that, The system includes: The text acquisition module is used to acquire historical input text; The causal reasoning module is used to extract the task target from the historical input text, perform three-stage causal reasoning on the task target, and obtain a causal graph. The graph generation module is used to perform graph verification on the causal graph to obtain the target causal graph; The template generation module is used to automatically synthesize an executable workflow template based on the target causal graph.

15. A computer device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the workflow template generation method based on Agentic AI causal reasoning as described in any one of claims 1-13.

16. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the workflow template generation method based on Agentic AI causal reasoning as described in any one of claims 1-13.