fix(actions): send media after card instead of silently dropping it#297
fix(actions): send media after card instead of silently dropping it#297panpeter2024 wants to merge 1 commit intolarksuite:mainfrom
Conversation
When both card and mediaUrl are present in a send action, deliverMessage only sent the card and returned immediately, silently discarding the media file. This caused image files to be lost when sent alongside interactive cards. Follow the same pattern as reply-dispatcher.ts: send the card first, then deliver media as a separate message. Ref: openclaw/openclaw#55091 Made-with: Cursor
HanShaoshuai-k
left a comment
There was a problem hiding this comment.
Thanks for the PR! I took a closer look at the code and related context, and I think the current card/media mutual exclusion in deliverMessage is intentional rather than a gap:
payloadTypeis computed ascard ? 'card' : mediaUrl ? 'media' : 'text'— modeling the three as mutually exclusive types.- The #288 fix (treating empty
{}asundefined) was specifically designed to let routing fall through to the media branch correctly, which confirms the mutual-exclusion model. sendCardLark's error message explicitly recommends: "If you need images, send them as separate media messages, not inside cards."messageToolHintsmakes no mention of card + media combination.
In practice, an LLM agent almost never fills both card and filePath/media in a single tool call. Other channel plugins in the openclaw core repo don't support this combination either — Slack even rejects it explicitly with "Slack send does not support blocks with mediaUrl".
If we do want to handle the edge case where an agent mistakenly passes both, I'd suggest explicitly rejecting with a clear error (consistent with Slack's approach) rather than silently splitting into two messages — that way the agent learns to make separate calls.
|
Peter seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Summary
deliverMessageto send both card and media when both are present, instead of silently dropping the media fileProblem
When using the
messagetool'ssendaction with both acardand afilePath/mediaparameter, the media file is silently dropped. ThedeliverMessagefunction inactions.tssends only the card and returns immediately, never reaching the media delivery path.Before (broken):
After (fixed):
This follows the same pattern already used by
reply-dispatcher.ts(line 297-361) andoutbound.ts(line 215-238), where card and media are sent as separate messages.Root cause
In
deliverMessage(src/messaging/outbound/actions.ts), the card path had an earlyreturnthat prevented media from ever being sent:Fix
Added a
card && mediaUrlbranch that sends card first, then delivers media:Test plan
tsc --noEmitpassescard+filePath→ both card and image deliveredcardonly → card delivered (unchanged)filePathonly → image delivered (unchanged)Ref: openclaw/openclaw#55091
Made with Cursor