Skip to content

feat(feishu): bot-to-bot with post+at, require_mention loop guard, manual MAP config - #51269

Closed
crayfish-ai wants to merge 4 commits into
NousResearch:mainfrom
crayfish-ai:feat/feishu-bot-to-bot
Closed

crayfish-ai wants to merge 4 commits into
NousResearch:mainfrom
crayfish-ai:feat/feishu-bot-to-bot

Conversation

@crayfish-ai

@crayfish-ai crayfish-ai commented Jun 23, 2026 •

Copy link
Copy Markdown

Problem

Hermes bots in Feishu group chats cannot interact with each other. Messages from bots are ignored, and there's no way for a bot to @mention another bot and have it actually receive a mention event.

Solution

Enables bot-to-bot communication in Feishu group chats through these mechanisms:

  1. post+at outbound messages — Converts text @bot_name into Feishu post format with at tags, which triggers real mention events that other bots can receive.

  2. require_mention loop guard — In group chats, non-bot messages require @mention to pass admission. Bot messages (is_bot=True) are exempt when allow_bots="all", allowing unknown bots to be discovered without pre-configuration.

  3. Bot name persistence — Maps bot names to open_ids via FEISHU_BOT_MENTION_MAP env var (seed config) + JSON file cache (runtime persistence). Unknown bots encountered at runtime are captured by their open_id and survive gateway restarts, avoiding repeated "unknown bot" treatment.

  4. Group reply routing — Group replies skip message.reply (which lands in topic threads invisible to other members) and always use message.create to the main chat.

Design Notes

  • Bot name resolution: Uses contact.v3.user.get API (unified user/bot query within app contact scope) instead of bot/basic_batch which required elevated permissions.
  • Bot mention map: Seeded from env var at startup. Runtime-encountered bots are persisted with their open_id as a fallback name — users can later replace with friendly names in the env var.
  • Empty name caching: API responses with empty names are negative-cached to prevent repeated calls.

Changes

File +/-
adapter.py +290 / -90
test_feishu.py +90 / -40
test_feishu_bot_admission.py +18 / -3
Total +398 / -133

10 commits. All 265 feishu tests pass.

@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter P3 Low — cosmetic, nice to have labels Jun 23, 2026
@crayfish-ai
crayfish-ai force-pushed the feat/feishu-bot-to-bot branch 4 times, most recently from cf8e836 to 5946d92 Compare June 25, 2026 14:39
@crayfish-ai crayfish-ai changed the title feat(feishu): bot-to-bot LLM-driven auto-@ with persistent cache feat(feishu): bot-to-bot with post+at, require_mention loop guard, manual MAP config Jun 25, 2026
@crayfish-ai
crayfish-ai force-pushed the feat/feishu-bot-to-bot branch from fabf2c1 to 00fdb33 Compare June 26, 2026 02:53
@crayfish-ai
crayfish-ai force-pushed the feat/feishu-bot-to-bot branch from 00fdb33 to e1c6bd3 Compare June 26, 2026 02:54
- fix(gateway): clear stale resume_pending markers in scheduler
- fix(hermes_state): add active column to message INSERT (NousResearch#51646)
- feat(feishu): restore bot-to-bot mention support (FEISHU_BOT_MENTION_MAP)
…state): explicit active=1 in INSERT

- hermes_state.py: add active column to add_message INSERT (NousResearch#51646)
- hindsight/__init__.py: check auto_recall before claiming memory injected (NousResearch#52153)
- tests: add auto_recall=false test case for hindsight
…-bot review follow-up)

- Remove dead register_p2_im_chat_member_bot_added_v1 mock
- Update tests for reply→create API change
- Update bot name resolution tests from batch_bots→contact.v3.user.get
- Change allow_bots default from 'none' to 'all'
- Fix _resolve_sender_profile test for new contact.v3.user.get API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants