fix(auto-reply): preserve session text when message tool sends only media#37900
fix(auto-reply): preserve session text when message tool sends only media#37900Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…edia When the message tool sends media to the same target in the same turn, shouldSuppressMessagingToolReplies returns true and all final payloads (including the agent's text response) are dropped. This silently loses the session text with no error or warning. Gate the suppression on messagingToolSentTexts.length > 0 so that media-only sends do not trigger reply suppression. Text deduplication still works when the tool sends text content to the same target. Closes openclaw#37841
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟠 Messaging-tool suppression bypass when sends contain no tracked text (media/caption/components) causing duplicate outbound replies
Description
As a result:
This creates an abuse/spam/billing amplification vector: a malicious prompt (or a user prompt that the agent follows) can instruct the agent to send via the messaging tool using non-text fields (e.g., media + caption) to keep Vulnerable logic: const messagingToolSentText = messagingToolSentTexts.length > 0;
const suppressMessagingToolReplies =
messagingToolSentText &&
shouldSuppressMessagingToolReplies({ ... });
const dedupeMessagingToolPayloads =
suppressMessagingToolReplies || messagingToolSentTargets.length === 0;RecommendationDecouple suppression (whether to drop all final replies) from dedupe (removing duplicates) and base both on whether the messaging tool actually sent anything to the same origin target, not on Safer options:
const sentSameTarget = shouldSuppressMessagingToolReplies({
messageProvider: resolveOriginMessageProvider({
originatingChannel: params.originatingChannel,
provider: params.messageProvider,
}),
messagingToolSentTargets,
originatingTo: resolveOriginMessageTo({ originatingTo: params.originatingTo }),
accountId: resolveOriginAccountId({ originatingAccountId: params.accountId }),
});
// Keep the new behavior (don’t drop the whole reply) if tool only sent media,
// but still dedupe against tool-sent media/text.
const suppressMessagingToolReplies = sentSameTarget && messagingToolSentTexts.length > 0;
const dedupeMessagingToolPayloads = sentSameTarget || messagingToolSentTargets.length === 0;
and use that for suppression/guardrails.
Add tests asserting that when a same-target tool send occurs with only media/caption, duplicates are still deduped (and/or suppression is applied according to the intended policy). Analyzed PR: #37900 at commit Last updated on: 2026-03-06T14:47:18Z |
Greptile SummaryThis PR fixes a silent data-loss bug where session text was dropped whenever the message tool sent media to the same target in a single agent turn. The fix gates Core fix is correct — the Media deduplication regression — Confidence Score: 3/5
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21c7dc0e89
ℹ️ 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".
| const messagingToolSentText = messagingToolSentTexts.length > 0; | ||
| const suppressMessagingToolReplies = | ||
| messagingToolSentText && |
There was a problem hiding this comment.
Preserve same-target media dedupe for media-only sends
Conditioning suppression on messagingToolSentTexts.length > 0 breaks the same-target dedupe path when a tool send has no tracked text (for example media-only sends, or caption-based sends where text is not recorded): suppressMessagingToolReplies becomes false, messagingToolSentTargets is non-empty, and dedupeMessagingToolPayloads becomes false, so filterMessagingToolMediaDuplicates is skipped and duplicate attachments can be sent again to the same chat.
Useful? React with 👍 / 👎.
|
To avoid the one mentioned regression, maybe you can check message content to deduplicate the caption across other messages that are indended to be sent from the session? |
Summary
shouldSuppressMessagingToolRepliesonmessagingToolSentTexts.length > 0inbuildReplyPayloads. Media-only sends no longer trigger reply suppression, preserving the agent's session text.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
Expected
Actual
Evidence
New test verifies: media-only message tool send does not suppress session text for same-target WhatsApp delivery.
Human Verification (required)
Compatibility / Migration
Yes— only un-suppresses previously dropped textNoNoFailure Recovery (if this breaks)
src/auto-reply/reply/agent-runner-payloads.tsRisks and Mitigations