A dual-rail fusing method for agent tool invocation
By employing a dual-track circuit breaker method, utilizing a call log key and two-layer failure identification, the problems of misjudgment and duplicate calls in intelligent agent tool calls are solved, achieving accurate circuit breaker control and resource optimization.
Patent Information
- Application Number
- CN202611291622.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-20
AI Technical Summary
Existing circuit breaker mechanisms struggle to accurately distinguish between tool execution failures, result failures, business failures, and normal return content during agent tool calls, leading to misjudgments and duplicate calls, consuming resources and prolonging user waiting time.
A dual-track circuit breaker method is adopted. By obtaining the session identifier, agent identifier, tool identifier, scope fingerprint and parameter fingerprint of the tool call request, a call record key is generated to perform two-level tool failure identification, including tool execution failure identification and result failure identification. The circuit breaker record is updated according to preset conditions to distinguish between consecutive failures of the same call and similar errors.
It effectively prevents repeated invalid calls, reduces false positives, distinguishes between tool execution and result failure, reduces resource consumption and user waiting time, and improves the success rate of intelligent agent tool calls.
Smart Images

Figure CN123137985A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a dual-track circuit breaker method for intelligent agent tool calls. Background Technology
[0002] Language model-based agent systems typically perform operations such as file reading, command execution, knowledge retrieval, external service access, sub-agent task invocation, and user confirmation through tool calls. Because tool call requests are dynamically generated by the model, the call sequence and parameters are difficult to predict in advance. Therefore, when tool calls fail, agents are prone to repeated attempts, parameter jitter, and recurring similar errors.
[0003] In actual operation, the agent may repeatedly read the same non-existent file path, repeatedly execute commands with missing dependencies or insufficient permissions, or continuously call related tools when external services or retrieval services are unavailable. Such repeated calls consume model context, tool resources, and user waiting time, and may increase the pressure on downstream services.
[0004] Traditional service circuit breaker mechanisms are typically designed for stable service interface traffic, often using request volume, error rate, time window, and concurrency as the main criteria for judgment. However, intelligent agent tool calls are characterized by model-driven processes, short-term concentrated processing, multi-tool exploration, and the potential for switching parameters or tools after failure. Directly applying traditional circuit breaker conditions can easily lead to false positives or false negatives.
[0005] For example, a simple fixed retry limit can only restrict the same request and is difficult to identify similar errors after changing parameters; a simple error rate circuit breaker is easily triggered by momentary failures when there are concentrated calls or concurrent calls in a short period of time; and a simple full-text error keyword scan may misjudge the error or traceback text in log files, search results, and error report documents as tool failures.
[0006] Furthermore, a successful tool call does not necessarily indicate a semantic success of the task. For example, a tool might return structured results with fields such as ok=false, success=false, or status=error. Conversely, the normal content returned by a tool might also contain text such as "Error" or "Traceback," for example, when reading log files, search results, or error report documents. Therefore, a simple full-text keyword scan cannot be used to determine if the tool has failed.
[0007] Search tools, retrieval tools, or document query tools may also return empty results, no-hit results, or low-confidence results. These results usually indicate that the business objective has not yet been achieved or that further exploration is needed, and do not necessarily indicate that the tool is malfunctioning. If these results are directly included in the tool failure statistics, it may cause the agent to be prematurely blocked during normal exploration.
[0008] Therefore, a circuit breaker mechanism more suitable for intelligent agent tool invocation scenarios is needed, which can accurately distinguish between tool execution failure, tool result failure, business failure to achieve results, and normal return content, and can handle two types of problems: continuous failure of the same call and repeated occurrence of the same type of error across time windows. Summary of the Invention
[0009] This invention provides a dual-track circuit breaker method for intelligent agent tool invocation, the main purpose of which is to address the problems raised in the background art above.
[0010] To achieve the above objectives, the present invention provides a dual-track circuit breaker method for intelligent agent tool calls, comprising: Obtain the tool invocation request generated by the intelligent agent unit. The tool invocation request includes a tool identifier and tool parameters. Integrate the session identifier, intelligent agent identifier, tool identifier, scope fingerprint, and parameter fingerprint corresponding to the tool invocation request into an invocation record key. Before executing the tool call request, query for consecutive failure records of the same call that match the call record key, and query for open error records that match at least one of the tool identifier and the scope fingerprint; When the same call failure record or the same type of error record is open and the preset cooldown time has not been exceeded, the execution of the tool call request will be blocked and a circuit breaker prompt message will be returned to the intelligent agent unit. When the tool call request is not blocked, the tool call request is executed and the tool call result is obtained. The tool call result is then subjected to two-layer tool failure identification to determine tool failure. If the tool failure is detected, the record of consecutive failures of the same call is updated based on the call record key, and an error fingerprint is generated based on the tool failure. The record of the same type of error within the time window is updated based on the error fingerprint. When the consecutive failure records of the same call meet the preset first circuit breaker condition, or the similar error records meet the preset second circuit breaker condition, the corresponding circuit breaker record is set to the open state. If no tool failure is detected, the consecutive failure records of the same call under the same session identifier and the same agent identifier are cleared, and the similar error records that are not in the half-open detection success state are retained.
[0011] Preferably, the two-layer tool failure identification includes: The system identifies tool execution failures and tool result failures, but does not perform a full-text error keyword scan on the tool call results. The tool's failure detection includes: The tool call processor throws a non-control flow exception, and the status field in the tool call result indicates the error status. The tool's failure identification includes: When the structured fields 'ok', 'success', 'status' in the tool call result indicate negation, failure, or execution failure, the tool call result is determined to be a tool result failure.
[0012] Preferably, the tool's failure identification further includes: When the tool call result, after removing the leading whitespace, begins with a preset failure identifier, the tool call result is determined to be a tool result failure. The preset failure identifiers include error identifiers, failure identifiers, exception identifiers, stack identifiers, or runtime exception type identifiers; If the tool call result contains error text, exception text, or stack trace text in the middle, but the tool call result does not meet the tool execution failure identification condition and the tool result failure identification condition, the tool call result will not be counted as a tool failure.
[0013] Preferably, the step of obtaining the parameter fingerprint includes: The parameter fingerprint is obtained by serializing the tool parameters and then calculating the hash value.
[0014] Preferably, the first fuse condition and the second fuse condition include: The first circuit breaker condition includes: the number of consecutive failures corresponding to the same call record key reaches a preset same call failure threshold; The second circuit breaker condition includes: within a preset time window, the number of occurrences of the same type of error in the records of the same type of error reaches a preset threshold for the same type of error, and the same type of error is distributed in no less than a preset number of time distribution units; The time distribution unit is determined based on the failure occurrence time and the preset time bucket length.
[0015] Preferably, the step of obtaining the erroneous fingerprint includes: An error fingerprint is obtained by normalizing at least one of the following elements in the error text: call identifier, tool call identifier, request identifier, trace identifier, session identifier, universally unique identifier, timestamp, line number, port number, network address, temporary directory path, and whitespace character, and then calculating the hash value.
[0016] Preferably, the step of obtaining the domain fingerprint includes: When the tool call request is a sub-agent task call, a scope fingerprint is generated based on the sub-agent type, agent name, or task name in the tool parameters.
[0017] Preferably, the half-open detection further includes: When the half-open probe call is successful, the corresponding circuit breaker record is closed; when the half-open probe call fails, the corresponding circuit breaker record is reset to the open state. When the half-open probe calls the corresponding error record of the same type and the probe fails, the failure occurrence time in the error record of the same type is reset to the current probe failure time.
[0018] Preferably, the tool invocation request includes: Calls include calls to common tools, file reading tools, command execution tools, retrieval tools, external services, and sub-agent tasks.
[0019] Preferably, the step of obtaining the records of consecutive failures of the same call and the records of similar errors further includes: The records of consecutive failures of the same call and the records of similar errors are stored in the process memory, database, distributed cache and key-value storage unit corresponding to the agent unit.
[0020] Compared with the prior art, the present invention has the following beneficial effects: This invention can prevent an agent from making consecutive invalid retries for the same failed tool parameters, and can identify problems where the same type of error keeps recurring within a time window, even when there are successful tool calls in between.
[0021] This invention can reduce the misjudgment of traditional error rate circuit breakers in scenarios where intelligent agents call a large number of times in a short period of time. It can avoid false triggering caused by full-text scanning of error keywords in logs, file content, and search results. It can distinguish and process business failures such as tool execution failure, tool result failure, empty results, missed results, or low confidence results.
[0022] This invention can distinguish the scope and strategy of ordinary tools and sub-agent task calls, reduce the probability of sub-agent calls being accidentally blocked, and restore tool call capabilities after a cooldown period through a half-open detection mechanism.
[0023] This invention can guide the model to stop repeated calls through circuit breaker prompt messages, and explain the reasons for failure, the parameters tried, and the next steps to the user. In cluster deployment scenarios, it can achieve consistent circuit breaker control among multiple instances by sharing circuit breaker records, atomic updates, and half-open probe locks. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating a dual-track circuit breaker method for intelligent agent tool calls, provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the overall architecture of a dual-track fuse method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the dual-track fusing method provided in an embodiment of the present invention; Figure 4 A schematic diagram of two-layer tool failure in a dual-track fuse method provided in an embodiment of the present invention; Figure 5 A schematic diagram illustrating the continuous failure record of the same call in a dual-track circuit breaker method provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the fusing state of a dual-track fusing method provided in an embodiment of the present invention; The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0025] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0026] This application provides a dual-track circuit breaker method for intelligent agent tool calls. The executing entity of this dual-track circuit breaker method for intelligent agent tool calls includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the dual-track circuit breaker method for intelligent agent tool calls can be executed by software or hardware installed on a terminal device or a server device. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks, and big data and artificial intelligence platforms.
[0027] Reference Figure 1 The diagram shown is a flowchart illustrating a dual-track circuit breaker method for intelligent agent tool calls according to an embodiment of the present invention. In this embodiment, the dual-track circuit breaker method for intelligent agent tool calls includes: Obtain the tool invocation request generated by the intelligent agent unit. The tool invocation request includes a tool identifier and tool parameters. Integrate the session identifier, intelligent agent identifier, tool identifier, scope fingerprint, and parameter fingerprint corresponding to the tool invocation request into an invocation record key. In this embodiment, the two-layer tool failure identification includes: The system identifies tool execution failures and tool result failures, but does not perform a full-text error keyword scan on the tool call results. The tool's failure detection includes: The tool call processor throws a non-control flow exception, and the status field in the tool call result indicates the error status. The tool's failure identification includes: When the structured fields 'ok', 'success', 'status' in the tool call result indicate negation, failure, or execution failure, the tool call result is determined to be a tool result failure.
[0028] Specifically, after a user requests entry into the large model agent, the tool invocation generation module generates a tool invocation request. This request passes through a tool failure circuit breaker before entering the tool execution module.
[0029] The tool failure circuit breaker middleware is used to query the circuit breaker record table, determine whether a tool call should be blocked, identify failures after a tool call, and update the circuit breaker record. The circuit breaker record table stores records of consecutive failures of the same call and records of similar errors. The tool execution module is used to actually execute ordinary tools or sub-agent tasks.
[0030] Specifically, the process first retrieves the tool calls output by the model, calculates the scope key and call record key, and then checks whether records of consecutive failed calls and similar errors are in an open state. If a record is in an open state and has not expired, a circuit breaker warning is returned directly. If a record is in an open state but has expired, a half-open probe is initiated. If no open record is found, the tool call is executed.
[0031] After the tool call is executed, the system extracts the failure text and determines whether it failed. If it failed, it updates the records of consecutive failures of the same call and the records of similar errors; if it succeeded, it clears the chain of consecutive failures of the same call and returns the tool result. For records of similar errors, except for successful half-open probes or records that have expired, other successful tool calls that occurred in between do not have their time windows directly cleared.
[0032] In this embodiment, the tool result failure identification further includes: When the tool call result, after removing the leading whitespace, begins with a preset failure identifier, the tool call result is determined to be a tool result failure. The preset failure identifiers include error identifiers, failure identifiers, exception identifiers, stack identifiers, or runtime exception type identifiers; If the tool call result contains error text, exception text, or stack trace text in the middle, but the tool call result does not meet the tool execution failure identification condition and the tool result failure identification condition, the tool call result will not be counted as a tool failure.
[0033] In this embodiment, the step of obtaining the parameter fingerprint includes: The parameter fingerprint is obtained by serializing the tool parameters and then calculating the hash value.
[0034] In this embodiment, the step of obtaining the domain fingerprint includes: When the tool call request is a sub-agent task call, a scope fingerprint is generated based on the sub-agent type, agent name, or task name in the tool parameters.
[0035] In this embodiment, the tool invocation request includes: Calls include calls to common tools, file reading tools, command execution tools, retrieval tools, external services, and sub-agent tasks.
[0036] Before executing the tool call request, query for consecutive failure records of the same call that match the call record key, and query for open error records that match at least one of the tool identifier and the scope fingerprint; In this embodiment, the step of obtaining the records of consecutive failures of the same call and the records of similar errors further includes: The records of consecutive failures of the same call and the records of similar errors are stored in the process memory, database, distributed cache and key-value storage unit corresponding to the agent unit.
[0037] When the same call failure record or the same type of error record is open and the preset cooldown time has not been exceeded, the execution of the tool call request will be blocked and a circuit breaker prompt message will be returned to the intelligent agent unit. When the tool call request is not blocked, the tool call request is executed and the tool call result is obtained. The tool call result is then subjected to two-layer tool failure identification to determine tool failure. If the tool failure is detected, the record of consecutive failures of the same call is updated based on the call record key, and an error fingerprint is generated based on the tool failure. The record of the same type of error within the time window is updated based on the error fingerprint. Specifically, when the same call corresponding to the same tool, scope, and parameters fails, the system increments the failure count of the consecutive failure record for the same call. If the failure count reaches a preset threshold for the same call failure, the corresponding record is set to an open state and the circuit breaker for the same call is triggered. If the threshold is not reached, the system continues to monitor the situation.
[0038] When any successful tool call occurs within the same session and the same agent, the system cleans up the record of consecutive failures of the same call to break the chain of consecutive failures. For example, two consecutive failures of read_file A can trigger a circuit breaker for the same call; however, if read_file A fails and then ls succeeds, and then read_file A fails again, the circuit breaker will not be triggered as if there were consecutive failures of the same call.
[0039] In detail, the agent calls `read_file("error.log")`, the tool executes successfully and returns the log text, which contains strings such as "Error", "Exception", or "Traceback" in the middle. Because the tool call result message does not display an error status and the result content does not begin with a leading failure indicator, the system does not count this tool call result as a tool failure.
[0040] Furthermore, upon detecting a tool failure, the error text is extracted and normalized. Normalization may include replacement call identifier, tool call identifier, request identifier, trace identifier, session identifier, universally unique identifier, timestamp, line number, port number, network address, temporary directory path, and compressed whitespace characters. The system then calculates the error fingerprint and adds the current time to the failure time series of the corresponding error record.
[0041] Delete failure times outside the preset statistics window, calculate the number of failures within the window, and calculate the number of active time buckets based on the failure time and time bucket length. When the number of failures within the window reaches the threshold for the same type of error, and the number of active time buckets reaches the preset time bucket threshold, the system will enable the corresponding error record for that type.
[0042] In one exemplary configuration, the preset statistics window is 60 seconds, the time bucket length is 10 seconds, the threshold for the same type of error is 3 times, and the time bucket threshold is 2. If all 3 errors of the same type occur within the same 10-second time bucket, the circuit breaker for the same type of error will not be triggered; if the 3 errors of the same type are distributed in at least 2 different time buckets, the circuit breaker for the same type of error will be triggered.
[0043] By setting both the number of failures threshold and the time bucket threshold, the system can prevent immediate circuit breaking when all failures fall into the same time bucket within a short period of time, while also capturing similar errors that occur continuously.
[0044] In this embodiment, the step of obtaining the erroneous fingerprint includes: An error fingerprint is obtained by normalizing at least one of the following elements in the error text: call identifier, tool call identifier, request identifier, trace identifier, session identifier, universally unique identifier, timestamp, line number, port number, network address, temporary directory path, and whitespace character, and then calculating the hash value.
[0045] When the consecutive failure records of the same call meet the preset first circuit breaker condition, or the similar error records meet the preset second circuit breaker condition, the corresponding circuit breaker record is set to the open state. If no tool failure is detected, the consecutive failure records of the same call under the same session identifier and the same agent identifier are cleared, and the similar error records that are not in the half-open detection success state are retained.
[0046] In this embodiment, the first fuse-breaking condition and the second fuse-breaking condition include: The first circuit breaker condition includes: the number of consecutive failures corresponding to the same call record key reaches a preset same call failure threshold; The second circuit breaker condition includes: within a preset time window, the number of occurrences of the same type of error in the records of the same type of error reaches a preset threshold for the same type of error, and the same type of error is distributed in no less than a preset number of time distribution units; The time distribution unit is determined based on the failure occurrence time and the preset time bucket length.
[0047] In this embodiment, the half-open detection further includes: When the half-open probe call is successful, the corresponding circuit breaker record is closed; when the half-open probe call fails, the corresponding circuit breaker record is reset to the open state. When the half-open probe calls the corresponding error record of the same type and the probe fails, the failure occurrence time in the error record of the same type is reset to the current probe failure time.
[0048] Specifically, the circuit breaker record includes closed, open, and half-open states. The closed state indicates that the tool call is executed normally; the open state indicates that the matching tool call is blocked; and the half-open state indicates that one probe call is allowed after the cooldown period ends.
[0049] When consecutive failures of the same call or similar error records meet the circuit breaker conditions, the circuit breaker record switches from the closed state to the open state. When the open state duration reaches the cooldown time, the circuit breaker record enters the half-open state. If the half-open probe call succeeds, the corresponding circuit breaker record is closed or cleared; if the half-open probe call fails, it re-enters the open state. For half-open probe failures of similar error records, the failure time series is reset to the current time.
[0050] In a multi-instance deployment, a half-open probe lock or probe lease can be written when entering a half-open state. The service instance that acquires the lock or lease executes a half-open probe call, while other service instances that do not acquire the lock or lease continue to process the application as open until the probe result updates the circuit breaker record.
[0051] Furthermore, in a single-instance deployment, circuit breaker records can be stored in the process's memory. In a multi-instance or cluster deployment, circuit breaker records can be stored in Redis, a database, a distributed cache, or a key-value store. Multiple agent service instances can read and write records of consecutive failures of the same call and similar errors through shared storage, so that a tool call failure detected by one instance can affect other instances within the same session, the same tenant, or the same agent scope.
[0052] In one alternative implementation, the shared circuit breaker record may include a record key, status, number of failures, open deadline, most recent failure time, most recent failure summary, error fingerprint, and failure time sequence. The shared storage may also be configured with an expiration time, allowing the record to be automatically cleared after the cooldown period ends or the session ends.
[0053] In one alternative implementation, updates to shared circuit breaker records employ atomic incrementing, optimistic locking, distributed locking, or scripted atomic operations. For example, in a distributed cache, a single atomic script can complete tasks such as reading failure times within a window, deleting expired failure times, appending the current failure time, calculating the number of active time buckets, and updating the circuit breaker status, thereby reducing count loss caused by concurrent updates.
[0054] More specifically, when a tool call hits an open circuit breaker record, the system does not continue executing the tool call. Instead, it constructs a tool call result message and returns it to the agent system. This message may include a message indicating that the tool call has triggered the circuit breaker, a warning not to retry the tool call, a summary of the most recent failure, the parameters already tried, and a suggested next step. This mechanism does not directly terminate the entire agent task; instead, it allows the agent to explain the reason for the failure, select an alternative, or request additional information from the user.
[0055] In one alternative implementation, the circuit breaker notification message further includes the circuit breaker type, the circuit breaker scope, the remaining cooldown time, and suggestions for alternative tools. The circuit breaker type may include circuit breaker for consecutive failures of the same call and circuit breaker for the same type of error time window.
[0056] To prevent the circuit breaker record from growing indefinitely, the system can be configured with a maximum number of records. When the total number of consecutive failure records of the same call and the number of records of the same type of error exceeds the preset maximum number of records, the system will first clean up expired open records; if it still exceeds the limit, the oldest record will be deleted according to the most recent failure time.
[0057] In one exemplary scenario, an agent continuously generates `read_file(" / a / b / not_exist.md")` tool calls, but the tool execution module returns a file non-existent error. The system generates identical call record keys based on the session identifier, agent identifier, tool identifier, scope fingerprint, and parameter fingerprint. After the number of consecutive failures reaches a threshold for identical call failures, the system opens the circuit breaker for identical calls. Subsequent identical call requests are blocked before execution, and a circuit breaker warning message is returned.
[0058] In this example, even if the model continues to generate the exact same file read requests, the tool failure circuit breaker will not continue to access the file system, thereby reducing invalid tool calls, context appending, and user wait time.
[0059] Furthermore, in an exemplary scenario, the agent sequentially generates search tool calls with different parameters, such as search("A"), search("B"), and search("C"), and the search service returns a connection timeout error in each call. Because the parameters are different, a chain of consecutive failures based solely on the same call record key may not trigger a circuit breaker. This invention normalizes the connection timeout error text and generates identical error fingerprints, enabling the aforementioned failures to fall within the same error time window.
[0060] When the number of similar errors within a window reaches a threshold and is distributed across at least a preset number of time buckets, the system activates the circuit breaker for similar errors. This prevents the agent from continuously making invalid calls to unavailable search services, even if it constantly changes its search parameters.
[0061] More specifically, instead of scanning the returned text for full-text error keywords, this invention identifies failures by combining the tool's execution status, structured failure fields, and leading failure identifiers. Therefore, it can reduce the probability of false circuit breakers when reading log files, error report documents, or searching for error information. This invention can also be implemented in the form of a computer program product.
[0062] In the several embodiments provided by this invention, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0063] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0064] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0065] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0066] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A dual-track circuit breaker method for intelligent agent tool invocation, characterized in that, The method includes: Obtain the tool invocation request generated by the intelligent agent unit. The tool invocation request includes a tool identifier and tool parameters. Integrate the session identifier, intelligent agent identifier, tool identifier, scope fingerprint, and parameter fingerprint corresponding to the tool invocation request into an invocation record key. Before executing the tool call request, query for consecutive failure records of the same call that match the call record key, and query for open error records that match at least one of the tool identifier and the scope fingerprint; When the same call failure record or the same type of error record is open and the preset cooldown time has not been exceeded, the execution of the tool call request will be blocked and a circuit breaker prompt message will be returned to the intelligent agent unit. When the tool call request is not blocked, the tool call request is executed and the tool call result is obtained. The tool call result is then subjected to two-layer tool failure identification to determine tool failure. If the tool failure is detected, the record of consecutive failures of the same call is updated based on the call record key, and an error fingerprint is generated based on the tool failure. The record of the same type of error within the time window is updated based on the error fingerprint. When the consecutive failure records of the same call meet the preset first circuit breaker condition, or the similar error records meet the preset second circuit breaker condition, the corresponding circuit breaker record is set to the open state. If no tool failure is detected, the consecutive failure records of the same call under the same session identifier and the same agent identifier are cleared, and the similar error records that are not in the half-open detection success state are retained.
2. The dual-track circuit breaker method for intelligent agent tool invocation as described in claim 1, characterized in that, The two-layer tool failure identification includes: The system identifies tool execution failures and tool result failures, but does not perform a full-text error keyword scan on the tool call results. The tool's failure detection includes: The tool call processor throws a non-control flow exception, and the status field in the tool call result indicates the error status. The tool's failure identification includes: When the structured fields 'ok', 'success', 'status' in the tool call result indicate negation, failure, or execution failure, the tool call result is determined to be a tool result failure.
3. The dual-track circuit breaker method for intelligent agent tool invocation as described in claim 2, characterized in that, The tool's failure identification also includes: When the tool call result, after removing the leading whitespace, begins with a preset failure identifier, the tool call result is determined to be a tool result failure. The preset failure identifiers include error identifiers, failure identifiers, exception identifiers, stack identifiers, or runtime exception type identifiers; If the tool call result contains error text, exception text, or stack trace text in the middle, but the tool call result does not meet the tool execution failure identification condition and the tool result failure identification condition, the tool call result will not be counted as a tool failure.
4. The dual-track circuit breaker method for intelligent agent tool invocation as described in claim 3, characterized in that, The steps for obtaining the parameter fingerprint include: The parameter fingerprint is obtained by serializing the tool parameters and then calculating the hash value.
5. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 1, characterized in that, The first fuse-breaking condition and the second fuse-breaking condition include: The first circuit breaker condition includes: the number of consecutive failures corresponding to the same call record key reaches a preset same call failure threshold; The second circuit breaker condition includes: within a preset time window, the number of occurrences of the same type of error in the records of the same type of error reaches a preset threshold for the same type of error, and the same type of error is distributed in no less than a preset number of time distribution units; The time distribution unit is determined based on the failure occurrence time and the preset time bucket length.
6. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 3, characterized in that, The steps for obtaining the erroneous fingerprint include: An error fingerprint is obtained by normalizing at least one of the following elements in the error text: call identifier, tool call identifier, request identifier, trace identifier, session identifier, universally unique identifier, timestamp, line number, port number, network address, temporary directory path, and whitespace character, and then calculating the hash value.
7. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 1, characterized in that, The steps for obtaining the scope fingerprint include: When the tool call request is a sub-agent task call, a scope fingerprint is generated based on the sub-agent type, agent name, or task name in the tool parameters.
8. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 7, characterized in that, The half-open detection also includes: When the half-open probe call is successful, the corresponding circuit breaker record is closed; when the half-open probe call fails, the corresponding circuit breaker record is reset to the open state. When the half-open probe calls the corresponding error record of the same type and the probe fails, the failure occurrence time in the error record of the same type is reset to the current probe failure time.
9. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 1, characterized in that, The tool invocation request includes: Calls to general tools, file reading tools, command execution tools, retrieval tools, external services, and sub-agent tasks.
10. A dual-track circuit breaker method for intelligent agent tool invocation as described in claim 1, characterized in that, The steps for obtaining consecutive failure records of the same call and similar error records also include: The records of consecutive failures of the same call and the records of similar errors are stored in the process memory, database, distributed cache and key-value storage unit corresponding to the agent unit.
