openclaw - 💡(How to fix) Fix Bug: False task failure reported when long-running media generation falls back to textual completion delivery

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…

When invoking a long-running media generation tool (such as image_generate or custom SD/DALL-E 3 wrapper taking > 30 seconds to complete), the original user session may go idle or expire before the image is generated.

Upon completion, scheduleMediaGenerationTaskCompletion attempts to wake the requester session. Since the session is no longer active (no_active_run), OpenClaw falls back to running a direct completion agent (runAnnounceAgentCall).

If the completion agent model (e.g. a reasoning model without tool-calling capabilities enabled) outputs the local media URL (file://...) as a plain text block instead of explicitly calling the message tool:

  1. The channel plugin (e.g. Telegram) successfully parses the text block, extracts the local media path, uploads the photo, and delivers it to the user.
  2. However, the task delivery validator strictly checks for tool invocation evidence (didSendViaMessagingTool / hasGatewayAgentMessagingToolDeliveryEvidence). Since no tool was called, completionDelivered evaluates to false.
  3. OpenClaw then throws a fatal error: image_generate completion delivery failed after successful generation, changing the task status to failed and delivering a confusing Image generation failed warning to the user, even though the image was successfully generated and sent.

This causes a contradiction where the user receives the successfully generated image, but immediately receives a task failure error message.

Error Message

  1. OpenClaw then throws a fatal error: image_generate completion delivery failed after successful generation, changing the task status to failed and delivering a confusing Image generation failed warning to the user, even though the image was successfully generated and sent. This causes a contradiction where the user receives the successfully generated image, but immediately receives a task failure error message. if (!completionDelivered) throw new Error(${params.toolName} completion delivery failed after successful generation); log.warn(${params.toolName} completion delivery failed after successful generation (non-fatal)); This ensures the background task successfully transitions to the completed status and does not trigger duplicate, contradicting error messages to the end user.

Root Cause

When invoking a long-running media generation tool (such as image_generate or custom SD/DALL-E 3 wrapper taking > 30 seconds to complete), the original user session may go idle or expire before the image is generated.

Upon completion, scheduleMediaGenerationTaskCompletion attempts to wake the requester session. Since the session is no longer active (no_active_run), OpenClaw falls back to running a direct completion agent (runAnnounceAgentCall).

If the completion agent model (e.g. a reasoning model without tool-calling capabilities enabled) outputs the local media URL (file://...) as a plain text block instead of explicitly calling the message tool:

  1. The channel plugin (e.g. Telegram) successfully parses the text block, extracts the local media path, uploads the photo, and delivers it to the user.
  2. However, the task delivery validator strictly checks for tool invocation evidence (didSendViaMessagingTool / hasGatewayAgentMessagingToolDeliveryEvidence). Since no tool was called, completionDelivered evaluates to false.
  3. OpenClaw then throws a fatal error: image_generate completion delivery failed after successful generation, changing the task status to failed and delivering a confusing Image generation failed warning to the user, even though the image was successfully generated and sent.

This causes a contradiction where the user receives the successfully generated image, but immediately receives a task failure error message.

Code Example

if (!completionDelivered) throw new Error(`${params.toolName} completion delivery failed after successful generation`);

---

if (!completionDelivered) {
    log.warn(`${params.toolName} completion delivery failed after successful generation (non-fatal)`);
}
RAW_BUFFERClick to expand / collapse

Description

When invoking a long-running media generation tool (such as image_generate or custom SD/DALL-E 3 wrapper taking > 30 seconds to complete), the original user session may go idle or expire before the image is generated.

Upon completion, scheduleMediaGenerationTaskCompletion attempts to wake the requester session. Since the session is no longer active (no_active_run), OpenClaw falls back to running a direct completion agent (runAnnounceAgentCall).

If the completion agent model (e.g. a reasoning model without tool-calling capabilities enabled) outputs the local media URL (file://...) as a plain text block instead of explicitly calling the message tool:

  1. The channel plugin (e.g. Telegram) successfully parses the text block, extracts the local media path, uploads the photo, and delivers it to the user.
  2. However, the task delivery validator strictly checks for tool invocation evidence (didSendViaMessagingTool / hasGatewayAgentMessagingToolDeliveryEvidence). Since no tool was called, completionDelivered evaluates to false.
  3. OpenClaw then throws a fatal error: image_generate completion delivery failed after successful generation, changing the task status to failed and delivering a confusing Image generation failed warning to the user, even though the image was successfully generated and sent.

This causes a contradiction where the user receives the successfully generated image, but immediately receives a task failure error message.

Steps to Reproduce

  1. Call image_generate (configured to run in the background).
  2. Wait for the original user session to go idle (e.g., simulate a long-running generation of > 60 seconds).
  3. The completion agent runs and outputs plain text containing the image URL.
  4. The user receives the image, but immediately after, receives a task failure message.

Suggested Fix

In src/agents/tools/media-generate-background-shared.ts (compiled to openclaw-tools-[hash].js), when the generation status is successful (status === "ok"), the delivery failure of the completion notice should be treated as a warning rather than a fatal task execution failure.

Change:

if (!completionDelivered) throw new Error(`${params.toolName} completion delivery failed after successful generation`);

To:

if (!completionDelivered) {
    log.warn(`${params.toolName} completion delivery failed after successful generation (non-fatal)`);
}

This ensures the background task successfully transitions to the completed status and does not trigger duplicate, contradicting error messages to the end user.

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: False task failure reported when long-running media generation falls back to textual completion delivery