openclaw - 💡(How to fix) Fix [2026.4.5 regression] Agent crash when bash tool calls 'openclaw message send' — 'Agent listener invoked outside active run' [2 comments, 2 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#61812Fetched 2026-04-08 02:54:13
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
3
Author
Participants
Timeline (top)
cross-referenced ×3commented ×2subscribed ×1

When a bash tool running inside an agent session calls openclaw message send, the gateway throws an unhandled promise rejection and crashes immediately after the send succeeds.

Error Message

Error: Agent listener invoked outside active run
    at Agent.processEvents (agent.ts:533)
    at agent-loop.ts:539
    at exec-defaults: emitUpdate (line 1524)
    at handleStdout (line 1546)
    at onSupervisorStdout (line 1610)

Root Cause

Root cause hypothesis

In 2026.4.5, the successful send of a Telegram message via openclaw message send (called from within a bash subprocess) appears to trigger an agent listener callback through the same event bus as incoming messages. By the time the stdout confirmation arrives through the subprocess pipe (handleStdout → emitUpdate → Agent.processEvents), the agent run has already been marked complete, causing the "outside active run" crash. This did not occur in 2026.4.2.

Fix Action

Workaround

Roll back to 2026.4.2. Note: rolling back also requires manually removing the plugins.entries.memory-core.config.dreaming field from openclaw.json (written by 4.5, not recognized by 4.2, causes boot loop).

Code Example

Error: Agent listener invoked outside active run
    at Agent.processEvents (agent.ts:533)
    at agent-loop.ts:539
    at exec-defaults: emitUpdate (line 1524)
    at handleStdout (line 1546)
    at onSupervisorStdout (line 1610)

---

[09:43:52][INFO]Sent via Telegram. Message ID: 8814
[09:43:52][ERROR] Unhandled promise rejection: Error: Agent listener invoked outside active run
[09:44:xx][INFO] gateway loading configuration...   ← restart
RAW_BUFFERClick to expand / collapse

Version

2026.4.5 (regression from 2026.4.2)

Description

When a bash tool running inside an agent session calls openclaw message send, the gateway throws an unhandled promise rejection and crashes immediately after the send succeeds.

Error

Error: Agent listener invoked outside active run
    at Agent.processEvents (agent.ts:533)
    at agent-loop.ts:539
    at exec-defaults: emitUpdate (line 1524)
    at handleStdout (line 1546)
    at onSupervisorStdout (line 1610)

Log evidence

[09:43:52][INFO] ✅ Sent via Telegram. Message ID: 8814
[09:43:52][ERROR] Unhandled promise rejection: Error: Agent listener invoked outside active run
[09:44:xx][INFO] gateway loading configuration...   ← restart

The crash occurs at the exact millisecond the send succeeds, every time.

Reproduction

  1. Start an agent session triggered by a Telegram message
  2. Agent runs a bash tool that calls openclaw message send --channel telegram --target <id> --message "..." mid-script
  3. Gateway crashes immediately after the send succeeds; bash subprocess is killed, run is lost

Impact

Any bash tool that sends Telegram notifications during execution will crash the gateway and interrupt the entire run. This affects all scripts using openclaw message send as a progress notification mechanism.

Workaround

Roll back to 2026.4.2. Note: rolling back also requires manually removing the plugins.entries.memory-core.config.dreaming field from openclaw.json (written by 4.5, not recognized by 4.2, causes boot loop).

Root cause hypothesis

In 2026.4.5, the successful send of a Telegram message via openclaw message send (called from within a bash subprocess) appears to trigger an agent listener callback through the same event bus as incoming messages. By the time the stdout confirmation arrives through the subprocess pipe (handleStdout → emitUpdate → Agent.processEvents), the agent run has already been marked complete, causing the "outside active run" crash. This did not occur in 2026.4.2.

extent analysis

TL;DR

The most likely fix is to modify the agent listener callback to handle events triggered by outgoing messages sent via openclaw message send without assuming an active run.

Guidance

  • Investigate the Agent.processEvents function in agent.ts to understand how it handles events and why it throws an error when invoked outside an active run.
  • Verify that the openclaw message send command is indeed triggering an agent listener callback through the same event bus as incoming messages, as hypothesized in the root cause analysis.
  • Consider adding a check in the agent listener callback to ignore events triggered by outgoing messages sent via openclaw message send when the agent run is not active.
  • Review the changes made in version 2026.4.5 to identify what introduced this regression and assess whether a similar fix can be applied to the current version.

Example

No code snippet is provided as the issue does not contain sufficient information to create a concrete example.

Notes

The provided workaround of rolling back to version 2026.4.2 may not be feasible in all cases, and a more permanent fix is needed. The root cause hypothesis suggests that the issue is related to the interaction between the agent listener callback and the event bus, but further investigation is required to confirm this.

Recommendation

Apply a workaround by modifying the agent listener callback to handle events triggered by outgoing messages sent via openclaw message send, as this is likely to be a more feasible solution than rolling back to a previous version.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [2026.4.5 regression] Agent crash when bash tool calls 'openclaw message send' — 'Agent listener invoked outside active run' [2 comments, 2 participants]