Skip to content

fix(feishu): preserve image/attachment context when replying to non-text messages - #26063

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/feishu-reply-to-image-context
Closed

fix(feishu): preserve image/attachment context when replying to non-text messages#26063
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/feishu-reply-to-image-context

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

Summary

Fixes #26037 — When a user replies to an image (or file/audio) message in Feishu, _fetch_message_text() returns None because _extract_text_from_raw_content() only checks text_content and placeholder_text, both of which are empty for image messages.

Root Cause

normalize_feishu_message() correctly parses image messages and populates image_keys, but sets text_content='' when the alt text equals FALLBACK_IMAGE_TEXT. The downstream _extract_text_from_raw_content() method never checks image_keys, so the parent context is silently lost.

Fix

In _extract_text_from_raw_content(), after the text_content check, add fallback handlers:

  • Image messages: return [Image: img_key_xxx] using normalized.image_keys
  • File/audio/media: return [Attachment: filename] using normalized.media_refs

This gives the agent enough context to know what the user is replying to and potentially use vision_analyze for image content.

Testing

407 Feishu tests passed, 0 failures.

Scope

1 file changed (gateway/platforms/feishu.py), 10 lines added.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competes with open #13115 and #24285 (both address the same Feishu reply-to-image context loss). This PR takes a lighter approach (fallback in _extract_text_from_raw_content) vs #13115 (fetches full parent media). Related: #14371 (group chat media).

…ext messages

_extract_text_from_raw_content() returned None for image messages because
normalize_feishu_message() sets text_content='' for images (when alt_text
equals FALLBACK_IMAGE_TEXT). This caused reply-to-image messages to lose
all parent context.

Now returns a placeholder like '[Image: img_v3_xxx]' for image messages
and '[Attachment: filename]' for file/audio/media messages, so the agent
knows what the user is replying to and can use vision_analyze if needed.

Fixes NousResearch#26037
@luyao618

Copy link
Copy Markdown
Contributor Author

Closing — open too long, no longer relevant.

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 P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu: reply-to-image messages lose parent context (_fetch_message_text returns empty for non-text msgs)

2 participants