fix: extract <at> tags as standalone post elements for real mentions#480
Open
iamkentzhu wants to merge 2 commits into
Open
fix: extract <at> tags as standalone post elements for real mentions#480iamkentzhu wants to merge 2 commits into
iamkentzhu wants to merge 2 commits into
Conversation
|
Kent seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
`buildPostContent()` previously wrapped all text in a single `{tag: "md"}`
element. When the text contained `<at user_id="...">Name</at>` tags, Feishu
rendered them visually but did NOT populate the `mentions` array or trigger
`im.message.receive_v1` events for the mentioned user/bot.
This change splits the text around `<at>` tags, emitting each as a standalone
`{tag: "at", user_id: "..."}` post element alongside `{tag: "md"}` elements
for the surrounding text. Feishu correctly recognises these as real mentions.
This is critical for multi-bot collaboration scenarios where Bot A needs to
@mention Bot B in group chats and have the mention trigger Bot B's event
handler.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous commit (849c35b) fixed buildPostContent in deliver.ts but missed three identical patterns in send.ts (single-locale, multi-locale, and editMessage). All paths still embedded <at> tags inside {tag: "md"} elements, which Feishu renders visually but does not treat as real mentions (empty mentions array, no im.message.receive_v1 event). - Extract buildPostElements() as a shared helper from deliver.ts - Replace inline [[{tag: "md", text}]] in send.ts with [buildPostElements(text)] across all three code paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2071af8 to
6fdb80d
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.
Problem
When an LLM response contains
<at user_id="ou_xxx">Name</at>tags, the currentbuildPostContent()function wraps the entire text — including<at>tags — inside a single{tag: "md", text: "..."}element. Lark's post message API treats<at>tags embedded in markdown text as visual rendering only — it does NOT populate thementionsarray or triggerim.message.receive_v1events.This blocks multi-bot collaboration scenarios where Bot A needs to @mention Bot B in group chats.
Verified behavior
mentionsarray{tag: "md", text: "...<at>..."}(current){tag: "at", user_id: "..."}as standalone elementTested with Lark API
POST /open-apis/im/v1/messagesand verified viaim.message.receive_v1WebSocket events.Change
buildPostContent()insrc/messaging/outbound/deliver.tsnow:\"→"(LLM output may contain escaped quotes)<at user_id="...">...</at>boundaries<at>matches as{tag: "at", user_id: "..."}elements{tag: "md", text: "..."}elements<at>tags are presentImpact
<at>tags behave identically to before<at>tags now produce real mentionsnormalizeAtMentions()which already fixes common AI-generated<at>format errorsUse case
Multi-bot group chats where agents @mention each other to create discussion chains. Without this fix, the mention is rendered visually but the target bot never receives the event.