Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

fix(bot): hide mention-mode announcement in Feishu group chats (#20219)

Rdmclin2acecee42626e
diff --git a/apps/server/src/services/bot/BotMessageRouter.ts b/apps/server/src/services/bot/BotMessageRouter.ts
index 4e6495f38c5..720d774184a 100644
--- a/apps/server/src/services/bot/BotMessageRouter.ts
+++ b/apps/server/src/services/bot/BotMessageRouter.ts
@@ -26,6 +26,7 @@ import {
releasePairingClaim,
} from './dmPairingStore';
import { submitBotFeedback } from './feedbackSubmit';
+import { isWholeGroupChatThreadId } from './isWholeGroupChatThreadId';
import { buildReplayMessages, getSameSenderMessages, mergeBotMessages } from './mergeMessages';
import { patchSenderBatches } from './patchSenderBatches';
import {
@@ -1469,7 +1470,11 @@ export class BotMessageRouter {
// first skip in this thread → tell participants the bot
// is now mention-only so newcomers don't think it broke. Dedupe by
// thread id so we never announce more than once.
- if (!thread.isDM && (humanCount >= 2 || platformReportsShared)) {
+ if (
+ !thread.isDM &&
+ !isWholeGroupChatThreadId(thread.id) &&
+ (humanCount >= 2 || platformReportsShared)
+ ) {
try {
const fresh = await bot
.getState()
diff --git a/apps/server/src/services/bot/__tests__/BotMessageRouter.test.ts b/apps/server/src/services/bot/__tests__/BotMessageRouter.test.ts
index c544ac06e4d..91d9cf63d85 100644
--- a/apps/server/src/services/bot/__tests__/BotMessageRouter.test.ts
+++ b/apps/server/src/services/bot/__tests__/BotMessageRouter.test.ts
@@ -1113,6 +1113,28 @@ describe('BotMessageRouter', () => {
expect(thread.post).toHaveBeenCalledTimes(1);
});
+ it('does not announce mention-only mode in a Feishu group main chat', async () => {
+ // Feishu group mains are already mention-only. Membership reports
+ // shared (isSoloBotConversation=false) but posting the English notice
+ // is spam — LOBE-14475.
+ mockGetList.mockResolvedValue([]);
+ const isSoloBotConversation = vi.fn().mockResolvedValue(false);
+ withMembershipLookup(isSoloBotConversation);
+ const handler = await loadSubscribedHandler();
+ const thread = makeThread({ id: 'feishu:group:oc_citic_sentry', isDM: false });
+
+ await handler(thread, makeMessage({ isMention: false, text: 'just chatting' }));
+
+ expect(isSoloBotConversation).toHaveBeenCalledWith('feishu:group:oc_citic_sentry');
+ expect(mockHandleSubscribedMessage).not.toHaveBeenCalled();
+ expect(thread.post).not.toHaveBeenCalled();
+ expect(mockStateSetIfNotExists).not.toHaveBeenCalledWith(
+ expect.stringContaining('mention-required-announced'),
+ expect.anything(),
+ expect.anything(),
+ );
+ });
+
it('routes real Discord membership verdicts and preserves batched participants', async () => {
const { DiscordClientFactory } = await import('../platforms/discord/client');
const { clearDiscordChatCompositionMemoryCache } =
diff --git a/apps/server/src/services/bot/isWholeGroupChatThreadId.test.ts b/apps/server/src/services/bot/isWholeGroupChatThreadId.test.ts
new file mode 100644
index 00000000000..fd736534d1d
--- /dev/null
+++ b/apps/server/src/services/bot/isWholeGroupChatThreadId.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from 'vitest';
+
+import { isWholeGroupChatThreadId } from './isWholeGroupChatThreadId';
+
+describe('isWholeGroupChatThreadId', () => {
+ it('classifies Feishu/Lark group chats as whole-group conversations', () => {
+ expect(isWholeGroupChatThreadId('feishu:group:oc_citic_sentry')).toBe(true);
+ expect(isWholeGroupChatThreadId('lark:group:oc_xxx')).toBe(true);
+ });
+
+ it('leaves Feishu/Lark 1:1 chats and type-less ids alone', () => {
+ expect(isWholeGroupChatThreadId('feishu:p2p:oc_xxx')).toBe(false);
+ expect(isWholeGroupChatThreadId('lark:p2p:oc_xxx')).toBe(false);
+ // Ids without an encoded chat type cannot be proven to be group mains, so
+ // they keep the pre-existing behaviour.
+ expect(isWholeGroupChatThreadId('feishu:oc_legacy')).toBe(false);
+ expect(isWholeGroupChatThreadId('lark:oc_legacy')).toBe(false);
+ });
+
+ it('leaves other platforms alone', () => {
+ expect(isWholeGroupChatThreadId('discord:guild-1:channel-1:thread-1')).toBe(false);
+ expect(isWholeGroupChatThreadId('slack:C_GENERAL:1715000000.000100')).toBe(false);
+ expect(isWholeGroupChatThreadId('telegram:chat-1')).toBe(false);
+ });
+});
diff --git a/apps/server/src/services/bot/isWholeGroupChatThreadId.ts b/apps/server/src/services/bot/isWholeGroupChatThreadId.ts
new file mode 100644
index 00000000000..6e7a9310a43
--- /dev/null
+++ b/apps/server/src/services/bot/isWholeGroupChatThreadId.ts
@@ -0,0 +1,26 @@
+/**
+ * Is this conversation the platform's **whole group chat**?
+ *
+ * LOBE-14475: a Feishu/Lark group main is mention-only from its very first
+ * message, so the "Multiple people are talking in this thread now…" notice
+ * explains nothing there — it just spams the room (see the 中信 Agent Sentry
+ * report). Suppress it for those conversations.
+ *
+ * The predicate reads the chat type the inbound adapter encodes into the
+ * thread id (`encodeLarkThreadId` → `lark:group:oc_xxx` / `lark:p2p:oc_xxx`),
+ * i.e. the shape production actually emits.
+ *
+ * It is deliberately NOT a thread-vs-topic check: Feishu conversations are
+ * keyed by `chat_id` alone today (`packages/chat-adapter-feishu/src/adapter.ts`),
+ * and outbound sends only support `receive_id_type=chat_id`
+ * (`api.sendMessage`), so a topic inside a group currently looks exactly like
+ * the group main and is suppressed with it. Giving topics their own notice
+ * needs the adapter to carry topic identity both ways — tracked separately.
+ */
+export const isWholeGroupChatThreadId = (threadId: string): boolean => {
+ const [platform, chatType] = threadId.split(':');
+ // Only Feishu/Lark group chats are affected; every other platform keeps its
+ // existing announcement behaviour.
+ if (platform !== 'feishu' && platform !== 'lark') return false;
+ return chatType === 'group';
+};
diff --git a/apps/server/src/services/messenger/MessengerRouter.test.ts b/apps/server/src/services/messenger/MessengerRouter.test.ts
index 3cf054a39b5..3dc71d5d611 100644
--- a/apps/server/src/services/messenger/MessengerRouter.test.ts
+++ b/apps/server/src/services/messenger/MessengerRouter.test.ts
@@ -1693,6 +1693,41 @@ describe('MessengerRouter onSubscribedMessage gating', () => {
expect(thread.post).toHaveBeenCalledWith(expect.stringContaining('@mention me'));
});
+ it('does not announce mention-only mode in a Feishu group main chat', async () => {
+ // Same skip path as Slack multi-human, but Feishu group mains already
+ // require @mention — do not post the English notice (LOBE-14475).
+ await loadSlackBot();
+ mockGetList.mockResolvedValue(['U_ALICE']);
+ const thread = {
+ id: 'feishu:group:oc_citic_sentry',
+ isDM: false,
+ post: vi.fn(),
+ subscribe: vi.fn(),
+ };
+
+ const handler = mockChatBot.onSubscribedMessage.mock.calls[0][0] as (
+ thread: any,
+ msg: any,
+ ) => Promise<void>;
+ await handler(
+ thread,
+ fakeMessage({
+ author: { isBot: false, userId: 'U_BOB', userName: 'bob' },
+ isMention: false,
+ text: 'taking over',
+ }),
+ );
+
+ expect(mockHandleSubscribed).not.toHaveBeenCalled();
+ expect(mockHandleMention).not.toHaveBeenCalled();
+ expect(thread.post).not.toHaveBeenCalled();
+ expect(mockSetIfNotExists).not.toHaveBeenCalledWith(
+ expect.stringContaining('mention-required-announced'),
+ expect.anything(),
+ expect.anything(),
+ );
+ });
+
it('only announces mention-only mode once per channel thread ()', async () => {
// Second non-mention in a multi-human thread → `setIfNotExists` returns
// false, the announcement is suppressed.
diff --git a/apps/server/src/services/messenger/MessengerRouter.ts b/apps/server/src/services/messenger/MessengerRouter.ts
index ffa5ef28c71..16e45802292 100644
--- a/apps/server/src/services/messenger/MessengerRouter.ts
+++ b/apps/server/src/services/messenger/MessengerRouter.ts
@@ -21,6 +21,7 @@ import { AgentBridgeService } from '@/server/services/bot/AgentBridgeService';
import { buildBotContext } from '@/server/services/bot/buildBotContext';
import { replayDeferredBotMessages } from '@/server/services/bot/deferredMessages';
import { submitBotFeedback } from '@/server/services/bot/feedbackSubmit';
+import { isWholeGroupChatThreadId } from '@/server/services/bot/isWholeGroupChatThreadId';
import {
buildReplayMessages,
getSameSenderMessages,
@@ -786,18 +787,21 @@ export class MessengerRouter {
if (!shouldHandle) {
// First skip in this thread → tell the room why the bot just went
// quiet so participants know to @mention if they need it. Dedupe
- // by thread id so we never spam more than once.
- try {
- const fresh = await bot
- .getState()
- .setIfNotExists(mentionRequiredAnnouncedKey(thread.id), '1', PARTICIPANTS_TTL_MS);
- if (fresh) {
- await thread.post(
- "Multiple people are talking in this thread now. From here on I'll only respond when you @mention me.",
- );
+ // by thread id so we never spam more than once. Feishu/Lark group
+ // mains are already mention-only — skip the notice there (LOBE-14475).
+ if (!isWholeGroupChatThreadId(thread.id)) {
+ try {
+ const fresh = await bot
+ .getState()
+ .setIfNotExists(mentionRequiredAnnouncedKey(thread.id), '1', PARTICIPANTS_TTL_MS);
+ if (fresh) {
+ await thread.post(
+ "Multiple people are talking in this thread now. From here on I'll only respond when you @mention me.",
+ );
+ }
+ } catch (error) {
+ log('onSubscribedMessage: mention-mode announcement failed: %O', error);
}
- } catch (error) {
- log('onSubscribedMessage: mention-mode announcement failed: %O', error);
}
return;
}