openclaw - 💡(How to fix) Fix [Feishu] Auto-normalize @mention syntax across message formats (card/text/post) [1 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#60103Fetched 2026-04-08 02:36:14
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Root Cause

Problem

Feishu has 3 different message formats with incompatible @mention syntax:

FormatSyntaxUsed when
text<at user_id="ou_xxx">Name</at>Non-card text messages
card (interactive)<at id=ou_xxx></at>Streaming replies, card messages
post (rich text){"tag":"at","user_id":"ou_xxx"}Post messages
When an AI agent writes <at user_id="ou_xxx">Name</at> in its reply, but OpenClaw sends it as a card (default with streaming enabled), the mention silently fails — renders as plain text instead of an actual @mention.
This is common because:
  1. Agents naturally write text-style syntax (it appears in inbound message context)
  2. The system prompt tells agents: "content may include mention tags in the form <at user_id>name</at>"
  3. But outbound messages default to card format where this syntax does not work

Proposed Solution

Add automatic mention syntax normalization in the Feishu outbound pipeline:

  1. Before sending card: Detect <at user_id="ou_xxx">Name</at> and convert to <at id=ou_xxx></at>
  2. Before sending text: Detect <at id=ou_xxx></at> and convert to <at user_id="ou_xxx"></at>

Regex

RAW_BUFFERClick to expand / collapse

Problem

Feishu has 3 different message formats with incompatible @mention syntax:

FormatSyntaxUsed when
text<at user_id="ou_xxx">Name</at>Non-card text messages
card (interactive)<at id=ou_xxx></at>Streaming replies, card messages
post (rich text){"tag":"at","user_id":"ou_xxx"}Post messages
When an AI agent writes <at user_id="ou_xxx">Name</at> in its reply, but OpenClaw sends it as a card (default with streaming enabled), the mention silently fails — renders as plain text instead of an actual @mention.
This is common because:
  1. Agents naturally write text-style syntax (it appears in inbound message context)
  2. The system prompt tells agents: "content may include mention tags in the form <at user_id>name</at>"
  3. But outbound messages default to card format where this syntax does not work

Proposed Solution

Add automatic mention syntax normalization in the Feishu outbound pipeline:

  1. Before sending card: Detect <at user_id="ou_xxx">Name</at> and convert to <at id=ou_xxx></at>
  2. Before sending text: Detect <at id=ou_xxx></at> and convert to <at user_id="ou_xxx"></at>

Regex

javascript // text-style to card-style const TEXT_MENTION_RE = /<at\s+user_id="([^"]+)">[^<]*</at>/g; text.replace(TEXT_MENTION_RE, (_, id) => <at id=${id}></at>);

Code References

  • formatMentionForText() generates text syntax
  • formatMentionForCard() generates card syntax
  • buildMentionedCardContent() works for mentionTargets
  • Gap: manually written <at> tags in agent reply text are NOT transformed

Impact

All Feishu bots that @mention users in group messages. We run 9 bots and this is a persistent issue.

extent analysis

TL;DR

Implement automatic mention syntax normalization in the Feishu outbound pipeline to convert between text and card syntax.

Guidance

  • Detect and convert text-style mention syntax to card-style syntax using a regex replacement, such as the provided TEXT_MENTION_RE pattern, before sending card messages.
  • Consider adding a similar conversion for card-style to text-style syntax to handle inbound messages or other scenarios where text syntax is required.
  • Review the formatMentionForText(), formatMentionForCard(), and buildMentionedCardContent() functions to ensure they are correctly generating the desired mention syntax.
  • Test the normalization pipeline with various input scenarios to ensure correct conversion and rendering of @mentions.

Example

// text-style to card-style
const TEXT_MENTION_RE = /<at\s+user_id="([^"]+)">[^<]*<\/at>/g;
const text = '<at user_id="ou_xxx">Name</at>';
const cardText = text.replace(TEXT_MENTION_RE, (_, id) => `<at id=${id}></at>`);
console.log(cardText); // Output: <at id=ou_xxx></at>

Notes

The proposed solution focuses on converting text-style syntax to card-style syntax, but it may be necessary to also handle the reverse conversion depending on the specific requirements of the Feishu platform and the bots using it.

Recommendation

Apply the workaround by implementing the automatic mention syntax normalization in the Feishu outbound pipeline, as it directly addresses the identified issue and provides a clear solution to the problem of silently failing @mentions.

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

openclaw - 💡(How to fix) Fix [Feishu] Auto-normalize @mention syntax across message formats (card/text/post) [1 participants]