Skip to content

feat(gateway): add FEISHU_REQUIRE_MENTION config to control group @mention gate - #7546

Closed
antik-x wants to merge 1 commit into
NousResearch:mainfrom
antik-x:feat/feishu-require-mention
Closed

feat(gateway): add FEISHU_REQUIRE_MENTION config to control group @mention gate#7546
antik-x wants to merge 1 commit into
NousResearch:mainfrom
antik-x:feat/feishu-require-mention

Conversation

@antik-x

@antik-x antik-x commented Apr 11, 2026

Copy link
Copy Markdown

Summary

Add a FEISHU_REQUIRE_MENTION configuration option to the Feishu gateway adapter, allowing users to disable the requirement for @mentioning the bot in group chats. By default, the bot still requires being @mentioned in groups (backward compatible), but this can be turned off via config or environment variable.

Motivation

Currently, the Feishu bot only responds when @mentioned in group chats. Some users prefer the bot to respond to all messages in a group (e.g., dedicated bot channels). This PR makes the behavior configurable.

Changes

  • gateway/platforms/feishu.py:

    • Add require_mention: bool = True to FeishuAdapterSettings (default: True, backward compatible)
    • Add _feishu_require_mention() validation function for config parsing
    • Add FEISHU_REQUIRE_MENTION env var support in FeishuAdapter.from_config()
    • Gate the _is_mentioned() check on the new setting in FeishuAdapter._process_message()
  • tests/test_feishu.py:

    • Add tests for require_mention=False (bot responds to all group messages)
    • Add tests for require_mention=True default (bot only responds when @mentioned)
    • Add tests for env var override FEISHU_REQUIRE_MENTION

Configuration

# config.yaml
feishu:
  require_mention: false  # bot responds to all group messages

Or via environment variable:

export FEISHU_REQUIRE_MENTION=false

Important: Feishu Platform Event Subscription

Setting require_mention: false alone is not sufficient. You must also configure the event subscription on the Feishu Open Platform:

  1. Go to Feishu Developer Console > your app > Events & Callbacks (事件与回调)
  2. Add the im.message.receive_v1 event subscription
  3. If you want the bot to receive all group messages (not just @mentions), also ensure the im:message.group_msg:readonly permission is granted under Permissions (权限管理)

Without the im.message.receive_v1 event subscription, the Feishu platform will not push any message events to your bot, regardless of the require_mention setting.

重要:飞书平台事件订阅配置

仅设置 require_mention: false 是不够的。你还需要在飞书开放平台进行以下配置:

  1. 前往 飞书开发者后台 > 你的应用 > 事件与回调
  2. 添加 im.message.receive_v1 事件订阅
  3. 如果你希望机器人接收群里的所有消息(而不仅仅是 @消息),还需要在权限管理中开通 im:message.group_msg:readonly 权限

如果没有添加 im.message.receive_v1 事件订阅,飞书平台不会向你的机器人推送任何消息事件,无论 require_mention 如何设置。

Backward Compatibility

Fully backward compatible. Default is require_mention: true, preserving existing behavior.

…ntion gate

When FEISHU_REQUIRE_MENTION is set to false/0/no/off, group messages
bypass the @mention requirement while still respecting the group policy
gate (open/allowlist/blacklist/etc). This matches the require_mention
pattern used by Slack, Discord, and Matrix adapters.

The default remains true (mention gating on) for backward compatibility.

Closes NousResearch#5465
@antik-x
antik-x force-pushed the feat/feishu-require-mention branch from cb11851 to 88d7b1d Compare April 12, 2026 14:19
@Max0x400

Copy link
Copy Markdown

I manually verified this on the current latest main, and can confirm the issue is reproducible in a real Feishu group.

Config

feishu:
  require_mention: false

Repro

I sent a normal group message in Feishu without @mentioning the bot.

Expected

The bot should reply, because feishu.require_mention is explicitly set to false.

Actual

The bot did not reply.

This was tested against an up-to-date local checkout synced to origin/main, so this does not appear to be just a configuration mistake.

One related observation: free_response_chats for Feishu also appears to be incomplete / not wired through like Telegram and WhatsApp, although that may be best tracked separately from the core require_mention issue.

@Max0x400

Copy link
Copy Markdown

Following up on my previous comment after checking this more closely:

This PR seems to address the global require_mention switch for Feishu, which is definitely the main issue I reproduced on current main.

However, one related gap I noticed is that it still does not seem to cover per-chat mention bypass for Feishu (similar to free_response_chats behavior in Telegram and WhatsApp).

So from my perspective, the Feishu mention-gating/config story currently has two closely related pieces:

  1. global feishu.require_mention: false
  2. per-chat bypass for selected chats

Would you prefer to extend this PR to cover the per-chat bypass case as well, or should that be handled in a separate follow-up PR?

I mainly want to avoid duplicating work, since the implementation areas seem closely related (gateway/config.py, gateway/platforms/feishu.py, and tests).

@alt-glitch

Copy link
Copy Markdown
Collaborator

Competes with #9479, #4591, and others addressing #10275. Multiple implementations of the same FEISHU_REQUIRE_MENTION feature.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This is an automated hermes-sweeper review; the requested behavior is already implemented on current main.

  • b94cb8e2c4ebf2a8c7688cf676c3cf9899584adb added FEISHU_REQUIRE_MENTION support, including config.extra.require_mention handling in plugins/platforms/feishu/adapter.py:1600.
  • Group admission enforces the mention check only when enabled and supports per-chat overrides in plugins/platforms/feishu/adapter.py:4237-4282.
  • Current coverage includes config/env parsing and unmentioned group-message admission in tests/gateway/test_feishu_bot_admission.py:100-111 and :343.
  • The Feishu adapter was subsequently migrated from this PR's target path to plugins/platforms/feishu/adapter.py by 560010547; current docs also cover the global and per-chat settings in website/docs/user-guide/messaging/feishu.md:240-246 and :514-527.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:implemented-on-main Sweeper: behavior already present on current main type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants