feat(discord): preserve user mention UIDs for LLM mention-back#461
Merged
thepagent merged 1 commit intoopenabdev:mainfrom Apr 19, 2026
Merged
Conversation
cfa4e23 to
f4181c0
Compare
thepagent
approved these changes
Apr 19, 2026
Collaborator
thepagent
left a comment
There was a problem hiding this comment.
LGTM — clean implementation.
- Inbound
resolve_mentions()now runs unconditionally (good: thread follow-ups also get enrichment) - Outbound
strip_mention_names()correctly applied in both streaming and final send paths - Regex safety verified:
USER_MENTION_REwon't clobber resolved<@UID|Name>mentions - No Slack impact (separate code paths)
- Empirically confirmed Discord does not render
<@UID|Name>(see #460 comment)
Minor note: for thread follow-ups without explicit @mention, msg.mentions may be sparse — unresolved UIDs fall through to @(user) which is acceptable.
dc3eb9e to
6668e62
Compare
6668e62 to
bce12c9
Compare
bce12c9 to
80e0010
Compare
80e0010 to
60db6f9
Compare
d99f136 to
bf6f354
Compare
thepagent
approved these changes
Apr 19, 2026
Simplify resolve_mentions() to keep other-user <@uid> mentions as-is instead of resolving them to @DisplayName (which discards the UID). This lets the LLM copy <@uid> into its reply for correct Discord mention rendering. - Remove mention-to-DisplayName resolution (step 2) - Remove USER_MENTION_RE (no longer needed) - Call resolve_mentions unconditionally (not just when is_mentioned) Closes openabdev#460
bf6f354 to
d866166
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #460
Simplify
resolve_mentions()to keep other-user<@UID>mentions as-is instead of resolving them to@DisplayName(which discards the UID). This lets the LLM copy<@UID>into its reply for correct Discord mention rendering — no outbound transformation needed.Changes (
src/discord.rs, +6/-24)<@UID>→@DisplayName. User mentions pass through as raw<@UID>.USER_MENTION_RE— no longer needed since user mentions are preserved.mentionsparameter —resolve_mentionsno longer needs the serenityUserlist.is_mentioned, so thread follow-ups also get bot-mention stripping.What stays the same
@(role)fallbacksend_message/ outbound: untouchedWhy preserve raw
<@UID>instead of<@UID|DisplayName>We explored
<@UID|DisplayName>(Slack-style) but LLMs don't reliably preserve token formats — the model might respond with@Name,<@Name>, or<@UID|Name>. Only raw<@UID>is safe:<@UID>→ Discord renders clickable mention ✅@Name→ plain text, no worse than beforeRecommended usage: ice-breaking in multi-bot chatrooms
Since
<@UID>is now preserved, bots need a UID→name mapping to know who is who. The recommended approach is to send an ice-breaking greeting at the start of a multi-bot chatroom (via system prompt or context entry):This lets each bot build the UID→name mapping in its own context from the very beginning and learn how to mention others correctly.
Design notes
Slack isolation: Slack has its own independent mention handling in
src/slack.rs. Not touched.Thread title:
shorten_thread_name()will show raw<@UID>in thread titles. Pre-existing gap (old code stripped mentions entirely), can be addressed separately.DC: https://discord.com/channels/1491295327620169908/1494739741600387204/1495368292146217071