Skip to content

[Bug] Cron task summary ignores agent self-correction - picks tool error over final assistant reply #74807

@u5008907541-jpg

Description

@u5008907541-jpg

Problem

When a Cron agentTurn job runs in an isolated session, the final summary/announcement picks the last tool error message as the task result instead of the agent's final self-corrected assistant reply.

Observed behaviour

  1. Agent runs a task that involves file editing via tool calls.
  2. First edit call fails (e.g. oldText not found).
  3. Agent recognises the error, adjusts its approach, and successfully completes the task in subsequent turns.
  4. The Cron system scans the session transcript and selects the failing tool result as the "last meaningful output" for the summary/announcement.
  5. User receives a failure announcement even though the task actually succeeded.

Root cause

The summary logic appears to prefer tool results (which are system-generated) over the agent's final assistant message when determining what to announce. This means any intermediate tool failure that the agent later overcomes is surfaced as the final status.

Expected behaviour

The summary should prefer the last assistant turn in the session as the authoritative outcome, not an intermediate tool error. If the agent's final message indicates success, the announcement should reflect success.

Suggested fix

When walking the session transcript to build the announcement:

  1. Start from the last assistant message (not the last tool/system message).
  2. If the assistant's final turn claims success, trust that over any prior tool errors.
  3. Only fall back to tool-error-based summaries if the session ends with a tool call (no final assistant reply), or the assistant explicitly reports failure.

Environment

  • OpenClaw version: 2026.4.26
  • Cron job type: agentTurn in isolated session
  • Models affected: all (framework-level issue)

Discovered during analysis of a daily-cleanup Cron job that self-corrected a file-edit error but was still reported as failed.

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:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    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