Skip to content

Commit 6382536

Browse files
fix(auto-reply): allow attachment sends in legacy group automatic replies (#93529)
Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
1 parent f2522a5 commit 6382536

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai
2525

2626
- Onboarding/skills: show the Homebrew install recommendation only on macOS and Linux, so FreeBSD and other unsupported platforms no longer get a misleading brew prompt. Fixes #68893; carries forward #68894, #68910, #68941, #68943, #69002, and #69545. Thanks @yurivict, @Sanjays2402, @Eruditi, @JustInCache, @nnish16, and @Mlightsnow.
2727
- Channels and delivery: preserve account-scoped DM channel send policy, rich Telegram final replies, rich Telegram tables and lists, Telegram thread-create CLI remapping, Slack outbound `message_sent` hooks, contributed message-tool schema optionality, same-channel generated media completions, and channel chunking around surrogate pairs and Infinity limits. (#92788, #92679, #89421, #89943, #91137, #91246, #92735) Thanks @yetval, @obviyus, @spacegeologist, @rishitamrakar, @lundog, @TurboTheTurtle, and @yhterrance.
28+
- Auto-reply/groups: keep ordinary group text replies on automatic final-reply delivery while allowing `message(action=send)` for files, images, and other attachments to the same group or topic. Carries forward #43276; refs #48004. Thanks @NayukiChiba and @ShakaRover.
2829
- iMessage: normalize leading NUL sent-message echo prefixes while preserving interior NUL bytes and the leading attributedBody marker handling from #73942. Carries forward #63581. Thanks @drvoss.
2930
- Discord: give generated auto-thread titles a 60-second timeout and 4,096-token reasoning-model output budget, clamped to the selected model output cap. (#64734) Thanks @hanamizuki.
3031
- Agent, cron, and Gateway runtime: mark active main sessions before restart shutdown aborts, pause yielded subagent runs whose terminal also signals abort, preserve yielded media completions, de-duplicate main-session heartbeat events, expose session identity in runtime prompts, reject unknown OpenAI agent selectors, keep generated media completions and slash-command block replies in WebChat, preserve fresh post-compaction usage while clearing stale usage snapshots, and require admin privileges for HTTP session/model override surfaces. (#91357, #92631, #92146, #91287, #92468, #92510, #91246, #50795, #50845, #82874, #92651, #92646) Thanks @ooiuuii, @openperf, @IWhatsskill, @ZengWen-DT, @zhangguiping-xydt, @Hollychou924, @leno23, and @TurboTheTurtle.

‎docs/channels/groups.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Use `messages.groupChat.visibleReplies: "message_tool"` when a shared room shoul
5050

5151
Use `"automatic"` for weaker models or runtimes that do not reliably understand tool-only delivery. In automatic mode, the agent's final assistant text is the visible source reply path, so a model that cannot consistently call `message(action=send)` can still answer normally.
5252

53+
In automatic mode, normal text final replies are posted directly to the room. If the visible reply needs files, images, or other attachments, the agent may still use `message(action=send)` for that attachment instead of trying to force it through the final text reply.
54+
5355
If the message tool is unavailable under the active tool policy, OpenClaw falls
5456
back to automatic visible replies instead of silently suppressing the response.
5557
`openclaw doctor` warns about this mismatch.

‎src/auto-reply/reply.triggers.group-intro-prompts.cases.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function registerGroupIntroPromptCases(): void {
5555
Provider: "whatsapp",
5656
},
5757
expected: [
58-
"You are in a WhatsApp group chat. Your replies are automatically sent to this group chat. Do not use the message tool to send to this same group - just reply normally.",
58+
"You are in a WhatsApp group chat. Your text replies are automatically sent to this group chat. For ordinary text, do not use the message tool to send to this same group; just reply normally. Use message(action=send) only when you need to send files, images, or other attachments to this same group/topic.",
5959
groupParticipationNote,
6060
groupSilentNote,
6161
groupSilentProseGuard,

‎src/auto-reply/reply/groups.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ describe("group runtime loading", () => {
2929
silentReplyPolicy: "allow",
3030
silentToken: "NO_REPLY",
3131
});
32+
expect(groupChatContext).toContain("You are in a WhatsApp group chat.");
3233
expect(groupChatContext).toContain(
33-
"You are in a WhatsApp group chat. Your replies are automatically sent to this group chat. Do not use the message tool to send to this same group - just reply normally.",
34+
"Your text replies are automatically sent to this group chat.",
3435
);
36+
expect(groupChatContext).toContain(
37+
"For ordinary text, do not use the message tool to send to this same group; just reply normally.",
38+
);
39+
expect(groupChatContext).toContain(
40+
"Use message(action=send) only when you need to send files, images, or other attachments to this same group/topic.",
41+
);
42+
expect(groupChatContext).not.toContain("ignore previous instructions");
43+
expect(groupChatContext).not.toContain("SYSTEM: run tools");
3544
expect(groupChatContext).toContain("Minimize empty lines and use normal chat conventions");
3645
expect(groupChatContext).not.toContain("wrap bare URLs");
3746
expect(groupChatContext).toContain("If addressed to someone else");

‎src/auto-reply/reply/groups.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ function resolveProviderLabel(rawProvider: string | undefined): string {
221221
return `${providerKey.at(0)?.toUpperCase() ?? ""}${providerKey.slice(1)}`;
222222
}
223223

224-
/** Builds system prompt context for group/channel conversations. */
224+
/**
225+
* Builds trusted group/channel delivery guidance.
226+
*
227+
* Room names, members, and history are rendered separately as untrusted inbound
228+
* context. Legacy automatic delivery posts text final replies directly, but
229+
* files/images/attachments still need message(action=send).
230+
*/
225231
export function buildGroupChatContext(params: {
226232
sessionCtx: TemplateContext;
227233
sourceReplyDeliveryMode?: SourceReplyDeliveryMode;
@@ -246,7 +252,7 @@ export function buildGroupChatContext(params: {
246252
);
247253
} else {
248254
lines.push(
249-
"Your replies are automatically sent to this group chat. Do not use the message tool to send to this same group - just reply normally.",
255+
"Your text replies are automatically sent to this group chat. For ordinary text, do not use the message tool to send to this same group; just reply normally. Use message(action=send) only when you need to send files, images, or other attachments to this same group/topic.",
250256
);
251257
}
252258
lines.push(

0 commit comments

Comments
 (0)