fix(discord): send_message for streaming replies with bot mentions - #1112
Merged
Conversation
added 3 commits
June 14, 2026 23:51
- Support nickname-style mentions (<@!UID>) in contains_bot_mention() - Add platform == "discord" check so the delete+send path only applies to Discord, not Slack or other adapters - Fix misleading comment about '!' being for role mentions
Role mentions (e.g. <@&1496247626675257384>) should also trigger MESSAGE_CREATE so all bots with that role receive the gateway event.
Covers user mentions (<@uid>), nickname mentions (<@!UID>), role mentions (<@&ROLE_ID>), and negative cases.
thepagent
approved these changes
Jun 15, 2026
tomcatzh
added a commit
to tomcatzh/openab
that referenced
this pull request
Jun 30, 2026
…openabdev#1198 bd16546) Re-implemented (not merged) from upstream openab onto the 0.8.4 patch branch, kept consistent with upstream shapes/names for future convergence. All in the handoff-critical adapter path the local fork already owns. openabdev#1153 mention propagation across split chunks: a >2000-char reply mentioning a peer is split, but only chunk 1 carries the mention, so a receiver gated on mentions (allowBotMessages="off" + trustedBotIds, accept only when mentioned) rejects chunks 2+ and silently truncates the handoff. extract_mentions() + propagate_mentions_to_chunks() now append every mention to each chunk (pre-deducting the footer from the split limit so it never busts 2000), Discord-only, at the single split site that feeds every send path. openabdev#1112 auto MESSAGE_CREATE on bot-mention: the streaming path edits the reply into the placeholder (MESSAGE_UPDATE), which Discord emits no mention notification for (openabdev#1110), so a mentioned peer never wakes. Now if the content mentions a bot and there is no [[reply_to]] directive, delete the placeholder and send as new message(s). contains_bot_mention() + a new streaming branch. openabdev#1198 EOF without final response: the recv-loop broke silently to "_(no response)_" when the agent stdout closed without an id-bearing session/prompt response (a bridged agent crashing on backend HTTP 500 / quota exhaustion exits without an ACP error). Now sets response_error = "Agent process exited unexpectedly". bd16546 silent empty turn: stopReason="end_turn" with 0 output tokens is a silent provider/auth failure. Added TurnResult / parse_turn_result / is_silent_failure (protocol.rs, exported via mod.rs); the result branch surfaces a diagnostic instead of "_(no response)_". Tests: +21 unit tests; cargo test = 521 passed, 0 failed. Rollback: tag pre-upstream-ports-2026-06-30. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
When a streaming response contains
<@UID>bot mentions, the current code edits the placeholder message (MESSAGE_UPDATE). Discord does not send mention notifications for edited messages, so the mentioned bot never receives the gateway event.Root Cause
Fix
In the streaming finalization path, detect if the final content contains Discord mentions (
<@UID>,<@!UID>, or<@&ROLE_ID>). If so:MESSAGE_CREATE)This ensures Discord triggers the mention notification and the mentioned bot receives the gateway event.
Scope
adapter.platform() == "discord"; Slack and other adapters are unaffectedsend_messageand works correctly<@123>), nickname mentions (<@!123>), and role mentions (<@&123>)What Was Tested
POST /channels/{thread_id}/messageswith<@bot_id>triggers the mentioned bot ✅edit_messagewith the same mention does not trigger the mentioned bot ❌checkpassed ✅Fixes #1110