openclaw - 💡(How to fix) Fix feat: Tool error circuit breaker & edit safety pre-validation [1 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#72555Fetched 2026-04-28 06:34:34
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

Before executing edit: IF oldText == newText: → Reject immediately with clear error: "oldText and newText are identical. No change will be made." → Do NOT count against retry limits

Root Cause

  1. No pre-validation: edit tool doesn't check if oldText == newText before execution
  2. AI can't self-correct: When the model generates identical oldText/newText, it doesn't recognize the error as "non-retryable"
  3. No circuit breaker: System has no hard limit on repeated tool failures
  4. Error messages unclear: Type mismatch errors don't clearly indicate "parameters are identical"

Code Example

Before executing edit:
  IF oldText == newText:
Reject immediately with clear error:
      "oldText and newText are identical. No change will be made."
Do NOT count against retry limits

---

Per tool, per session:
  IF same tool returns same error N times:
Force pause, notify user
Do NOT allow retry without user intervention

Recommended thresholds:
  - edit: 3 identical errors → circuit break
  - exec: 5 identical errors → circuit break
  - Other tools: 5 identical errors → circuit break

---

Tool Error Handling Rules:
1. If a tool returns the SAME error 3 times → STOP immediately
2. Do NOT retry with identical parameters
3. Classify errors:
   - "Not found" / "No match" → parameter error, NOT retryable
   - "Timeout" / "Rate limited" → retryable, backoff
4. After stopping, report status and wait for user instruction
5. Maximum 5 retries total for any single operation
RAW_BUFFERClick to expand / collapse

OpenClaw Improvement Proposal: Tool Error Circuit Breaker & Edit Safety

Date: 2026-04-27
Severity: Medium (token waste, task blocking)
Environment: OpenClaw 2026.4.22, WSL2, Linux


Problem Summary

The edit tool enters infinite retry loops when oldText and newText are identical, causing massive token waste (50K-80K tokens per incident).

Incident Log

DateRetriesTokens WastedRoot Cause
2026-04-24 16:0030+~20KoldText == newText, edit fails, AI retries same params
2026-04-27 08:44100+~50K-80KSame issue, AI retries 100+ times

Root Cause Analysis

  1. No pre-validation: edit tool doesn't check if oldText == newText before execution
  2. AI can't self-correct: When the model generates identical oldText/newText, it doesn't recognize the error as "non-retryable"
  3. No circuit breaker: System has no hard limit on repeated tool failures
  4. Error messages unclear: Type mismatch errors don't clearly indicate "parameters are identical"

Proposed Solutions

1. System-Level: Edit Tool Pre-Validation (Highest Priority)

Before executing edit:
  IF oldText == newText:
    → Reject immediately with clear error:
      "oldText and newText are identical. No change will be made."
    → Do NOT count against retry limits

2. System-Level: Tool Circuit Breaker

Per tool, per session:
  IF same tool returns same error N times:
    → Force pause, notify user
    → Do NOT allow retry without user intervention

Recommended thresholds:
  - edit: 3 identical errors → circuit break
  - exec: 5 identical errors → circuit break
  - Other tools: 5 identical errors → circuit break

3. System-Level: Error Classification

Distinguish between:

  • Retryable errors: timeout, network, rate limit, temporary failures
  • Non-retryable errors: parameter validation, type mismatch, identical content

Non-retryable errors should:

  • Not trigger automatic retry
  • Clear the retry counter
  • Optionally notify user immediately

4. Agent Behavior Guidelines (Documentation)

Add to agent system prompt or behavior docs:

Tool Error Handling Rules:
1. If a tool returns the SAME error 3 times → STOP immediately
2. Do NOT retry with identical parameters
3. Classify errors:
   - "Not found" / "No match" → parameter error, NOT retryable
   - "Timeout" / "Rate limited" → retryable, backoff
4. After stopping, report status and wait for user instruction
5. Maximum 5 retries total for any single operation

Impact Assessment

MetricValue
Token waste per incident50K-100K tokens
Frequency2 incidents in 4 days
Monthly budget impact7-10% if unaddressed
Data loss riskNone (idempotent operations)
Task blockingYes, retries consume session turns

Implementation Priority

PrioritySolutionEffortImpact
🔴 P0edit pre-validation (oldText == newText)LowHigh
🔴 P0Circuit breaker (3 same errors → stop)MediumHigh
🟡 P1Error classification (retryable vs non-retryable)MediumMedium
🟡 P1Agent behavior guidelines updateLowMedium
🟢 P2Retry with exponential backoffMediumLow

Additional Context

  • Running in WSL2 environment
  • Token budget: 50K daily / 1M monthly (百炼 Lite plan)
  • Model: bailian/qwen3.5-plus (fallback: ollama/deepseek-r1:1.5b)
  • System uptime: 41+ days stable before these incidents

This proposal is based on real incidents observed in production. The author is a community user running OpenClaw for personal assistant use.

extent analysis

TL;DR

Implementing a pre-validation check in the edit tool to reject identical oldText and newText inputs can prevent infinite retry loops and token waste.

Guidance

  • Verify the proposed solution by testing the edit tool with identical oldText and newText inputs to ensure it rejects the request immediately.
  • Implement a circuit breaker mechanism to force a pause and notify the user after a specified number of identical errors (e.g., 3 errors).
  • Review and update the error classification system to distinguish between retryable and non-retryable errors, ensuring that identical content errors are classified as non-retryable.
  • Consider updating the agent behavior guidelines to include rules for handling tool errors, such as stopping after 3 identical errors and not retrying with identical parameters.

Example

def edit_tool(oldText, newText):
    if oldText == newText:
        raise ValueError("oldText and newText are identical. No change will be made.")
    # ... rest of the edit tool implementation ...

Notes

The proposed solutions focus on addressing the specific issue of infinite retry loops caused by identical oldText and newText inputs. However, the implementation of these solutions may require additional considerations, such as handling edge cases and ensuring compatibility with existing system components.

Recommendation

Apply the workaround by implementing the pre-validation check in the edit tool, as it is a low-effort, high-impact solution that can immediately prevent token waste and task blocking.

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…

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 feat: Tool error circuit breaker & edit safety pre-validation [1 participants]