#22957: fix(feishu): download media from quoted messages in group chats (#22872)
channel: feishu
size: S
trusted-contributor
Cluster:
Media Handling Improvements
## Problem
In Feishu group chats, image recognition is completely broken. When a user sends an image and then replies to it with @bot, the model receives a raw JSON string like `{"image_key":"img_v3_02v5_xxx"}` instead of the actual image.
This happens because:
1. The quoted-message fetch path (`getMessageFeishu`) only extracts text content and never checks `contentType` for media types
2. History entries record raw `image_key` JSON for image messages
DM image recognition works fine because the message itself is dispatched as an image type and goes through `resolveFeishuMediaList()`.
### Why this matters
Feishu's UI does not allow sending an image and @mentioning the bot in the same message — images are sent immediately on selection. The only natural workflow in group chats is: send image → reply to it with @bot. This means there is **no working path** for image recognition in group chats.
## Changes
### Fix 1: Download media from quoted messages (high priority)
When fetching a quoted message, check its `contentType`. For media types (image, file, audio, video, sticker, post), call `resolveFeishuMediaList()` to download the actual media and append it to the media payload sent to the model.
### Fix 2: Human-readable history entries for media messages
Replace raw `{"image_key":"xxx"}` in history entries with human-readable placeholders like `[sent an image]` so the model gets useful context instead of cryptic JSON strings.
### Supporting change
Add `rawContent` field to `FeishuMessageInfo` so the original JSON content is preserved for media key parsing by `resolveFeishuMediaList()`.
## Files changed
- `extensions/feishu/src/bot.ts` — quoted message media download + history placeholder
- `extensions/feishu/src/send.ts` — `rawContent` field in `FeishuMessageInfo`
Fixes #22872
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes Feishu group chat image recognition by downloading media from quoted messages and improving history entries. However, there's a critical bug: `mediaPayload` is created before quoted media is added to `mediaList`, so quoted media won't actually reach the agent.
**Changes made:**
- Added media download for quoted messages (image, file, audio, video, sticker, post)
- Replaced raw JSON in history entries with readable placeholders like `[sent an image]`
- Added `rawContent` field to preserve original JSON for media key parsing
**Critical issue:**
- `mediaPayload` on line 779:779 is built too early—before quoted media is added to `mediaList` on line 806:806. This means the fix won't work as intended.
<h3>Confidence Score: 1/5</h3>
- This PR has a critical logic bug that prevents the main feature from working
- The PR addresses a real problem but contains a critical timing bug where `mediaPayload` is created before quoted media is added to `mediaList`. This means quoted media will be downloaded but never sent to the agent, breaking the intended functionality. The fix is straightforward—move the `buildAgentMediaPayload` call after all media collection is complete.
- extensions/feishu/src/bot.ts requires immediate attention—the `mediaPayload` build timing bug must be fixed
<sub>Last reviewed commit: 7d40875</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21786: feat(feishu): extract embedded video/media from post (rich text) me...
by laopuhuluwa · 2026-02-20
80.5%
#19171: fix(feishu): pass mediaLocalRoots to sendMediaFeishu for agent-scop...
by whiskyboy · 2026-02-17
77.1%
#13211: feat(feishu): skip reply-to in DM conversations
by Vincentwei1021 · 2026-02-10
76.8%
#10675: feat(feishu): add audio message support and fix file upload
by YumoeZhung · 2026-02-06
76.6%
#10309: fix: use group ID for peer.id in Feishu group messages
by ParsifalC · 2026-02-06
76.1%
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
74.7%
#13761: fix(feishu): silently degrade when contact permission is missing
by echoVic · 2026-02-11
74.6%
#19793: feat(feishu): reply-in-thread, parallel group sessions, and fire-an...
by yinsn · 2026-02-18
74.5%
#22675: feishu: move message dedup to just before dispatch
by zijiegeng · 2026-02-21
74.3%
#15351: feat(feishu): Add native audio message support (voice bubble)
by lovejing0306 · 2026-02-13
74.2%