Skip to content

Feishu replies can lose reply-to context when only root_id is present #18566

@CNSeniorious000

Description

@CNSeniorious000

Bug Description

Feishu/Lark inbound reply events can carry reply-tree context in root_id. Hermes currently resolves MessageEvent.reply_to_message_id from parent_id or upper_message_id only. If the SDK/event payload has root_id but no parent_id, Hermes does not fetch the replied-to/root message text, so the gateway never injects the [Replying to: ...] context for the agent.

This is separate from the Feishu topic outbound-routing issues tracked in #6969 / #17875: this report is only about inbound reply context (reply_to_message_id / reply_to_text).

Steps to Reproduce

  1. Receive a Feishu im.message.receive_v1 event for a reply message where message.root_id is set but message.parent_id and message.upper_message_id are absent.
  2. Let FeishuAdapter._process_inbound_message() normalize the event.
  3. Inspect the resulting MessageEvent.

Expected Behavior

MessageEvent.reply_to_message_id should use the available reply root id, _fetch_message_text() should fetch the referenced message, and reply_to_text should be populated so the gateway can inject reply context.

Actual Behavior

reply_to_message_id is None, _fetch_message_text() is not called, and the agent receives the user's reply without explicit replied-to context.

Proposed Fix

Treat root_id as a fallback reply target after parent_id and upper_message_id, with regression coverage for root-id-only Feishu reply payloads.

Test Plan

  • uv run pytest tests/gateway/test_feishu.py -q -o 'addopts='

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/feishuFeishu / Lark adaptersweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions