openclaw - 💡(How to fix) Fix [Bug]: assistant turn can enter repeated terminated state immediately after a tool error instead of reporting the failure [1 comments, 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#70622Fetched 2026-04-24 05:55:31
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

In a main chat session on OpenClaw 2026.4.21 using openai-codex/gpt-5.4, a real tool failure occurred during an active turn, and instead of returning a normal assistant message explaining the failure, the run fell into repeated error=terminated assistant responses.

This was not a long-running overnight turn. It happened immediately after a concrete tool error during a normal interactive turn.

The proximate tool failure was an external CLI auth/permission error from a shell command invoked through exec.

After that tool result, the assistant did not send a normal reply saying the command failed or asking to retry with corrected auth/context. Instead, the session history showed repeated assistant entries with:

  • stopReason: error
  • errorMessage: terminated

This caused the user to see the turn as terminated instead of receiving the actual failure report.

Error Message

In a main chat session on OpenClaw 2026.4.21 using openai-codex/gpt-5.4, a real tool failure occurred during an active turn, and instead of returning a normal assistant message explaining the failure, the run fell into repeated error=terminated assistant responses. This was not a long-running overnight turn. It happened immediately after a concrete tool error during a normal interactive turn. The proximate tool failure was an external CLI auth/permission error from a shell command invoked through exec.

  • stopReason: error
  1. Trigger a concrete tool error during the turn. In our case this was an exec shell command invoking an external CLI that returned an auth/permission failure. After a tool error, the assistant should still be able to produce a normal response for the user, for example: The tool error landed successfully in session history, but the subsequent assistant responses were repeatedly marked:
  • stopReason: error
  • one exec command that later failed with an auth/permission error
  1. The failing exec tool result returned a concrete permission/auth error. <external CLI permission/auth error> Observed repeated assistant error state immediately after: stopReason: error This breaks trust in the runtime because a normal tool failure gets swallowed by repeated termination behavior. The user does not get the real error report, and it looks like the assistant simply died mid-turn.
  • a concrete tool error is already present in session history So this may be the same family, but if so it would be helpful to track that this also happens in the simpler "tool error arrived normally, post-tool assistant reply terminated" case.

Root Cause

This breaks trust in the runtime because a normal tool failure gets swallowed by repeated termination behavior. The user does not get the real error report, and it looks like the assistant simply died mid-turn.

Code Example

<external CLI permission/auth error>
(Command exited with code 1)

---

stopReason: error
errorMessage: terminated
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

In a main chat session on OpenClaw 2026.4.21 using openai-codex/gpt-5.4, a real tool failure occurred during an active turn, and instead of returning a normal assistant message explaining the failure, the run fell into repeated error=terminated assistant responses.

This was not a long-running overnight turn. It happened immediately after a concrete tool error during a normal interactive turn.

The proximate tool failure was an external CLI auth/permission error from a shell command invoked through exec.

After that tool result, the assistant did not send a normal reply saying the command failed or asking to retry with corrected auth/context. Instead, the session history showed repeated assistant entries with:

  • stopReason: error
  • errorMessage: terminated

This caused the user to see the turn as terminated instead of receiving the actual failure report.

Steps to reproduce

  1. Use OpenClaw 2026.4.21 in a normal main agent session with model openai-codex/gpt-5.4.
  2. Ask the assistant to do real work that uses tools.
  3. Trigger a concrete tool error during the turn. In our case this was an exec shell command invoking an external CLI that returned an auth/permission failure.
  4. Observe what happens after the tool result arrives.

Expected behavior

After a tool error, the assistant should still be able to produce a normal response for the user, for example:

  • report the exact tool failure
  • explain the likely cause
  • ask for permission to retry or retry with corrected context if appropriate

At minimum, the run should fail once, clearly, instead of degrading into repeated terminated assistant responses.

Actual behavior

The tool error landed successfully in session history, but the subsequent assistant responses were repeatedly marked:

  • stopReason: error
  • errorMessage: terminated

The user saw the turn terminate instead of receiving the actual failure explanation.

OpenClaw version

2026.4.21

Operating system

Linux

Install method

npm global

Model

openai-codex/gpt-5.4

Provider / routing chain

OpenClaw -> OpenAI Codex

Additional provider/model setup details

Main session model was openai-codex/gpt-5.4.

Logs, screenshots, and evidence

Relevant session-history sequence:

  1. User asked for real work in a normal interactive turn.
  2. Assistant successfully called:
    • update_plan
    • one exec command that later failed with an auth/permission error
    • another local exec command that succeeded
  3. The failing exec tool result returned a concrete permission/auth error.
  4. After that, the assistant generated multiple entries with errorMessage: terminated instead of a normal text reply.

Representative failing tool result shape:

<external CLI permission/auth error>
(Command exited with code 1)

Observed repeated assistant error state immediately after:

stopReason: error
errorMessage: terminated

Impact and severity

Medium to high.

This breaks trust in the runtime because a normal tool failure gets swallowed by repeated termination behavior. The user does not get the real error report, and it looks like the assistant simply died mid-turn.

Additional information

There is an existing issue about interrupted streaming tool calls and retry loops:

  • #53109 Better handling for interrupted streaming tool calls to avoid silent failure and retry loops

This report may be related, but this repro is narrower and clearer:

  • a concrete tool error is already present in session history
  • then the assistant repeatedly terminates instead of reporting that tool failure back to the user

So this may be the same family, but if so it would be helpful to track that this also happens in the simpler "tool error arrived normally, post-tool assistant reply terminated" case.

extent analysis

TL;DR

The issue can be addressed by modifying the error handling mechanism to properly process and report tool failures, rather than entering a repeated termination state.

Guidance

  • Review the error handling logic in the openai-codex/gpt-5.4 model to ensure it correctly processes tool failures and generates a normal response.
  • Investigate the relationship between this issue and the existing issue #53109, as they may be related and resolving one could impact the other.
  • Verify that the exec command's error handling is properly configured to return the error message to the assistant, allowing it to generate a normal response.
  • Consider adding logging or debugging statements to track the flow of errors and responses to better understand the issue.

Example

No specific code snippet can be provided without more information on the implementation, but an example of improved error handling might involve catching and processing the exec command's error, then generating a response that reports the failure to the user.

Notes

The issue's root cause is unclear, but it appears to be related to how the assistant handles tool failures. Resolving this issue may require changes to the model's error handling logic or the exec command's configuration.

Recommendation

Apply a workaround by modifying the error handling mechanism to properly process and report tool failures, as this is likely to address the issue directly.

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…

FAQ

Expected behavior

After a tool error, the assistant should still be able to produce a normal response for the user, for example:

  • report the exact tool failure
  • explain the likely cause
  • ask for permission to retry or retry with corrected context if appropriate

At minimum, the run should fail once, clearly, instead of degrading into repeated terminated assistant responses.

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]: assistant turn can enter repeated terminated state immediately after a tool error instead of reporting the failure [1 comments, 1 participants]