Skip to content

[Bug]: Cron isolated agentTurn skips delivery before dispatch when a recovered early tool error is classified as fatal #94846

Description

@needtocalmdown

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

An isolated scheduled agentTurn recovered from an early missing-file tool error, produced final assistant output, and ended successfully, but cron finalization treated the earlier tool error as fatal and skipped delivery before dispatchCronDelivery(...) was reached.

Steps to reproduce

The original issue was first observed in a natural scheduled run. I later reproduced the same state with a reduced one-shot scheduled isolated agentTurn. The reduced repro below was a real scheduled at run, not a manual rerun.

  1. Configure an isolated scheduled agentTurn cron job with direct delivery enabled.

    In my repro, the delivery target was a Feishu direct message with bestEffort=true.

  2. Use a prompt that intentionally triggers an early recoverable missing-file tool error, then continues and produces a final assistant message.

    Minimal prompt shape:

    1. First run:
       sed -n '1,20p' memory/repro-cron-delivery-skip-2026-06-19.md
    2. If the file is missing, treat it as recoverable and continue.
    3. Create memory/repro-cron-delivery-skip-2026-06-19.md.
    4. Final output exactly:
       REPRO_FINAL_OUTPUT_PRESENT
    
  3. Let the job run through the scheduler.

    In my repro, this was a one-shot scheduled run:

    schedule: one-shot at 2026-06-19T14:45:03+08:00
    sessionTarget: isolated
    delivery: Feishu direct announce, bestEffort=true
    
  4. Inspect the isolated session trajectory.

    The expected trajectory shape for the repro is:

    early tool.result:
      name: bash
      status: failed
      isError: true
      output: sed: can't read memory/repro-cron-delivery-skip-2026-06-19.md: No such file or directory
    
    later tool.result:
      name: apply_patch
      status: completed
      isError: false
    
    model.completed:
      assistantTexts: ["REPRO_FINAL_OUTPUT_PRESENT"]
    
    session.ended:
      status: success
    
  5. Inspect the outer cron run record.

    In the reproduced case, the isolated session succeeded and final assistant output existed, but the outer cron run was recorded as an error and delivery was not performed:

    status: error
    error: "⚠️ 🛠️ print lines 1-20 from memory/repro-cron-delivery-skip-2026-06-19.md (agent) failed"
    delivered: false
    deliveryStatus: "not-delivered"
    deliveryError: same early tool error
    delivery.resolved.ok: true
    delivery.resolved.channel: "feishu"
    delivery.fallbackUsed: false
    
  6. Confirm the key reproduced state:

    isolated session ending: success
    final assistant output: present
    delivery.resolved.ok: true
    delivery.fallbackUsed: false
    deliveryStatus: not-delivered
    final output was not delivered
    

This reproduces the pre-dispatch delivery skip with a minimal scheduled isolated agentTurn, so the issue does not appear to be specific to the original complex maintenance prompt.

Expected behavior

If an isolated scheduled agentTurn recovers from a non-terminal tool error, produces final assistant output, and ends with status=success, the final assistant output should still be eligible for delivery dispatch.

A recovered earlier tool error should not by itself prevent the run from reaching dispatchCronDelivery(...).

At minimum, if OpenClaw intentionally skips delivery because a structured agent error is considered fatal, the cron run record should explicitly distinguish this from a delivery send failure, for example by recording that delivery was not attempted and why.

Actual behavior

The isolated agentTurn recovered from the early missing-file tool error, continued with later successful tool calls, produced final assistant output, and ended with status=success.

During cron finalization, the earlier recovered tool error was selected as the fatal run outcome. Because delivery had been requested, the cron runner returned before dispatchCronDelivery(...) was reached.

The outer cron run was recorded as:

status: error
summary/error: early missing-file tool error
delivered: false
deliveryStatus: "not-delivered"
deliveryError: same early tool error
delivery.resolved.ok: true
delivery.fallbackUsed: false

This was not a Feishu/API send failure. The delivery target was resolved, but delivery dispatch was not attempted, and the final assistant output was not delivered.

OpenClaw version

2026.6.6

Operating system

Ubuntu 22.04.5 LTS on WSL2

Install method

npm global

Model

gpt-5.5

Provider / routing chain

OpenClaw -> openai

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Original natural run evidence:


runAtIso: 2026-06-18T21:00:00.014+08:00
finishedAtIso: 2026-06-18T21:02:39.772+08:00
durationMs: 159751
model: gpt-5.5
provider: openai
status: error
error: "⚠️ 🛠️ print lines 1-260 from memory/2026-06-18.md (agent) failed"
summary: "⚠️ 🛠️ print lines 1-260 from memory/2026-06-18.md (agent) failed"
delivered: false
deliveryStatus: "not-delivered"
deliveryError: "⚠️ 🛠️ print lines 1-260 from memory/2026-06-18.md (agent) failed"
delivery.resolved.ok: true
delivery.resolved.channel: "feishu"
delivery.delivered: false
delivery.fallbackUsed: false


Original isolated session evidence:


tool call:
  sed -n '1,260p' memory/2026-06-18.md

tool result:
  sed: can't read memory/2026-06-18.md: No such file or directory
  isError: true

later session behavior:
  continued with later successful tool calls
  created memory/2026-06-18.md
  produced final assistant output
  session ended with status=success


Reduced scheduled repro evidence:


cron job id: 0e015367-c53d-4569-a673-02e889584157
job name: repro-2026-06-19-cron-delivery-pre-dispatch-skip
schedule: one-shot at 2026-06-19T14:45:03+08:00
sessionTarget: isolated
delivery: Feishu direct announce, bestEffort=true
session id: e7ae707a-08db-47ae-ba02-dbe6209964da


Reduced repro cron run result:


runAtMs: 1781851503004
finishedAtMs: 1781851535307
durationMs: 32297
model: gpt-5.5
provider: openai
status: error
error: "⚠️ 🛠️ print lines 1-20 from memory/repro-cron-delivery-skip-2026-06-19.md (agent) failed"
summary: same as error
delivered: false
deliveryStatus: "not-delivered"
deliveryError: same early tool error
delivery.resolved.ok: true
delivery.resolved.channel: "feishu"
delivery.fallbackUsed: false


Reduced repro isolated session trajectory:


early tool.result:
  name: bash
  status: failed
  isError: true
  output: sed: can't read memory/repro-cron-delivery-skip-2026-06-19.md: No such file or directory

later tool.result:
  name: apply_patch
  status: completed
  isError: false

model.completed:
  assistantTexts: ["REPRO_FINAL_OUTPUT_PRESENT"]

session.ended:
  status: success


Local code-path observation from the bundled build:


resolveCronPayloadOutcome(...)
  detects hasFatalStructuredErrorPayload
  if hasFatalStructuredErrorPayload && deliveryRequested:
    build delivery trace with fallbackUsed=false
    return resolveRunOutcome(...)
    // dispatchCronDelivery(...) is not called


The important evidence for the pre-dispatch shape is:


isolated session ending: success
final assistant output: present
delivery.resolved.ok: true
delivery.fallbackUsed: false
deliveryError: earlier agent tool error, not a Feishu/API error

Impact and severity

Impact and severity

Affected:

Scheduled isolated agentTurn cron jobs that request delivery and contain a recoverable tool error before final assistant output.

Severity:

Medium to high for scheduled reporting/maintenance workflows.

Frequency:

Observed in the original natural scheduled run and reproduced with a reduced one-shot scheduled isolated agentTurn. A similar missing-date-file shape was also observed in an earlier local cron run of the same job class.

Consequence:

The user does not receive the final scheduled report even though the agent completed it. The run record also makes the event look like a generic not-delivered delivery failure, although delivery dispatch was not attempted.

Additional information

This is related to #94058 and #94116, but it is not the same failure shape.

#94058 describes the broader boundary problem where an isolated agentTurn can finish successfully while the outer cron run is recorded as error / not-delivered.

This report focuses on a narrower pre-dispatch case:

successful isolated agentTurn with final output
-> earlier recovered tool error selected as fatal during cron finalization
-> deliveryRequested branch returns before dispatchCronDelivery(...)
-> delivery is skipped before any Feishu/API send attempt

Suggested fixes:

  1. Persist a first-class deliveryAttempted field in cron run records.
  2. Separate target resolution, delivery attempt, and delivery result in cron delivery state.
  3. Do not let a recovered non-terminal tool error suppress delivery when the isolated session ended successfully and final assistant output exists.
  4. If delivery is intentionally skipped because a structured agent error is treated as fatal, record deliveryStatus=not-attempted or an equivalent explicit reason instead of generic not-delivered.
  5. Preserve or reference the final assistant output in run diagnostics even when the outer cron status is error.

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.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.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions