openclaw - 💡(How to fix) Fix Circuit breaker: auto-reset sessions after N consecutive aborts [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#59161Fetched 2026-04-08 02:28:01
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants
RAW_BUFFERClick to expand / collapse

Problem

When a session accumulates toxic context (e.g., from repeated failures or bad state), the gateway keeps replaying that poisoned context on every retry, causing the same abort loop.

Proposed Solution

The gateway should detect this pattern natively: if the same session has been aborted N times consecutively (e.g., 3), it should auto-reset to a fresh session instead of replaying the toxic context.

Essentially a "circuit breaker" for poisoned sessions.

Details

  • Configurable threshold (default: 3 consecutive aborts)
  • On trigger: discard the poisoned session context and start fresh
  • Prevents infinite abort loops that waste tokens and time
  • Could optionally log/notify when circuit breaker fires

Filed on behalf of Qi.

extent analysis

TL;DR

Implement a circuit breaker mechanism to auto-reset sessions after a configurable number of consecutive aborts to prevent infinite loops.

Guidance

  • Introduce a counter to track consecutive aborts for each session, resetting it upon successful completion.
  • Set a configurable threshold (e.g., 3) for the number of consecutive aborts allowed before triggering a session reset.
  • Upon reaching the threshold, discard the current session context and initiate a new session.
  • Consider logging or notifying when the circuit breaker is triggered for monitoring and debugging purposes.

Example

class SessionManager:
    def __init__(self, threshold=3):
        self.threshold = threshold
        self.abort_count = 0

    def handle_abort(self):
        self.abort_count += 1
        if self.abort_count >= self.threshold:
            self.reset_session()
            self.abort_count = 0

    def reset_session(self):
        # Discard current session context and start fresh
        pass

    def handle_success(self):
        self.abort_count = 0

Notes

This approach assumes that the session context can be safely discarded and restarted without significant side effects. The threshold value may need to be adjusted based on the specific application requirements and failure patterns.

Recommendation

Apply workaround: Implement the proposed circuit breaker mechanism to prevent infinite abort loops and reduce waste of resources. This approach directly addresses the problem by introducing a mechanism to detect and reset poisoned sessions, thereby preventing the replay of toxic context.

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