Skip to content

[Bug]: Scheduled isolated agentTurn outer run records error although session ended success #94058

Description

@needtocalmdown

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

In one scheduled cron agentTurn run with sessionTarget=isolated, the isolated session completed successfully and produced a final assistant message, but the parent cron run was recorded as status=error with deliveryStatus=not-delivered.

The key distinction is not "agent failed before producing a report" versus "agent produced no useful output". The final assistant report existed. The issue is that the successful isolated session result was not reflected in the parent cron run status, and normal completion delivery did not complete.

This appears specific to the scheduled trigger path. Manual openclaw cron run checks, including controlled checks with recoverable tool/shell errors inside the agent session, ended with isolated session success, parent cron status=ok, and completed delivery. These checks suggest the mismatch is not caused by a simple recoverable tool error inside the agent session.

Steps to reproduce

NOT_ENOUGH_INFO
I have not reduced this to a deterministic standalone repro, but the observed failing case used this path:

1. Run OpenClaw 2026.6.6 (8c802aa) on Ubuntu 22.04.5 LTS under WSL2.
2. Run the OpenClaw Gateway as a systemd user service.
   Observed status: gateway service installed, enabled, and running.
3. Confirm the cron scheduler is enabled through Gateway:
   openclaw cron status
   -> enabled=true
   -> jobs=3
4. Configure an enabled scheduled cron job with:
   schedule.kind=cron
   schedule.expr="0 21 * * *"
   schedule.tz="Asia/Shanghai"
   payload.kind=agentTurn
   sessionTarget=isolated
   payload.timeoutSeconds=600
   delivery.mode=announce
   delivery.bestEffort=true
5. Let the job fire through the natural scheduled trigger path.
   The failing observed run started at 2026-06-16T21:00:00.013+08:00.
6. Inspect the parent cron run record:
   openclaw cron runs --id <JOB_ID> --limit 5 --expect-final
7. Use the `sessionId` / `sessionKey` from that run record to inspect the
   isolated session trajectory and transcript in the local OpenClaw session store.
8. Observe that the isolated session ended with `data.status=success` and a
   final assistant message existed, while the parent cron run recorded
   `status=error` and `deliveryStatus=not-delivered`.

The run/session association came from the parent cron run entry:

sessionId=<SESSION_ID>
sessionKey=agent:<AGENT_ID>:cron:<JOB_ID>:run:<SESSION_ID>

Manual negative checks used the debug path:

openclaw cron run <JOB_ID or controlled debug job>

Those manual runs did not reproduce the parent cron error.

Expected behavior

If an isolated agentTurn session ends with data.status=success and produces a final assistant message, the parent cron run should preserve that successful payload outcome.

If completion delivery succeeds, the parent cron run should be recorded as successful and delivered.

If post-session finalization or delivery fails after the isolated session has already succeeded, the run record should preserve the successful agent execution outcome and separately record the finalization or delivery failure phase. It should not collapse the successful isolated agent execution into a generic error="run openclaw cron (agent) failed" without indicating what post-session phase failed.

Actual behavior

For the same scheduled run:

1. The isolated session transcript contained the intended final assistant report.

2. The isolated trajectory ended with:
   type=session.ended
   data.status=success
   timedOut=false
   promptError=null

3. The parent cron run recorded:
   status=error
   error="run openclaw cron (agent) failed"
   delivered=false
   deliveryStatus=not-delivered

4. The run record did not explain whether the failure happened during payload
   outcome resolution, cron finalization, or completion delivery.

The local run record included warning/tool glyphs before run openclaw cron (agent) failed; they are omitted here in the redacted ASCII snippets.

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

### Scheduled path details


Gateway service:
  systemd user installed
  enabled
  running

Cron scheduler:
  openclaw cron status
  enabled=true
  jobs=3

Failing trigger:
  scheduled cron trigger
  runAtIso=2026-06-16T21:00:00.013+08:00
  tsIso=2026-06-16T21:04:51.198+08:00

Run record command:
  openclaw cron runs --id <JOB_ID> --limit 5 --expect-final

Session inspection:
  sessionId/sessionKey copied from the parent cron run entry
  trajectory file ended with session.ended success
  transcript contained a final assistant message


### Redacted cron job shape


{
  "enabled": true,
  "deleteAfterRun": false,
  "schedule": {
    "kind": "cron",
    "expr": "0 21 * * *",
    "tz": "Asia/Shanghai"
  },
  "sessionTarget": "isolated",
  "wakeMode": "now",
  "payload": {
    "kind": "agentTurn",
    "message": "<REDACTED_LONG_DAILY_MAINTENANCE_PROMPT>",
    "timeoutSeconds": 600
  },
  "delivery": {
    "mode": "announce",
    "channel": "feishu",
    "to": "<REDACTED_USER>",
    "accountId": "<REDACTED_ACCOUNT>",
    "bestEffort": true
  }
}


### Parent cron run record


{
  "tsIso": "2026-06-16T21:04:51.198+08:00",
  "runAtIso": "2026-06-16T21:00:00.013+08:00",
  "jobId": "<JOB_ID>",
  "action": "finished",
  "status": "error",
  "error": "run openclaw cron (agent) failed",
  "summary": "run openclaw cron (agent) failed",
  "diagnostics": {
    "summary": "run openclaw cron (agent) failed",
    "entries": [
      {
        "source": "tool",
        "severity": "error",
        "message": "run openclaw cron (agent) failed"
      },
      {
        "source": "agent-run",
        "severity": "error",
        "message": "run openclaw cron (agent) failed"
      }
    ]
  },
  "durationMs": 291176,
  "model": "gpt-5.5",
  "provider": "openai",
  "delivered": false,
  "deliveryStatus": "not-delivered",
  "deliveryError": "run openclaw cron (agent) failed",
  "failureNotificationDelivery": {
    "status": "not-delivered",
    "delivered": false,
    "error": "run openclaw cron (agent) failed"
  },
  "delivery": {
    "intended": {
      "channel": "feishu",
      "to": "<REDACTED_USER>",
      "accountId": "<REDACTED_ACCOUNT>",
      "source": "explicit"
    },
    "resolved": {
      "ok": true,
      "channel": "feishu",
      "to": "<REDACTED_USER>",
      "accountId": "<REDACTED_ACCOUNT>",
      "source": "explicit"
    },
    "fallbackUsed": false,
    "delivered": false
  },
  "sessionId": "<SESSION_ID>",
  "sessionKey": "agent:<AGENT_ID>:cron:<JOB_ID>:run:<SESSION_ID>"
}


### Isolated session end state


{
  "type": "session.ended",
  "ts": "2026-06-16T13:04:50.951Z",
  "sessionId": "<SESSION_ID>",
  "sessionKey": "agent:<AGENT_ID>:cron:<JOB_ID>:run:<SESSION_ID>",
  "provider": "openai",
  "modelId": "gpt-5.5",
  "modelApi": "openai-chatgpt-responses",
  "data": {
    "status": "success",
    "timedOut": false,
    "yieldDetected": false,
    "promptError": null
  }
}


### Final assistant report existed


{
  "type": "message",
  "timestamp": "2026-06-16T13:04:51.129Z",
  "message": {
    "role": "assistant",
    "content": [
      {
        "type": "text",
        "text": "<FINAL_ASSISTANT_REPORT_REDACTED>"
      }
    ],
    "api": "openai-chatgpt-responses",
    "provider": "openai",
    "model": "gpt-5.5",
    "stopReason": "stop"
  }
}


### Manual negative checks

Two controlled manual debug runs using `openclaw cron run` did not reproduce the mismatch:


Attempt A:
  path: openclaw cron run
  shape: recoverable missing-file shell error inside the agent session
  session evidence: later successful tool call; session.ended success; final report marker existed
  parent cron result: status=ok; deliveryStatus=delivered

Attempt B:
  path: openclaw cron run
  shape: diagnostic command printed a marker and exited 17
  session evidence: later successful tool call; session.ended success; final report marker existed
  parent cron result: status=ok; deliveryStatus=delivered


These manual checks are important because they reproduced successful isolated agent completion with recoverable internal tool errors, but did not reproduce the parent cron error. This points away from ordinary recoverable tool/shell errors inside the agent session and toward a difference between the scheduled trigger path and manual `openclaw cron run`.

No raw trajectory or full transcript is included here to avoid exposing unrelated agent report content, local paths, account identifiers, or chat identifiers.

Impact and severity

Affected area: scheduled isolated cron agentTurn jobs with announce delivery.

Severity: Medium to High for monitoring, report, audit, and maintenance jobs.

Frequency: observed on one scheduled run in this exact success/error mismatch form; not reproduced in two controlled manual debug runs.

Consequence: the final report existed in the isolated session transcript but was not delivered through the normal completion path, and the run history showed only a generic agent failure. This hides the most useful diagnostic artifact at the moment when it is needed.

The important distinction is:

agent failed before producing a report
vs.
agent produced a report, but outer cron finalization/delivery failed

The current run history made that boundary hard to understand.

Additional information

This may overlap with existing cron status/finalization work, but I do not think it is an exact duplicate.

delivery.bestEffort=true is included above because it is part of the factual job configuration. I cannot tell from the run record whether delivery was skipped, attempted and failed, or whether a post-session finalization step failed before delivery. That ambiguity is part of the reported problem.

Possible inspection area, based on the visible bundled code:

executeDetachedCronJob
-> runIsolatedAgentJob
-> finalizeCronRun
-> resolveCronPayloadOutcome
-> cron run status

This is only a possible inspection area. The report is based on the externally observable mismatch between the isolated session outcome, parent cron status, and delivery status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.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.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.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions