openclaw - ✅(Solved) Fix [Bug]: event.messages.push [2 pull requests, 1 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#63601Fetched 2026-04-10 03:42:36
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2commented ×1referenced ×1

I want to set up a quick reply after receiving a message. I defined a hook to listen for the message:received event and push a message into event.messages, but it seems this approach cannot actually send the message back to the user.

const handler = async (event) => {
  console.log(`[my-hook] New command triggered`);
  if (event.type !== "message" && event.action !== "received") {
    return;
  }
  // send message to user
  event.messages.push("Hook executed!");
};
export default handler;

Root Cause

I want to set up a quick reply after receiving a message. I defined a hook to listen for the message:received event and push a message into event.messages, but it seems this approach cannot actually send the message back to the user.

const handler = async (event) => {
  console.log(`[my-hook] New command triggered`);
  if (event.type !== "message" && event.action !== "received") {
    return;
  }
  // send message to user
  event.messages.push("Hook executed!");
};
export default handler;

Fix Action

Fixed

PR fix notes

PR #63795: fix(hooks): send messages pushed via event.messages in message:received hooks

Description (problem / solution / changelog)

Summary

Closes #63601

  • When a message:received hook replies via event.messages.push(...), those messages are now forwarded to the routing layer as expected — previously only messages from the hook's return value were sent.

This PR was developed with AI assistance (Claude). Built with islo.dev

Changed files

  • src/auto-reply/reply/dispatch-from-config.ts (modified, +32/-9)

PR #63849: fix(hooks): send messages pushed via event.messages in message:received hooks

Description (problem / solution / changelog)

Summary

The message:received internal hook was triggered with fireAndForgetHook(), which discarded the result and never processed messages pushed to event.messages by hook handlers. This caused hooks that push reply messages to silently fail.

Switches to fireHook() so pushed messages are collected and sent.

Closes #63601

Changes

  • Use fireHook() instead of fireAndForgetHook() for the message:received hook
  • Process event.messages after hook execution

Testing

  • Verified that hook handlers pushing messages to event.messages now have those messages delivered

This PR was developed with AI assistance (Claude). Built with islo.dev

Changed files

  • src/auto-reply/reply/dispatch-from-config.ts (modified, +32/-9)

Code Example

const handler = async (event) => {
  console.log(`[my-hook] New command triggered`);
  if (event.type !== "message" && event.action !== "received") {
    return;
  }
  // send message to user
  event.messages.push("Hook executed!");
};
export default handler;

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

I want to set up a quick reply after receiving a message. I defined a hook to listen for the message:received event and push a message into event.messages, but it seems this approach cannot actually send the message back to the user.

const handler = async (event) => {
  console.log(`[my-hook] New command triggered`);
  if (event.type !== "message" && event.action !== "received") {
    return;
  }
  // send message to user
  event.messages.push("Hook executed!");
};
export default handler;

Steps to reproduce

const handler = async (event) => { console.log([my-hook] New command triggered); if (event.type !== "message" && event.action !== "received") { return; } // send message to user event.messages.push("Hook executed!"); }; export default handler;

Expected behavior

send message to user

Actual behavior

user ui not found message

OpenClaw version

2026.3.30

Operating system

ubuntu20.4

Install method

npm

Model

.

Provider / routing chain

.

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The issue is likely due to the incorrect condition in the if statement, preventing the message from being sent to the user.

Guidance

  • The condition event.type !== "message" && event.action !== "received" seems incorrect, as it will only execute the code inside the if block when both conditions are false. Consider changing it to event.type === "message" && event.action === "received".
  • Verify that the event.messages array is being used correctly to send messages to the user. Check the documentation for the messaging system to ensure that pushing messages to this array is the correct way to send them.
  • Check the logs for any errors that may be occurring when trying to send the message.
  • Consider adding additional logging or debugging statements to understand the flow of the code and why the message is not being sent.

Example

const handler = async (event) => {
  console.log(`[my-hook] New command triggered`);
  if (event.type === "message" && event.action === "received") {
    // send message to user
    event.messages.push("Hook executed!");
  }
};
export default handler;

Notes

The provided code snippet seems to be the same in both the summary and steps to reproduce sections, which may indicate a copy-paste error. Additionally, there is no information about the expected behavior of the event.messages array, which makes it difficult to provide a more specific solution.

Recommendation

Apply workaround: The recommended solution is to change the condition in the if statement to event.type === "message" && event.action === "received" and verify that the event.messages array is being used correctly. This should fix the issue and allow the message to be sent to the user.

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

send message to user

Still need to ship something?

×6

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

Back to top recommendations

TRENDING