feat(feishu): operator-configurable bot admission and mention policy - #15937
Closed
Roy-oss1 wants to merge 1 commit into
Closed
feat(feishu): operator-configurable bot admission and mention policy#15937Roy-oss1 wants to merge 1 commit into
Roy-oss1 wants to merge 1 commit into
Conversation
Add two operator-facing toggles for inbound Feishu admission, enabling
bot-to-bot scenarios such as A2A orchestration and inter-bot
notifications:
FEISHU_ALLOW_BOTS=none|mentions|all (default: none)
Accept messages from other bots. `mentions` requires the peer
bot to @-mention Hermes; `all` admits every peer-bot message.
FEISHU_REQUIRE_MENTION=true|false (default: true)
Whether group messages must @-mention the bot. Override per-chat
via `group_rules.<chat_id>.require_mention` in config.yaml.
Defaults preserve prior behavior. Self-echo protection is always on:
when the bot's identity is unresolved (auto-detection failed and
FEISHU_BOT_OPEN_ID unset), peer-bot messages are rejected fail-closed
to avoid feedback loops.
Admitted peer bots bypass the human-user allowlist
(FEISHU_ALLOWED_USERS) to match existing Discord behavior; humans
still need an explicit allowlist entry. yaml feishu.allow_bots is
bridged to the env var so the adapter and gateway auth layer share
one source of truth.
Resolving peer-bot display names requires the
application:bot.basic_info:read scope; without it, peers still route
but appear as their open_id.
Test: tests/gateway/test_feishu_bot_admission.py covers the admission
pipeline, group-policy bot-bypass, hydration, and event-dispatch
plumbing as a parametrized matrix.
Change-Id: I363cccb578c2a5c8b8bf0f0a890c01c89909e256
Roy-oss1
force-pushed
the
feat/feishu-bot-to-bot-messaging
branch
from
April 28, 2026 03:58
b9b40af to
7bf7763
Compare
Contributor
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds two operator-facing toggles for inbound Feishu admission, addressing several long-standing requests for
require_mention=falsesupport and laying groundwork for bot-to-bot scenarios such as A2A orchestration and inter-bot notifications:FEISHU_ALLOW_BOTS=none|mentions|all(default:none) — control whether messages from other bots are accepted, optionally requiring an@mention.FEISHU_REQUIRE_MENTION=true|false(default:true) — control whether group messages must@mentionthe bot, with per-chat override viagroup_rules.<chat_id>.require_mention.Inbound admission is consolidated into a four-step pipeline (self-echo → bot filter → DM bypass → group policy + mention) with explicit fail-closed behavior when the bot's self-identity is unresolved. Admitted peer bots bypass the human-user allowlist (matching existing Discord behavior). yaml
feishu.allow_botsis bridged to the env var so the adapter and gateway auth layer share one source of truth — same pattern as Slack.Defaults preserve prior behavior; existing operators see no change unless they opt in.
Related Issue
Fixes #10275
Fixes #15226
Fixes #9835
Fixes #5465
Type of Change
Changes Made
gateway/platforms/feishu.py— admission pipeline (_admit), self-identity hydration via/open-apis/bot/v3/info, peer-bot name resolution via/open-apis/bot/v3/bots/basic_batch, reaction-routing fix for peer-bot messages,FEISHU_ALLOW_BOTS/FEISHU_REQUIRE_MENTIONsettings, fail-closed self-id check.gateway/run.py— table-drivenplatform_allow_bots_mapso admitted peer bots bypass the human user allowlist (collapses the existing Discord DISCORD_ALLOW_BOTS has no effect without also adding the bot to DISCORD_ALLOWED_USERS #4466 special-case and the new Feishu one into one clause).gateway/config.py— bridgefeishu.allow_botsyaml →FEISHU_ALLOW_BOTSenv so both layers see one source of truth.tests/gateway/feishu_helpers.py— shared fixtures for cross-test reuse.tests/gateway/test_feishu_bot_admission.py— parametrized matrices for the admission pipeline (19 cases) and_allow_group_message(12 cases) plus call-count, hydration, and event-dispatch tests.tests/gateway/test_config.py— yaml→env bridge tests.tests/gateway/test_feishu.py— peer-bot reaction routing regression test.website/docs/user-guide/messaging/feishu.md+website/docs/reference/environment-variables.md— new sections forFEISHU_REQUIRE_MENTION, Bot Identity, Bot-to-Bot Messaging (with requiredapplication:bot.basic_info:readscope), per-grouprequire_mentionoverride, troubleshooting entries.How to Test
@mentionand peer-bot messages are still ignored.FEISHU_REQUIRE_MENTION=false: set the env var, runhermes gateway, send a non-mention message in a group chat — Hermes responds.platforms.feishu.extra.group_rules.<chat_id>.require_mention: falseto~/.hermes/config.yaml; that chat skips the mention requirement, others inherit the global default.FEISHU_ALLOW_BOTS=mentions, have a peer bot@mentionHermes from another app — message is processed. Without the mention, it's dropped.feishu.allow_bots: allin~/.hermes/config.yaml; peer bots are admitted without mention.FEISHU_ALLOW_BOTS=all, Hermes' own outbound messages remain filtered.application:bot.basic_info:readgranted, peer bots show by display name; without it, they show asou_xxxxxx.pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_bot_admission.py tests/gateway/test_feishu_bot_auth_bypass.py tests/gateway/test_config.py -q.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A