openclaw - 💡(How to fix) Fix Bug: Circuit breaker blocks tool but not agent turn; exec loop only warns, never blocks [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75355Fetched 2026-05-01 05:34:47
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Timeline (top)
labeled ×2closed ×1commented ×1

When the global circuit breaker triggers, it blocks the tool execution but does not terminate the agent turn. The agent continues to retry indefinitely. Additionally, exec tool loops only produce warnings and never reach critical/block status because the tool output changes on each call (e.g., timestamps).

Error Message

The circuit breaker correctly blocked the tool after 30 calls. However, the agent turn was NOT terminated. The agent kept retrying, and each retry was blocked, producing an endless stream of error logs. 3. Escalating warnings with hard stop: After N warnings (e.g., 20), the system should force-terminate the turn rather than continuing to warn. The agent should not be allowed to continue after the critical threshold.

  • Log pollution: Endless error logs fill up the log file, making it hard to diagnose other issues

Root Cause

  1. Circuit breaker only blocks tool execution, not agent turn: When blocked: true is returned, the tool call fails but the agent continues its reasoning loop. The agent does not receive a clear signal to abandon the task.
  2. exec detection checks output, not just parameters: The loop detection compares tool name + parameter hash + result hash. For exec, the result changes on every call (e.g., date command returns different timestamps), so the detection never sees "identical no-progress outcomes" and never triggers critical/block.
  3. Warnings are ineffective: The agent receives warning messages like "WARNING: You have called exec 10 times with identical arguments. If this is not making progress, stop retrying and report the task as failed." but completely ignores them and continues the loop.

Code Example

### Evidence from logs

#### Phase 1: `tdai_conversation_search` loop (08:24 - 08:29)
08:24:48 tools loop: tools=tdai_dialogue_search_level=warning action=warning detector=generic_repeat count=10
08:25:24 tools loop: tools=tdai_dialogue_search_level=warning action=warning detector=generic_repeat count=20
08:26:23 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
08:26:27 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
08:26:30 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
... (continues indefinitely, every ~3 - 4 seconds)

The circuit breaker correctly blocked the tool after 30 calls. However, the agent turn was NOT terminated. The agent kept retrying, and each retry was blocked, producing an endless stream of error logs.
#### Phase 2: `exec` loop (08:38 - 08:42+)
08:38:58 Loop warning: exec is called 10 times with the same parameters 08:39:06 Loop warning: exec is called 11 times with the same parameters 08:39:12 Loop warning: exec is called 12 times with the same parameters... (Lasts more than 30 calls) 08:41:18 Loop warning: exec is called 30 times with the same parameters 08:41:23 Loop warning: exec is called 30 times with the same parameters... (Infinite duration)
The `exec` tool loop never reached critical/block status. The detection logic saw different outputs on each call (system command returns with different timestamps) and classified them as "making progress", so only warnings were emitted. The agent continued executing the same command 30+ times.
### Root Cause Analysis
1. **Circuit breaker only blocks tool execution, not agent turn**: When `blocked: true` is returned, the tool call fails but the agent continues its reasoning loop. The agent does not receive a clear signal to abandon the task.
2. **`exec` detection checks output, not just parameters**: The loop detection compares tool name + parameter hash + result hash. For `exec`, the result changes on every call (e.g., `date` command returns different timestamps), so the detection never sees "identical no-progress outcomes" and never triggers critical/block.
3. **Warnings are ineffective**: The agent receives warning messages like "WARNING: You have called exec 10 times with identical arguments. If this is not making progress, stop retrying and report the task as failed." but completely ignores them and continues the loop.
### Proposed Solutions
1. **Terminate agent turn on circuit breaker**: When `global_circuit_breaker` triggers, the agent turn should be terminated immediately. The agent should receive a system message indicating the task cannot be completed and should report failure to the user.
2. **Parameter-only detection for `exec` and similar tools**: For tools where the output naturally changes (like `exec`, `read`, `browser`), the loop detection should only compare tool name + parameter hash, ignoring the result hash. If the same command is executed multiple times, it is a loop regardless of output.
3. **Escalating warnings with hard stop**: After N warnings (e.g., 20), the system should force-terminate the turn rather than continuing to warn. The agent should not be allowed to continue after the critical threshold.
4. **Better agent guidance**: The warning message should be more explicit: "This is warning #20 of 20. The task will be terminated. You must report failure to the user now."
### Impact
- **Token waste**: Each loop iteration consumes input tokens for the agent to process the blocked result and decide to retry again
- **Log pollution**: Endless error logs fill up the log file, making it hard to diagnose other issues
- **User experience**: User sees the agent "stuck" with no clear failure message
### Alternatives Considered
- **Lowering thresholds**: Would reduce the number of wasted calls but does not solve the fundamental issue of the agent not terminating
- **Disabling loop detection**: Would allow the circuit breaker to work but leaves the agent in an infinite loop
- **Manual intervention**: Requires user to manually stop the agent, which is not practical for autonomous operation
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

When the global circuit breaker triggers, it blocks the tool execution but does not terminate the agent turn. The agent continues to retry indefinitely. Additionally, exec tool loops only produce warnings and never reach critical/block status because the tool output changes on each call (e.g., timestamps).

Steps to reproduce

  1. Send a message that triggers a tool call returning identical results (e.g., tdai_conversation_search with a query that returns the same cached results)
  2. Agent enters a loop calling the same tool with identical parameters
  3. After 30 calls, global circuit breaker triggers and blocks the tool
  4. Expected: Agent turn terminates, agent reports failure
  5. Actual: Agent continues to retry the same tool indefinitely; each retry is blocked but agent never gives up

Expected behavior

Don't repeat it without limits

Actual behavior

NOT_ENOUGH_INFO

OpenClaw version

2026.4.25

Operating system

opencloud

Install method

No response

Model

qwencode/qwen3.5-plus

Provider / routing chain

feishu - openclaw -modle

Additional provider/model setup details

No response

Logs, screenshots, and evidence

### Evidence from logs

#### Phase 1: `tdai_conversation_search` loop (08:24 - 08:29)
08:24:48 tools loop: tools=tdai_dialogue_search_level=warning action=warning detector=generic_repeat count=10
08:25:24 tools loop: tools=tdai_dialogue_search_level=warning action=warning detector=generic_repeat count=20
08:26:23 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
08:26:27 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
08:26:30 Tools loop: tools=tdai_dialogue_search_level=critical action=block detector=global_circuit_breaker_count=30
... (continues indefinitely, every ~3 - 4 seconds)

The circuit breaker correctly blocked the tool after 30 calls. However, the agent turn was NOT terminated. The agent kept retrying, and each retry was blocked, producing an endless stream of error logs.
#### Phase 2: `exec` loop (08:38 - 08:42+)
08:38:58 Loop warning: exec is called 10 times with the same parameters 08:39:06 Loop warning: exec is called 11 times with the same parameters 08:39:12 Loop warning: exec is called 12 times with the same parameters... (Lasts more than 30 calls) 08:41:18 Loop warning: exec is called 30 times with the same parameters 08:41:23 Loop warning: exec is called 30 times with the same parameters... (Infinite duration)
The `exec` tool loop never reached critical/block status. The detection logic saw different outputs on each call (system command returns with different timestamps) and classified them as "making progress", so only warnings were emitted. The agent continued executing the same command 30+ times.
### Root Cause Analysis
1. **Circuit breaker only blocks tool execution, not agent turn**: When `blocked: true` is returned, the tool call fails but the agent continues its reasoning loop. The agent does not receive a clear signal to abandon the task.
2. **`exec` detection checks output, not just parameters**: The loop detection compares tool name + parameter hash + result hash. For `exec`, the result changes on every call (e.g., `date` command returns different timestamps), so the detection never sees "identical no-progress outcomes" and never triggers critical/block.
3. **Warnings are ineffective**: The agent receives warning messages like "WARNING: You have called exec 10 times with identical arguments. If this is not making progress, stop retrying and report the task as failed." but completely ignores them and continues the loop.
### Proposed Solutions
1. **Terminate agent turn on circuit breaker**: When `global_circuit_breaker` triggers, the agent turn should be terminated immediately. The agent should receive a system message indicating the task cannot be completed and should report failure to the user.
2. **Parameter-only detection for `exec` and similar tools**: For tools where the output naturally changes (like `exec`, `read`, `browser`), the loop detection should only compare tool name + parameter hash, ignoring the result hash. If the same command is executed multiple times, it is a loop regardless of output.
3. **Escalating warnings with hard stop**: After N warnings (e.g., 20), the system should force-terminate the turn rather than continuing to warn. The agent should not be allowed to continue after the critical threshold.
4. **Better agent guidance**: The warning message should be more explicit: "This is warning #20 of 20. The task will be terminated. You must report failure to the user now."
### Impact
- **Token waste**: Each loop iteration consumes input tokens for the agent to process the blocked result and decide to retry again
- **Log pollution**: Endless error logs fill up the log file, making it hard to diagnose other issues
- **User experience**: User sees the agent "stuck" with no clear failure message
### Alternatives Considered
- **Lowering thresholds**: Would reduce the number of wasted calls but does not solve the fundamental issue of the agent not terminating
- **Disabling loop detection**: Would allow the circuit breaker to work but leaves the agent in an infinite loop
- **Manual intervention**: Requires user to manually stop the agent, which is not practical for autonomous operation

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The agent turn should be terminated when the global circuit breaker triggers, and loop detection for exec tools should be based on parameters only, not output.

Guidance

  • Implement a mechanism to terminate the agent turn immediately when the global_circuit_breaker triggers, ensuring the agent reports failure to the user.
  • Modify the loop detection logic for exec and similar tools to compare only tool name and parameter hash, ignoring the result hash to correctly identify loops.
  • Introduce escalating warnings with a hard stop after a certain threshold (e.g., 20 warnings) to prevent indefinite looping.
  • Enhance warning messages to guide the agent to report failure after a specified number of warnings.

Example

# Pseudo-code example for terminating agent turn on circuit breaker trigger
if global_circuit_breaker_triggered:
    terminate_agent_turn()
    report_failure_to_user()

Notes

The provided solutions aim to address the root causes identified: the circuit breaker not terminating the agent turn and the loop detection logic being ineffective for exec tools due to changing outputs. Implementing these changes should mitigate the issues of token waste, log pollution, and poor user experience.

Recommendation

Apply the proposed workaround by implementing the necessary changes to the circuit breaker and loop detection logic to ensure the agent turn is terminated when the global circuit breaker triggers and to improve loop detection for exec tools. This approach directly addresses the identified root causes and should provide a more robust solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Don't repeat it without limits

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: Circuit breaker blocks tool but not agent turn; exec loop only warns, never blocks [1 comments, 2 participants]