← Back to PRs

#13961: fix(telegram): support media attachments in replied Telegram messages

by shan-mx open 2026-02-11 08:12 View on GitHub →
channel: telegram stale
## Problem Currently, the agent has no context to media attachments in a replied Telegram message. Example: 1. User/bot sent a message containing an image in the session 2. User reply to that message, asking about that image 3. The bot is unable to access or read that image ## Fix This PR adds several metadata about ReplyToMedia into MsgContext, making the bot able to access and read the media attachments in replied messages. ## Test Added a test file (src/auto-reply/reply/inbound-meta.test.ts) and modified two test cases in existing tests to ensure the new behavior works as expected. The patch is built and verified manually in my local deployment. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds support for staging and exposing media attachments from replied Telegram messages by: - Downloading media from `reply_to_message`/`external_reply` in Telegram delivery, and passing it into message-context construction. - Extending `MsgContext`/templating metadata with `ReplyToMedia*` fields. - Updating sandbox media staging to copy replied media into the sandbox workspace and rewrite paths/URLs. - Including replied-media paths/types in the inbound “replied message” context block. Main issue to address before merge: the new unit test for `buildInboundUserContextPrefix` is brittle because it parses the first JSON block, but the function may emit other JSON blocks before the replied-message block depending on inputs. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge once the failing/brittle unit test is fixed. - Behavioral changes are localized and covered by new tests for reply-media download and sandbox staging, but the new inbound-meta test is structured in a way that will fail under common inputs because it assumes the first JSON block is the reply context. - src/auto-reply/reply/inbound-meta.test.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs