openclaw - ✅(Solved) Fix Telegram MEDIA directives with local image paths are sent as text instead of attachments [1 pull requests, 1 comments, 2 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#77702Fetched 2026-05-06 06:22:46
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
commented ×1cross-referenced ×1

When an assistant reply contains MEDIA: directives for local image paths in a Telegram direct chat, the Telegram adapter can send the reply as a plain text message instead of attaching the images. The visible result is that the user receives literal MEDIA:/path/to/file.jpg lines and no photos/documents.

Root Cause

Diagnostics / likely root cause

Fix Action

Fixed

PR fix notes

PR #77911: fix: allow safe JSON media artifacts

Description (problem / solution / changelog)

Summary

  • allow host-local .json files to be sent as MEDIA: document artifacts when they parse as validated JSON text
  • block risky JSON filenames such as openclaw.json, openclaw.config.json, credentials/secrets/token/service-account JSON files
  • reject JSON artifacts with secret-like keys such as apiKey, token, password, and privateKey
  • document the JSON artifact policy for local MEDIA: sends

Fixes #77702

Testing

  • pnpm exec vitest run --config test/vitest/vitest.media.config.ts src/media/web-media.test.ts
  • pnpm exec oxfmt --check src/media/web-media.ts src/media/web-media.test.ts docs/start/openclaw.md docs/help/faq.md docs/reference/rich-output-protocol.md
  • pnpm exec oxlint src/media/web-media.ts src/media/web-media.test.ts
  • pnpm dlx --config.resolution-mode=highest markdownlint-cli2 --config config/markdownlint-cli2.jsonc docs/start/openclaw.md docs/help/faq.md docs/reference/rich-output-protocol.md
  • pnpm check:changed --base origin/main --head HEAD

Changed files

  • docs/help/faq.md (modified, +1/-1)
  • docs/reference/rich-output-protocol.md (modified, +4/-1)
  • docs/start/openclaw.md (modified, +3/-1)
  • src/media/web-media.test.ts (modified, +67/-0)
  • src/media/web-media.ts (modified, +181/-1)

Code Example

MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/example.jpg

---

MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/a.jpg
MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/b.jpg
MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/c.jpg

---

[
  {
    "text": "",
    "mediaUrls": [
      "/Users/.../.openclaw/media/generated/neetware-pfps/a.jpg",
      "/Users/.../.openclaw/media/generated/neetware-pfps/b.jpg",
      "/Users/.../.openclaw/media/generated/neetware-pfps/c.jpg"
    ]
  }
]
RAW_BUFFERClick to expand / collapse

Summary

When an assistant reply contains MEDIA: directives for local image paths in a Telegram direct chat, the Telegram adapter can send the reply as a plain text message instead of attaching the images. The visible result is that the user receives literal MEDIA:/path/to/file.jpg lines and no photos/documents.

Environment

  • OpenClaw app: 2026.5.3
  • OS: macOS 26.3 arm64
  • Channel: Telegram direct chat
  • Gateway: local LaunchAgent

Repro

  1. Have a Telegram direct conversation with OpenClaw.
  2. Create local images inside an allowed OpenClaw path, e.g.:
    • /Users/.../.openclaw/workspace/neetware-pfps/example.jpg
    • /Users/.../.openclaw/media/generated/neetware-pfps/example.jpg
  3. Reply from the assistant with one or more standalone MEDIA: lines, e.g.:
MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/example.jpg

or multiple:

MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/a.jpg
MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/b.jpg
MEDIA:/Users/.../.openclaw/media/generated/neetware-pfps/c.jpg

Expected

Telegram should deliver the files as photo/document attachments, using sendPhoto / sendDocument as appropriate, and strip the MEDIA: directive lines from the visible text.

Actual

Telegram sends a normal text message containing the literal MEDIA: lines. Gateway logs show sendMessage ok; no corresponding sendPhoto or sendDocument call appears for these replies.

Diagnostics / likely root cause

I checked the local docs and runtime behavior:

  • Docs say local-path MEDIA: attachments can use absolute paths, workspace-relative paths, or ~/ paths, subject to file-read/media type checks.
  • The outbound parser correctly extracts these local paths. Running OpenClaw’s normalized payload path on the same text produced:
[
  {
    "text": "",
    "mediaUrls": [
      "/Users/.../.openclaw/media/generated/neetware-pfps/a.jpg",
      "/Users/.../.openclaw/media/generated/neetware-pfps/b.jpg",
      "/Users/.../.openclaw/media/generated/neetware-pfps/c.jpg"
    ]
  }
]
  • However, Telegram delivery appears to make the preview/finalization decision using resolveSendableOutboundReplyParts(payload, { text }) before parsing inline MEDIA: directives out of text.
  • Because the raw payload has text but no payload.mediaUrls yet, the Telegram path treats it as text-only and chooses the preview/edit or sendMessage path. The media parser never gets a chance to turn those MEDIA: lines into attachments for that final send.

Relevant local areas inspected:

  • docs/reference/rich-output-protocol.md
  • docs/start/openclaw.md media section
  • dist/deliver-*.js / outbound payload planning: createOutboundPayloadPlanEntry(...) parses directives correctly
  • dist/bot-*.js Telegram finalization path: hasMedia = resolveSendableOutboundReplyParts(payload, { text }).hasMedia seems to be evaluated on unparsed text
  • dist/delivery-*.js Telegram send path only saw text payloads in this case

Suggested fix

Before Telegram decides whether a final reply can be edited/sent as text-only, normalize/parse reply directives so MEDIA: lines contribute to mediaUrls. In other words, the hasMedia check in Telegram preview/finalization should use the same directive-parsed payload that delivery later uses, not the raw text-only payload.

This should prevent MEDIA: replies from going through the sendMessage/preview path and ensure they reach the media delivery path.

extent analysis

TL;DR

The Telegram adapter should parse MEDIA: directives before deciding whether a reply is text-only, to ensure images are sent as attachments instead of plain text.

Guidance

  • Verify that the resolveSendableOutboundReplyParts function is using the raw text payload without parsing MEDIA: directives.
  • Check the createOutboundPayloadPlanEntry function to ensure it correctly parses MEDIA: directives and adds them to payload.mediaUrls.
  • Consider modifying the Telegram finalization path to use the parsed payload with mediaUrls when evaluating hasMedia.
  • Test the fix by sending a reply with MEDIA: directives and verifying that the images are sent as attachments.

Example

No code snippet is provided as the issue does not contain sufficient code details.

Notes

The suggested fix assumes that the createOutboundPayloadPlanEntry function is correctly parsing MEDIA: directives and adding them to payload.mediaUrls. If this is not the case, additional modifications may be necessary.

Recommendation

Apply the workaround by modifying the Telegram finalization path to use the parsed payload with mediaUrls when evaluating hasMedia, as this should prevent MEDIA: replies from being sent as plain text.

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 Telegram MEDIA directives with local image paths are sent as text instead of attachments [1 pull requests, 1 comments, 2 participants]