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:
- 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.
- However, the task delivery validator strictly checks for tool invocation evidence (
didSendViaMessagingTool / hasGatewayAgentMessagingToolDeliveryEvidence). Since no tool was called, completionDelivered evaluates to false.
- 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
- Call
image_generate (configured to run in the background).
- Wait for the original user session to go idle (e.g., simulate a long-running generation of > 60 seconds).
- The completion agent runs and outputs plain text containing the image URL.
- 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.
Description
When invoking a long-running media generation tool (such as
image_generateor 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,
scheduleMediaGenerationTaskCompletionattempts 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 themessagetool:didSendViaMessagingTool/hasGatewayAgentMessagingToolDeliveryEvidence). Since no tool was called,completionDeliveredevaluates tofalse.image_generate completion delivery failed after successful generation, changing the task status tofailedand delivering a confusingImage generation failedwarning 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
image_generate(configured to run in the background).Suggested Fix
In
src/agents/tools/media-generate-background-shared.ts(compiled toopenclaw-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:
To:
This ensures the background task successfully transitions to the
completedstatus and does not trigger duplicate, contradicting error messages to the end user.