Skip to content

fix(openclaw): capture inbound identity on message_received so Goals can start - #5530

Merged
nicoloboschi merged 2 commits into
mainfrom
fix/openclaw-goal-before-dispatch
Oct 12, 2026
Merged

nicoloboschi merged 2 commits into
mainfrom
fix/openclaw-goal-before-dispatch

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Closes #5177.

Bug: OpenClaw refuses to start or resume a Goal while any plugin registers before_dispatch, because it can't replay that hook after a restart (src/plugins/restart-recovery-hook-safety.ts). With Hindsight enabled, Goal start failed with "Goal start or resume requires the built-in OpenClaw runtime and an idle local session with recoverable history".

Fix: our before_dispatch only cached the sender and dispatch surface per session. message_received carries the same fields (ctx.channelId is the surface, senderId, sessionKey), fires earlier on the same inbound path, and is not on OpenClaw's restart-unsafe list. The handler body is unchanged apart from reading the surface from ctx.channelId.

Test: goal-safe-hooks.test.ts fails if the plugin registers any of OpenClaw's four Goal-unsafe hooks. It fails on main.

Verified on real OpenClaw 2026.10.2 (built-in runtime, local Hindsight API), Goal start via chat.send with a session-goal-start intent:

plugin Goal start web-chat turns saved
0.13.0 enabled rejected n/a
plugin disabled starts n/a
this branch starts 2 / 2

A probe confirmed message_received fires before before_dispatch with the same channel, sender and session, and the debug log shows the identity cached from it (webchat/webchat sender=cli).

…can start

OpenClaw refuses to start or resume a Goal while any plugin registers
before_dispatch (it cannot replay that hook after a restart), so enabling
Hindsight blocked Goals with "Goal start or resume requires the built-in
OpenClaw runtime...". The hook only cached the sender and dispatch surface.
message_received carries the same fields and fires earlier on the same
inbound path, and is not on OpenClaw's restart-unsafe list.

The new test fails if the plugin registers any of OpenClaw's Goal-unsafe
hooks.

Closes #5177
@nicoloboschi
nicoloboschi merged commit 9e3e26f into main Oct 12, 2026
99 checks passed
@nicoloboschi
nicoloboschi deleted the fix/openclaw-goal-before-dispatch branch October 12, 2026 10:57
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenClaw: before_dispatch hook blocks web UI Goal start and resume

1 participant