fix(feishu): include attachments from replied messages - #54570
Conversation
Related: competing open Feishu reply-media PRs — #13115 (earliest, canonical), #27545, #14371. This is a rebase of closed #24285. Verified on |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing the missing parent-media path; the underlying defect remains on current main. Current reply handling calls only _fetch_message_text at plugins/platforms/feishu/adapter.py:3259, while the existing resource pipeline is available at :3771-3800.
Problems
- On PR head, the empty-text guard at
plugins/platforms/feishu/adapter.py:3116-3119runs before the new lookup at:3137. A pure@Hermesreply to an attachment returns before parent media is hydrated. _fetch_message_contextredownloads parent resources on every repeat reply (:4057-4060) and has no context cache. The cache helpers create UUID-named paths (gateway/platforms/base.py:719,:839,:1576).- The
gateway/run.pyhunk is already superseded by current main's broader per-attachment handling atgateway/run.py:10526-10571(505bc27d8d911465ae1e6e63e9329455f8213ecb).
Suggested changes
- Hydrate parent context before the empty-text guard and add a bare-mention reply regression test.
- Add a bounded parent-context LRU cache and tests for repeated-parent reuse.
- Port the SDK GET through current main's
_run_blockinghelper (plugins/platforms/feishu/adapter.py:1692-1695) and retain current main's gateway preprocessing.
Automated hermes-sweeper review.
| reply_media_urls: List[str] = [] | ||
| reply_media_types: List[str] = [] | ||
| if reply_to_message_id: | ||
| reply_to_text, reply_media_urls, reply_media_types = await self._fetch_message_context(reply_to_message_id) |
There was a problem hiding this comment.
This lookup occurs after the empty-text guard at lines 3116-3119. A user who quote-replies to an attachment with only an @bot mention is stripped to empty and returned before this runs; move hydration before that guard (or make the guard parent-media-aware) and add that regression case.
| return None | ||
|
|
||
| async def _fetch_message_text(self, message_id: str) -> Optional[str]: | ||
| async def _fetch_message_context(self, message_id: str) -> tuple[Optional[str], List[str], List[str]]: |
There was a problem hiding this comment.
Please add a bounded parent-context cache here. Repeat replies to the same parent re-run the download at line 4057, and the cache helpers create UUID-named files for each download, so repeated replies duplicate cached media until cleanup.
|
Superseded by a clean rebuild from main. See new PR. |
Carries replied attachment media into the current event so the agent can see files/images the user is replying to.
Rebased onto current main (v0.17.0+). Original PR was #24285.
Closes #26037
What this fixes
When replying to a Feishu message that contains attachments (images, documents), the agent only sees the text — the attachments are lost. This PR fetches the parent message's full context including cached attachment resources.
Changes