Skip to content

feat(feishu): add FEISHU_REQUIRE_MENTION toggle + hermes upgrade deps validation - #10802

Open
bugmaker2 wants to merge 2 commits into
NousResearch:mainfrom
bugmaker2:fix/feishu-upgrade-require-mention
Open

feat(feishu): add FEISHU_REQUIRE_MENTION toggle + hermes upgrade deps validation#10802
bugmaker2 wants to merge 2 commits into
NousResearch:mainfrom
bugmaker2:fix/feishu-upgrade-require-mention

Conversation

@bugmaker2

Copy link
Copy Markdown

What does this PR do?

Two Feishu improvements:

  1. FEISHU_REQUIRE_MENTION toggle (implements feat(gateway): add FEISHU_REQUIRE_MENTION environment variable for Feishu group chats #10275, fixes [Bug]: Feishu adapter has no require_mention toggle — file messages in group chats are silently dropped #9835): Added FEISHU_REQUIRE_MENTION environment variable to control whether group messages require an explicit @mention. When set to false/0/no/off, the bot responds to all group messages that pass the group policy. File/image/audio messages are now handled the same as text messages regarding @mention detection. Default is True (safe default matching Slack/Discord patterns).

  2. hermes upgrade deps validation (fixes Bug: hermes upgrade silently fails optional extras (e.g. feishu/lark-oapi), gateway crashes on restart #10651): After hermes upgrade completes, if FEISHU_APP_ID or FEISHU_APP_SECRET environment variables are set, the upgrade process validates that lark_oapi can be imported. If import fails, a clear error message directs the user to install the feishu extra: pip install hermes-agent[feishu].

Related Issue

Fixes #10275 (FEISHU_REQUIRE_MENTION)
Fixes #9835 (file messages silently dropped)
Fixes #10651 (hermes upgrade deps validation)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/feishu.py: Added require_mention: bool = True field to FeishuAdapterSettings, _parse_require_mention() helper function (parses env var and config, explicit-false detection), _feishu_require_mention() instance method, modified _require_group_mention() to return True early when mention is disabled
  • hermes_cli/main.py: Added post-upgrade Feishu deps validation — checks if FEISHU_APP_ID/FEISHU_APP_SECRET are set, attempts import lark_oapi, prints clear error if missing
  • tests/gateway/test_feishu.py: Added test_feishu_require_mention_loaded_from_env, test_parse_require_mention_defaults_true, test_parse_require_mention_explicit_false, test_parse_require_mention_explicit_true

How to Test

  1. FEISHU_REQUIRE_MENTION=false hermes gateway — verify bot responds to group messages without @mention
  2. FEISHU_REQUIRE_MENTION=true hermes gateway — verify bot requires @mention (default behavior)
  3. Start a fresh hermes installation without feishu extra, set FEISHU_APP_ID, run hermes upgrade — verify clear error message about missing deps
  4. Run: python -m pytest tests/gateway/test_feishu.py -q -k "require_mention or parse_require_mention" → all pass

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (feat(feishu):, fix(hermes):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/gateway/test_feishu.py -q — 103 passed, 16 skipped, 2 failed (lark-oapi optional dep not installed in test env)
  • I've added tests for my changes
  • I've tested on macOS Python 3.11

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-rm impact (Windows, macOS) per the compatibility guide — N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

bugmaker2 and others added 2 commits April 16, 2026 13:32
… env vars set

When `hermes upgrade` runs and `pip install -e ".[all]"` fails (e.g. network
issues), the fallback path `pip install -e "."` only installs base deps and
omits optional extras like feishu (lark-oapi). No warning was shown, causing
the gateway to crash on restart when Feishu env vars were set.

After the fallback installation completes, check if FEISHU_APP_ID and
FEISHU_APP_SECRET env vars are set. If so, attempt to import lark_oapi. If
the import fails, print a clear error message directing the user to install
the feishu extra.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s without @mention

Add a require_mention toggle for Feishu group messages. When
FEISHU_REQUIRE_MENTION=false, the bot accepts all group messages that pass
the group policy check (allowlist/blacklist), even without an @mention.
This matches the behavior already supported by Slack, Discord, and WhatsApp.

Previously, file/image/audio messages in group chats were silently dropped
because the @mention check ran before the message type was resolved, and
those message types had no mention metadata. With require_mention=false,
file/audio/image messages are now accepted in group chats when the policy
allows it.

The setting can be configured via:
- Environment variable: FEISHU_REQUIRE_MENTION=false
- Config.yaml: platforms.feishu.require_mention: false

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Multiple competing PRs implement the same FEISHU_REQUIRE_MENTION feature: #12411, #12887, #13880 (closed). Please coordinate to avoid duplicate work. Also addresses #10275, #9835, #10651.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution. The Feishu mention-toggle portion has been superseded on current main by b94cb8e2c4ebf2a8c7688cf676c3cf9899584adb.

Problems

  • The PR edits the former gateway/platforms/feishu.py surface, but the active implementation is now plugins/platforms/feishu/adapter.py. Main already loads FEISHU_REQUIRE_MENTION at plugins/platforms/feishu/adapter.py:1600, applies admission at :4231, documents it at website/docs/user-guide/messaging/feishu.md:240, and covers it in tests/gateway/test_feishu_bot_admission.py:91.
  • The remaining upgrade diagnostic has no regression coverage: this PR changes only tests/gateway/test_feishu.py, while the relevant current helper is hermes_cli/main.py:7656. Main currently reports only failed extra names at hermes_cli/main.py:7690-7706.

Suggested changes

  • Rescope to the still-separate configured-Feishu dependency diagnostic, reworking it against the current fallback helper.
  • Add a focused tests/hermes_cli test that simulates a failed Feishu extra and missing lark_oapi with Feishu configured.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added 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/cli CLI entry point, hermes_cli/, setup wizard 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: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

3 participants