Skip to content

feat(feishu): add require_mention config option for group chats - #12887

Closed
hillerliao wants to merge 2 commits into
NousResearch:mainfrom
hillerliao:feishu-require-mention-opt-in
Closed

hillerliao wants to merge 2 commits into
NousResearch:mainfrom
hillerliao:feishu-require-mention-opt-in

Conversation

@hillerliao

Copy link
Copy Markdown

Feishu 群聊 require_mention 配置选项

允许在飞书群聊中关闭必须 @mention 机器人才能触发回复的限制。

使用方法

~/.hermes/config.yaml 中添加:

platforms:
  feishu:
    extra:
      require_mention: false

然后 hermes gateway restart 重启网关即可。

⚠️ 重要前提:飞书应用权限

此配置依赖飞书平台级权限,仅修改配置不够。必须在 飞书开放平台 给应用添加以下权限:

权限 说明
im:message.group_msg(读取群组中所有消息) 接收群聊中所有消息(不需要 @mention)

如果只具备 im:message.group_at_msg(获取 @机器人的消息),飞书服务器本身不会把非 @mention 消息转发给应用,配置无效。

代码改动

  • FeishuAdapterSettings:新增 require_mention: bool = True 字段
  • _load_settings():从 extra 读取 require_mention,默认为 true
  • _should_accept_group_message()require_mention=False 时跳过 @mention 检查但仍执行群策略

测试

4 个新增测试用例全部通过(118 passing)

Charlie Liao added 2 commits April 20, 2026 13:27
Add a configurable require_mention option to FeishuAdapterSettings that
allows users to opt out of the @mention requirement in group chats via
config.yaml. When require_mention is set to false, the bot will respond
to all group messages (subject to group policy) without needing to be
@mentioned.

Default is true (backward-compatible).
Tests cover:
- require_mention=false accepts group message without @mention
- require_mention=false still enforces group allowlist policy
- require_mention=true (default) still requires @mention
- require_mention=false combined with allowlist blocks non-allowed users
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter area/config Config system, migrations, profiles labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown

Multiple prior attempts at this feature exist: #4591, #5219, #7546. Consider consolidating.

1 similar comment
@alt-glitch

Copy link
Copy Markdown

Multiple prior attempts at this feature exist: #4591, #5219, #7546. Consider consolidating.

@de1tydev

Copy link
Copy Markdown
Contributor

Current-status note for reviewer context:

The underlying Feishu require_mention gap still exists on current main; Feishu group messages still require an explicit bot mention in Hermes-side filtering, and there is no upstream FEISHU_REQUIRE_MENTION / require_mention option yet.

This PR covers the core config-file path. A newer focused implementation is also open in #17406; it keeps the default behavior unchanged, preserves the group policy / allowlist gate before bypassing mention matching, adds env-var support, updates docs, and includes broader directed unit coverage. Maintainers may want to consolidate these rather than review them independently.

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused Feishu configuration and test coverage. This is now implemented on current main; this is an automated hermes-sweeper review.

  • plugins/platforms/feishu/adapter.py:1600 loads require_mention from Feishu config extra or FEISHU_REQUIRE_MENTION, defaulting safely to true.
  • plugins/platforms/feishu/adapter.py:4270 applies the group-policy gate before plugins/platforms/feishu/adapter.py:4274 conditionally enforces a bot mention.
  • plugins/platforms/feishu/adapter.py:4278 supports per-group group_rules.<chat_id>.require_mention overrides.
  • tests/gateway/test_feishu_bot_admission.py:100 and :343 cover config/env resolution and unmentioned group admission when disabled.
  • website/docs/user-guide/messaging/feishu.md:240 and :527 document the global and per-group controls.
  • The merged implementation is b94cb8e2c4ebf2a8c7688cf676c3cf9899584adb (feat(feishu): operator-configurable bot admission and mention policy), included in v2026.5.7.

The earlier discussion correctly identified duplicate Feishu require_mention work; the PR's legacy target path has since migrated to the bundled platform plugin.

@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