Skip to content

fix(feishu): use open_message_id for card action reply instead of token - #51915

Closed
wlknight wants to merge 1 commit into
NousResearch:mainfrom
wlknight:fix/feishu-card-action-reply
Closed

wlknight wants to merge 1 commit into
NousResearch:mainfrom
wlknight:fix/feishu-card-action-reply

Conversation

@wlknight

Copy link
Copy Markdown

When a Feishu interactive card button is clicked, the agent fails to send a reply with: 'Invalid ids: [c-...]'. The root cause is that _handle_card_action_event() sets message_id to the card action token (format c-xxx), but the Feishu ReplyMessage API requires an open_message_id (format om_xxx).

P2CardActionTriggerData.CallBackContext already provides the open_message_id field, but the adapter only extracted open_chat_id from it while ignoring open_message_id.

Two-line fix:

  1. Extract open_message_id from CallBackContext
  2. Prefer open_message_id as message_id (fall back to token/uuid)

What does this PR do?

Related Issue

Fixes #

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

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • 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/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

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

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter P2 Medium — degraded but workaround exists labels Jun 24, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Related: #6422 (same open_message_id approach) and #43609 (sets message_id=None) both target gateway/platforms/feishu.py, which has been relocated to plugins/platforms/feishu/adapter.py (the old core path no longer exists on main). This PR patches the live plugin path directly (the buggy message_id=token or uuid is still on main at line ~2896), so it is the version aligned with current code. Broader #43048 fixes this plus two other card-action bugs. Flagging the cluster so a maintainer can pick.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for targeting the live Feishu plugin path. The defect remains on current main: plugins/platforms/feishu/adapter.py:3009 places the card callback token in MessageEvent.message_id; gateway/platforms/base.py:107 then uses that value as the reply anchor, and plugins/platforms/feishu/adapter.py:4613-4621 sends it to Feishu's reply endpoint.

Problems

  • The PR has no regression test. The shared callback fixture at tests/gateway/test_feishu_approval_buttons.py:57-74 exposes only open_chat_id, and TestNonApprovalCardAction.test_routes_as_synthetic_command at lines 417-438 never asserts the emitted event ID.

Suggested changes

  • Add open_message_id to the fixture and assert that a non-approval card action uses it as MessageEvent.message_id; retain fallback coverage for absent context IDs.

Automated hermes-sweeper review.

@@ -2893,7 +2894,7 @@ async def _handle_card_action_event(self, data: Any) -> None:
message_type=MessageType.COMMAND,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add focused coverage for this path: provide context.open_message_id in the card-action fixture and assert that the dispatched synthetic event uses it as message_id. The existing non-approval card-action test only checks the generated text.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 15, 2026
When a Feishu interactive card button is clicked, the agent fails to
send a reply with: [99992354] Invalid ids: [c-...]

Root cause: _handle_card_action_event() sets message_id to the card
action token (format c-xxx), but the Feishu ReplyMessage API requires
an open_message_id (format om_xxx).

P2CardActionTriggerData.CallBackContext already provides the
open_message_id field, but the adapter only extracted open_chat_id
while ignoring open_message_id.

Two-line fix in plugins/platforms/feishu/adapter.py:
1. Extract open_message_id from CallBackContext
2. Prefer open_message_id as message_id (fall back to token/uuid)

Regression tests added in tests/gateway/test_feishu_approval_buttons.py:
- test_uses_open_message_id_when_available: verifies om_xxx is used
  when present in the callback context
- test_falls_back_to_token_when_open_message_id_absent: verifies token
  fallback when open_message_id is absent

All 40 tests pass.
@wlknight
wlknight force-pushed the fix/feishu-card-action-reply branch from 6219408 to dac9b59 Compare July 25, 2026 00:41
@wlknight wlknight closed this Jul 29, 2026
@wlknight
wlknight deleted the fix/feishu-card-action-reply branch July 29, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants