openclaw - 💡(How to fix) Fix [Feature]: Discord - auto-inject @mention for guild message replies [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51534Fetched 2026-04-08 01:09:53
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

In a multi-agent Discord setup with replyToMode: all and requireMention: true, agents often fail to include <@userID> mentions in their replies. This means the original message author does not receive a Discord notification, even though the bot is replying to them.

Root Cause

In a multi-agent Discord setup with replyToMode: all and requireMention: true, agents often fail to include <@userID> mentions in their replies. This means the original message author does not receive a Discord notification, even though the bot is replying to them.

Code Example

{
  "channels": {
    "discord": {
      "autoMentionReply": true
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

In a multi-agent Discord setup with replyToMode: all and requireMention: true, agents often fail to include <@userID> mentions in their replies. This means the original message author does not receive a Discord notification, even though the bot is replying to them.

Problem

When an agent replies to a message in a guild channel:

  1. replyToMode: all adds message_reference (quote reply) — ✅ works
  2. But the agent LLM does not reliably include <@originalAuthorID> in the message text
  3. Discord reply notifications depend on allowed_mentions.replied_user being true (which is the default), BUT many users expect an explicit <@ID> mention for visibility
  4. When agents are triggered via sessions_send or new thread sessions, there may be no replyTo context at all, so even message_reference is missing

Proposed Solution

Add a new config option channels.discord.autoMentionReply (default: false):

{
  "channels": {
    "discord": {
      "autoMentionReply": true
    }
  }
}

When enabled, the gateway automatically prepends <@originalAuthorID> to the first outbound message chunk when:

  • The message is a reply (has message_reference)
  • The message text does not already contain <@originalAuthorID>
  • The channel is a guild channel (not DM)

This ensures the original author always gets notified, regardless of whether the LLM remembered to include the mention.

Alternatives Considered

  1. SOUL.md rules: Unreliable — LLMs do not consistently follow mention formatting rules
  2. allowed_mentions.replied_user: true: Already default, but does not add visible @ in message text
  3. Post-processing middleware: Would work but adds complexity outside the gateway

Environment

  • OpenClaw version: 2026.3.8
  • Setup: 26 Discord bots, single gateway, allowBots: "mentions", requireMention: true, replyToMode: all
  • Use case: Multi-agent team collaboration server where bots need to notify each other and human users reliably

extent analysis

Fix Plan

To fix the issue of agents failing to include <@userID> mentions in their replies, we will implement the proposed solution by adding a new config option channels.discord.autoMentionReply and modifying the gateway to automatically prepend the mention to the outbound message.

Step-by-Step Solution:

  1. Add config option: Update the config file to include the new option:
{
  "channels": {
    "discord": {
      "autoMentionReply": true
    }
  }
}
  1. Modify gateway: Update the gateway code to check for the autoMentionReply option and prepend the mention to the outbound message if necessary:
if (config.channels.discord.autoMentionReply && message.reference && !message.content.includes(`<@${message.reference.author.id}>`)) {
  message.content = `<@${message.reference.author.id}> ${message.content}`;
}
  1. Verify guild channel: Ensure the channel is a guild channel before prepending the mention:
if (message.channel.type === 'GUILD_TEXT' && config.channels.discord.autoMentionReply) {
  // prepend mention
}

Verification

To verify that the fix worked, test the following scenarios:

  • Send a message to a bot and verify that the bot's reply includes the <@userID> mention.
  • Test with multiple bots and users to ensure the mention is always included.
  • Check that the mention is not prepended to messages in DM channels.

Extra Tips

  • Make sure to update the documentation to reflect the new config option and its behavior.
  • Consider adding logging to track when the mention is automatically prepended to ensure it's working as expected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING