openclaw - 💡(How to fix) Fix [Bug]: Cron runs finish with status ok but delivery is lost (not-delivered) and gateway throws "Agent listener invoked outside active run" [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#62397Fetched 2026-04-08 03:04:52
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
commented ×1renamed ×1subscribed ×1

OpenClaw cron runs can complete with status: ok but lose their final summary delivery, ending as deliveryStatus: not-delivered and summary: null.

In the same time window, the gateway logs show an unhandled promise rejection:

Error: Agent listener invoked outside active run

This looks like a run-lifecycle / delivery bug rather than a task failure.

Error Message

Error: Agent listener invoked outside active run

Root Cause

Because the agent run itself completes successfully (status: ok) but the result is lost during or after final event handling. The strongest indicator is the unhandled promise rejection complaining that an agent listener is receiving updates after the run is no longer considered active.

Code Example

Error: Agent listener invoked outside active run

---

{"ts":1775547942230,"runAtMs":1775547432863,"status":"ok","delivered":true,"deliveryStatus":"delivered","durationMs":115692,"summary":"PR head is not actionable yet: CI still in progress","sessionId":"f1d557a5-5a8e-4ccf-a6f9-11467c3f71cb"}

---

{"ts":1775549178490,"runAtMs":1775549100022,"status":"ok","delivered":false,"deliveryStatus":"not-delivered","durationMs":78461,"summary":null,"sessionId":"c27fde38-605a-47f0-8ddc-1717880050f4"}

---

{"ts":1775549400150,"runAtMs":1775549330706,"status":"ok","delivered":false,"deliveryStatus":"not-delivered","durationMs":69440,"summary":null,"sessionId":"2ac6804b-2eb9-452f-b3f7-24129c1b9ad8"}

---

[openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
    at Agent.processEvents (.../@mariozechner/pi-agent-core/src/agent.ts:533:10)
    at .../@mariozechner/pi-agent-core/src/agent.ts:380:21
    at Object.onUpdate (.../@mariozechner/pi-agent-core/src/agent-loop.ts:539:7)
    at emitUpdate (.../dist/exec-defaults-uj0McX2k.js:1524:8)
    at handleStdout (.../dist/exec-defaults-uj0McX2k.js:1546:4)
    at Object.onSupervisorStdout [as onStdout] (.../dist/exec-defaults-uj0McX2k.js:1610:3)

---

lane wait exceeded: lane=session:agent:main:cron:... waitedMs=391829 queueAhead=3

---

[cron:...] skipping stale delivery scheduled at 2026-04-06T21:05:00.000Z, started 573m late, current age 576m
RAW_BUFFERClick to expand / collapse

Summary

OpenClaw cron runs can complete with status: ok but lose their final summary delivery, ending as deliveryStatus: not-delivered and summary: null.

In the same time window, the gateway logs show an unhandled promise rejection:

Error: Agent listener invoked outside active run

This looks like a run-lifecycle / delivery bug rather than a task failure.

Environment

  • OpenClaw: 2026.4.5
  • Node: 22.22.2
  • Gateway service: local systemd-managed gateway
  • Runtime model: openai-codex/gpt-5.4
  • Surface/channel is not important to reproduce; the problem appears in cron execution + delivery handling

What happened

A cron job that normally posts concise progress updates started showing this pattern:

  • earlier run finishes normally and is delivered
  • next run finishes with status: ok
  • but delivery becomes not-delivered
  • summary is missing/null
  • manual rerun reproduces the same ok + not-delivered outcome

The underlying task did not crash. The delivery path seems to break after completion.

Minimal evidence

Cron run history

Healthy run:

{"ts":1775547942230,"runAtMs":1775547432863,"status":"ok","delivered":true,"deliveryStatus":"delivered","durationMs":115692,"summary":"PR head is not actionable yet: CI still in progress","sessionId":"f1d557a5-5a8e-4ccf-a6f9-11467c3f71cb"}

Broken scheduled run right after:

{"ts":1775549178490,"runAtMs":1775549100022,"status":"ok","delivered":false,"deliveryStatus":"not-delivered","durationMs":78461,"summary":null,"sessionId":"c27fde38-605a-47f0-8ddc-1717880050f4"}

Broken manual rerun:

{"ts":1775549400150,"runAtMs":1775549330706,"status":"ok","delivered":false,"deliveryStatus":"not-delivered","durationMs":69440,"summary":null,"sessionId":"2ac6804b-2eb9-452f-b3f7-24129c1b9ad8"}

Gateway log error

[openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
    at Agent.processEvents (.../@mariozechner/pi-agent-core/src/agent.ts:533:10)
    at .../@mariozechner/pi-agent-core/src/agent.ts:380:21
    at Object.onUpdate (.../@mariozechner/pi-agent-core/src/agent-loop.ts:539:7)
    at emitUpdate (.../dist/exec-defaults-uj0McX2k.js:1524:8)
    at handleStdout (.../dist/exec-defaults-uj0McX2k.js:1546:4)
    at Object.onSupervisorStdout [as onStdout] (.../dist/exec-defaults-uj0McX2k.js:1610:3)

Related warnings seen before/around the failure

lane wait exceeded: lane=session:agent:main:cron:... waitedMs=391829 queueAhead=3
[cron:...] skipping stale delivery scheduled at 2026-04-06T21:05:00.000Z, started 573m late, current age 576m

Why this looks like an OpenClaw bug

Because the agent run itself completes successfully (status: ok) but the result is lost during or after final event handling. The strongest indicator is the unhandled promise rejection complaining that an agent listener is receiving updates after the run is no longer considered active.

That suggests a race / ordering bug in one of these areas:

  • agent event listener lifecycle
  • cron announce delivery finalization
  • supervisor stdout updates arriving after run close
  • queue/lane delay interacting badly with run completion state

Impact

  • cron jobs appear healthy in run history (status: ok) while user-visible delivery is silently lost
  • summaries vanish (summary: null)
  • manual reruns may reproduce the same broken delivery path
  • this makes cron automation unreliable and hard to trust operationally

Reproduction hypothesis

I do not yet have a tiny standalone reproduction, but the recurring pattern is:

  1. Run an isolated cron job that performs non-trivial work and emits progress/final output.
  2. Let the session lane be somewhat congested or delayed.
  3. Observe successful run completion in JSONL.
  4. Observe final delivery dropped with not-delivered and missing summary.
  5. Check gateway logs for Agent listener invoked outside active run.

Expected behavior

If a cron run reaches status: ok, OpenClaw should either:

  • deliver the final summary successfully, or
  • mark the run as a delivery error with a concrete reason, without losing the summary payload

It should not silently convert a successful run into not-delivered with summary: null, and it definitely should not hit an unhandled promise rejection in the gateway.

extent analysis

TL;DR

The most likely fix for the OpenClaw cron job issue is to address the agent event listener lifecycle bug, potentially by ensuring that agent listeners are properly cleaned up after a run is completed.

Guidance

  • Investigate the agent event listener lifecycle to identify the root cause of the unhandled promise rejection error.
  • Review the cron announce delivery finalization and supervisor stdout updates to ensure they are properly synchronized with the run completion state.
  • Consider adding logging or debugging statements to track the execution flow and identify potential race conditions.
  • Examine the queue/lane delay and its interaction with run completion state to determine if it contributes to the issue.

Example

No specific code example is provided due to the lack of explicit code references in the issue.

Notes

The provided information suggests a complex issue involving multiple components and potential race conditions. A thorough investigation of the agent event listener lifecycle, cron job delivery, and queue/lane delay is necessary to identify the root cause.

Recommendation

Apply a workaround to mitigate the issue, such as implementing a retry mechanism for failed deliveries or adding additional logging to help identify the root cause. This is recommended because the issue appears to be related to a bug in the OpenClaw system, and a workaround can help minimize the impact until a fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

If a cron run reaches status: ok, OpenClaw should either:

  • deliver the final summary successfully, or
  • mark the run as a delivery error with a concrete reason, without losing the summary payload

It should not silently convert a successful run into not-delivered with summary: null, and it definitely should not hit an unhandled promise rejection in the gateway.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING