openclaw - 💡(How to fix) Fix [Bug]: Tool call replay loop: runtime repeats agent's previous tool call after failure, causing infinite loops [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#73781Fetched 2026-04-29 06:15:16
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
labeled ×2commented ×1

Root Cause

  • Adding anti-loop rules to AGENTS.md (agent behavior config) — ineffective because the loop is at the runtime level
  • Increasing context window (100k → 200k → 500k) — delays ctx exhaustion but doesn't stop the loop
  • Manual stop command — only way to interrupt

Fix Action

Fix / Workaround

Workarounds Attempted

RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Bug Description

After upgrading to OpenClaw 2026.4.25, the agent enters an infinite tool loop where the runtime replays the agent's previous tool call after a tool failure, rather than allowing the agent to reason and take a new action. The agent does not "decide" to repeat — the runtime automatically re-emits the same tool call.

Symptoms

  1. Agent issues a tool call (e.g., exec)
  2. Tool returns failure/empty output
  3. Runtime feeds result back to agent
  4. Agent attempts to fix/reason
  5. Runtime replays the original tool call (not issued by the agent in this turn)
  6. Loop repeats indefinitely (observed up to 9+ iterations)

This also manifests as:

  • Successful workflows completing but then repeating anyway (e.g., file sent to Feishu, but the entire workflow replays)
  • Context window filling up with duplicate tool calls (ctx 100% before raising token limit to 500k)
  • Files growing with duplicate data appended each iteration

Environment

  • OpenClaw version: 2026.4.25 (aa36ee6)
  • Model: bailian/qwen3.5-plus
  • OS: macOS (Darwin 25.3.0, arm64)
  • Node.js: v22.22.0
  • Channel: Feishu (DM)

Timeline

  • Pre-2026.4.25: No tool loop issues
  • After 2026.4.25 upgrade: First symptom was ctx 100% (context window exhaustion)
  • Raised context limit to 200k, then 500k — ctx 100% stopped, but tool loops persist
  • Agent behavior rules (AGENTS.md) with anti-loop constraints are ineffective — the loop is at the runtime level, not agent decision level

Relevant Changelog Items (v2026.4.25)

The following changes in 2026.4.25 may be related:

  • Agents/runtime: submit heartbeat, cron, and exec wakeups as transient runtime context instead of visible user prompts
  • Auto-reply: poison inbound message dedupe after replay-unsafe provider/runtime failures
  • New openclaw.tool.loop OpenTelemetry spans suggest the team is aware of tool loop diagnostics

Expected Behavior

After a tool call fails and the agent receives the output, the agent should be able to reason and issue a new tool call (or no tool call). The runtime should not replay the previous tool call.

Actual Behavior

The runtime replays the agent's previous tool call automatically, creating an infinite loop that can only be stopped by manually killing the agent process.

Steps to Reproduce

  1. Run a multi-step workflow involving exec tool calls
  2. Trigger a tool failure (e.g., command returns non-zero exit code)
  3. Observe: agent attempts to reason/fix
  4. Observe: runtime replays the same tool call
  5. Loop continues until manually stopped

Workarounds Attempted

  • Adding anti-loop rules to AGENTS.md (agent behavior config) — ineffective because the loop is at the runtime level
  • Increasing context window (100k → 200k → 500k) — delays ctx exhaustion but doesn't stop the loop
  • Manual stop command — only way to interrupt

Logs / Evidence

In the WebUI, the agent shows repeated tool call → tool output → tool call sequences with identical tool inputs. The agent's own text output shows it attempting to reason, but the runtime keeps replaying the same tool call.

Example pattern (repeated 9 times): Agent: "让我查一下..." → exec: cat /path/to/config | python3 -c "..." → Tool output: (empty) Agent: "你说到了最关键的问题。让我查一下..." → exec: cat /path/to/config | python3 -c "..." (SAME call, replayed by runtime) → Tool output: (empty) ... repeats ...

Suggested Investigation

  1. Check the tool loop / replay logic introduced or modified in 2026.4.25
  2. Review poison inbound message dedupe after tool failures
  3. Verify that runtime context injection after tool failure doesn't trigger tool replay
  4. Consider adding a hard tool call loop limit at the runtime level (not agent level)

Steps to reproduce

Agent: "让我查一下..." → exec: cat /path/to/config | python3 -c "..." → Tool output: (empty) Agent: "你说到了最关键的问题。让我查一下..." → exec: cat /path/to/config | python3 -c "..." (SAME call, replayed by runtime) → Tool output: (empty) ... repeats ...

Expected behavior

Suggested Investigation

  1. Check the tool loop / replay logic introduced or modified in 2026.4.25
  2. Review poison inbound message dedupe after tool failures
  3. Verify that runtime context injection after tool failure doesn't trigger tool replay
  4. Consider adding a hard tool call loop limit at the runtime level (not agent level)

Actual behavior

No replay

OpenClaw version

2026.04.25

Operating system

macOS

Install method

No response

Model

qwen3.5-plus

Provider / routing chain

openclaw ->gateway ->qwen3.5

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The most likely fix is to modify the tool loop/replay logic introduced in OpenClaw version 2026.4.25 to prevent the runtime from automatically replaying the previous tool call after a tool failure.

Guidance

  • Review the changes made in OpenClaw version 2026.4.25, specifically the Agents/runtime: submit heartbeat, cron, and exec wakeups as transient runtime context instead of visible user prompts and Auto-reply: poison inbound message dedupe after replay-unsafe provider/runtime failures changes, to understand how they may be contributing to the tool loop issue.
  • Verify that the runtime context injection after tool failure is not triggering the tool replay, and consider adding a hard tool call loop limit at the runtime level to prevent infinite loops.
  • Investigate the openclaw.tool.loop OpenTelemetry spans to see if they provide any insights into the tool loop diagnostics.
  • Consider downgrading to a previous version of OpenClaw to see if the issue persists, to isolate the problem to the 2026.4.25 release.

Example

No code example is provided as the issue is related to the OpenClaw runtime behavior and not a specific code snippet.

Notes

The issue seems to be specific to the OpenClaw version 2026.4.25 and the qwen3.5-plus model, and may not be reproducible in other environments or versions.

Recommendation

Apply a workaround by adding a hard tool call loop limit at the runtime level, as the root cause of the issue is likely related to the changes introduced in OpenClaw version 2026.4.25, and a fix may require modifications to the OpenClaw runtime logic.

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 [Bug]: Tool call replay loop: runtime repeats agent's previous tool call after failure, causing infinite loops [1 comments, 2 participants]