A graph-based intelligent adaptive agent control method

By adopting a graph-based intelligent adaptive agent control method, the problems of task graphs not being able to close automatically, edge semantics being simplistic, lack of adaptability at runtime, and unsafe execution with long execution times are solved. This method achieves the adaptability and security of task graphs, ensuring the closure of data edges and the reliability of execution.

CN123070871APending Publication Date: 2026-11-10杭州智元研究院有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611209959.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-11
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

In existing intelligent agent control technologies, task graphs cannot be closed automatically, the edges of the graphs have simple semantics, lack runtime adaptability, long-running execution lacks crash safety protection, write operations lack side effect protection, and intelligent agent memory lacks timeliness adaptability.

Method used

A graph-based intelligent adaptive agent control method is adopted. By generating a task graph skeleton and using contract deterministic graph supplementation, the automatic closure of data edges is achieved. Four types of heterogeneous edge models are used for task graph modeling. Parallel execution and post-observation review are carried out. Combined with execution lease and idempotency judgment, the adaptability and security of the task graph are ensured.

Benefits of technology

It achieves forced closure of data edges in the task graph, autonomy of exception and compensation flows on the same graph, runtime adaptability and full auditability, crash safety for long-running operations, zero duplicate side effects for write operations, and time-sensitive adaptability of memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123070871A_ABST
    Figure CN123070871A_ABST
Patent Text Reader

Abstract

This invention relates to the fields of artificial intelligence, graph relation modeling, and intelligent agent control technology. Specifically, it relates to an intelligent adaptive intelligent agent control method based on graph relations. This method is mainly used to automatically transform the user's natural language goal into a persistent, dynamically rewritable, and crash-safe task graph. Through contract-driven deterministic graph completion, dependency-ready parallel scheduling, observation-reviewed dynamic graph rewriting, and execution lease protection, it enables the intelligent agent to achieve adaptive execution and safe control in complex business scenarios (such as task allocation in industrial plants and long-duration human-machine collaborative operations).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence, graph relationship modeling, and intelligent agent control technology, specifically to an intelligent adaptive intelligent agent control method based on graph relationships. Background Technology

[0002] With the rapid development of Large Language Model (LLM) technology, LLM-based agent systems have become an important direction for artificial intelligence applications. Currently, agent control mainly adopts the following technical approaches:

[0003] (1) ReAct mode: The agent calls the tool step by step through the reasoning-action loop. The execution path is entirely determined by the LLM's temporary decision at each step. There is no explicit graph structure. The parameter passing between tools depends on the LLM "remembering" and repeating in the context. It is easy to miss, mispass, and phantom identifiers.

[0004] (2) Static graph execution framework: Supports orchestrating agent processes into directed graphs, but the graph structure needs to be hard-coded in advance by developers. Figure 1 Once the execution path is defined, it is fixed and cannot be added or removed at runtime based on intermediate observation results. It also lacks crash recovery and the ability for multiple workers to execute mutually exclusively.

[0005] (3) Function Calling mechanism: LLM can select and call tools independently, but there is no explicit dependency relationship, data flow and exception handling relationship description between tools. The correctness of multi-step tasks depends entirely on the quality of LLM's single inference.

[0006] (4) Workflow engines (such as Airflow, n8n): support manual drawing of multi-step processes and scheduling according to dependencies, but the process lacks deep integration with LLM's natural language understanding, the process is fixed, it does not have language-driven runtime adaptability, and the data transfer between nodes depends on manual connection or handwritten expressions.

[0007] However, the aforementioned technical approach to agent control has the following problems:

[0008] (1) The task graph cannot be closed automatically: In the existing technology, task decomposition either relies entirely on LLM to generate freely or entirely on manual predefinition. There is a lack of a graph construction mechanism in which "LLM is responsible for the skeleton and deterministic algorithms are responsible for closing the data edges", so that the necessary inputs of each node in the graph have verifiable in-graph sources.

[0009] (2) The edge semantics of the graph are singular: the existing dependency graph only expresses the order of execution and cannot uniformly express the data flow, abnormal flow and compensation flow on the same graph.

[0010] (3) Graph execution lacks runtime adaptability: The execution path of the existing graph execution engine is fixed after the graph is defined. It cannot review the entire graph after the observation results of each node are generated, dynamically add or delete nodes, or recover failed nodes. It also cannot terminate in advance when the target is met in advance, and it lacks version auditing for each graph rewrite.

[0011] (4) Lack of crash safety protection for long-running tasks: Intelligent agent tasks often include long-running steps such as manual approval waiting and external system calls. In scenarios where the execution process crashes and multiple workers are running concurrently, existing systems have problems such as the same task being executed repeatedly, tasks being suspended after a crash, and revived processes submitting dirty results.

[0012] (5) Lack of side effect protection for write operations: The existing system’s failure retry strategy does not distinguish between the idempotency of operations. Blindly retrying non-idempotent write operations such as “task allocation” and “instruction issuance” will cause real business side effects. There is also a lack of human-machine collaborative approval mechanism with risk level and reversibility judgment before the execution of key nodes.

[0013] (6) The agent's memory is not timely and adaptable: the long-term memory of the existing system either does not exist or is permanently stored with equal weight, which cannot reflect the real constraints that "preferences will expire and new information should replace old information", and also lacks the interception of sensitive information being written into memory. Summary of the Invention

[0014] This invention aims to address the shortcomings of the prior art by providing a graph-based intelligent adaptive agent control method. This method primarily transforms the user's natural language objective into a persistent, dynamically rewritable, and crash-safe task graph. Through contract-driven deterministic graph completion, dependency-ready parallel scheduling, observation-reviewed dynamic graph rewriting, and execution lease protection, it enables the agent to achieve adaptive execution and secure control in complex business scenarios (such as task allocation in industrial plants and long-duration human-machine collaborative operations).

[0015] The technical solution to achieve the purpose of this invention is as follows:

[0016] A graph-relation-based intelligent adaptive agent control method includes:

[0017] Step 1: Based on the task issued to the agent, a task graph skeleton is generated through a large language model. When the agent executes the task, the task graph is dynamically generated based on the task graph skeleton. The task graph is a persistent directed graph. Nodes in the graph represent skill invocation units to be executed, nodes carry completion conditions, and data dependency edges between nodes represent the order of execution.

[0018] Step 2, Contract Deterministic Graph Completion: For each node bound to a skill, read the input and output contracts declared for that skill; when the input parameters of a node lack a source in the graph skeleton, the graph is automatically completed using a deterministic algorithm.

[0019] Step 3: Filter the set of ready nodes according to the node status, execute the set of ready nodes in parallel within the concurrency limit, and apply execution timeout constraints to each node. When executing each node, perform safe evaluation of data flow edges first. The ready node is the node to be executed whose predecessor nodes pointed to by all its data dependency edges have been completed.

[0020] The data flow edge safety evaluation is as follows: based on the data flow edge of the node to be executed, a restricted path selector is used to deterministically extract values ​​from the completed outputs of the corresponding predecessor node, and the declared data transformation is applied before injecting the values ​​into the input parameters of this node. When the restricted path selector hits multiple candidate values ​​and no transformation rule is declared, execution is paused and a manual selection is requested from the candidate values. The restricted path selector and the deterministic complement graph in step 2 share the same declarative contract.

[0021] Step 4: For each node's execution result, the large language model is called to review the current task graph, and the task graph is dynamically rewritten based on the review results. After each dynamic rewrite, the version number of the task graph is increased and the review reason is recorded. When the review result meets the review judgment target, the remaining nodes to be executed are set to skipped and the execution ends.

[0022] Step 5: Summarize the execution results of each node in the task graph to obtain the final result.

[0023] Furthermore, the edges of the task graph also include at least one of data flow edges, failed routing edges, and compensation edges; when a node fails and it includes a failed routing edge, the node pointed to by the failed routing edge is included in the set of ready nodes; when a node fails and it includes a compensation edge, a corresponding compensation node is automatically generated, and its state is set to compensated after the original failed node is compensated.

[0024] Furthermore, completion is automatically performed using a deterministic algorithm, specifically including: adding a provider node to the task graph, establishing a data dependency edge between the node lacking a provider and the provider node, and establishing a data flow edge carrying the source node identifier, source output name, and data transformation type, until all necessary inputs of the node lacking a provider are closed by deterministic sources within the graph.

[0025] Furthermore, the ready node mentioned in step 3 is executed by the background worker after obtaining the execution lease in an atomic manner. During the execution, the lease is renewed at a period shorter than the lease duration. When the renewal fails, the execution of the node is immediately and safely terminated without submitting its result, so that the corresponding task can be re-acquired and executed by other workers. Each write-back of the running status is accompanied by a lease holder verification.

[0026] Furthermore, when a node fails to execute and it is a retryable temporary error, if the skill bound to the node has an idempotent flag, or if the node's request method is a read-only method, then automatic retrying of the node is allowed; if the node is a write operation node without an idempotent flag, then automatic retrying is prohibited.

[0027] Furthermore, the restricted path selector only supports four types of primitives: field access, array subscript access, array wildcard access, and recursive field access, and does not execute arbitrary expressions or code; the data transformation of the restricted path selector includes at least one of the following: extracting the first value, extracting a list, JSON stringification, comma concatenation, stringification, integerization, and booleanization.

[0028] Furthermore, after a node completes execution, it uses the restricted path selector to deterministically extract named outputs from the original skill response and attach them to the node result, based on the output contract of the skill it is bound to, for reference by the data flow edges of downstream nodes; when the output contract declares that a required output is missing, the node is determined to have failed to bind the output.

[0029] Furthermore, for nodes with business side effects, an approval request carrying the risk level, reversibility, side effect flag, target effect and validity period is generated before the node is executed and execution is suspended; upon receiving approval, the approval result is injected as an observation into the original execution state and execution is resumed from the suspension point; upon receiving rejection, the node status is set back to pending execution.

[0030] Furthermore, the task graph is dynamically rewritten, including adding recovery or successor nodes, skipping no longer needed nodes, or recovering failed nodes.

[0031] Furthermore, after each dynamic rewrite, the version number of the task graph is increased and the review reasons are recorded, including: persisting the reasons for each review, the dynamic rewrite content and the task graph version number, and publishing the start of operation, node start, node completion, node failure, retry plan, plan revision and operation completion events in an auto-incrementing sequence through the event stream, supporting replay by sequence number.

[0032] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] (1) Forced closure of data edges within the graph to eliminate LLM parameter passing failure: Contract-driven deterministic graph complement ensures that the required inputs of each node have verifiable sources within the graph. Execution failures caused by "LLM missing parameters / illusion identifiers" are structurally eliminated, rather than being mitigated by prompt word engineering.

[0035] (2) Unified modeling of four types of heterogeneous edges, and autonomy within the anomaly and compensation graph: control flow, data flow, anomaly flow and compensation flow are expressed on the same persistent graph. If a node fails, it can continue along the failed route edge or roll back along the compensation edge without external manual intervention.

[0036] (3) Truly adaptable and auditable at runtime: The dynamic graph rewriting driven by observation and review makes the execution path evolve with the intermediate results. Each rewriting has a version number and review reason, achieving both adaptability and interpretability; the early termination when the goal is met saves computation and calling costs.

[0037] (4) Long-term execution crash safety: lease + heartbeat + no submission upon lease loss + holder verification, ensuring that multiple workers do not execute repeatedly, crashes can be taken over, and the revived process has zero dirty writes, adapting to long-term human-machine collaborative tasks with manual approval;

[0038] (5) Zero repetitive side effects of write operations: Idempotency determination prohibits automatic retry of non-idempotent write operations. Combined with the approval gateway carrying risk level and reversibility, it meets the strong constraints on business side effects in high-security scenarios such as industrial control.

[0039] (6) Memory adapts to change with time and conflict: half-life decay causes expired information to be automatically downgraded, conflict replacement chains preserve the complete evolutionary trajectory, and sensitive information is refused to be written to ensure privacy compliance. Attached Figure Description

[0040] Figure 1 This is a diagram of the overall hierarchical architecture of a system based on graph relationships.

[0041] Figure 2 For the task Figure 4 Heterogeneous edge relationship graph.

[0042] Figure 3 Build a flowchart for a contract-driven two-phase diagram.

[0043] Figure 4 This is a diagram illustrating the definition of graph nodes and the format of graph edge attributes.

[0044] Figure 5 To execute the lease lifecycle sequence diagram.

[0045] Figure 6 This is the state transition diagram for a node-level state machine. Detailed Implementation

[0046] This invention provides a graph-based intelligent adaptive agent control method, which incorporates a hierarchical architecture design based on graph relationships, combined with... Figure 1 From bottom to top, the layers are: Access Layer: REST API / Streaming Event Interface; Session and Memory Layer: Adaptive Memory Library + Historical Snapshots; Task Graph Planning Layer: Autonomous Planner; Task Graph Execution Layer: Persistent Task Graph Execution Engine, including Ready Scheduler, Execution Lease Manager, and Binding Evaluator; Skill Contract Layer: Declarative Skill Registry, with each skill carrying Input Contracts (requires) and Output Contracts (produces); Capability Layer: Multi-Provider LLM Gateway / Security Barrier / Event Sourcing.

[0047] The task graph execution layer is the core of this invention: the task graph is persisted using relational storage, and nodes in the graph represent skill invocation units to be executed, carrying completion conditions. Nodes are connected by four types of semantically distinct edges. The entire execution lifecycle is controlled by a two-layer system: an outer graph-level scheduling layer (ready computation, parallel execution, review and rewriting, lease protection) and an inner node-level state machine layer (planning → verification → approval waiting → execution → observation → completion). Figure 6 Specifically, it includes:

[0048] 1. Declarative Skill Contracts and Automatic "Weaving"

[0049] Each skill is described by a declarative contract: metadata, name, description, risk level, whether it is idempotent, and whether it has a business side effect; input contract requirements, the name, type, and source type of each required input—session variable, context, constant, or provider skill; output contract produces, the name of each named output and its restricted path selector in the tool's original response, including multiple selector fallback and required flags.

[0050] The contract serves a dual purpose: firstly, during the planning phase, it provides a basis for deterministic graph completion algorithms to automatically complete provider nodes and data edges; secondly, after a node is completed, the execution engine, according to the `produces` contract, uses a restricted path selector to deterministically extract named outputs from the tool's original response and attaches them to the node results for reference by downstream data flow edges; when an output declared as required by the contract is missing, the node's output binding is deemed to have failed. Therefore, the orchestrator does not need to write any data flow scripts manually; the graph is automatically closed by the tool's contract.

[0051] This embodiment illustrates the basic deployment method and declarative definition method of skill contracts of the present invention. The system is implemented in Python, and the task graph and running state are persisted in a relational database (SQLite). Multi-vendor LLM gateways support OpenAI, Claude, Qwen, DeepSeek, and Ollam native models (including Ollam native Function Calling adaptation).

[0052] Domain experts define skills using declarative contracts. Taking the "Query Plan List" skill in a factory inspection system as an example: its metadata declares a low risk level and idempotent=true; the `requires` contract declares that an SHGSID (session credential) must be input, its source type is provider, and the provider is the login skill; the `produces` contract declares a named output plan_list, whose restricted path selector is $.data.list (and can declare alternative selectors and require=true). After the system loads the contract, it has the ability to automatically generate data structures and output data to the system, without requiring any data flow code to be written for this skill.

[0053] 2. Combining Figure 3 A contract-driven two-phase task graph construction method. This includes:

[0054] The first stage is LLM skeleton generation: receiving the user's natural language goal, calling LLM to generate a minimal task graph skeleton, the skeleton only contains nodes (bound skills, completion conditions) and dependency edges representing the order of execution.

[0055] The second phase involves a deterministic completion of the contract: a deterministic algorithm traverses each node in the skeleton containing bound skills, checking its requirements contract item by item.

[0056] (1) If the source type of a required input is a session variable / context / constant, then the corresponding static binding is generated directly;

[0057] (2) If a required input is provided by a provider skill, but the provider node does not yet exist in the graph, three completion actions are automatically performed: ① Add the provider node in the graph; ② Establish a dependency edge depends_on between the current node and the provider node; ③ Establish a data flow edge input_bindings carrying a triple <source node identifier from_node, source output name output, data transformation type transform>.

[0058] (3) Repeat the above process until all the necessary inputs for each node in the graph are closed by deterministic sources within the graph.

[0059] The technical essence of this step is that the data integrity of the graph is guaranteed by a verifiable deterministic algorithm, rather than by the free splicing of LLMs, thus fundamentally eliminating the inherent failure mode of existing technologies, namely "LLM missing parameters / fabricated identifiers".

[0060] 3. Four types of heterogeneous edge models for task graphs

[0061] Combination Figure 2 This invention defines four types of semantically distinct edges on the same persistent task graph:

[0062] (1) Data dependency edges depend_on: represent the topological order and are used for readiness determination;

[0063] (2) Data flow edge input_bindings: carries <source node, source output name, transformation type>, describing "which named output of which upstream node is taken, what kind of deterministic transformation is performed, and which input parameter is injected into this node";

[0064] (3) Failure route edge failure_route: When a node fails, the replacement node pointed to by the edge is added to the ready set to realize the graph routing of abnormal flow;

[0065] (4) Compensation edge: For nodes that have declared compensation skills, a corresponding compensation node is automatically generated when the node fails or rolls back. The original node is set to "compensated" status after the compensation is completed.

[0066] The node state set is as follows:

[0067] The four types of edges—pending, ready, running, approval_wait, input_wait, completed, failed, skipped, compensating, and compensated—are linked with the node state machines to form a complete unified graph model of "control flow + data flow + exception flow + compensation flow".

[0068] 4. Rely on ready scheduling and bounded parallel execution

[0069] The scheduler periodically calculates the set of ready nodes: a pending node is considered ready if and only if all its dependent_on predecessor nodes are in the completed, compensated, or skipped state, or if it is the failure_route target of a failed node. The ready set is executed in parallel using a thread pool within the concurrency limit (configurable maximum number of parallel nodes), and an execution timeout constraint is imposed on each node. Nodes that time out are marked as retryable temporary failures. Thus, dependent nodes automatically run in parallel, and scheduling is determined by the graph topology rather than LLM, balancing determinism and throughput.

[0070] 5. Constrained path selection and deterministic transformation evaluation of data flow edges

[0071] Before executing a node, the bound evaluator evaluates based on its data flow edges:

[0072] (1) Restricted path selector: It only supports a subset of paths consisting of four primitives: field access (.field), array index access ([i]), array wildcard access ([*]), and recursive field access (..field), and extracts values ​​from the completed named output of the corresponding preceding node; the selector does not execute arbitrary expressions, regular expressions, or code, thus eliminating the risk of injection.

[0073] (2) Deterministic transformation: After applying the declared transformation to the extracted value, inject it into the input parameter of this node. The transformation types include seven types: first, list, json_string, join_comma, string, integer, and boolean.

[0074] (3) Multi-meaning non-guessing strategy: When the selector hits multiple candidate values ​​and no transformation rule is declared, it does not randomly select one, but pauses execution, carries a list of candidate values ​​and requests manual selection before resuming.

[0075] 6. Post-observation review and dynamic rewriting of task diagrams

[0076] Combination Figure 4 For each observation generated at a node, the controller calls the LLM to perform a comprehensive review of the current task graph. The review returns a structured conclusion: {Whether the goal has been satisfied (goal_satisfied), suggestions to add nodes (add_nodes), suggestions to skip nodes (skip_node_keys), suggestions to recover failed nodes (recover_failed_keys), and the review reason (reason). Based on this, the controller dynamically rewrites the task graph.

[0077] (1) Add a recovery node or successor node (marked with dynamic=true to distinguish it from the original plan);

[0078] (2) Skip nodes that are no longer needed;

[0079] (3) Re-enter the queue for a failed recovery node;

[0080] (4) Each rewrite increments the task diagram version number and persists the review reasons as versioned audit records;

[0081] (5) When the review determines that the objective has been met, the remaining pending nodes are set to skipped in batches and the operation is terminated early.

[0082] As a result, the execution path is rewritten at runtime based on the observation results, forming a versioned, auditable, and interpretable adaptive execution trajectory.

[0083] 7. Crash safety mechanism for enforcing leases and heartbeat renewals.

[0084] Task execution is carried out by a background worker pool, with execution lease protection introduced:

[0085] (1) Atomic acquisition: Workers acquire the execution to be executed using atomic database operations and obtain an execution lease with a duration of lease_seconds, ensuring that multiple workers will not acquire the same execution repeatedly;

[0086] (2) Heartbeat renewal: During the execution period, heartbeat renewals are sent at one-third intervals of the lease duration;

[0087] (3) Safe termination of lease loss: When the lease renewal fails (e.g., the lease has been judged to have expired and taken over by another party), the holder immediately and safely terminates the execution without submitting any results. Each write-back of the running status is accompanied by the holder's verification.

[0088] (4) Crash takeover: After the execution process crashes and the lease expires, the process automatically returns to the available state and is taken over by other workers. Even if the original process is revived, it will be unable to submit dirty results due to the loss of the lease.

[0089] 8. Idempotency-based adaptive retry decision

[0090] When a node execution result fails the verification, the retry decision not only examines whether the error is a retryable temporary error, but also further considers the idempotency declaration of the skill bound to the node: automatic retry is only allowed if the skill explicitly declares idempotent=true or its request method is a read-only method (GET / HEAD / OPTIONS) and the number of retries has not exceeded the limit; automatic retry is prohibited for non-idempotent write operations (such as task allocation and instruction issuance), and the review mechanism decides to add a recovery node or trigger a compensation edge, thereby avoiding repeated execution that causes real business side effects.

[0091] 9. Approval gateway, impact analysis, and original context re-feedback recovery

[0092] For nodes that declare business side effects, an approval request is automatically generated and the process is paused before execution (the node is set to `approval_wait`). The approval request carries an impact analysis structure: `impact`, which includes the following parameters: `risk_level`, `reversible`, `side_effect`, `target`, and `expires_in_seconds`. Upon receiving approval, the result is injected into the original execution state machine as an observation, and the process resumes seamlessly from the pause point. Upon receiving rejection, the node is put back into pending execution. Similarly, when multiple candidate parameters or necessary parameters cannot be deterministically evaluated during data flow edge evaluation, the node is set to `input_wait` and paused with a candidate list. After manual supplementation, the process resumes via the same backfeeding mechanism.

[0093] 10. Confidence half-life decay and adaptive memory of conflict replacement chains

[0094] The agent maintains memory entries with confidence levels. The effective confidence level decays exponentially over time according to the formula: Effective Confidence Level = Original Confidence Level × exp(−ln2 × Duration Days / Half-life), automatically reducing the weight of expired preferences. When a new value with the same memory key appears, the old value is set to superseded and grouped into the same conflict group to form a traceable replacement chain. Before writing to memory, content containing passwords, tokens, ID numbers, or card numbers is rejected. When assembling the LLM context, the agent dynamically selects <session summary + long-term memory + recent messages> in order from newest to oldest within a given token budget.

[0095] 11. Event tracing and full replay capability

[0096] Throughout the graph execution process, events are published using auto-incrementing sequence numbers (seq): run.started, node.started, node.completed, node.failed, node.retry_scheduled, plan.revised, run.completed, etc. Events are persisted and can be replayed by sequence number. Combined with task graph versioning and historical snapshots, this meets the auditing and fault recovery needs of scenarios with high security requirements. The system also sets security check nodes at the graph execution input and output ends. If the output is non-compliant, it prompts for the LLM node to be regenerated, with the number of retries limited by an upper limit.

[0097] This invention solves the following technical problems:

[0098] (1) Construct a two-stage task graph construction mechanism of "LLM skeleton generation + tool contract deterministic completion" so that the data edge closure of the graph is guaranteed by a deterministic algorithm, eliminating execution failures caused by LLM missing parameters and phantom identifiers;

[0099] (2) Model four types of edges—control flow, data flow, anomaly flow, and compensation flow—on the same persistent directed graph, and implement dependent-ready bounded parallel scheduling accordingly.

[0100] (3) Construct a runtime adaptive control strategy of "review after each round of observation - dynamic graph rewriting - version auditing" so that the execution path can adapt and evolve with intermediate results and be traceable throughout the process;

[0101] (4) By implementing the lease and heartbeat renewal mechanism, we ensure that long-running tasks are not repeatedly executed, do not submit dirty results, and can be taken over and continued to run in scenarios with multiple workers and process crashes;

[0102] (5) Based on the tool idempotency declaration, adaptive retry judgment of write operation and human-machine collaborative approval with impact analysis are realized to ensure that the business side effects in high security scenarios are controllable.

[0103] Example

[0104] Take the "temporary target task allocation" scenario during factory area inspection as an example. The operator inputs the target: "Assign tasks to targets 1102 and 1103".

[0105] In the first stage, LLM generates a task graph skeleton: <Query Plan List> → <Query Target List> → <Resolve Target Number> → <Task Allocation Calculation> → <One-Click Execution of Task Allocation>. The skeleton does not contain a login node.

[0106] In the second stage, the deterministic graph completion algorithm traverses the `requires` contract of each node. It finds that the required input `shgssid` for the `<Query Plan List>` is declared to be provided by `login`, but there is no provider in the graph. Therefore, it automatically: ① adds a `provide_login` node; ② establishes a dependency edge `depends_on provide_login` for the `<Query Plan List>`; ③ establishes a data flow edge `{from_node:provide_login, output: shgssid, transform: first}`. Nodes with the same name, such as the `<Query Target List>`, reuse this provider node (to remove duplicates), ultimately closing all required inputs in the graph.

[0107] During execution, the bound evaluator deterministically extracts the session credentials from the named output of the login node using the restricted path selector $.outputs.shgssid, applies the first transformation, and then injects them into the input parameters of subsequent nodes—the entire process involves no LLM, no template string replacement, and is statically verifiable. If a selector hits multiple candidates and no transformation is declared, the node sets input_wait and lists the candidates for manual selection.

[0108] After the <Target Number> node is completed, its observation results show that target 1103 is not in the current target list. The review mechanism intervenes: The LLM review returns {goal_satisfied: false, add_nodes: [<Refresh Target List>],skip_node_keys: [], reason: "Target 1103 is missing, the target list needs to be refreshed first"}. Based on this, the controller dynamically adds a node (dynamic=true), upgrades the task graph version from v1 to v2, and persists the review reason.

[0109] When execution reaches the "One-Click Task Assignment" node, because the skill declaration `side_effect=true` and it is not idempotent, the approval gateway generates an approval request carrying the impact analysis `{risk_level: high, reversible: false, side_effect:true, target: "Task 1102 Assignment", expires_in_seconds: 3600}`, and the node is paused with `approval_wait`. After operator approval, the approval result is used as an observation to feed back into the original state machine and execution resumes from the pause point. If the node fails to execute, it is prohibited from automatic retrying due to its non-idempotency. The reviewer decides whether to add a recovery node or trigger a compensation edge to generate a compensation node. The entire process is pushed in real time via event streams (node.started / plan.revised / node.completed, etc., with auto-incrementing sequence numbers) and can be replayed.

[0110] Combination Figure 5 Worker A atomically acquires a long-running task (lease for 60 seconds) and renews the lease with a heartbeat every 20 seconds. During execution, the process containing A is forcibly terminated, the heartbeat stops, and the task returns to an available state after the lease expires. Worker B atomically acquires the task and continues running it from the latest state in the persistent task graph (completed nodes are not executed repeatedly). Subsequently, process A revives and attempts to write back the old result, but is rejected due to holder verification failure (lease loss), and the dirty result is not committed. This mechanism guarantees that the same task will not be executed repeatedly, will not be suspended, and will have zero dirty writes in multi-worker and crash scenarios.

[0111] This invention uses a "contract-closed, dynamically rewritable, and crash-safe persistent task graph" as the sole central control of the intelligent agent. It achieves technical effects that existing technologies cannot simultaneously achieve in terms of reliability (forced data edge closure and crash safety), adaptability (dynamic rewriting after observation), and security and auditability (idempotent protection, approval gateway, and event replay).

[0112] This invention revolves around the unified concept of "using a contract-closed, dynamically rewritable, and crash-safe persistent task graph as the sole control center." Deterministic closed edges provide a "verifiable data source" foundation for all other reliability and security features. Because data edges are closed by deterministic algorithms and their values ​​are limited by restricted selectors, dynamic rewriting after observation can evolve safely without compromising data consistency. Lease crash safety allows for the reproduction of deterministic results during continuation, and idempotent retries can safely refuse retries on non-idempotent write operations. In existing technologies, LangGraph only addresses adaptation but relies on developers manually writing data connections and lacks fine-grained dirty write protection against crashes. Temporal only addresses reliable execution but doesn't understand the uncertainty of language models and therefore cannot be directly applied to freely planning agents. AdaPlanner and others only address planning adaptation but lack in-graph data closure and crash safety. This invention, for the first time, unifies the three long-standing mutually constraining goals of "reliability, adaptability, and security" into a single graph model—a technical effect that cannot be achieved by any single existing technology or simple superposition.

[0113] The description of the preferred embodiments above enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other embodiments without the use of inventiveness. Therefore, the invention is not limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for controlling intelligent adaptive agents based on graph relationships, characterized in that, include: Step 1: Based on the task issued to the agent, a task graph skeleton is generated through a large language model. When the agent executes the task, the task graph is dynamically generated based on the task graph skeleton. The task graph is a persistent directed graph. Nodes in the graph represent skill invocation units to be executed, nodes carry completion conditions, and data dependency edges between nodes represent the order of execution. Step 2, Contract Deterministic Completion Graph: For each node bound to a skill, read the input and output contracts declared for that skill; When the input parameters of a node lack a source in the graph skeleton, a deterministic algorithm is used to automatically complete the input. Step 3: Filter the set of ready nodes according to the node status, execute the set of ready nodes in parallel within the concurrency limit, and apply execution timeout constraints to each node. When executing each node, perform safe evaluation of data flow edges first. The ready node is the node to be executed whose predecessor nodes pointed to by all its data dependency edges have been completed. The data flow edge safety evaluation is as follows: based on the data flow edge of the node to be executed, a restricted path selector is used to deterministically extract values ​​from the completed outputs of the corresponding predecessor node, and the declared data transformation is applied before injecting the values ​​into the input parameters of this node. When the restricted path selector hits multiple candidate values ​​and no transformation rule is declared, execution is paused and a manual selection is requested from the candidate values. The restricted path selector and the deterministic complement graph in step 2 share the same declarative contract. Step 4: For each node's execution result, the large language model is called to review the current task graph, and the task graph is dynamically rewritten based on the review results. After each dynamic rewrite, the version number of the task graph is increased and the review reason is recorded. When the review result meets the review judgment target, the remaining nodes to be executed are set to skipped and the execution ends. Step 5: Summarize the execution results of each node in the task graph to obtain the final result.

2. The intelligent adaptive agent control method according to claim 1, further characterized in that, The edges of the task graph also include at least one of data flow edges, failed route edges, and compensation edges; when a node fails and it includes a failed route edge, the node pointed to by the failed route edge is included in the set of ready nodes; when a node fails and it includes a compensation edge, a corresponding compensation node is automatically generated, and its status is set to compensated after the original failed node is compensated.

3. The intelligent adaptive agent control method according to claim 1, further characterized in that, Automatic completion is performed using a deterministic algorithm, specifically including: adding a provider node to the task graph, establishing a data dependency edge between the node lacking a provider and the provider node, and establishing a data flow edge carrying the source node identifier, source output name, and data transformation type, until all necessary inputs of the node lacking a provider are closed by deterministic sources within the graph.

4. The intelligent adaptive agent control method according to claim 1, further characterized in that, The ready node mentioned in step 3 is executed by the background worker after obtaining the execution lease in an atomic manner. During the execution, the lease is renewed at a period shorter than the lease duration. When the renewal fails, the execution of the node is immediately and safely terminated without submitting its result, so that the corresponding task can be re-acquired and executed by other workers. Each write-back of the running status is accompanied by a lease holder verification.

5. The intelligent adaptive agent control method according to claim 1, further characterized in that, When a node fails to execute and it is a retryable temporary error, automatic retry is allowed if the skill bound to the node has an idempotent flag or the request method of the node is a read-only method; if the node is a write operation node without an idempotent flag, automatic retry is prohibited.

6. The intelligent adaptive agent control method according to claim 1, further characterized in that, The restricted path selector only supports four types of primitives: field access, array subscript access, array wildcard access, and recursive field access. It does not execute arbitrary expressions or code. The data transformation of the restricted path selector includes at least one of the following: extracting the first value, extracting the list, JSON stringification, comma concatenation, stringification, integerization, and booleanization.

7. The intelligent adaptive agent control method according to claim 1, further characterized in that, After a node completes execution, it uses the restricted path selector to deterministically extract named outputs from the original skill response and attach them to the node result, based on the output contract of the skill it is bound to, for reference by the data flow edges of downstream nodes; if the output contract declares that a required output is missing, the node is determined to have failed to bind the output.

8. The intelligent adaptive agent control method according to claim 1, further characterized in that, For nodes with business side effects, generate an approval request with risk level, reversibility, side effect flag, target effect and validity period before the node is executed and suspend execution. Upon receiving approval, the approval result is injected into the original execution state as an observation and execution is resumed from the pause point; upon receiving rejection, the node state is set back to pending execution.

9. The intelligent adaptive agent control method according to claim 1, further characterized in that, Dynamically rewrite the task graph, including: adding recovery or successor nodes, skipping no longer needed nodes, or recovering failed nodes.

10. The intelligent adaptive agent control method according to any one of claims 1-9, characterized in that, Each time the task graph is dynamically rewritten, its version number is increased and the review reasons are recorded. This includes: persisting the reasons for each review, the dynamic rewrite content, and the task graph version number, and publishing the start of operation, node start, node completion, node failure, retry plan, plan revision, and operation completion events in an auto-incrementing sequence number through an event stream, supporting replay by sequence number.