An agent running method and system based on contractual governance
Patent Information
- Application Number
- CN202611162033.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2046-08-03
AI Technical Summary
Existing intelligent agents lack effective constraint mechanisms when performing tasks, resulting in uncontrollable behavior, a lack of fault tolerance and insufficient transparency in the execution process, which affects user trust and resource utilization efficiency.
By adopting a contract-based governance approach, a contract text is generated that includes input constraints, output constraints, and execution boundaries. Resource consumption is monitored and execution is resumed in case of interruption. Audit logs are recorded to achieve transparency and traceability of agent behavior.
It improves the reliability and transparency of intelligent agent task execution, reduces resource waste and time costs, and enhances users' trust in intelligent agents and the controllability of task execution.
Smart Images

Figure CN122691775B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, and in particular to a method and system for operating intelligent agents based on contractual governance. Background Technology
[0002] With the rapid development of artificial intelligence technology, intelligent agents are widely used in fields such as automated task execution and decision support. Intelligent agents are typically based on large language models or other AI technologies, enabling them to understand user intent and autonomously complete complex tasks. However, existing intelligent agents face numerous challenges in practical operation.
[0003] First, the behavior of intelligent agents lacks effective constraint mechanisms. Specifically, users often find it difficult to precisely control the execution boundaries of intelligent agents when submitting tasks, leading to the agents potentially performing operations beyond expectations or producing non-compliant outputs. This uncontrollability is particularly pronounced in scenarios involving sensitive data processing, resource-intensive tasks, or those requiring strict compliance. Second, the execution process of intelligent agents lacks fault tolerance. Specifically, when an intelligent agent is interrupted while executing a long-running task, such as due to system failure, network anomalies, or resource exhaustion, existing solutions typically require re-executing the entire task from scratch, easily resulting in significant waste of computing resources and increased time costs. This problem is exacerbated in complex scenarios with multiple steps and sub-tasks.
[0004] In addition, the operation of most existing intelligent agents lacks transparency and traceability. Users find it difficult to understand the specific behavior of the intelligent agent during execution, its resource consumption, and whether it complies with preset constraints. This "black box" characteristic not only affects users' trust in intelligent agents but also impacts post-event auditing and problem investigation. Summary of the Invention
[0005] In view of the aforementioned problems, this application is proposed to provide a method and system for operating intelligent agents based on contractual governance to overcome or at least partially solve the aforementioned problems, comprising: The above-mentioned objective of this application is achieved through the following technical solution: A method for operating an intelligent agent based on contractual governance is applied to the task execution process of a target intelligent agent, wherein the task includes several sub-tasks and includes the following steps: In response to user-inputted task information, extract the constraints from the task information and generate a contract text that includes input constraints, output constraints, and execution boundaries; The input parameters of the target agent are validated based on the input constraints. When the input parameters do not meet the input constraints, the task execution process of the target agent is blocked and a violation information is returned. When the input parameters meet the input constraints, the control target agent executes each sub-task sequentially according to the execution boundary, and monitors the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. When the task execution of the target agent is interrupted, the most recent state snapshot is read from the persistent storage medium, the interruption location is determined based on the state snapshot, and execution is resumed from the interruption location. Once the target agent completes its task execution, the output result is verified based on the output constraints. If the output result does not meet the output constraints, it is marked as a violation. Write the time of the snapshot of the task execution process, resource consumption, verification results, and details of the breach into the audit log.
[0006] The second objective of this invention is achieved through the following technical solution: A smart agent operation system based on contractual governance, comprising: The constraint parsing module is used to respond to user-inputted task information, extract the constraints from the task information, and generate contract text including input constraints, output constraints, and execution boundaries. The input validation module is used to validate the input parameters of the target agent based on the input constraints. When the input parameters do not meet the input constraints, the task execution process of the target agent is blocked and a violation information is returned. The execution monitoring module is used to control the target intelligent agent to execute each sub-task sequentially according to the execution boundary when the input parameters meet the input constraints, and to monitor the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. The execution recovery module is used to read the most recent state snapshot from the persistent storage medium when the interruption of the target agent's task execution is detected, determine the interruption location based on the state snapshot, and resume execution from the interruption location. The output verification module is used to verify the output results according to the output constraints after the target agent completes the task execution process. If the output results do not meet the output constraints, they are marked as violations. The log generation module is used to write the time of the snapshot of the task execution process, resource consumption, verification results, and violation details into the audit log.
[0007] This application also relates to a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described intelligent agent operation method based on contractual governance.
[0008] This application also relates to a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described intelligent agent operation method based on contractual governance.
[0009] This application has the following advantages: In the embodiments of this application, a method and system for operating intelligent agents based on contractual governance is provided. By using contractual text to achieve dynamic governance of input constraints, output constraints and execution boundaries, and combining a state snapshot mechanism and an audit log system, it can effectively solve the technical problems of insufficient behavioral constraints, poor execution fault tolerance and opaque process of intelligent agents. It has the technical effects of improving the reliability of task execution, supporting interruption recovery and enhancing process auditability. Attached Figure Description
[0010] Figure 1 This is a flowchart of an embodiment of an intelligent agent operation method based on contractual governance according to this application; Figure 2 This is a schematic block diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0011] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0012] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0013] All terms used in this application, including technical or scientific terms, have the same meaning as understood by one of ordinary skill in the art to which this application pertains, unless otherwise specifically defined. It should also be understood that terms defined in general dictionaries, such as those in common dictionaries, should be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and not as having an idealized or highly formalized meaning, unless expressly defined herein.
[0014] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment shall be considered part of the specification.
[0015] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows: Contractual governance refers to a management paradigm that regulates and constrains the behavior of intelligent agents by predefining and enforcing a series of rules and conditions. Its purpose is to ensure that intelligent agents can meet expectations, comply with norms, and achieve predetermined goals when performing tasks.
[0016] Intelligent agents typically refer to software entities with a certain degree of autonomous decision-making and execution capabilities, such as AI assistants based on large language models, automated robots, or decision support systems, which can understand instructions, plan actions, and execute complex tasks.
[0017] Task information refers to the collection of all relevant data and instructions provided by the user when submitting a task to the agent. Task information typically includes the task's objective, requirements, context, and any specific constraints or preferences.
[0018] Constraints are restrictive rules imposed on the execution of tasks by an intelligent agent. They can be divided into input constraints, output constraints, and execution boundaries. Input constraints regulate the input parameters received by the agent, output constraints regulate the output results produced by the agent, and execution boundaries define the scope of the agent's behavior and resource usage limitations when executing subtasks.
[0019] A contract text is a document that encodes the aforementioned constraints in a structured and parsable form. It serves as the basis for an intelligent agent to perform tasks and clarifies the agent's rights and obligations during the task execution process.
[0020] Input parameters refer to all the data and configuration items received by the agent before it begins to execute a task, and are the basis for the agent to process tasks.
[0021] Breach of contract information refers to the report information generated by the system when an agent fails to comply with the constraints defined in the contract text during task execution. It typically includes the type of breach, the parameters involved, and the expected and actual values.
[0022] A subtask is a smaller, more specific unit of execution that constitutes a complete task. A complex task can usually be broken down into multiple interrelated subtasks, which the agent needs to complete sequentially according to a specific order or logical relationship.
[0023] Resource consumption refers to the total amount of computing resources used by an intelligent agent in the process of executing a task or subtask, such as computing time, memory usage, number of API calls, and token consumption.
[0024] The resource consumption threshold refers to a pre-set upper limit for resource consumption. When the resource consumption of an agent reaches this threshold, the system will trigger a specific processing mechanism, such as generating a state snapshot.
[0025] A state snapshot is a data set that records the current execution state of an agent at a specific point in time during the execution of a task. It usually contains all the key information needed to resume task execution.
[0026] Persistent storage media refers to storage devices or systems that can preserve data for a long period of time, such as hard drives, solid-state drives, databases, or distributed file systems. Generally speaking, data stored on this persistent storage medium will not be lost even if the system loses power or restarts.
[0027] An interruption point refers to the last successfully completed subtask or execution step of an agent when its task execution process is stopped for some reason. By identifying the interruption point, task execution can be resumed from that point.
[0028] Output results refer to the final products or information generated by the intelligent agent after completing the task. They usually need to be verified to ensure that they meet the preset output constraints.
[0029] Audit logs are immutable records automatically generated by the system of all events, state changes, resource consumption, verification results, and details of breaches related to the execution of agent tasks. They are used for post-event traceability, problem investigation, and compliance review.
[0030] In one embodiment, such as Figure 1 As shown, this application discloses a method for operating an intelligent agent based on contractual governance, applied to the task execution process of a target intelligent agent, wherein the task includes several sub-tasks, specifically including the following steps: S10: In response to the task information input by the user, extract the constraints in the task information and generate a contract text including input constraints, output constraints and execution boundaries; In one embodiment of this application, after receiving a task request submitted by a user, the system can prompt the user to manually input or select a predefined constraint template. For example, the user can manually fill out a form, explicitly specifying the type and range of input parameters, the format and content requirements of the output results, as well as the steps and resource limits for task execution. The system receives these manually input configurations and combines them into a contract text. Alternatively, the system can provide a series of predefined task templates, each containing a set of standard input constraints, output constraints, and execution boundaries. The user selects a suitable template based on the task type, and the system generates the corresponding contract text based on that template.
[0031] S20: Validate the input parameters of the target agent based on the input constraints. If the input parameters do not meet the input constraints, prevent the target agent from executing its task and return a violation message. In embodiments of this application, for example, the system can perform basic type checks on input parameters to verify whether a parameter expected to be a numerical value is indeed a numerical value, or whether a parameter expected to be a string is indeed a string. If the types do not match, it is determined that the input constraints are not met. Furthermore, the system can check whether the value of the input parameter is within a preset fixed range. For example, if a parameter is limited to between 1 and 100, the system will check whether the actual input value falls within this range. When the verification fails, the system will generate a violation message and immediately prevent the agent from executing its task to avoid subsequent problems caused by non-compliant input.
[0032] S30: When the input parameters meet the input constraints, the control target agent executes each sub-task sequentially according to the execution boundary, and monitors the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. In one embodiment of this application, the agent can execute subtasks in a fixed order defined in the contract text. The system can set a fixed time interval (e.g., every 5 minutes) or check the current resource consumption after each subtask is completed. Once the consumption threshold is reached or the subtask is completed, a state snapshot containing the current execution progress is generated. In another embodiment, during execution, the agent triggers resource consumption events when calling external APIs, accessing databases, or performing large amounts of computation. Upon receiving these events, the system accumulates the resource consumption. When the accumulated value reaches the consumption threshold or the subtask is completed, a state snapshot is generated. This state snapshot records the agent's current execution state, such as a list of completed subtasks, the current subtask execution progress, remaining resource quota, and intermediate results.
[0033] S40: When the task execution of the target agent is interrupted, the most recent state snapshot is read from the persistent storage medium, the interruption location is determined based on the state snapshot, and execution is resumed from the interruption location; In embodiments of this application, for example, when a task is interrupted, the system retrieves a recently stored state snapshot from persistent storage. This snapshot may contain a list of completed subtasks. The system simply restarts execution from the next subtask following the last completed subtask recorded in the snapshot. Furthermore, the system appends a timestamp when storing the state snapshot. When the task is interrupted, the system reads the snapshot with the latest timestamp. This snapshot may contain an identifier of the currently executing subtask. The system attempts to restart execution from the beginning of that subtask.
[0034] S50: After the target agent completes its task execution, the output result is verified according to the output constraints. If the output result does not meet the output constraints, it is marked as a violation. In embodiments of this application, for example, the system may check whether the output conforms to a predefined format template, such as whether it is in JSON format, XML format, or a specific text structure. If it does not match, it is marked as a breach. Furthermore, the system may check whether the output contains certain expected keywords or phrases. If they are missing, it is marked as a breach.
[0035] S60: Write the time of the snapshot of the task execution process, resource consumption, verification results, and details of the breach into the audit log.
[0036] In one embodiment of this application, the system can append the aforementioned information to a log file in plain text format. Each record contains a timestamp and related data. Alternatively, the system can insert this information as a new record into a simple relational database table, with each field corresponding to a data item. This audit log provides a complete record of the task execution process, facilitating subsequent traceability and analysis.
[0037] For example, as a specific implementation, suppose user A needs an agent to process a report containing sensitive customer information and generate a summary. This task places strict requirements on the agent's behavior, including: the input file must be an encrypted PDF, the output summary must be plain text and cannot contain any customer names or addresses, and the total token consumption for the entire process cannot exceed 10,000.
[0038] First, in response to the task information input by user A, which may include descriptions of input file format, output content restrictions, and resource consumption limits, the system extracts specific constraints from the task information. Specifically, the input constraint is "the input file must be an encrypted PDF," the output constraint is "the output summary must be plain text and cannot contain the customer's name and address," and the execution boundary is "token consumption cannot exceed 10,000." Subsequently, the system integrates the extracted constraints to generate a structured contract text, which clearly defines all the rules the agent must follow when performing the report summary task.
[0039] Before the agent begins executing a task, the system validates the input parameters provided by user A according to the input constraints in the contract text. In this example, the input parameter is the encrypted PDF report file. For instance, the system checks whether the report file is indeed in PDF format and whether it has been correctly encrypted. If user A accidentally uploads an unencrypted PDF file or a file in a non-PDF format, the system will determine that the input parameters do not meet the input constraints. In this case, the agent's task execution will be immediately halted, and a breach of contract message will be returned to user A, clearly stating the reason why the input parameters do not meet the requirements, such as "the input file is not encrypted" or "the file format is incorrect." Thus, the agent can avoid processing non-compliant input before the task begins, thereby preventing potential data security risks and resource waste.
[0040] Once the input parameters pass validation and meet the input constraints, the system will control the target agent to execute each subtask sequentially according to the execution boundaries defined in the contract text. For example, a task might be broken down into subtasks such as "decrypting a file," "extracting text content," "identifying key information," and "generating a summary." During the agent's execution of subtasks, the system continuously monitors its resource consumption, such as token consumption. To ensure task fault tolerance, the system sets a consumption threshold, such as automatically generating a state snapshot every 2000 tokens consumed, or upon completion of any subtask. This state snapshot records key information such as the agent's current execution progress, completed subtasks, intermediate results, and remaining resource quota, and stores it in persistent storage. For example, even if the token consumption has not reached the consumption threshold, a state snapshot will still be generated after the agent completes the "decrypting a file" subtask.
[0041] Furthermore, if the task execution is interrupted due to network fluctuations or system failures during the agent's "identifying key information" subtask, the system can detect this interruption event. In this case, the system will not re-execute the entire task from the beginning, but will instead read the most recently stored state snapshot from persistent storage. For example, if the most recent state snapshot was generated after the "decrypting file" subtask was completed, this snapshot will contain information about the completion of "decrypting file" and the intermediate results of the "extracting text content" subtask. The system will then determine the interruption point based on this snapshot and resume execution from that point—either the start of the "extracting text content" subtask or some intermediate point—thereby reducing resource waste and time costs caused by interruptions.
[0042] Once the target agent successfully completes all subtasks and generates a report summary, the system validates the output result against the output constraints defined in the contract text. For example, it checks whether the report summary is in plain text format and scans it for any sensitive information such as customer names or addresses. If the agent inadvertently includes a customer name in the summary, the system determines that the output result does not meet the output constraints and marks it as a breach of contract, thus ensuring that the agent's final output meets user A's expectations and security requirements.
[0043] Finally, to provide transparency and traceability in the task execution process, key information throughout the entire process will be written to the audit log. This information includes the generation time of the state snapshot, the agent's resource consumption, the validation results of inputs and outputs, and details of any breaches. By recording the audit log, user A or the administrator can review the agent's behavior at any time, understand every stage of task execution, thereby enhancing trust in the agent's operation and providing a basis for future troubleshooting and compliance audits.
[0044] Based on the above examples, firstly, addressing the problem of the lack of effective constraints on the behavior of existing intelligent agents, the solution in this embodiment extracts and generates a contract text that includes input constraints, output constraints, and execution boundaries in response to user input before task execution, thus clearly defining the behavior of the intelligent agent from the source. For example, in the example above, the system can enforce that the input file is an encrypted PDF and restrict the output digest from containing sensitive information. Compared to the problem in existing technologies where users have difficulty precisely controlling the execution boundaries of intelligent agents, the solution in this embodiment, through pre-defined contract and input / output verification mechanisms, can effectively prevent the intelligent agent from performing operations beyond the expected range or producing unacceptable output results, thereby improving the reliability and security of the intelligent agent's operation.
[0045] Secondly, addressing the insufficient fault tolerance in existing intelligent agent execution processes, this embodiment further introduces a state snapshot mechanism and an interruption recovery mechanism. Specifically, during the execution of subtasks by the intelligent agent, the system continuously monitors resource consumption and generates and stores a state snapshot when a preset consumption threshold is reached or when any subtask is completed. Furthermore, if task execution is interrupted, the system can resume execution from the most recent state snapshot. In the above example, even if the intelligent agent is interrupted during processing, it does not need to start from the beginning but can resume from the most recent snapshot point, for example, continuing from the "extract text content" subtask. Compared with existing technologies, this embodiment's solution can reduce the waste of computing resources and time costs, especially in multi-step, long-duration task scenarios, where its efficiency improvement is more significant.
[0046] Finally, addressing the lack of transparency and traceability in the operation of existing intelligent agents, this embodiment constructs a comprehensive traceability system by writing key information such as the generation time of state snapshots during task execution, resource consumption, verification results, and details of breaches into the audit log. In the example above, user A can view every key node, resource consumption, and compliance with all constraints during the processing of the report summary by the intelligent agent. This improves upon the "black box" nature of intelligent agents, enhances user trust in their operation, and provides a data foundation for post-audit, problem investigation, and compliance review.
[0047] In summary, the solution in this embodiment constructs a more controllable, fault-tolerant, and transparent intelligent agent operation framework through contractual governance, state snapshots and recovery, and a comprehensive audit log mechanism. It can effectively solve the defects in the existing technology and provide technical support for the application of intelligent agents in complex and sensitive task scenarios.
[0048] The following will further explain a method for operating intelligent agents based on contractual governance in this exemplary embodiment.
[0049] In one embodiment, step S20, "validating the input parameters of the target agent based on input constraints, and preventing the task execution process of the target agent and returning violation information when the input parameters do not meet the input constraints," specifically includes: Static rules are generated based on input constraints, and the static rules include predefined type constraints and value range constraints. In the embodiments of this application, static rules refer to fixed validation rules predefined according to the input constraints in the contract text. Static rules include predefined type constraints and value range constraints. Type constraints ensure that the data type of the input parameters conforms to expectations; for example, a parameter must be an integer, string, or boolean value. This can be implemented by explicitly specifying the data type of the parameter in the contract text, such as using JSON Schema or XML Schema; or by using the type system of a programming language for forced type conversion and checking. Value range constraints limit the numerical or length range of the input parameters; for example, a numerical parameter must be between 0 and 100, or the length of a string parameter cannot exceed 256 characters. Furthermore, static rules can be loaded through a configuration file during system initialization or automatically generated by a contract text parsing tool.
[0050] Determine the task type, obtain the historical input parameter distribution of the target agent based on the same task type, calculate the statistical feature value of each parameter item in the historical input parameter distribution, and generate dynamic rules; In the embodiments of this application, the task type refers to the classification identifier of the task performed by the intelligent agent, such as "text summarization," "image recognition," or "data analysis." The system retrieves input parameter data used in past executions of tasks of that type from historical audit logs or historical data storage, based on the current task type. Then, based on the retrieved historical input parameter data, statistical analysis is performed on each parameter item to calculate its statistical characteristic values, such as mean, standard deviation, median, mode, and frequency distribution, thereby forming dynamic rules. These dynamic rules are used to describe the normal behavior pattern of input parameters under that task type. For example, the recent mean and variance of the parameters can be calculated using a sliding window averaging method, or a clustering algorithm can be used to identify typical distribution patterns of historical parameters.
[0051] The input parameters are validated using static and dynamic rules in sequence, respectively. In the embodiments of this application, the input parameter verification process is divided into two stages. First, static rule verification is performed on the input parameters to check whether they meet predefined type constraints and value range constraints. If the static verification passes, dynamic rule verification is further performed, comparing the input parameters with dynamic rules generated based on historical data to assess whether they deviate from normal behavior patterns, so as to ensure that the input parameters meet basic compliance while also conforming to the rationality of historical experience.
[0052] When static rule validation fails, it is marked as a hard violation, violation information is generated, and the task execution process of the target intelligent agent is blocked. The violation information includes the name of the violation parameter, the type of rule violation, the expected value, and the actual value. In the embodiments of this application, a hard breach indicates that the input parameter violates a basic static rule, such as a data type mismatch or a value exceeding the allowed range. Once a hard breach occurs, the system immediately blocks the target agent's task execution process because this type of error is usually fatal and cannot be handled by the agent itself. Simultaneously, the system generates detailed breach information, clearly indicating the name of the breaching parameter, the type of rule violated, and the expected and actual values received for that rule, enabling users or administrators to quickly locate the problem.
[0053] When static rule validation passes but dynamic rule validation fails, it is marked as a soft violation, and the deviation of the input parameters from the historical input parameter distribution is calculated. In the embodiments of this application, a soft breach occurs when the input parameter passes static rule validation but fails dynamic rule validation. That is, although the input parameter is grammatically or numerically compliant, its characteristics significantly deviate from the normal distribution of historical input parameters for this task type. In this case, the system calculates the deviation between the current input parameter and the historical input parameter distribution, for example, by assessing its degree of anomalousness using statistical distance or probability density functions.
[0054] Retrieve historical parameter samples with deviations within the same range from the audit logs, calculate the task execution success rate of the historical parameter samples, and block the task execution process of the target agent when the task execution success rate is lower than the preset safety threshold.
[0055] In the embodiments of this application, for input parameters marked as soft defaults, the system further analyzes their potential risks. Specifically, it first retrieves historical parameter samples with similar deviations from the current input parameter by querying the audit log. Then, it statistically analyzes the task execution results corresponding to the retrieved historical parameter samples and calculates their task execution success rate. If the success rate is lower than a preset safety threshold, indicating that input parameters with such deviations are prone to task failure, the system will prevent the target agent from executing its task to avoid unnecessary resource consumption and potential erroneous results.
[0056] For example, as a specific implementation, suppose the target agent is designed to perform the task of "generating product descriptions".
[0057] First, the system generates static rules for the task based on the contract text. For example, for the input parameter "product name", the static rules might include a type constraint of "string" and a value range constraint of "length between 5 and 50 characters". For the parameter "product category", the static rules might include a type constraint of "string" and a value range constraint of "must be one of the predefined lists [electronic products, clothing, home furnishings]".
[0058] Furthermore, the current task type is determined to be "Generate Product Description," and historical data on the input parameters used in past executions of this task type are obtained from the audit logs. For example, the historical length distribution of "Product Name" is statistically analyzed, revealing an average length of 25 characters and a standard deviation of 5 characters; the historical distribution of "Product Category" shows that "Electronic Products" accounts for 60%, "Clothing" for 30%, and "Home Furnishings" for 10%. Subsequently, based on the above statistical characteristics, dynamic rules are generated. For example, the dynamic length range of "Product Name" is set to [15, 35] characters, and the dynamic rule for "Product Category" is set to an anomaly detection model based on historical frequency distribution.
[0059] When a user enters a task request, such as "Smartphone" as the "Product Name" and "Electronic Products" as the "Product Category," then static rule validation is performed first, including: The "Product Name" is "Smartphone", which is a string of length 4, between 5 and 50 characters.
[0060] The "Product Category" is "Electronic Products", which is a string and is within a predefined list, so it passes.
[0061] Based on this, the static rule validation passes. Then, dynamic rule validation is further performed, including: The "Product Name" is "Smartphone" with a length of 4. Although it passes static validation, its length of 4 is significantly lower than the dynamic rule's range of [15, 35]. In this case, the system will calculate its deviation.
[0062] The "Product Category" is "Electronic Products," which accounts for 60% of the historical distribution, which is within the normal range and is approved.
[0063] At this point, the "product name" is marked as a soft breach, and the system calculates a deviation of 4 for the "product name".
[0064] Based on this, the system retrieves historical parameter samples from the audit logs that have similar deviations in "product name" length to the current input. For example, it finds 100 past task execution records where the "product name" length was between 4 and 6 characters, of which 80 tasks failed, indicating that the agent could not generate a meaningful short product name description, resulting in a task success rate of 20%. If the preset safety threshold is 30%, then 20% is below the safety threshold. Therefore, the system will block the target agent's task execution process and prompt the user, "The product name is too short, which may cause the description generation to fail. It is recommended to provide a more detailed product name."
[0065] Through the above technical solution, this application introduces a dynamic rule verification mechanism based on historical data learning, on the basis of traditional input parameter verification, thereby improving the reliability of intelligent agent task execution. Traditional verification methods can only identify inputs that violate preset hard rules, while the solution in this embodiment can further identify abnormal inputs that, although formally compliant, significantly deviate from historical normal behavior patterns. By dividing verification into static rule verification and dynamic rule verification, and adopting different processing strategies for different types of violations, the system can accurately determine the risk level of input parameters. Specifically, for hard violations, task execution is usually immediately blocked, effectively avoiding resource waste and system crashes caused by fundamental errors. For soft violations, risk assessment is performed based on historical execution success rates, avoiding excessive restrictions on compliant but rare inputs, while effectively preventing high-risk abnormal inputs, thereby reducing the task failure rate, improving the efficiency and success rate of intelligent agent task execution, enabling the intelligent agent system to better cope with complex and ever-changing application scenarios, and improving the overall intelligence level and effectiveness of contractual governance of the intelligent agent system.
[0066] Furthermore, dynamic rules can be adaptively updated, specifically including: After each task is completed, obtain the execution result flag for this task. This execution result flag includes success, failure, and partial success. Based on the execution result label, the probability distribution of the parameter items involved in the dynamic rule is corrected by Bayesian update to update the statistical feature values of the corresponding parameter items; The execution results of each parameter item violating the dynamic rules within a preset time window are statistically analyzed. When the number of times the same parameter item violates the dynamic rules consecutively but the execution results are all marked as successful reaches the preset relaxation trigger threshold, the upper limit of the dynamic rule threshold for that parameter item is increased. When the number of times the same parameter item violates the dynamic rule and the execution result is marked as failed reaches the preset tightening trigger threshold, the upper limit of the dynamic rule threshold for that parameter item is reduced.
[0067] In addition, when the target agent executes a certain task type for the first time and the number of historical execution samples of that task type is lower than the preset minimum sample size threshold, a reference task type with the highest feature similarity to that task type can be retrieved from the audit log. The dynamic rule corresponding to the reference task type is used as the initial prior distribution of the current task type to replace the dynamic rule generated based on the empty historical distribution. When the boundary distance between the dynamic rule threshold of the same parameter item and the value range constraint of the corresponding parameter item in the static rule is lower than the preset lower limit of the distance, it can be identified that the parameter item has a rule fuzzy interval. For input parameters that fall into the rule fuzzy interval, the target agent is allowed to execute the test path in a manner that does not exceed the preset upper limit of the restricted resource quota, and the dynamic rule threshold is corrected once based on the execution result of the test path.
[0068] The execution result label indicates the final state of task execution. Besides the common success or failure, partial success is introduced, allowing the system to distinguish between execution results that, while not fully meeting expectations, still possess value, thus providing richer feedback information. Bayesian updating is a statistical method based on probability theory. Its function is to revise the previous probability distribution based on new observation data, enabling dynamic rules to continuously learn and adjust with actual feedback from task execution, improving the accuracy and adaptability of the dynamic rules. Specifically, this can be achieved by modeling the probability distribution of parameter terms as a Gaussian or Poisson distribution, and updating the mean and variance of the distribution based on the success, failure, or partial success result of each task.
[0069] The preset time window is used to statistically analyze the time range of historical execution results, such as the last 100 tasks or tasks within the last 24 hours. This ensures that adjustments to dynamic rules are based on recent data to adapt to environmental changes. Both the relaxation and tightening trigger thresholds are preset values used to determine when the upper limit of the dynamic rule threshold needs adjustment. For example, the relaxation trigger threshold could be 5 times, and the tightening trigger threshold could be 3 times, to balance the flexibility and stability of the rule and avoid excessively frequent or unnecessary adjustments. Increasing or decreasing the upper limit of the dynamic rule threshold for a parameter indicates that when the current upper limit of the rule may be too strict, hindering successful task execution, it needs to be adjusted upwards to allow a wider range of values; conversely, when the current upper limit of the rule is too lenient, leading to failed tasks, it needs to be adjusted downwards to limit the range of values. For example, for a numerical parameter, its upper limit value of the dynamic rule can be increased or decreased by a preset step size; for a classification parameter, its allowed set of categories can be adjusted.
[0070] The minimum sample size threshold is a preset value used to determine whether a task type has sufficient historical data to generate reliable dynamic rules. For example, if the threshold is 100, a task type with fewer than 100 historical execution samples is considered to have insufficient data, thus avoiding the generation of inaccurate or unstable dynamic rules in the case of sparse data. The reference task type refers to an existing task type that is closest to the current new task type in certain key features. Similarity can be determined by calculating the cosine similarity or Jaccard similarity between task feature vectors. Its role is to use existing knowledge to guide the rule generation of the new task type, thus solving the cold start problem. The initial prior distribution refers to dynamic rules borrowed from similar task types, serving as the starting rules for the new task type when it lacks sufficient historical data of its own. This approach is usually more effective than generating rules from an empty historical distribution.
[0071] When the boundary distance between the dynamic rule threshold and the corresponding parameter range constraint in the static rule for the same parameter item is lower than the preset lower limit, it indicates a potential conflict or uncertainty between the hard constraints of the static rule and the soft constraints of the dynamic rule. In this case, the parameter item is identified as having a rule fuzzy interval. The rule fuzzy interval refers to the area where the input parameter value is within the allowed range of the static rule, but very close to or slightly outside the dynamic rule's boundary. The limited resource quota limit refers to the limited resources allocated for executing experimental paths, such as less token consumption, shorter execution time, and lower API call frequency. Its purpose is to control the risk and cost of experiments, avoiding excessive resource waste or negative impacts caused by exploratory execution. Executing an experimental path allows the agent to attempt tasks corresponding to input parameters falling within the rule fuzzy interval under limited resources. This is an active exploration and learning mechanism designed to verify the effectiveness of fuzzy inputs through actual execution. A single adjustment to the dynamic rule threshold based on the execution result of the experimental path refers to a one-time targeted adjustment of the dynamic rule threshold based on the success or failure of the experimental path. This aims to fine-tune the dynamic rule rather than perform a large-scale reconstruction.
[0072] In one embodiment, the input parameters include numerical parameters, prompt words, and context. The step of "performing static rule validation and dynamic rule validation on the input parameters sequentially based on static rules and dynamic rules" specifically includes: Perform type constraint validation and value range constraint validation on numerical parameters; In the embodiments of this application, input parameters include numerical parameters, prompts, and context. Numerical parameters refer to input data represented in numerical form, such as integers, floating-point numbers, percentages, etc., typically used to quantify specific aspects of a task or as the basis for calculations. Prompts refer to instructions, questions, or guidance information provided in natural language text form, used to guide the agent in understanding task intent, generating content, or performing specific operations. Context refers to background information, historical dialogue records, document fragments, or external data related to the current task, providing the agent with the necessary context and knowledge to perform the task. Type constraint validation aims to ensure that the data type of the numerical parameters conforms to expectations, preventing program errors or logical anomalies caused by data type mismatches. For example, a parameter representing quantity should be an integer type, while a parameter representing proportion should be a floating-point number type. Value range constraint validation aims to ensure that the value of the numerical parameters falls within a preset valid range, helping to avoid abnormal or malicious input affecting the system. For example, the value of a percentage parameter should be between 0 and 100, and the value of an age parameter should be a positive integer and not exceed a reasonable upper limit.
[0073] Perform structural integrity checks on the prompt words, parse the paragraph structure of the prompt words, verify whether they contain predefined required instruction segments, and detect whether there are prohibited keywords; In the embodiments of this application, structural integrity verification aims to ensure that the organization of the prompts conforms to specific specifications, such as whether they contain titles, paragraphs, lists, etc., which helps the agent to more accurately understand the intent of the prompts. Parsing the paragraph structure of the prompts refers to decomposing the prompt text into logically independent components, such as identifying different paragraphs such as task objectives, background information, and specific requirements, providing a basis for instruction extraction and keyword detection. Verifying whether predefined necessary instruction segments are included aims to ensure that the prompts contain key instructions or information modules necessary to complete the task, so as to avoid task failure or incomplete results due to missing instructions. For example, for a code generation task, it may be necessary to include instruction segments such as "functional description," "input parameters," and "output format." Detecting the presence of prohibited keywords aims to identify whether the prompts contain prohibited words or phrases, such as words involving sensitive information, malicious instructions, or words that violate ethical norms, which helps to enhance the security and compliance of the agent.
[0074] Perform length constraint verification and information completeness verification on the context, count the number of tokens in the context and verify whether they are within the preset length range, identify the information type of the context and verify whether it contains the key information type required for the task execution process; In the embodiments of this application, length constraint verification aims to control the size of the context, preventing excessively long contexts from causing decreased agent processing efficiency, excessive resource consumption, or exceeding the model's processing capacity limit. Counting the number of context tokens and verifying whether it is within a preset length range involves converting the context text into basic units that the agent model can process, and checking whether the total number of these tokens is between the preset minimum and maximum length limits, thereby optimizing agent performance and resource usage. Information completeness verification aims to ensure that the context provides all the necessary information to complete the task, avoiding situations where the agent cannot effectively perform the task due to insufficient information. Identifying the information types of the context and verifying whether it contains the key information types required for task execution involves classifying the context content, which helps improve the accuracy and success rate of task execution. For example, identifying time information, location information, entity information, event descriptions, etc., and checking whether these information types contain the elements necessary for task execution.
[0075] Perform tool call permission verification and output format verification on the target intelligent agent, intercept tool call requests and verify whether the corresponding tool is in the predefined permission whitelist, parse the output content of the target intelligent agent and verify whether it conforms to the preset format template.
[0076] In the embodiments of this application, tool call permission verification aims to control the range of external tools that an agent can call, preventing the agent from calling unauthorized or potentially risky tools. Intercepting tool call requests and verifying whether the corresponding tool is within a predefined permission whitelist means that when an agent attempts to call an external tool, the system intercepts the call request and checks it against a pre-approved tool whitelist. Only tools on the whitelist are allowed to be called, thereby effectively enhancing system security. Output format verification aims to ensure that the output generated by the agent conforms to the expected structure and data type, facilitating subsequent processing or display. Parsing the target agent's output content and verifying whether it conforms to a preset format template means performing structured analysis on the output generated by the agent and checking whether it matches the predefined format specifications to ensure the usability and parsability of the output.
[0077] For example, as a specific implementation, suppose an agent is designed to generate a market analysis report based on user-provided requirements. The user-input task information includes: a numerical parameter, such as the target market size, expected to be a positive integer; a prompt, such as a natural language description containing instructions like "analysis objective" and "data source requirements"; and a context, such as historical sales data and competitor analysis reports.
[0078] When performing input parameter validation, the system first performs type constraint validation on the numerical parameter "target market size" to ensure it is an integer, and then performs value range constraint validation, for example, verifying whether its value is greater than zero and less than a certain preset maximum value. If the user enters "10.5" or "-5", it will be identified as non-compliant.
[0079] Furthermore, the system performs structural integrity checks on the prompts. For example, the system can parse the paragraph structure of the prompts to verify whether they contain predefined necessary instruction segments such as "analysis target" and "data source requirements." If the prompt is missing the crucial instruction "data source requirements," the system can prompt the user to add it. Simultaneously, the system will also detect whether the prompts contain prohibited keywords, such as "illegally obtaining data" or "false advertising." If detected, the task execution will be immediately blocked.
[0080] Furthermore, the system performs length constraint checks and information completeness checks on the context. For example, it counts the number of tokens in the context and verifies whether it is within a preset length range, such as no more than 5000 tokens. If the context is too long, the system can prompt the user to shorten it. Simultaneously, the system also identifies the information types in the context, such as verifying whether it contains key information types required for task execution, such as "product name," "sales amount," and "time period." If the context lacks the key information "product name," it will be marked as incomplete.
[0081] Building upon this, if an agent attempts to call an external tool, such as an API for data scraping, during task execution, the system first intercepts the tool's call request and then verifies whether the API is on a predefined permission whitelist. If the API is not on the whitelist, the system will block the call, thus preventing the agent from performing unauthorized operations.
[0082] Finally, when the agent generates the market analysis report, the system performs output format validation. For example, the report can be pre-defined as being in JSON format, containing fields such as "Report Title," "Summary," "Market Trend Analysis," and "Recommendations." Based on this, the system parses the agent's output and verifies whether it conforms to this pre-defined JSON format template. If the output is plain text or has an incorrect JSON structure, it will be marked as a format violation.
[0083] Through the above technical solutions, this application can perform more refined and comprehensive verification of the input parameters of intelligent agent tasks, thereby effectively addressing the complexity of diverse input types such as numerical parameters, prompts, and context. Specifically, by verifying the type and value range constraints of numerical parameters, the accuracy and rationality of the data can be ensured from the source; by detecting the structural integrity, necessary instruction segments, and prohibited keywords of prompts, the accuracy of the intelligent agent's understanding of the task intent can be improved, and potential security risks and inappropriate instructions can be effectively prevented; by verifying the length and information completeness of the context, the processing efficiency of the intelligent agent can be optimized, and the sufficiency of the information required for task execution can be ensured; in addition, by introducing tool call permission verification and output format verification, the solution of this embodiment can effectively control the external behavioral boundaries of the intelligent agent, prevent unauthorized resource access, and ensure the standardization and usability of the intelligent agent's output results. Through these multi-dimensional verification mechanisms, combined with the aforementioned static and dynamic rule verification, the security and predictability of intelligent agent task execution can be enhanced, the risk of breach of contract due to improper input or loss of control can be reduced, thereby improving the overall reliability of the intelligent agent system.
[0084] In one embodiment, step S30, which involves "when the input parameters meet the input constraints, controlling the target agent to execute each sub-task sequentially according to the execution boundary, and monitoring resource consumption during execution; when resource consumption reaches a preset consumption threshold or any sub-task is completed, generating a state snapshot and storing it in a persistent storage medium," specifically includes: The execution boundary is parsed to determine the execution order and resource quotas of each subtask; In the embodiments of this application, this step aims to transform the execution boundaries defined in the contract text into operable instructions, clarifying the execution order and allowed resource consumption of each subtask, thereby ensuring the standardization and controllability of task execution. Specifically, this step can be implemented through a predefined syntax parser or a domain-specific language interpreter. For example, the execution boundary can be a JSON file containing fields such as subtask identifiers, dependencies, maximum token consumption, and maximum API call count. The parser reads these fields, constructs a directed acyclic graph to represent the execution order of the subtasks, and extracts the resource quota for each subtask. Alternatively, a machine learning-based natural language processing model can be used to parse complex execution boundaries described in natural language. For example, the natural language processing model identifies key entities and relationships in the text and maps them to a structured execution plan and resource allocation table.
[0085] During the execution of the subtask, resource consumption is monitored in real time, including token consumption, number of API calls, and execution time. In the embodiments of this application, this step aims to ensure that the agent does not exceed the preset resource quota when executing subtasks, and to provide triggering conditions and data for generating state snapshots, which helps prevent resource abuse, control costs, and provide a basis for auditing and optimization. Specifically, this step can be implemented by embedding interceptors or proxies at key points of interaction between the agent and external services. For example, each time a large language model API is called, the interceptor records the number of tokens for the request and response; each time an external API is called, a counter increments; and a timer records the start and end times of the subtasks to calculate the execution duration. Alternatively, lower-level resource usage, such as CPU time and memory usage, can be obtained through operating system or virtual machine-level resource monitoring tools and correlated with the agent's logical operations.
[0086] When the resource consumption reaches the preset consumption threshold or any subtask is completed, the current execution state of the target agent is obtained and a state snapshot is generated. The state snapshot includes a list of completed subtasks, the current execution progress of the subtasks, the remaining resource quota, and intermediate results. In the embodiments of this application, this step aims to capture the complete execution state of the agent under specific conditions so that it can recover from the most recent effective point when the task is interrupted, avoiding starting from scratch and improving the resilience of task execution. When the triggering condition is met, a state capture module can be invoked. This state capture module performs the following actions: querying the task manager to obtain a list of completed subtask identifiers and their output; querying the internal state variables of the currently executing subtask; obtaining the current total resource consumption from the resource manager and calculating the remaining resources in conjunction with the total quota; and extracting temporary data, variable values, etc. generated by the current subtask from the agent's memory or temporary storage as intermediate results. As another implementation, the agent can be designed as an event-driven architecture. When a "subtask completed" or "resource threshold alarm" event occurs, a dedicated snapshot service is triggered. This snapshot service accesses the agent's internal state, including the subtask queue, current execution context, local variables, and handles for interacting with external systems, through the agent's API interface or shared memory, and structures it into a state snapshot.
[0087] The state snapshot is serialized and stored in a persistent storage medium, and the timestamp of the state snapshot generation is recorded.
[0088] In the embodiments of this application, this step aims to convert the data structure in memory into a storable or transmittable format, ensuring that data is not lost after system restarts or failures. Additionally, the timestamp is used to identify the generation order and validity of snapshots, which is crucial for selecting the latest snapshot during recovery. Specifically, this step can be implemented by converting the state snapshot object into a byte stream using data serialization formats such as JSON, Protocol Buffers, YAML, or MessagePack, and then writing the byte stream to a file system, relational database, or object storage service. The timestamp can be added to the snapshot data structure before serialization or used as metadata for storage operations. Furthermore, more efficient binary serialization methods, such as Java's ObjectOutputStream or Python's pickle module, can be used to reduce storage space and improve read / write speeds. For persistent storage, a distributed file system or a dedicated key-value store system can be considered to provide higher availability and scalability.
[0089] For example, as a specific implementation, suppose a target agent is assigned a task, such as "analyzing user review data from an e-commerce platform, identifying product defects, and generating a summary report." In this case, the execution boundaries in the contract text might be defined in a structured format, such as a JSON file, which details three subtasks: Subtask 1 is "crawl user review data," Subtask 2 is "perform sentiment analysis and topic extraction on the review data," and Subtask 3 is "generate a product defect summary report." Each subtask explicitly specifies its execution order, dependencies, and resource quotas, such as the maximum token consumption, API call count, and execution time for Subtask 1.
[0090] During task execution, when the target agent begins executing subtask 1, the system can activate a pre-defined resource monitoring module. This module tracks in real time the number of tokens consumed by subtask 1 when calling external crawler APIs and natural language processing model APIs, the number of API calls, and records the actual runtime of subtask 1. If the token consumption of subtask 1 reaches a preset consumption threshold before completion, such as consuming 90% of the quota, or if subtask 1 is successfully completed, the system will trigger the generation of a state snapshot. At this time, the system will obtain the current execution status of the target agent, including the list of completed subtasks, the current execution progress of subtasks, the remaining resource quota, and the intermediate results generated during the execution of subtask 1, such as some of the crawled raw comment data or the data after preliminary cleaning.
[0091] Finally, these state snapshot data are serialized into JSON format strings and stored together with the current system timestamp in a persistent storage medium, such as a distributed file system or key-value database.
[0092] Through the above technical solution, the solution of this embodiment can manage resource usage during the execution of intelligent agent tasks and provide accurate and comprehensive recovery points, thereby improving the reliability and efficiency of intelligent agent task execution. Especially when facing complex, time-consuming, or easily interrupted tasks, the solution of this embodiment can effectively reduce the cost and time loss caused by failures, ensure that tasks can be seamlessly recovered from the point of interruption, and thus ensure the effective implementation of contractual governance.
[0093] In one embodiment, the step of "when resource consumption reaches a preset consumption threshold or any subtask is completed, obtaining the current execution state of the target agent and generating a state snapshot, the state snapshot including a list of completed subtasks, the current subtask execution progress, remaining resource quota, and intermediate results" specifically includes: Traverse the subtask queue, mark completed subtasks, extract the output results of completed subtasks, and generate a list of completed subtasks; In the embodiments of this application, this step aims to systematically identify and record each successfully completed subtask and its specific output during task execution. Specifically, this step can be implemented by maintaining a subtask status table, which records the unique identifier of each subtask, its current status, and the storage location or content of its output. When generating a status snapshot, the system can scan this status table, filter out all subtasks with a status of "completed," and collect their corresponding outputs, thereby constructing a list of completed subtasks. Alternatively, after each subtask is completed, its identifier and output are pushed to a dedicated completion queue, which is then read directly during snapshot generation.
[0094] Get the identifier of the currently executing subtask, record the number of steps executed and the amount of resources consumed in the currently executing subtask, and generate the execution progress of the current subtask; In one implementation of this application, each subtask can maintain an independent execution context, which includes the subtask's internal state machine, a counter of executed atomic operations, and the amount of resources consumed independently by the subtask, such as token consumption and API call count. When generating a snapshot, the system can directly extract this real-time data from the execution context of the currently active subtask. Alternatively, probes or hook functions can be embedded at key execution points of the subtask to update its progress and resource consumption information in real time, and this data can be obtained through an interface when a snapshot is triggered.
[0095] Read the preset total resource quota in the execution boundary, calculate the difference between the total resource quota and the amount of resources consumed, and generate the remaining resource quota; In the embodiments of this application, this step aims to ensure that the task still adheres to its preset resource limits when execution resumes. When the task starts, the total resource quota can be parsed from the execution boundary of the contract text and stored in a globally accessible configuration item. When a snapshot is generated, the total quota can be read from this configuration item, and the accumulated resource consumption of the current task can be subtracted to obtain the remaining resource quota. Alternatively, the total resource quota and real-time consumption can be continuously tracked, and the current remaining resource quota can be directly queried from them when a snapshot is triggered.
[0096] Extract intermediate variables, temporary file paths, and context states generated by the currently executing subtask from the runtime memory of the target agent, and generate intermediate results; In one embodiment of this application, the runtime environment of the target agent can provide a snapshot interface that can serialize the stack frame, local variables, global variables, and references to temporary storage of the currently active subtask. Another implementation involves scanning the runtime memory of the target agent when a snapshot is triggered using memory mirroring technology or specific runtime debugging tools to identify and extract key data structures and file handles related to the current subtask.
[0097] The list of completed subtasks, the execution progress of the current subtask, the remaining resource quota, and intermediate results are encapsulated into structured data objects to generate a state snapshot.
[0098] In one embodiment of this application, a preset JSON or XML schema can be defined to populate the aforementioned data into the corresponding fields, forming a unified structured data object. Alternatively, the serialization mechanism provided by the programming language can be used to directly serialize the custom class instance containing all state information into binary or text format.
[0099] For example, as a specific implementation, suppose the target agent is performing a multi-step data analysis task, which includes four sub-tasks: "data cleaning", "feature engineering", "model training", and "results reporting".
[0100] At a certain point, when the task reaches the 500th iteration of the "model training" subtask, a state snapshot is generated. At this time, the system first checks the subtask queue, finds that the "data cleaning" and "feature engineering" subtasks have been completed, and extracts the output data of these two subtasks, such as the file path of the cleaned dataset and the file path of the generated feature vector, to form a list of completed subtasks.
[0101] For the currently executing "model training" subtask, the system obtains its identifier and records the number of iterations it has performed and the amount of GPU computing time or memory resources consumed in this training, generating the current subtask execution progress. At the same time, the system reads the total computing resource quota of the data analysis task from the task's execution boundary and subtracts the consumed resources to calculate the remaining resource quota.
[0102] In addition, the system will extract intermediate variables and context states such as the current model weights, optimizer state, training log file path, and current training batch data from the target agent's runtime memory as intermediate results. Finally, all of the above information will be encapsulated into a JSON-formatted structured data object as a snapshot of the current state and stored in persistent storage.
[0103] By traversing completed subtasks, recording the execution progress of the current subtask, dynamically calculating remaining resource quotas, and extracting intermediate runtime results, the generated state snapshots contain all necessary contextual information and progress details during task execution. This allows the task's execution flow to be restored from a precise and complete state point even if the task is interrupted for various reasons, avoiding the resource waste and time loss caused by starting the task from scratch. Furthermore, this detailed state recording provides a data foundation for auditing, debugging, and performance analysis, thereby improving the transparency and controllability of agent task management.
[0104] In one embodiment, step S50, "after the target agent completes its task execution, the output result is verified according to the output constraints, and if the output result does not meet the output constraints, it is marked as a violation," specifically includes: Parse the data structure of the output results, verify whether the output results conform to the predefined format template, and mark the violation type as a format violation when they do not conform. In the embodiments of this application, data structure refers to the specific organizational form followed by the output content, such as JSON, XML, tabular data, or plain text with specific delimiters. Format template refers to a predefined structured pattern or specification that the output should follow. Specifically, this step can utilize tools such as JSON Schema or XML Schema Definition to perform pattern validation on the output, comparing it with the preset template; or for text output, regular expression matching can be used to check its structure; alternatively, the output can be parsed into an object model in the program, and its structure can be validated based on the expected class definitions.
[0105] Extract the list of predefined required fields from the output constraints, iterate through the output results and verify whether the output results contain all required fields in the list of required fields. If any required field is missing, mark the default type as integrity default. In the embodiments of this application, the required field list clearly defines the essential information items that must be included in the output. An integrity breach indicates that key information is missing from the output. This step can be specifically implemented by traversing the required field list, checking the existence of each field in the parsed output data structure. For structured data, this typically also involves checking the existence of keys; for natural language output, named entity recognition or keyword extraction techniques may be needed to determine whether a specific entity or concept is mentioned.
[0106] A quality assessment is performed on the output results, which includes semantic consistency detection, logical completeness detection, and accuracy detection. When the quality assessment fails, the default type is marked as a quality default. In the embodiments of this application, quality assessment refers to a comprehensive analysis encompassing the meaning of the output, the reasoning process, and the correctness of the facts. Semantic consistency testing is used to assess whether the meaning of the output content is consistent with the expected goals of the task. Logical completeness testing is used to check whether any reasoning chains or argumentation processes in the output are rigorous and free from logical flaws. Accuracy testing is used to verify the truthfulness of factual statements in the output. When any of the above tests fails, it is marked as a quality breach. In terms of implementation, semantic consistency can be measured by calculating the cosine similarity between the output text and the semantic embedding vector of the task objective description, or by using a natural language reasoning model; logical completeness can involve parsing the output into a knowledge graph or logical proposition and verifying it using automated theorem proving or rule-based reasoning methods; accuracy testing can be implemented by cross-validating the factual statements in the output with a trusted knowledge base or external API.
[0107] When any default type is detected, a default report is generated, including the default type, default fields, expected value, actual value, and default severity, and written to the audit log.
[0108] In the embodiments of this application, a default report refers to a structured record that typically describes in detail the specific circumstances of a default, including the type of default, the specific field where the default occurred, the expected value and the actual value received, and the severity of the default. An audit log refers to a persistent recording system used to store all events, including default reports. In terms of implementation, once any type of default is detected, a pre-built reporting module can collect all relevant details generated during the verification process. For example, if a format default occurs, the reporting module records the format default as the default type, the specific data path as the default field, the expected format as the expected value, and the actual erroneous data as the actual value. Furthermore, the severity of the default can be assigned according to preset rules; for example, missing critical fields may be marked as high severity. Finally, the default report is written to the audit log.
[0109] For example, as a specific implementation, suppose an agent needs to generate an analysis report on market trends and is required to output the analysis report in JSON format, including fields such as "report title", "analysis date", "key findings" and "recommendations", and the "key findings" section should contain at least three statements with a clear logical relationship.
[0110] Once the agent has generated the report, it first checks whether its output conforms to the JSON format. If the output contains a syntax error, such as a missing parenthesis, the system will immediately mark it as a "format violation" and generate a violation report, which will record in detail "Violation type: format violation", "Violation field: entire output", "Expected value: valid JSON format", "Actual value: [actual erroneous output fragment]", and mark its severity as high.
[0111] If the format validation passes, the system will continue to check the report's completeness. Specifically, it will verify that the output contains the required fields: "Report Title," "Analysis Date," "Key Findings," and "Recommendations." If the "Recommendations" field is missing, the system will mark it as an "Integrity Breach" and indicate in the breach report: "Breach Type: Integrity Breach," "Breached Field: Recommendation," "Expected Value: Field Present," or "Actual Value: Field Missing." The severity may be marked as moderate.
[0112] After the format and completeness requirements are met, the system will further assess the quality of the report content. For example, in the "Semantic Consistency Detection," if the "Key Findings" section of the report primarily describes internal operational efficiency rather than market trends, it may be deemed semantically inconsistent. In the "Logical Completeness Detection," if the three statements in the "Key Findings" lack a clear causal or progressive relationship, or contain logical contradictions, they will be marked as logical flaws. In the "Accuracy Detection," if a market data cited in the report does not match the latest data released by an authoritative institution, it will be judged as a factual error. Once any quality assessment fails, the system will mark it as a "Quality Default" and generate a corresponding default report. For example, for a logical flaw, the report may include "Default Type: Quality Default," "Default Field: Key Findings," "Expected Value: Logically Sound Statement," and "Actual Value: [Actually Logically Incoherent Statement]," and mark the severity according to its impact on the core conclusions of the report.
[0113] Ultimately, all of these detailed default reports will be recorded in the audit log.
[0114] Through the above technical solution, after the target agent completes its task execution, the data structure of the output result is first parsed and verified to ensure it conforms to the predefined format template. This effectively avoids subsequent processing failures or system anomalies caused by non-standard output formats, ensuring the usability of the output result. Secondly, by extracting the predefined list of required fields from the output constraints and verifying the completeness of the output result, the presentation of key information required by the task can be ensured, avoiding the impact of missing information on decision-making or the inability to achieve the task objective. Furthermore, by introducing quality assessment mechanisms such as semantic consistency detection, logical completeness detection, and accuracy detection, the solution in this embodiment can deeply understand the quality of the output content, ensuring that the agent outputs not only structurally complete and information-rich results, but also high-quality content that is semantically accurate, logically rigorous, and factually reliable. When any type of breach is detected, the system can generate a detailed breach report and write it to the audit log. Through this detailed verification and breach report generation mechanism, the solution in this embodiment can improve the efficiency and accuracy of problem diagnosis, enabling developers or maintenance personnel to quickly locate the root cause of the problem and make targeted optimizations to the agent model or adjustments to the strategy, thereby improving the reliability of the agent's task execution and the trustworthiness of the output result.
[0115] In one embodiment, the step of "performing a quality assessment on the output results, the quality assessment including semantic consistency detection, logical completeness detection, and accuracy detection, and marking the breach type as a quality breach when the quality assessment fails" specifically includes: Extract the predefined task target description from the output constraints, perform semantic matching between the output result and the task target description, and calculate the semantic similarity. When the semantic similarity is lower than the preset similarity threshold, it is determined that the semantic consistency detection has failed. In the embodiments of this application, extracting the predefined task objective description from the output constraints refers to obtaining the expected goal or desired result of the task from the output constraint portion of the contract text. The task objective description can serve as a reference benchmark for the agent's output. For example, the task objective description can be an explicit field in the contract text, specified by the user or system during task creation; or it can be dynamically loaded from a predefined task template library based on the task type. Semantic matching and semantic similarity calculation between the output and the task objective description aims to quantify the semantic fit between the agent's output and the task objective. This can be achieved using natural language processing techniques, converting the output and task objective description into high-dimensional semantic vectors, such as using pre-trained models like Word2Vec, BERT, or Sentence-BERT, and then calculating the cosine similarity between these semantic vectors. Alternatively, a domain knowledge graph can be constructed, mapping key entities and relationships in the output and task objective descriptions to the knowledge graph, and evaluating semantic similarity by comparing the overlap of graph structures or paths. When the semantic similarity is lower than the preset similarity threshold, the semantic consistency detection is deemed to have failed. The similarity threshold can be an empirical value, such as 0.7 or 0.8, or it can be dynamically adjusted according to the sensitivity or importance of the task.
[0116] Extract the reasoning chain from the output results and verify whether there are logical defects between the reasoning steps in the reasoning chain. When a logical defect is detected, it is determined that the logical completeness test has failed. In the embodiments of this application, extracting the reasoning chain from the output result refers to identifying the logical deduction process from premises, arguments to conclusions in the agent's output. For tasks involving complex decision-making or problem-solving, the agent's output often contains a series of intermediate reasoning steps. For example, causal relationships, conditional relationships, or deductive steps in the output text can be identified through pattern matching, syntactic analysis, or by using a specially trained language model, thereby constructing a complete reasoning chain. Verifying whether there are logical defects between the reasoning steps in the reasoning chain aims to check the validity and rationality of the reasoning process. Specifically, this can include detecting common logical fallacies, such as circular reasoning, improper induction, and contradictory statements. For example, the reasoning chain can be converted into a formal logic expression, and an automated theorem prover or logical reasoning engine can be used to detect inconsistencies or invalid derivations; alternatively, heuristic rules and machine learning models can be used to identify problems such as logical jumps, insufficient premises, or inappropriate conclusions in the reasoning steps. When a logical defect is detected, it is determined that the logical completeness check has failed, indicating that the agent's reasoning process has flaws and may lead to unreliable conclusions.
[0117] Extract factual statements from the output results and cross-validate them with a pre-set knowledge base. If contradictory or unverifiable factual statements are detected, the accuracy test is deemed to have failed. In the embodiments of this application, extracting factual statements from the output results refers to identifying all statements or phrases that claim to be objective facts from the agent's output. For example, named entity recognition technology can be used to identify entities, and then the statements containing the identified entities can be extracted; alternatively, subject-verb-object structures can be identified through syntactic analysis to locate factual assertions. Cross-validating the factual statements with a preset knowledge base aims to verify the accuracy of the factual information in the agent's output. The preset knowledge base can be a structured database, a domain knowledge graph, an authoritative document corpus, or a real-time updated external information source. For example, the system can query the knowledge base for the extracted factual statements to compare whether there is identical or contradictory information in the knowledge base; or, information retrieval technology can be used to search for evidence supporting or refuting the factual statement from a large amount of credible text. When a contradictory or unverifiable factual statement is detected, it is determined that the accuracy test has failed, where a contradiction means that there is information in the knowledge base that directly contradicts the agent's statement, and unverifiable means that there is insufficient information in the knowledge base to confirm or refute the statement.
[0118] The quality assessment is deemed unsuccessful if any of the following tests fails: semantic consistency, logical completeness, or accuracy.
[0119] In the embodiments of this application, if any of the semantic consistency detection, logical completeness detection, or accuracy detection fails, the quality assessment is deemed to have failed, indicating that as long as the agent's output has defects in any aspect of semantics, logic, or fact, its overall quality is considered unqualified.
[0120] For example, as a specific implementation, suppose an agent is asked to perform the task of "analyzing the latest market reports, summarizing the three industries with the greatest growth potential in the coming year, and providing supporting data".
[0121] First, the system extracts predefined task objective descriptions from the output constraints, such as: "Summarize the three industries with the greatest growth potential and provide data support."
[0122] After the intelligent agent performs the task, the output result is as follows: "According to market reports, artificial intelligence, biotechnology, and clean energy are the three industries with the greatest growth potential in the coming year. The artificial intelligence industry is expected to grow by 20%, biotechnology by 15%, and clean energy by 18%. Therefore, it is recommended to invest in these areas. However, the report also points out that traditional manufacturing will see a recovery, with an expected growth of 25%." At this point, the system will perform the following checks on this output: Semantic consistency detection specifically includes: the system semantically matching the agent's output with the task objective description. If the agent's output contains redundant information unrelated to the task objective, or fails to fully cover the core semantics of the task objective—for example, if the output only mentions two industries or does not provide supporting data—the calculated semantic similarity may be lower than a preset similarity threshold, thus failing the semantic consistency detection.
[0123] The logical completeness check specifically includes: the system extracts the reasoning chain from the output, such as: "Artificial intelligence, biotechnology, and clean energy are the three industries with the greatest growth potential," and "Investment in these areas is recommended." Simultaneously, the system also identifies the statement, "Traditional manufacturing will see a recovery, with an expected growth of 25%." If the growth rate of "traditional manufacturing" is higher than any of the "three industries with the greatest growth potential" listed by the agent, then the agent's reasoning in excluding "traditional manufacturing" from the list of "most promising industries" is logically flawed because its conclusion contradicts the data it provided. In this case, the logical completeness check will be deemed a failure.
[0124] Accuracy testing specifically involves the system extracting factual statements from the output, such as "the artificial intelligence industry is expected to grow by 20%." The system then queries a pre-defined knowledge base, such as the latest market report or authoritative industry databases. If the knowledge base records a projected growth rate of 22% for the artificial intelligence industry instead of 20%, a contradiction is detected, and the accuracy test fails. Similarly, if the knowledge base contains no data on "clean energy growth of 18%," it is deemed unverifiable, and the accuracy test also fails.
[0125] Ultimately, if any of the above tests fail, the entire quality assessment is deemed unsuccessful.
[0126] Through the above technical solution, this application can evaluate the quality of the intelligent agent's output results in multiple dimensions, thereby identifying specific defects in the output results at the semantic, logical, and factual levels. This not only improves the reliability and credibility of the intelligent agent's output results, but also provides a clear basis for the diagnosis and improvement of the intelligent agent's performance. It also reduces the complexity of manual review and debugging, thereby more effectively ensuring the quality of task execution.
[0127] Furthermore, when a quality assessment is deemed unsuccessful, the following steps can be performed: The semantic topic coverage of the output results and the task objective description is calculated to identify the semantic dimensions in the task objective description that are not covered by the output results and generate a list of missing coverage. Extract the generation probability confidence of each statement in the output results, and mark the statements with generation probability confidence below the preset confidence lower limit as confidence-deficient statements; The deviation and direction of the output semantic vector from the task target semantic vector are calculated. Based on whether the deviation is lower than the preset recoverable deviation limit, it is determined whether the semantic defect is recoverable.
[0128] When the logic completeness test fails, the missing reasoning steps in the reasoning chain are extracted, and each missing step is classified as either a missing deductive reasoning step, a missing inductive reasoning step, or a missing analogical reasoning step. Based on the degree of influence of the missing steps on the reasoning conclusion, they are marked as either a type that must be supplemented or a type that can be optimized. When the accuracy test fails, the detected erroneous factual statements are classified as follows: if there is a record in the knowledge base that contradicts the statement, it is marked as a factual error; if there is no record in the knowledge base that is related to the statement, it is marked as an illusion error. Based on the above fine-grained analysis results, improvement strategies corresponding to each defect type are retrieved from the pre-built defect improvement strategy library. The improvement strategies include parameter adjustment items and prompt word supplement items for the target agent. Based on the improved strategy, adjust the execution parameters of the target agent within the allowable resource quota and re-execute the task; Perform a quality assessment on the output results after re-execution. When the quality assessment passes, associate the parameter adjustment items and prompt word supplement items used in this improvement with the corresponding defect types and write them into the defect improvement strategy library. If the quality assessment still fails, add a hard defect marked as unhealable by the system to the default report; Generate a quality report, which includes quantitative scores for each dimension of semantic consistency, logical completeness, and accuracy, defect location information, improvement suggestions, and risk warnings on whether the output results are applicable to high-risk decision-making scenarios. Write the quality report to the audit log.
[0129] When semantic consistency detection fails, the fine-grained analysis aims to analyze the essence of semantic defects. Semantic topic coverage calculation can employ natural language processing techniques, such as topic models (e.g., LDA, BERT-based topic models) or keyword extraction and matching, to quantify the degree to which the output covers key semantic points in the task objective description, thereby identifying insufficiently covered semantic dimensions. Generating a coverage gap list clearly indicates in which aspects the output content fails to meet the task's semantic requirements. Generation probability confidence can typically utilize the probability scores internally calculated by a large language model when generating each word or sentence, or be judged by an external confidence assessment model. Statements below a pre-set confidence lower limit are marked as confidence-deficient sentences, helping to identify parts of the agent-generated content with high uncertainty. Calculating the deviation and direction of the output semantic vector from the task objective semantic vector can be achieved by converting the text into a high-dimensional vector using word embedding or sentence embedding techniques, and measuring the degree of deviation by calculating cosine similarity or Euclidean distance. A pre-set recoverable deviation upper limit is used to determine whether the defects can be resolved through fine-tuning or minor corrections.
[0130] When a logical completeness check fails, the missing reasoning steps in the reasoning chain are extracted. A logic parser or rule-based reasoning engine can be used to analyze the argument structure of the output, identifying jumps or inconsistencies in the argument. Missing steps are categorized; for example, missing deductive reasoning might indicate insufficient derivation from general principles to specific conclusions, missing inductive reasoning might indicate insufficient summarization from specific observations to general laws, and missing analogical reasoning might indicate a lack of effective analogical arguments. Based on the degree of impact of the missing steps on the reasoning conclusion, they can be marked as either "must be supplemented" (e.g., missing key premises render the conclusion invalid) or "optional optimization" (e.g., missing supporting arguments but the conclusion is still generally reasonable), to facilitate adjusting the priority ranking.
[0131] When an accuracy test fails, classifying the detected erroneous factual statements is a crucial method for distinguishing different types of accuracy problems. If a record in the knowledge base contradicts the statement, it is marked as a factual error, indicating that the agent has generated information contrary to known facts. If no record in the knowledge base is related to the statement, it is marked as an illusion error, indicating that the agent has generated unverifiable or fabricated information. This classification method helps understand the root causes of agent errors and guides subsequent improvement strategies.
[0132] Based on the above fine-grained analysis results, improvement strategies corresponding to each defect type are retrieved from a pre-built defect improvement strategy library. This defect improvement strategy library can be a structured database that stores the mapping relationship between different defect types (such as insufficient semantic coverage, missing deductive reasoning, hallucination errors, etc.) and corresponding parameter adjustment items (such as adjusting model temperature, Top-P sampling parameters, Beam Search width, etc.) and prompt word supplementary items (such as adding contextual information, explicit instructions, providing examples, etc.). According to the retrieved improvement strategies, within the resource quota limits (e.g., limiting the token consumption of re-execution, the number of API calls, or the execution time), the execution parameters of the target agent are adjusted and the task is re-executed, enabling the agent to attempt self-correction. The output results after re-execution are subjected to quality evaluation again. If the quality evaluation passes, the parameter adjustment items and prompt word supplementary items used in this improvement are associated with the corresponding defect types and written into the defect improvement strategy library, thereby achieving adaptive learning and optimization of the strategy library. If the quality evaluation still fails, a hard defect marked as unhealable by the system is added to the default report, indicating that deeper intervention or manual review is required.
[0133] A quality report is generated, comprising quantitative scores for semantic consistency, logical completeness, and accuracy. These scores are weighted based on various indicators from fine-grained analysis, providing an intuitive quality assessment. Defect location information identifies specific paragraphs, sentences, or parameters in the output that contain problems. Improvement suggestions, based on the results of fine-grained analysis and the trial of improvement strategies, offer targeted corrective measures. A risk warning indicating whether the output is suitable for high-risk decision-making scenarios is provided based on the overall quality assessment results and the severity of the defects, offering decision-making references for users. Finally, the quality report is written to the audit log, forming a complete record of task execution and quality management.
[0134] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0135] In one embodiment, a contract-based agent operation system is provided, which corresponds one-to-one with the contract-based agent operation method described in the previous embodiment. The contract-based agent operation system includes: The constraint parsing module is used to respond to user-inputted task information, extract the constraints from the task information, and generate contract text including input constraints, output constraints, and execution boundaries. The input validation module is used to validate the input parameters of the target agent based on the input constraints. When the input parameters do not meet the input constraints, the task execution process of the target agent is blocked and a violation information is returned. The execution monitoring module is used to control the target intelligent agent to execute each sub-task sequentially according to the execution boundary when the input parameters meet the input constraints, and to monitor the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. The execution recovery module is used to read the most recent state snapshot from the persistent storage medium when the interruption of the target agent's task execution is detected, determine the interruption location based on the state snapshot, and resume execution from the interruption location. The output verification module is used to verify the output results according to the output constraints after the target agent completes the task execution process. If the output results do not meet the output constraints, they are marked as violations. The log generation module is used to write the time of the snapshot of the task execution process, resource consumption, verification results, and violation details into the audit log.
[0136] For specific limitations regarding the intelligent agent operation system based on contractual governance, please refer to the limitations of the intelligent agent operation method based on contractual governance mentioned above, which will not be repeated here. Each module in the aforementioned intelligent agent operation system based on contractual governance can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0137] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows. Figure 2As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a contract-based governance-based intelligent agent operation method.
[0138] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements a method for operating an intelligent agent based on contractual governance.
[0139] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a method for operating an intelligent agent based on contractual governance.
[0140] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0141] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for operating an intelligent agent based on contractual governance, applied to the task execution process of a target intelligent agent, wherein, The task comprises several sub-tasks, characterized by including the following steps: In response to user-inputted task information, extract the constraints from the task information and generate a contract text that includes input constraints, output constraints, and execution boundaries; The input parameters of the target agent are validated based on input constraints. If the input parameters do not meet the input constraints, the task execution process of the target agent is blocked and a violation message is returned. Specifically, this includes: Static rules are generated based on input constraints, and the static rules include predefined type constraints and value range constraints. Determine the task type, obtain the historical input parameter distribution of the target agent based on the same task type, calculate the statistical feature value of each parameter item in the historical input parameter distribution, and generate dynamic rules; The input parameters are validated using static and dynamic rules in sequence, respectively. During the operation of the target intelligent agent, the dynamic rules are adaptively updated, specifically including: After each task is completed, obtain the execution result flag for this task. The execution result flag includes success, failure, and partial success. Based on the execution result label, the probability distribution of the parameter items involved in the dynamic rule is corrected by Bayesian update to update the statistical feature values of the corresponding parameter items; The execution results of each parameter item violating the dynamic rules within a preset time window are statistically analyzed. When the number of times the same parameter item violates the dynamic rules consecutively but the execution results are all marked as successful reaches the preset relaxation trigger threshold, the upper limit of the dynamic rule threshold for that parameter item is increased. When the number of times the same parameter item violates the dynamic rule and the execution result is marked as failed reaches the preset tightening trigger threshold, the upper limit of the dynamic rule threshold for that parameter item is reduced. When the input parameters meet the input constraints, the control target agent executes each sub-task sequentially according to the execution boundary, and monitors the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. When the task execution of the target agent is interrupted, the most recent state snapshot is read from the persistent storage medium, the interruption location is determined based on the state snapshot, and execution is resumed from the interruption location. Once the target agent completes its task execution, the output result is verified based on the output constraints. If the output result does not meet the output constraints, it is marked as a violation. Write the time of the snapshot of the task execution process, resource consumption, verification results, and details of the breach into the audit log.
2. The intelligent agent operation method based on contractual governance according to claim 1, characterized in that, After the steps of performing static rule validation and dynamic rule validation on the input parameters based on static and dynamic rules respectively, the specific steps include: When static rule validation fails, it is marked as a hard violation, violation information is generated, and the task execution process of the target intelligent agent is blocked. The violation information includes the name of the violation parameter, the type of rule violation, the expected value, and the actual value. When static rule validation passes but dynamic rule validation fails, it is marked as a soft violation, and the deviation of the input parameters from the historical input parameter distribution is calculated. Retrieve historical parameter samples with deviations within the same range from the audit logs, calculate the task execution success rate of the historical parameter samples, and block the task execution process of the target agent when the task execution success rate is lower than the preset safety threshold.
3. The intelligent agent operation method based on contractual governance according to claim 1, characterized in that, The input parameters include numerical parameters, prompt words, and context. The steps of performing static rule validation and dynamic rule validation on the input parameters based on static and dynamic rules respectively specifically include: Perform type constraint validation and value range constraint validation on numerical parameters; Perform structural integrity checks on the prompt words, parse the paragraph structure of the prompt words, verify whether they contain predefined required instruction segments, and detect whether there are prohibited keywords; Perform length constraint verification and information completeness verification on the context, count the number of tokens in the context and verify whether they are within the preset length range, identify the information type of the context and verify whether it contains the key information type required for the task execution process; Perform tool call permission verification and output format verification on the target intelligent agent, intercept tool call requests and verify whether the corresponding tool is in the predefined permission whitelist, parse the output content of the target intelligent agent and verify whether it conforms to the preset format template.
4. The intelligent agent operation method based on contractual governance according to claim 1, characterized in that, The step of controlling the target intelligent agent to execute each sub-task sequentially according to the execution boundary when the input parameters meet the input constraints, and monitoring resource consumption during execution, generating a state snapshot and storing it to a persistent storage medium when the resource consumption reaches a preset consumption threshold or when any sub-task is completed, specifically includes: The execution boundary is parsed to determine the execution order and resource quotas of each subtask; During the execution of the subtask, resource consumption is monitored in real time, including token consumption, number of API calls, and execution time. When the resource consumption reaches the preset consumption threshold or any subtask is completed, the current execution state of the target agent is obtained and a state snapshot is generated. The state snapshot includes a list of completed subtasks, the current execution progress of the subtasks, the remaining resource quota, and intermediate results. The state snapshot is serialized and stored in a persistent storage medium, and the timestamp of the state snapshot generation is recorded.
5. The intelligent agent operation method based on contractual governance according to claim 4, characterized in that, The step of obtaining the current execution state of the target agent and generating a state snapshot when the resource consumption reaches a preset consumption threshold or when any subtask is completed, and the state snapshot includes a list of completed subtasks, the current subtask execution progress, the remaining resource quota, and intermediate results, specifically includes: Traverse the subtask queue, mark completed subtasks, extract the output results of completed subtasks, and generate a list of completed subtasks; Get the identifier of the currently executing subtask, record the number of steps executed and the amount of resources consumed in the currently executing subtask, and generate the execution progress of the current subtask; Read the preset total resource quota in the execution boundary, calculate the difference between the total resource quota and the amount of resources consumed, and generate the remaining resource quota; Extract intermediate variables, temporary file paths, and context states generated by the currently executing subtask from the runtime memory of the target agent, and generate intermediate results; The list of completed subtasks, the execution progress of the current subtask, the remaining resource quota, and intermediate results are encapsulated into structured data objects to generate a state snapshot.
6. The intelligent agent operation method based on contractual governance according to claim 1, characterized in that, The step of verifying the output result based on the output constraints after the target agent completes its task execution process, and marking the output result as a violation when it does not meet the output constraints, specifically includes: Parse the data structure of the output results, verify whether the output results conform to the predefined format template, and mark the violation type as a format violation when they do not conform. Extract the list of predefined required fields from the output constraints, iterate through the output results and verify whether the output results contain all required fields in the list of required fields. If any required field is missing, mark the default type as integrity default. A quality assessment is performed on the output results, which includes semantic consistency detection, logical completeness detection, and accuracy detection. When the quality assessment fails, the default type is marked as a quality default. When any default type is detected, a default report is generated, including the default type, default fields, expected value, actual value, and default severity, and written to the audit log.
7. The intelligent agent operation method based on contractual governance according to claim 6, characterized in that, The step of performing a quality assessment on the output results, which includes semantic consistency detection, logical completeness detection, and accuracy detection, and marking the breach type as a quality breach when the quality assessment fails, specifically includes: Extract the predefined task target description from the output constraints, perform semantic matching between the output result and the task target description, and calculate the semantic similarity. When the semantic similarity is lower than the preset similarity threshold, it is determined that the semantic consistency detection has failed. Extract the reasoning chain from the output results and verify whether there are logical defects between the reasoning steps in the reasoning chain. When a logical defect is detected, it is determined that the logical completeness test has failed. Extract factual statements from the output results and cross-validate them with a pre-set knowledge base. If contradictory or unverifiable factual statements are detected, the accuracy test is deemed to have failed. The quality assessment is deemed unsuccessful if any of the following tests fails: semantic consistency, logical completeness, or accuracy.
8. A smart agent operation system based on contractual governance, used to execute the steps of a smart agent operation method based on contractual governance as described in any one of claims 1-7, characterized in that, include: The constraint parsing module is used to respond to user-inputted task information, extract the constraints from the task information, and generate contract text including input constraints, output constraints, and execution boundaries. The input validation module is used to validate the input parameters of the target agent based on the input constraints. When the input parameters do not meet the input constraints, the task execution process of the target agent is blocked and a violation information is returned. The execution monitoring module is used to control the target intelligent agent to execute each sub-task sequentially according to the execution boundary when the input parameters meet the input constraints, and to monitor the resource consumption during the execution process. When the resource consumption reaches the preset consumption threshold or any sub-task is completed, a state snapshot is generated and stored in the persistent storage medium. The execution recovery module is used to read the most recent state snapshot from the persistent storage medium when the interruption of the target agent's task execution is detected, determine the interruption location based on the state snapshot, and resume execution from the interruption location. The output verification module is used to verify the output results according to the output constraints after the target agent completes the task execution process. If the output results do not meet the output constraints, they are marked as violations. The log generation module is used to write the time of the snapshot of the task execution process, resource consumption, verification results, and violation details into the audit log.
9. A computer electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, it implements the steps of an agent operation method based on contractual governance as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of an intelligent agent operation method based on contractual governance as described in any one of claims 1 to 7.
Citation Information
Patent Citations
AI agent distribution and authority control method and system
CN120850274A
Multi-agent contract cost evaluation integrated treatment system and method based on mode priority
CN122021703A
