{"id":643,"date":"2026-03-21T22:52:58","date_gmt":"2026-03-21T14:52:58","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/tools-loop-detection\/"},"modified":"2026-03-21T23:08:53","modified_gmt":"2026-03-21T15:08:53","slug":"tools-loop-detection","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/tools-loop-detection\/","title":{"rendered":"Tool-loop detection"},"content":{"rendered":"<h1>Tool-loop detection<\/h1>\n<p>OpenClaw can keep agents from getting stuck in repeated tool-call patterns.<br \/>\nThe guard is <strong>disabled by default<\/strong>.<\/p>\n<p>Enable it only where needed, because it can block legitimate repeated calls with strict settings.<\/p>\n<h2>Why this exists<\/h2>\n<ul>\n<li>Detect repetitive sequences that do not make progress.<\/li>\n<li>Detect high-frequency no-result loops (same tool, same inputs, repeated errors).<\/li>\n<li>Detect specific repeated-call patterns for known polling tools.<\/li>\n<\/ul>\n<h2>Configuration block<\/h2>\n<p>Global defaults:<\/p>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  tools: {<br \/>\n    loopDetection: {<br \/>\n      enabled: false,<br \/>\n      historySize: 30,<br \/>\n      warningThreshold: 10,<br \/>\n      criticalThreshold: 20,<br \/>\n      globalCircuitBreakerThreshold: 30,<br \/>\n      detectors: {<br \/>\n        genericRepeat: true,<br \/>\n        knownPollNoProgress: true,<br \/>\n        pingPong: true,<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\nPer-agent override (optional):\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    list: [\n      {\n        id: &quot;safe-runner&quot;,\n        tools: {\n          loopDetection: {\n            enabled: true,\n            warningThreshold: 8,\n            criticalThreshold: 16,\n          },\n        },\n      },\n    ],\n  },\n}\n<\/code><\/pre>\n<h3>Field behavior<\/h3>\n<ul>\n<li><code>enabled<\/code>: Master switch. <code>false<\/code> means no loop detection is performed.<\/li>\n<li><code>historySize<\/code>: number of recent tool calls kept for analysis.<\/li>\n<li><code>warningThreshold<\/code>: threshold before classifying a pattern as warning-only.<\/li>\n<li><code>criticalThreshold<\/code>: threshold for blocking repetitive loop patterns.<\/li>\n<li><code>globalCircuitBreakerThreshold<\/code>: global no-progress breaker threshold.<\/li>\n<li><code>detectors.genericRepeat<\/code>: detects repeated same-tool + same-params patterns.<\/li>\n<li><code>detectors.knownPollNoProgress<\/code>: detects known polling-like patterns with no state change.<\/li>\n<li><code>detectors.pingPong<\/code>: detects alternating ping-pong patterns.<\/li>\n<\/ul>\n<h2>Recommended setup<\/h2>\n<ul>\n<li>Start with <code>enabled: true<\/code>, defaults unchanged.<\/li>\n<li>Keep thresholds ordered as <code>warningThreshold &lt; criticalThreshold &lt; globalCircuitBreakerThreshold<\/code>.<\/li>\n<li>If false positives occur:<\/li>\n<li>raise <code>warningThreshold<\/code> and\/or <code>criticalThreshold<\/code><\/li>\n<li>(optionally) raise <code>globalCircuitBreakerThreshold<\/code><\/li>\n<li>disable only the detector causing issues<\/li>\n<li>reduce <code>historySize<\/code> for less strict historical context<\/li>\n<\/ul>\n<h2>Logs and expected behavior<\/h2>\n<p>When a loop is detected, OpenClaw reports a loop event and blocks or dampens the next tool-cycle depending on severity.<br \/>\nThis protects users from runaway token spend and lockups while preserving normal tool access.<\/p>\n<ul>\n<li>Prefer warning and temporary suppression first.<\/li>\n<li>Escalate only when repeated evidence accumulates.<\/li>\n<\/ul>\n<h2>Notes<\/h2>\n<ul>\n<li><code>tools.loopDetection<\/code> is merged with agent-level overrides.<\/li>\n<li>Per-agent config fully overrides or extends global values.<\/li>\n<li>If no config exists, guardrails stay off.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Tool-loop detection OpenClaw can keep agents from getti [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":2,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":709,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/643\/revisions\/709"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}