Skip to content

fix(signal): fall back to toolContext.currentMessageId for reactions#32217

Merged
steipete merged 2 commits intoopenclaw:mainfrom
dunamismax:fix/signal-reaction-messageid-fallback
Mar 2, 2026
Merged

fix(signal): fall back to toolContext.currentMessageId for reactions#32217
steipete merged 2 commits intoopenclaw:mainfrom
dunamismax:fix/signal-reaction-messageid-fallback

Conversation

@dunamismax
Copy link
Contributor

Problem

Signal reactions required an explicit messageId parameter from the agent, but the agent has no reliable way to obtain it. The inbound message ID is available in toolContext.currentMessageId (populated from MessageSid), but the Signal action handler never used it as a fallback.

Telegram already implements this fallback pattern — Signal was the gap.

Closes #17651

Changes

  • src/channels/plugins/actions/signal.ts: Destructure toolContext in the handler and fall back to toolContext.currentMessageId when messageId isn't provided explicitly. Same pattern as Telegram.
  • src/agents/tools/message-tool.ts: Updated reaction schema descriptions to remove the Telegram-specific qualifier — this fallback now works across channels.
  • src/channels/plugins/actions/actions.test.ts: Two new tests verifying the fallback works and that missing messageId without context still rejects properly. Updated runSignalAction helper to pass toolContext.

Testing

  • All 36 existing + new tests pass (vitest run src/channels/plugins/actions/actions.test.ts)
  • Minimal, surgical change matching the established Telegram pattern

Signal reactions required an explicit messageId parameter, unlike
Telegram which already fell back to toolContext.currentMessageId.
This made agent-initiated reactions fail on Signal because the
inbound message ID was available in tool context but never used.

- Destructure toolContext in Signal action handler
- Fall back to toolContext.currentMessageId when messageId omitted
- Update reaction schema descriptions (not Telegram-specific)
- Add tests for fallback and missing-messageId rejection

Closes openclaw#17651
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e36ba384d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +130 to +131
readStringParam(params, "messageId") ??
(toolContext?.currentMessageId != null ? String(toolContext.currentMessageId) : undefined);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor numeric messageId before falling back to tool context

When react is called with a numeric messageId (a common shape for timestamp IDs) and toolContext.currentMessageId is present, readStringParam returns undefined for the numeric value and the ?? fallback silently uses the inbound message ID instead. In that scenario the reaction is applied to the wrong message rather than the explicitly requested one. Coerce/validate messageId from both string and number before consulting the fallback.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Implemented fallback to toolContext.currentMessageId for Signal reactions when messageId parameter isn't explicitly provided by the agent. This brings Signal in line with Telegram's established pattern and fixes issue #17651.

Key changes:

  • Added toolContext parameter destructuring in Signal's handleAction
  • Falls back to toolContext.currentMessageId (populated from inbound MessageSid) when messageId is omitted
  • Properly converts currentMessageId (which can be string | number) to string for Signal's timestamp-based message IDs
  • Updated schema descriptions to indicate this fallback now works across channels, not just Telegram
  • Added comprehensive test coverage for both fallback success and error cases

The implementation is clean, surgical, and follows established patterns. The type conversions are correct, error messages are clear, and test coverage is thorough.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Small, focused change with clear intent. Follows established Telegram pattern, includes proper error handling, has comprehensive test coverage, and correctly handles type conversions. No breaking changes or security concerns.
  • No files require special attention

Last reviewed commit: e36ba38

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S labels Mar 2, 2026
@dunamismax
Copy link
Contributor Author

image

@dunamismax
Copy link
Contributor Author

Live-patched the fix onto my running OpenClaw instance and tested Signal reactions end-to-end before the PR was even open. The toolContext.currentMessageId fallback works exactly as expected — first successful agent-initiated Signal reaction. 🔥 reacted and received.

The followup runner (which processes queued messages) was calling
runEmbeddedPiAgent without currentChannelId or currentThreadTs.
This meant the message tool's toolContext had no channel routing
info, causing reactions (and other target-inferred actions) to
fail with 'Action react requires a target' on queued messages.

Pass originatingTo as currentChannelId so the message tool can
infer the reaction target from context, matching the behavior
of the initial (non-queued) agent run.
@steipete steipete merged commit f431f20 into openclaw:main Mar 2, 2026
19 of 21 checks passed
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Changelog + regression-coverage follow-up landed in #32274 after merge sequencing race:

Contributor authorship for this fix remains retained on the merged commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent cannot react to messages: messageId not exposed in inbound context

2 participants