openclaw - 💡(How to fix) Fix Tool error warnings appear after assistant response instead of before/inline [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#77255Fetched 2026-05-05 05:50:39
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
2
Timeline (top)
commented ×1

When a tool (like edit) fails during a run, the error warning message appears after the assistant's response text, which is confusing for users. The error happened during the run, but the notification about it comes after the actual answer.

Example output order (current):

[Assistant's response about the task...]

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

Expected order:

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

[Assistant's response about the task...]

Or inline with the tool progress during streaming.

Error Message

When a tool (like edit) fails during a run, the error warning message appears after the assistant's response text, which is confusing for users. The error happened during the run, but the notification about it comes after the actual answer.

  1. Error text (if assistant errored)
  2. Tool error warning ← pushed last

Root Cause

In src/agents/pi-embedded-runner/run/payloads.ts, the buildEmbeddedRunPayloads function pushes items to replyItems in this order:

  1. Error text (if assistant errored)
  2. Inline tool results
  3. Reasoning text
  4. Assistant answer texts ← pushed here
  5. Tool error warning ← pushed last

The lastToolError warning block comes after the answerTexts loop, causing warnings to always appear at the end.

Code Example

[Assistant's response about the task...]

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

---

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

[Assistant's response about the task...]
RAW_BUFFERClick to expand / collapse

Description

When a tool (like edit) fails during a run, the error warning message appears after the assistant's response text, which is confusing for users. The error happened during the run, but the notification about it comes after the actual answer.

Example output order (current):

[Assistant's response about the task...]

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

Expected order:

⚠️ 📝 Edit: in /path/to/file.py failed: File not found

[Assistant's response about the task...]

Or inline with the tool progress during streaming.

Root Cause

In src/agents/pi-embedded-runner/run/payloads.ts, the buildEmbeddedRunPayloads function pushes items to replyItems in this order:

  1. Error text (if assistant errored)
  2. Inline tool results
  3. Reasoning text
  4. Assistant answer texts ← pushed here
  5. Tool error warning ← pushed last

The lastToolError warning block comes after the answerTexts loop, causing warnings to always appear at the end.

Suggested Fix

Move the if (params.lastToolError) block before the for (const text of answerTexts) loop, so tool errors appear before the assistant's response.

Environment

  • OpenClaw version: 2026.4.22
  • Also verified in latest source (2026.5.3-1) - same behavior

extent analysis

TL;DR

Move the lastToolError block before the answerTexts loop in payloads.ts to display tool error warnings before the assistant's response.

Guidance

  • Verify the issue by checking the order of elements in the replyItems array in payloads.ts.
  • To fix, reorder the blocks in buildEmbeddedRunPayloads to push tool error warnings before assistant answer texts.
  • Test the change by running the tool and intentionally causing an error to ensure the warning appears before the assistant's response.
  • Review the code for any potential side effects of reordering the blocks, such as changes to the streaming behavior.

Example

// Before
// ...
for (const text of answerTexts) {
  // ...
}
if (params.lastToolError) {
  // ...
}

// After
if (params.lastToolError) {
  // ...
}
for (const text of answerTexts) {
  // ...
}

Notes

This fix assumes that the issue is solely caused by the order of elements in the replyItems array. If the problem persists after reordering, further investigation may be needed.

Recommendation

Apply the suggested fix by moving the lastToolError block before the answerTexts loop, as this directly addresses the identified root cause and is a targeted change.

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 Tool error warnings appear after assistant response instead of before/inline [1 comments, 2 participants]