openclaw - ✅(Solved) Fix bug(telegram): reply to bot photo injects bot-sent media as inbound user attachment [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57278Fetched 2026-04-08 01:51:39
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
referenced ×4cross-referenced ×2

Root Cause

isSelfAuthoredTelegramMessage exists and is correctly used at the top-level inbound handler to filter bot-authored messages, but this guard is missing from resolveReplyMediaForMessage in both:

  • extensions/telegram/src/bot-handlers.runtime.ts
  • extensions/telegram/src/bot-handlers.buffers.ts

Fix Action

Fix

Add guard after hasInboundMedia check in resolveReplyMediaForMessage in both files:

if (isSelfAuthoredTelegramMessage(ctx, replyMessage)) return [];

PR fix notes

PR #57280: fix(telegram): skip reply media download when replied-to message is from bot

Description (problem / solution / changelog)

Fixes #57278

When a user replies to a bot-sent photo, resolveReplyMediaForMessage downloaded the bot-sent image and injected it as inbound user media, causing the agent to react to images it previously generated.

isSelfAuthoredTelegramMessage already existed and was correctly used at the top-level inbound handler but was absent from resolveReplyMediaForMessage in both files.

Changes

bot-handlers.runtime.ts — uses the already-in-scope isSelfAuthoredTelegramMessage helper:

// Do not re-ingest media from messages sent by this bot
if (isSelfAuthoredTelegramMessage(ctx, replyMessage)) {
  return [];
}

bot-handlers.buffers.ts — uses an inline equivalent (helper not in scope):

// Do not re-ingest media from messages sent by this bot
if (ctx.me != null && replyMessage.from?.id === ctx.me.id) {
  return [];
}

Both guards are placed immediately after the hasInboundMedia check, before any file download is attempted.

Changed files

  • extensions/telegram/src/bot-handlers.buffers.ts (modified, +4/-0)
  • extensions/telegram/src/bot-handlers.runtime.ts (modified, +4/-0)

PR #57298: fix(telegram): skip bot-authored media in reply resolution

Description (problem / solution / changelog)

Summary

When a user replies to a bot-sent photo in Telegram, the bot's own photo is incorrectly downloaded and injected as a user-sent attachment. This confuses the agent into processing its own media as new user input.

Root cause

resolveReplyMediaForMessage in both the runtime and buffer handlers checks hasInboundMedia(replyMessage) but does not verify whether the reply target was authored by the bot itself. Bot-sent photos pass the media check and get re-injected.

Fix

Added a guard clause in both handler files to return early when the reply_to_message was authored by the bot:

  • bot-handlers.runtime.ts: uses existing isSelfAuthoredTelegramMessage(ctx, replyMessage)
  • bot-handlers.buffers.ts: uses inline replyMessage.from?.id === ctx.me?.id (helper not in scope in this file)

8 lines added, 0 removed. Purely defensive — no behavior change for non-bot messages.

Closes #57278

Changed files

  • extensions/telegram/src/bot-handlers.buffers.ts (modified, +4/-0)
  • extensions/telegram/src/bot-handlers.runtime.ts (modified, +4/-0)

Code Example

if (isSelfAuthoredTelegramMessage(ctx, replyMessage)) return [];
RAW_BUFFERClick to expand / collapse

When a user replies to a bot-sent photo, resolveReplyMediaForMessage downloads the original image and injects it as inbound user media. The agent incorrectly receives and reacts to images it previously generated.

Root Cause

isSelfAuthoredTelegramMessage exists and is correctly used at the top-level inbound handler to filter bot-authored messages, but this guard is missing from resolveReplyMediaForMessage in both:

  • extensions/telegram/src/bot-handlers.runtime.ts
  • extensions/telegram/src/bot-handlers.buffers.ts

Reproduction

  1. Bot sends a photo to user
  2. User replies to that message with text
  3. reply_to_message.photo contains the bot-sent image
  4. Gateway downloads and injects it as [media attached: ...]
  5. Agent sees the image as if the user sent it

Fix

Add guard after hasInboundMedia check in resolveReplyMediaForMessage in both files:

if (isSelfAuthoredTelegramMessage(ctx, replyMessage)) return [];

extent analysis

Fix Plan

To resolve the issue, we need to add a guard to filter out bot-authored messages in the resolveReplyMediaForMessage function. Here are the steps:

  • Open the files extensions/telegram/src/bot-handlers.runtime.ts and extensions/telegram/src/bot-handlers.buffers.ts
  • Locate the resolveReplyMediaForMessage function
  • Add the following check after the hasInboundMedia check:
if (hasInboundMedia(replyMessage)) {
  if (isSelfAuthoredTelegramMessage(ctx, replyMessage)) return [];
  // existing code to download and inject media
}
  • Save the changes and redeploy the updated code

Verification

To verify the fix, follow these steps:

  • Send a photo to a user using the bot
  • Have the user reply to the message with text
  • Check that the agent does not react to the image as if it were sent by the user

Extra Tips

  • Make sure to test the fix in a staging environment before deploying it to production
  • Consider adding additional logging or monitoring to detect similar issues in the future
  • Review the codebase for other places where the isSelfAuthoredTelegramMessage guard may be missing

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix bug(telegram): reply to bot photo injects bot-sent media as inbound user attachment [2 pull requests, 1 participants]