Skip to content

fix: deliver group/channel replies automatically when bot is @mentioned#75327

Closed
dalu610 wants to merge 12 commits into
openclaw:mainfrom
dalu610:fix/group-mention-reply-delivery
Closed

fix: deliver group/channel replies automatically when bot is @mentioned#75327
dalu610 wants to merge 12 commits into
openclaw:mainfrom
dalu610:fix/group-mention-reply-delivery

Conversation

@dalu610

@dalu610 dalu610 commented May 1, 2026

Copy link
Copy Markdown

Problem

Since v2026.4.27, groups and channels default sourceReplyDeliveryMode to "message_tool_only", which suppresses all automatic reply delivery — even when the bot is directly @mentioned. The model runs and generates output, but dispatchReplyFromConfig gates on !suppressDelivery and drops the response (replies=0).

Root Cause

resolveSourceReplyDeliveryMode does not consult ctx.WasMentioned. When a user @mentions the bot in a group or channel, they expect a visible response — the same contract as a DM. But the delivery mode stays "message_tool_only" regardless.

Fix

Add WasMentioned to SourceReplyDeliveryModeContext and check it in the group/channel branch: when the bot was directly @mentioned, override the default to "automatic". Falls through to the existing config/default path when WasMentioned is false or undefined.

Changes

  • source-reply-delivery-mode.ts: Add WasMentioned?: boolean to the context type. When WasMentioned === true in group/channel, force mode = "automatic".
  • source-reply-delivery-mode.test.ts: Add tests for WasMentioned: true in groups/channels returning "automatic", WasMentioned: false falling through to message_tool_only, and resolveSourceReplyVisibilityPolicy not suppressing delivery when mentioned.

No behavioral change for non-mentioned messages — the default remains message_tool_only with the existing private-delivery warning.

Relates to #74876.

Before / After

Before: @mention in group → dispatch complete (replies=0)
After: @mention in group → dispatch complete (replies=1)

@clawsweeper

clawsweeper Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main and v2026.5.28 already implement the central visible-reply behavior: normal group/channel source replies default to automatic delivery, while explicit message-tool-only mode remains documented opt-in behavior. The PR head no longer adds a runtime delivery change beyond current main and carries broad unrelated churn, so it is not useful as a landing branch.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the shipped automatic group/channel default and leave explicit message-tool-only room behavior as the documented opt-in path; any remaining typed-context or test cleanup should be proposed as a narrow PR without unrelated churn.

Do we have a high-confidence way to reproduce the issue?

No. Current main and v2026.5.28 resolve normal unconfigured group/channel source replies to automatic delivery; explicit message-tool-only suppression is now documented opt-in behavior rather than the original bug.

Is this the best way to solve the issue?

No. The current branch is not the best solution to land because current main already has the runtime behavior, and the remaining type/test slice is mixed with broad unrelated churn.

Security review:

Security review cleared: No concrete security or supply-chain regression was found; the script/template changes are unrelated churn but not a specific security issue.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • Peter Steinberger: The v2026.5.28 tag commit carries the shipped resolver, docs, and test state that already implement the central behavior. (role: release provenance; confidence: medium; commits: e93216080aa1; files: src/auto-reply/reply/source-reply-delivery-mode.ts, src/auto-reply/reply/source-reply-delivery-mode.test.ts, docs/gateway/config-channels.md)
  • Vincent Koc: Current-main blame for the resolver and visible-reply docs points to recent work carrying the same automatic group/channel behavior forward. (role: recent area contributor; confidence: medium; commits: 72ed2121f8f5, 340cc2c1e41c; files: src/auto-reply/reply/source-reply-delivery-mode.ts, docs/gateway/config-channels.md)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 340cc2c1e41c; fix evidence: release v2026.5.28, commit e93216080aa1.

@dalu610

dalu610 commented May 1, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough review! Both points addressed:

P2 (pre-resolution bypass): Fixed in 1f131b3. Moved the WasMentioned override out of the group/channel default branch so it applies after ALL resolution paths — including when Discord/Slack pre-resolve to message_tool_only and pass it as requested. Now WasMentioned === true && mode === "message_tool_only" unconditionally flips to "automatic", regardless of how message_tool_only was arrived at.

P3 (documentation): Agreed — if maintainers accept the @mention exception, docs and changelog should be updated. Happy to add those in a follow-up once the product decision is made.

New test: "overrides requested message_tool_only when bot is @mentioned" — covers the Discord/Slack pre-resolution case directly.

dabao added 4 commits May 1, 2026 13:58
When the bot is directly @mentioned in a group or channel, always
use 'automatic' delivery mode so users get a visible response.
Without a mention, the existing message_tool_only default is preserved.

This fixes the behavior where users @mention the bot in groups with
groupPolicy=open but never receive a visible reply because
sourceReplyDeliveryMode defaults to message_tool_only.

Root cause: resolveSourceReplyDeliveryMode unconditionally returned
message_tool_only for group/channel chats, ignoring WasMentioned.

Changes:
- Add WasMentioned to SourceReplyDeliveryModeContext type
- Check WasMentioned in resolveSourceReplyDeliveryMode — return
  'automatic' when true for group/channel chats
- Add unit tests for @mention delivery behavior
…ested mode

Discord and Slack pre-resolve sourceReplyDeliveryMode without
WasMentioned context, then pass it as an explicit "requested" mode
into the dispatch pipeline.  Move the WasMentioned → automatic
override so it applies after every mode resolution path (defaults,
config, requested, native) — not just the group/channel default
branch.  This ensures @mentioned messages always get a visible
reply, matching user expectation.

Adds a test for the pre-resolution override case (requested=
message_tool_only + WasMentioned=true).
Upstream removed the logger/warning infrastructure; the test assertion
no longer applies and was causing a TS2304 error in CI.
Upstream reordered the resolver to return early when a requested mode
is provided, which would skip the post-resolution WasMentioned override.
Add the WasMentioned check inside the requested branch so Discord/Slack
pre-resolution paths still get the override.
@dalu610
dalu610 force-pushed the fix/group-mention-reply-delivery branch from 1f131b3 to 2c5d72f Compare May 1, 2026 06:02
@dalu610

dalu610 commented May 1, 2026

Copy link
Copy Markdown
Author

Note: the CI failures (checks-node-agentic-cli, check-dependencies, check-additional-boundaries, build-artifacts) are pre-existing and unrelated to this PR. The relevant test passes cleanly:

✓ unit-fast src/auto-reply/reply/source-reply-delivery-mode.test.ts (20 tests) 4ms

@dalu610

dalu610 commented May 6, 2026

Copy link
Copy Markdown
Author

This is a bug, not a privacy feature

I want to push back on the "privacy-sensitive" framing from the automated review. The distinction matters:

Unsolicited bot activity in groups → that's a privacy concern. A bot reading every message and responding uninvited could leak information or cause disruption. The message_tool_only default makes sense for this case.

@mention → this is the exact opposite. An @mention is an explicit handshake from the user to the bot, just like a DM. The user is actively saying "I want the bot to see this and respond." When the bot receives an @mention, runs the model, generates a reply, and then discards it silently (replies=0 in logs, suppressDelivery=true), that is unambiguously a bug — not a privacy protection.

The current behavior violates the basic contract of @mention: you call the bot, it processes your message, and you get nothing back. Users see "processing…" but never receive a reply. This has been reported across all platforms (#74876, #77808).

This PR fixes the bug with surgical precision:

  • Non-mentioned messages: default message_tool_only preserved ✓
  • @mentioned messages: deliver automatically ✓
  • No config changes needed for existing users ✓

Would also suggest adding a bug / bug:behavior label to this PR — this is restoring expected behavior that was broken in v2026.4.27.

@hclsys

This comment was marked as low quality.

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 14, 2026
# Conflicts:
#	src/logging/diagnostic.test.ts
# Conflicts:
#	src/auto-reply/reply/source-reply-delivery-mode.test.ts
#	src/auto-reply/reply/source-reply-delivery-mode.ts
@dalu610
dalu610 requested a review from a team as a code owner June 2, 2026 00:49
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix channel: nostr Channel integration: nostr channel: zalo Channel integration: zalo app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling extensions: qa-lab extensions: memory-wiki extensions: codex extensions: diagnostics-prometheus extensions: deepinfra extensions: oc-path extensions: diffs extensions: openrouter size: XL and removed size: S labels Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 2, 2026
@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: matrix Channel integration: matrix channel: nostr Channel integration: nostr channel: zalo Channel integration: zalo cli CLI command changes commands Command implementations docker Docker and sandbox tooling extensions: codex extensions: deepinfra extensions: diagnostics-prometheus extensions: diffs extensions: memory-core Extension: memory-core extensions: memory-wiki extensions: oc-path extensions: openrouter extensions: qa-lab gateway Gateway runtime mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants