Skip to content

feat(feishu): add ignore_at_all config to opt out of @everyone triggering the bot - #96518

Open
DavidMetcalfe wants to merge 6 commits into
NousResearch:mainfrom
DavidMetcalfe:feishu-ignore-at-all
Open

DavidMetcalfe wants to merge 6 commits into
NousResearch:mainfrom
DavidMetcalfe:feishu-ignore-at-all

Conversation

@DavidMetcalfe

Copy link
Copy Markdown
Contributor

Closes #33723

Problem

In Feishu group chats, the bot always responds to @所有人/@everyone mentions because _mentions_self() in plugins/platforms/feishu/adapter.py short-circuits to True whenever @_all appears in the raw message content. In announcement-heavy groups this produces unwanted bot responses that can't be disabled.

Solution

Adds an opt-in config so @_all alone no longer triggers the bot:

  • Env var: FEISHU_IGNORE_AT_ALL=true
  • YAML: feishu.ignore_at_all: true (bridged to the env var via the plugin's apply_yaml_config_fn hook; env wins when both are set)
  • Default: false — behavior is unchanged for every existing user

When enabled, the @_all short-circuit in _mentions_self() is skipped and only explicit bot mentions trigger the bot (both the raw mentions[] path and the post/rich-text is_self ref path remain fully intact — an @_all ref never sets is_self, so the two paths don't interact).

Precedence chain: explicit env var → feishu.ignore_at_all YAML key → default false.

Naming note

The issue proposed FEISHU_IGNORE_MENTION_ALL / feishu.ignore_mention_all. This PR uses FEISHU_IGNORE_AT_ALL / feishu.ignore_at_all, the name that 3 of the 5 prior PRs for this issue converged on. Happy to rename if maintainers prefer.

Docs

Documented in English and zh-Hans: website/docs/user-guide/messaging/feishu.md (prose + table row), website/docs/reference/environment-variables.md, and both zh-Hans mirrors.

Test plan

  • python -m pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_bot_admission.py -q → 89 passed, 18 skipped
  • Full Feishu suite (test_feishu.py, test_feishu_bot_admission.py, test_feishu_bot_auth_bypass.py, test_feishu_approval_buttons.py) → 104 passed, 18 skipped
  • New tests cover: settings wiring (unset/false/true, extra-config override, env-wins-over-extra), _mentions_self gating (all-only gated when enabled, explicit bot mention still triggers when enabled), admission-level rejection/admission, YAML→env bridge (bridge set, env wins, key absent leaves env untouched), and _to_boolean edge pins ("TRUE"/"1"False)
  • git diff --check clean

Notes

Open question: the read path for require_mention in _load_settings uses the same extra.get(..., os.getenv(...)) ordering that makes extra-config override the env var (contradicting the apply_yaml_config_fn docstring "Env vars take precedence over YAML"). This PR fixes the ordering for the new key only, following the narrowest-patch approach — whether require_mention (and other keys using the same pattern) should be fixed too is a maintainer call.

… tests

Cross-vendor review findings (Gemini 3.1 Pro): extra.get() fallback ordering
made YAML override env at read time, contradicting the _apply_yaml_config
bridge contract. Also replaces manual os.environ.pop with patch.dict in the
bridge tests to prevent env pollution across the suite.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter area/config Config system, migrations, profiles 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 duplicate This issue or pull request already exists labels Aug 27, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #60910: both use the same opt-in ignore_at_all configuration to gate Feishu's @_all self-mention path. #60910 is the earlier open implementation.

…oad_gateway_config

Covers the gap the NousResearch#60910 review identified: the documented YAML key must
reach FEISHU_IGNORE_AT_ALL through the real gateway config load path, not
just the adapter's unit-level bridge.
@DavidMetcalfe

Copy link
Copy Markdown
Contributor Author

@alt-glitch — thanks for the triage cross-link. Adding context for the maintainers, since the label understates the differences:

  • feat(feishu): add ignore_at_all config to opt out of @everyone triggering the bot #60910 (opened July 8) has had no commits in 7+ weeks, and its maintainer review (teknium1, July 10) identified that the documented feishu.ignore_at_all YAML path was not actually wired_apply_yaml_config() only handled allow_bots — with a docs-table gap alongside it. That feedback remains unaddressed.
  • This PR is based on current main, wires both the FEISHU_IGNORE_AT_ALL env var and the feishu.ignore_at_all YAML bridge (with the load_gateway_config() integration test the review requested, plus unit coverage for both paths), and completes the documentation in both tables the review flagged.

Given that, this is closer to a superseding implementation than a duplicate — but that's a maintainer call, so leaving the label decision with them. @glow1128's approach preserved the same default behavior, and if they return, the branch is trivially salvageable.

This branch has not been deployed

No deployments
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/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter 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.

[Feature]: Add option to ignore @all/@everyone mentions in Feishu group chats

2 participants