Skip to content

[Bug]: Discord message_tool_only turns can append stale tool-failed warning after successful message send #93875

Description

@hoyanhan

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Discord source-channel turns that deliver the visible reply via message(action=send) can still append a separate stale tool-failed warning after the successful user-visible response.

Steps to reproduce

  1. Run OpenClaw with Discord enabled and a Discord source channel using source-reply delivery through the message tool (message_tool_only path).
  2. Trigger a Discord turn where an earlier tool call fails, but the agent later sends the final user-visible Discord reply successfully with message(action=send).
  3. Observe the Discord channel after the successful reply.

Expected behavior

Once the final response has been successfully delivered to Discord through message(action=send), OpenClaw should treat the turn as having a user-facing assistant reply and should not append a stale fallback tool-error warning for an earlier non-terminal tool failure.

Actual behavior

The user-visible Discord reply is delivered successfully, but a separate tool-failed warning can appear after it. This makes the turn look failed even though the final Discord response was sent.

OpenClaw version

Observed on 2026.6.1. The current 2026.6.8 source still appears to have the same accounting gap in src/agents/embedded-agent-runner/run/payloads.ts.

Operating system

Ubuntu 24.04

Install method

npm global

Model

OpenAI/Codex-backed model route

Provider / routing chain

OpenClaw gateway -> OpenAI/Codex-backed agent runtime

Additional provider/model setup details

No provider-specific behavior was required to reproduce the symptom. The relevant condition is Discord source delivery through the message tool plus an earlier failed tool call in the same turn.

Logs, screenshots, and evidence

Sanitized observed sequence:

1. Discord source turn enters message_tool_only delivery mode.
2. One or more earlier tool calls fail during the turn.
3. The assistant successfully sends the visible final response through message(action=send).
4. After that visible response, Discord receives an additional tool-failed warning payload.

Source-level evidence from current main / 2026.6.8:

const hasSourceReplyPayload = replyItems.length > sourceReplyStartIndex;
const deliveredSourceReplyViaMessageTool =
  params.sourceReplyDeliveryMode === "message_tool_only" &&
  params.didDeliverSourceReplyViaMessageTool === true;

const suppressAssistantArtifacts =
  params.didSendDeterministicApprovalPrompt === true ||
  hasSourceReplyPayload ||
  deliveredSourceReplyViaMessageTool;

// Later:
let hasUserFacingAssistantReply = hasSourceReplyPayload;

deliveredSourceReplyViaMessageTool suppresses duplicate assistant artifacts, but it is not included in the hasUserFacingAssistantReply gate that is passed to resolveToolErrorWarningPolicy. In the 2026.6.1 published bundle, the same gap existed with direct message-tool evidence (didSendViaMessagingTool) not counting as a user-facing reply.

A local mitigation for the published 2026.6.1 bundle was to count successful direct message-tool delivery as user-facing reply evidence:

let hasUserFacingAssistantReply =
  hasSourceReplyPayload || params.didSendViaMessagingTool === true;

For current main, the equivalent fix likely needs to account for deliveredSourceReplyViaMessageTool as well.

Impact and severity

Affected: Discord source-channel users where final replies are delivered through the message tool.

Severity: Moderate. The final response can be delivered, but users see a misleading failure message after every affected tool-use turn.

Frequency: Reproduced on affected Discord tool-use turns with earlier tool failures and successful final message(action=send) delivery.

Consequence: Users lose trust in successful tool-use responses because the channel shows an apparent failure after the successful answer.

Additional information

This does not appear to be a security issue; it is a user-visible delivery/accounting bug. No private logs, channel IDs, user IDs, tokens, hostnames, session IDs, or local filesystem paths are included in this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions