Skip to content

[Bug]: image_generate callbacks from failed isolated cron runs are routed to subsequent runs of the same job #86459

Description

@argus-as

Bug type: Regression (worked before, now fails)

Beta release blocker: No

Summary:
After upgrading to 2026.5.22, when an isolated cron session calls image_generate and terminates before receiving the callback, the pending image is delivered as the first message of the next run of the same job, bypassing the cron prompt entirely.

Steps to reproduce:

  1. Create a cron job with sessionTarget: isolated and payload.kind: agentTurn.
  2. Inside the agent turn, call image_generate (background task).
  3. Have the session terminate before receiving the image callback (e.g. due to a tool error or billing interruption).
  4. Trigger the job again (manually or via schedule).
  5. Observe that the new run starts with the orphaned image_generate callback as its first user message instead of the cron prompt.

Expected behavior:
Orphaned image_generate callbacks from a terminated session should be discarded or ignored. The new run should start with the cron's configured prompt as its first message, as it did in 2026.5.18.

Actual behavior:
The new run receives the stale image as its first user message (seq: 1). The cron prompt is not delivered. The agent processes the image without context, sends it to unrelated channels, and fails with stopReason=toolUse. This cascades: each failed run leaves new orphaned callbacks that poison the next run.

OpenClaw version: 2026.5.22

OS: Ubuntu 24.04

Install method: npm global

Model: anthropic/claude-sonnet-4-6

Provider / routing chain: openclaw -> anthropic

Logs:

incomplete turn detected: stopReason=toolUse payloads=1
Session history seq 1: role=user, provenance.sourceTool=image_generate (inter-session callback), no prior cron prompt message visible
Run duration: ~130-138s across 5 consecutive failed runs
input_tokens=16-21 (anomalously low vs working runs: 33-52)

Impact and severity:

  • Affected: any isolated cron job that uses image_generate
  • Severity: High — blocks the job entirely and creates a self-perpetuating failure cascade
  • Frequency: 100% reproduction after the first failure (5/5 runs failed)
  • Consequence: cron never completes, orphaned images sent to wrong channels, manual intervention required

Additional information:
Last known good: 2026.5.18. First known bad: 2026.5.22.
Workaround: run the agent as a subagent with a different sessionKey (not sharing the cron jobId prefix).
The 2026.5.22 changelog mentions image_generate now uses "separate session-backed background tasks with message-tool completion delivery" — this change appears to be the source of the regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions