Skip to content

fix: stop @_all from triggering bot mention; coerce MCP enum types - #72607

Open
Keithin wants to merge 1 commit into
NousResearch:mainfrom
Keithin:fix/feishu-atall-mention-enum-coerce
Open

fix: stop @_all from triggering bot mention; coerce MCP enum types#72607
Keithin wants to merge 1 commit into
NousResearch:mainfrom
Keithin:fix/feishu-atall-mention-enum-coerce

Conversation

@Keithin

@Keithin Keithin commented Jul 27, 2026

Copy link
Copy Markdown

What

Two fixes in this PR:

  1. @_all false-positive fix — Removed the @_all short-circuit in the Feishu gateway adapter that was causing bot mention detection to fire on @_all messages. Now only explicit personal @ mentions trigger bot reply.

  2. MCP enum type coercion — Added _coerce_enum_types() in mcp_tool.py to handle MCP tool schemas where enum values are strings (e.g. "10") but the declared type is integer. Oceanengine MCP tools send schemas like {enum: ["10","20"], type: integer}; this fix recursively coerces enum values to match the declared type.

Testing

- Remove @_all short-circuit in Feishu mention detection:
  @所有人都 no longer treated as mentioning the bot.
  Only individual @ with bot's open_id in mentions[] counts.
- Add no-op handler for user_status_change events to suppress
  56/day 'processor not found' ERROR log spam.
- Coerce MCP enum values to match declared property type
  (string '10' -> int 10) for Kimi/Moonshot compatibility.
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter tool/mcp MCP client and OAuth P2 Medium — degraded but workaround exists labels Jul 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: the Feishu @_all hunk overlaps open #59347, while this PR also carries a distinct MCP enum-schema coercion fix. The bundled scopes should be reviewed independently.

@teknium1 teknium1 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.

Thanks for addressing two current-main defects. The Feishu premise is confirmed at plugins/platforms/feishu/adapter.py:4399-4413, where raw @_all currently returns a self-mention; MCP normalization likewise has no enum coercion at tools/mcp_tool.py:5330-5340.

Problems

  • The new user_status_change registration will make the exact expected call list fail in tests/gateway/test_feishu.py:434-450; add customized:user_status_change before build.
  • tests/gateway/test_feishu.py:1664-1677 currently asserts the opposite @_all behavior. Update it to cover @_all alone being rejected under mention gating, while explicit bot mentions still pass.
  • Add MCP regression coverage: current schema tests cover definitions and nullable unions (tests/tools/test_mcp_tool.py:290-353), not recursive integer/number enum coercion.

The member note on #72607 correctly identifies the Feishu overlap with #59347 and the MCP repair as distinct scopes; preserve test coverage for both when salvaging. This is an automated hermes-sweeper review.

self._on_meeting_invited_event,
)
.register_p2_customized_event(
"user_status_change",

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.

Please update TestAdapterBehavior.test_build_event_handler_registers_reaction_and_card_processors: its exact expected call list at tests/gateway/test_feishu.py:434-450 currently omits this registration, so this hunk will fail that test.

@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 30, 2026
@Keithin

Keithin commented Aug 14, 2026

Copy link
Copy Markdown
Author

补充复现证据(2026-08-14,v0.20.1 仍受影响):

影响持续:此 bug 已导致我们本地第 5 次回归(hermes update 每次 reset 后 _mentions_self@_all 短路都会恢复)。每次升级后群聊 @所有人 都会被机器人回复,需要手动重打补丁。

复现步骤(v0.20.1 / origin/main 当前代码):

  1. 机器人加入飞书群
  2. 群成员发一条只 @所有人(不 @机器人)的消息
  3. 观察:_admit_mentions_self 命中 if "@_all" in raw_content: return True → 机器人错误回复

根因定位plugins/platforms/feishu/adapter.py _mentions_self()@_all 短路把 @everyone 当成 @bot。修复 = 删除短路,只认 mentions 数组里 bot open_id(本 PR 已实现,本地验证通过:@所有人 静默、单独 @bot 回复、@bot+@ALL 回复)。

附加发现(供参考):上游 _process_inbound_message 对"纯 @bot 无正文"消息会丢弃(Ignoring empty text message),但这对分段指令/上下文提醒场景是有意义的唤醒信号。我们已本地改为:mentions 含 bot 时放行(not self._message_mentions_bot(mentions) 守卫)。如需可另开 PR。

PR 修复经过本地 2 周生产验证,恳请维护者 review/merge。

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 P2 Medium — degraded but workaround exists 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 tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants