Skip to content

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

Closed
Leegenux wants to merge 6 commits into
NousResearch:mainfrom
Leegenux:feat/feishu-require-mention
Closed

feat(feishu): add require_mention config option for group chats#5219
Leegenux wants to merge 6 commits into
NousResearch:mainfrom
Leegenux:feat/feishu-require-mention

Conversation

@Leegenux

@Leegenux Leegenux commented Apr 5, 2026

Copy link
Copy Markdown

Add configurable @mention gating for Feishu group chats.

Changes

  • Add require_mention setting to Feishu adapter (default: true)
  • Support configuration via extra dict in config or FEISHU_REQUIRE_MENTION env var
  • When enabled: only route messages that @mention the bot or use @_all
  • When disabled: route all allowed group messages without mention requirement
  • Add tests for mention gating behavior
  • Handle falsy values correctly with explicit None checks

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

Leegenux and others added 4 commits April 5, 2026 20:04
Add feishu.require_mention config option (default: true) to control
whether @mention is required for bot to respond in group chats.

Previously, group_policy="open" would bypass @mention check, but this
was hardcoded behavior. Now users can configure this independently:

- require_mention=true (default): Only respond when bot is @mentioned or @_all
- require_mention=false: Respond to all allowed group messages without @mention

Configuration via config.yaml:
  feishu:
    require_mention: false

Or via environment variable:
  FEISHU_REQUIRE_MENTION=false

This matches the pattern used by Discord's require_mention setting.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
- Allow require_mention from extra.get() (platforms.feishu.extra) with env var fallback
- Add TestRequireMentionDisabled test class covering:
  - require_mention=false accepts messages without @mention
  - require_mention=true requires @mention (default)
  - Default behavior when env var unset
  - Allowlist policy still respected when require_mention=false

Addresses Copilot PR NousResearch#4591 review comments.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Use explicit None check instead of 'or' fallback to correctly handle
require_mention=False from PlatformConfig.extra. Previously the 'or'
operator treated False/0/empty string as 'not provided' and fell back
to env var, making it impossible to disable mention gating via config.

- Add _resolve_require_mention() helper with explicit None check
- Add tests for require_mention via PlatformConfig.extra (True/False)
- Add test for extra precedence over env var when explicitly False

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
The staticmethod was called without proper class reference in _load_settings.
Changed from '_resolve_require_mention(extra)' to 'FeishuAdapter._resolve_require_mention(extra)'.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 5, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable require_mention gate for Feishu/Lark group chats so operators can choose whether group messages must @mention the bot to be routed.

Changes:

  • Introduce require_mention into Feishu adapter settings with resolution from PlatformConfig.extra or FEISHU_REQUIRE_MENTION.
  • Update group message routing logic to optionally bypass mention checks when require_mention=false.
  • Add unit tests covering default behavior, env var configuration, and PlatformConfig.extra precedence.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
gateway/platforms/feishu.py Adds require_mention setting resolution and applies it to group message acceptance logic.
gateway/config.py Bridges feishu.require_mention from config.yaml into an env var.
hermes_cli/config.py Adds default config entry for Feishu require_mention.
tests/gateway/test_feishu.py Adds tests validating mention-gating behavior and precedence rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gateway/platforms/feishu.py
Comment thread gateway/config.py
Comment thread tests/gateway/test_feishu.py Outdated
Leegenux and others added 2 commits April 5, 2026 20:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the Feishu configuration and test coverage. Current main has already landed a stronger implementation of this behavior, so this PR is now redundant.

Automated hermes-sweeper review evidence:

  • b94cb8e2c4ebf2a8c7688cf676c3cf9899584adb added FEISHU_REQUIRE_MENTION (default true) plus per-group require_mention overrides; it is an ancestor of current main.
  • plugins/platforms/feishu/adapter.py:1600 resolves PlatformConfig.extra["require_mention"] with FEISHU_REQUIRE_MENTION fallback, and plugins/platforms/feishu/adapter.py:4274 enforces the effective gate during group admission.
  • tests/gateway/test_feishu_bot_admission.py:91 covers defaults, env configuration, and explicit extra.require_mention=False precedence.
  • The behavior is documented in website/docs/user-guide/messaging/feishu.md:240 and per-group override behavior in website/docs/user-guide/messaging/feishu.md:527.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants