openclaw - 💡(How to fix) Fix Claude Opus can produce false-success empty terminal turns (stop=stop, content=[], usage=0) leading to 'Agent couldn't generate a response' [2 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#71880Fetched 2026-04-26 05:07:05
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×2closed ×1

On OpenClaw 2026.4.23, Claude Opus 4.6 / 4.7 can intermittently fail with:

⚠️ Agent couldn't generate a response. Please try again.

In the failing cases, the assistant turn is sometimes recorded as a false-success empty terminal turn instead of an error:

  • stopReason = "stop"
  • content = []
  • usage.input = 0
  • usage.output = 0
  • usage.totalTokens = 0

This makes the run look like a normal completion even though no model output was produced.

Error Message

Between roughly 2026-04-26 07:50 and 09:15 Asia/Shanghai, Claude Opus 4.6 / 4.7 repeatedly failed in both Telegram and the web UI with the same user-facing error.

Root Cause

There was also compaction activity around some of the early failures in the old session, so compaction may have amplified the user-visible failure pattern. However, this does not fully explain the issue, because the problem also reappeared after /new.

Code Example

{
  "model": "claude-opus-4.6",
  "stop": "stop",
  "usage": {
    "input": 0,
    "output": 0,
    "cacheRead": 0,
    "cacheWrite": 0,
    "totalTokens": 0
  },
  "blocks": [],
  "textLen": 0,
  "raw": []
}
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.4.23, Claude Opus 4.6 / 4.7 can intermittently fail with:

⚠️ Agent couldn't generate a response. Please try again.

In the failing cases, the assistant turn is sometimes recorded as a false-success empty terminal turn instead of an error:

  • stopReason = "stop"
  • content = []
  • usage.input = 0
  • usage.output = 0
  • usage.totalTokens = 0

This makes the run look like a normal completion even though no model output was produced.

Environment

  • OpenClaw: 2026.4.23 (a979721)
  • Runtime: embedded Pi runner
  • Provider path: myclaw with anthropic-messages
  • Affected models observed: claude-opus-4.6, claude-opus-4.7
  • Comparison model: gpt-5.4 on openai-responses succeeded during the same period

Observed behavior

Between roughly 2026-04-26 07:50 and 09:15 Asia/Shanghai, Claude Opus 4.6 / 4.7 repeatedly failed in both Telegram and the web UI with the same user-facing error.

Important details:

  1. The problem was not channel-specific. It reproduced in both Telegram and the web UI.
  2. It was not limited to one corrupted old session. /new did not reliably recover it.
  3. In at least some failing runs, the session transcript recorded an assistant turn with:
    • stopReason: "stop"
    • empty content
    • zero token usage
  4. GPT-5.4 worked normally after switching away from Claude.

Concrete evidence

Example failing assistant turns from local session transcript (2026-04-26T00:04:50Z, 00:06:33Z, 00:07:42Z):

{
  "model": "claude-opus-4.6",
  "stop": "stop",
  "usage": {
    "input": 0,
    "output": 0,
    "cacheRead": 0,
    "cacheWrite": 0,
    "totalTokens": 0
  },
  "blocks": [],
  "textLen": 0,
  "raw": []
}

At the UI level this surfaced as:

⚠️ Agent couldn't generate a response. Please try again.

Why this seems like an OpenClaw bug

The key issue is not just that a provider path may have failed.

The more serious problem is that OpenClaw appears to accept a zero-token, empty-content assistant turn with stopReason="stop" as a successful terminal result.

That should probably not be treated as a valid success state.

Even if the upstream provider / proxy path is flaky, a terminal turn with all of the following:

  • no visible content
  • no tool call
  • no usage
  • stopReason = "stop"

should likely be upgraded to an internal error, retry, or fallback condition instead of being treated as a normal completion.

Additional context

There was also compaction activity around some of the early failures in the old session, so compaction may have amplified the user-visible failure pattern. However, this does not fully explain the issue, because the problem also reappeared after /new.

So the most likely interpretation is:

  • there may be instability in the Claude / Anthropic path,
  • and OpenClaw does not robustly handle the resulting empty terminal turn.

Suggested fix

Treat this state as invalid / retryable for all providers, not only specific strict-agentic lanes:

  • stopReason === "stop"
  • assistant content empty
  • no tool calls
  • total token usage is zero

Possible handling:

  1. convert to error, or
  2. trigger one automatic retry, or
  3. trigger fallback

Instead of surfacing it directly as a normal completed assistant turn.

Repro notes

This was observed multiple times with Claude Opus 4.6 / 4.7 during the same time window, while GPT-5.4 remained functional.

I can provide more local transcript / trajectory details if needed.

extent analysis

TL;DR

Modify OpenClaw to treat a zero-token, empty-content assistant turn with stopReason="stop" as an invalid or retryable state instead of a successful terminal result.

Guidance

  • Review the OpenClaw code to identify where it handles terminal turns and update the logic to check for the conditions: stopReason === "stop", empty assistant content, no tool calls, and zero total token usage.
  • Consider implementing a retry mechanism or fallback condition when these conditions are met, to improve robustness against upstream provider instability.
  • Verify that the updated handling correctly identifies and handles the previously problematic turns, using local transcript data for testing.
  • Test the changes with different providers, including Claude Opus 4.6/4.7 and GPT-5.4, to ensure the fix does not introduce new issues.

Example

No code snippet is provided due to the lack of specific code context in the issue.

Notes

The suggested fix assumes that the issue is primarily with OpenClaw's handling of terminal turns, rather than a problem with the Claude/Anthropic path itself. Additional debugging may be necessary to fully resolve the issue.

Recommendation

Apply the suggested workaround by modifying OpenClaw to treat the specified conditions as invalid or retryable, to improve the robustness of the system against similar issues in the future.

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