Skip to content

fix: resolve mentions instead of stripping all (#363)#364

Merged
thepagent merged 3 commits intoopenabdev:mainfrom
chaodu-agent:fix/resolve-mentions-363
Apr 15, 2026
Merged

fix: resolve mentions instead of stripping all (#363)#364
thepagent merged 3 commits intoopenabdev:mainfrom
chaodu-agent:fix/resolve-mentions-363

Conversation

@chaodu-agent
Copy link
Copy Markdown
Collaborator

@chaodu-agent chaodu-agent commented Apr 15, 2026

Summary

Fixes #363.

strip_mention used a blanket regex (<@[!&]?\d+>) that removed all Discord mention tokens from the prompt — including references to other bots/users. This broke bot-to-bot collaboration introduced in v0.7.4.

Changes

Replace strip_mention with resolve_mentions(content, bot_id, mentions):

  1. Strip only the bot's own trigger mention<@BOT_ID> is removed
  2. Resolve all other <@ID> to @DisplayName — using msg.mentions from serenity

Before

"<@超渡ID> you can see <@普渡ID> right?"
  → strip_mention → "you can see  right?"   ❌ @普渡法師 erased

After

"<@超渡ID> you can see <@普渡ID> right?"
  → resolve_mentions → "you can see @普渡法師 right?"   ✅

Approach

Follows the same pattern as OpenClaw's resolveDiscordMentionsnever strip, always resolve.

https://discord.com/channels/1491295327620169908/1494031440482926706

Replace strip_mention with resolve_mentions so only the bot's own
trigger mention is removed. All other <@id> tokens are resolved to
@DisplayName using msg.mentions, preserving bot-to-bot @mention
visibility.
@chaodu-agent chaodu-agent requested a review from thepagent as a code owner April 15, 2026 17:55
@github-actions github-actions bot added closing-soon PR missing Discord Discussion URL — will auto-close in 3 days and removed closing-soon PR missing Discord Discussion URL — will auto-close in 3 days labels Apr 15, 2026
超渡法師 added 2 commits April 15, 2026 18:00
- Use str::replace instead of Regex::new in the resolve loop (no
  per-call regex compilation)
- Restore handling of role mentions <@&ID> via the fallback
- Unresolved <@id> tokens (edge case: user not in msg.mentions)
  are replaced with @unknown instead of leaking raw tokens
@thepagent thepagent merged commit 4dadf09 into openabdev:main Apr 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: strip_mention removes all mentions from prompt, breaking bot-to-bot @mention visibility

2 participants