Skip to content

globalCircuitBreakerThreshold is per-tool-type, not session-global — allows cross-tool loop evasion #79252

Closed as not planned

Description

@xiachuncheng

Problem

The globalCircuitBreakerThreshold setting is implemented as a per-tool-type counter, not a session-level global counter. This allows agents to evade the circuit breaker by switching tools, leading to unbounded loops.

Real-world incident

  • Date: 2026-05-08
  • Session: feishu DM, model qwen/qwen3.5-plus
  • What happened: Agent entered a loop calling wecom_mcp → blocked after 5 calls → switched to exec → blocked after 5 calls → switched to memory_search → blocked after 5 calls → switched again... repeated across 4+ tools.
  • Result: ~60+ LLM calls, ~750k input tokens consumed, user had to manually /stop
  • Root cause: globalCircuitBreakerThreshold resets its counter for each tool type, so switching tools resets the count

Expected behavior

Per documentation: globalCircuitBreakerThreshold is described as "global no-progress breaker threshold". The word "global" implies it should count across all tools within a session, not per-tool-type.

Actual behavior

Each tool type has its own independent counter. Switching tools resets the count:

Tool Calls before block After block
wecom_mcp 5 blocked → switch to exec
exec 5 blocked → switch to memory_search
memory_search 5 blocked → switch to sessions_list
... ... continues indefinitely

Proposed fix

Track no-progress counts at the session level, not per-tool-type:

{
  "tools": {
    "loopDetection": {
      "globalCircuitBreakerThreshold": 5  // total across ALL tools in session
    }
  }
}

When the session-level counter reaches the threshold, block all tool calls (not just the current tool) and force the agent to produce a text response.

Workaround

Lower the threshold to 2-3 to reduce the blast radius of each tool switch, but this does not solve the fundamental issue.

Environment

  • OpenClaw 2026.5.6
  • Ubuntu 24.04
  • Model: qwen/qwen3.5-plus

Activity

  1. clawsweeper commented on May 8, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    Keep open: current main still allows stable three-tool rotations to evade critical loop detection, although bounded recovery mitigates the original block-and-switch sequence.

    Reproducibility: Source establishes that three stable successful tool signatures rotating within the 30-call window stay below critical thresholds and escape the two-pattern detector; no live reproduction is claimed.

    Root-cause cluster
    Relationship: canonical
    Canonical: #79252
    Summary: This issue remains the focused cross-tool counting report; the historical fix is unmerged and the open semantic-stagnation report covers broader behavior.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Maintainer decision needed

    • Question: Which stable outcomes should accumulate across tools, and which changes should reset the shared no-progress count?
    • Recommendation: Aggregate repeated stable patterns: Define conservative evidence and reset rules, then prove a three-tool rotation reaches critical admission without blocking progressing workflows.
    • Why: The counting gap is concrete, but current tests preserve legitimate stable successes and do not define cross-tool progress semantics.

    Next step
    Define cross-tool progress and reset rules, then establish a failing three-tool rotation regression through production admission before implementing the shared cutoff.

    Review details

    Best possible solution:

    Extend the existing run-scoped detector with conservative cross-tool aggregation that feeds the existing bounded recovery mechanism.

    Do we have a high-confidence way to reproduce the issue?

    Source establishes that three stable successful tool signatures rotating within the 30-call window stay below critical thresholds and escape the two-pattern detector; no live reproduction is claimed.

    Is this the best way to solve the issue?

    Shared counting addresses the gap, but counting every call or requiring identical hashes across unrelated tools is insufficient; aggregate repeated patterns with explicit progress resets.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Shared counting needs explicit qualifying-outcome and progress-reset rules to avoid stopping legitimate multi-tool workflows.
    • The remaining rotation gap is source-proven; no current-main Gateway reproduction was run.

    Codex review notes: model internal, reasoning medium; reviewed against 279739bbd9e1.

    Label changes

    Label changes:

    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: Enabled rolling detection retains a bounded coverage gap, while current critical recovery mitigates the original repeated-block sequence.
    • impact:other: Undetected tool rotations can waste model tokens and computation without completing the requested task.
    Evidence reviewed

    What I checked:

    • Current counting gap: The global breaker consumes getNoProgressStreak(history, toolName, currentHash); ordinary counting skips different tools and argument hashes instead of accumulating their stable outcomes. (src/agents/tool-loop-no-progress.ts:39, 279739bbd9e1)
    • Bounded history prevents escalation: History retains 30 calls, generic critical detection requires 20 matching outcomes, and the global breaker requires 30; three evenly rotating signatures retain only ten outcomes each, while ping-pong detection requires two alternating signatures. (src/agents/tool-loop-detection.ts:56, 279739bbd9e1)
    • Production admission: Enabled admission evaluates the detector with the current run ID and produces a critical intervention only for a critical classification; warning-only rotations do not enter bounded recovery. (src/agents/tool-loop-admission.ts:51, 279739bbd9e1)
    • Partial mitigation: The agent loop remembers the first critical intervention and terminates on another critical loop; this limits repeated detected loops but does not detect three-tool rotations. (packages/agent-core/src/agent-loop.ts:537, 279739bbd9e1)
    • Current documented behavior: https://docs.openclaw.ai/tools/loop-detection documents optional rolling detection, one recovery response with normal tools, and termination after another critical detection; the old numeric threshold setting is no longer exposed. (docs/tools/loop-detection.md:1, 279739bbd9e1)
    • False-positive contract: Existing coverage explicitly keeps generic stable successes warning-only when varying arguments lack semantic no-progress evidence, so indiscriminate shared counting would change established behavior. (src/agents/tool-loop-detection.test.ts:300, 279739bbd9e1)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 27, 2026, 4:31 AM ET / 08:31 UTC.

  2. barnacle-openclaw commented on May 31, 2026

    @barnacle-openclaw

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  3. added
    P2Normal backlog priority with limited blast radius.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    no-staleExclude from stale automation
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    and removed
    staleMarked as stale due to inactivity
    no-staleExclude from stale automation
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    on Jun 14, 2026
  4. 34 remaining items

  5. added
    P2Normal backlog priority with limited blast radius.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    and removed
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    on Sep 21, 2026
  6. added
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    clawsweeper:intake:needs-reproPreliminary submission classification; full source review pending.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    and removed
    clawsweeper:intake:bugPreliminary submission classification; full source review pending.
    clawsweeper:intake:needs-reproPreliminary submission classification; full source review pending.
    on Oct 27, 2026
  7. openclaw-barnacle commented on Oct 28, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale after 7 days without qualifying human activity.
    Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
    A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

  8. openclaw-barnacle commented on Nov 5, 2026

    @openclaw-barnacle

    Closing as not planned after the inactivity notice and full retest/update grace. This is an administrative close; the reported problem has not been confirmed fixed. Please reopen with current reproduction details if it still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions