fix(cron): deliver MEDIA files as native platform attachments#5921
Merged
Conversation
The cron delivery path sent raw 'MEDIA:/path/to/file' text instead of uploading the file as a native attachment. The standalone path (via _send_to_platform) already extracted MEDIA tags and forwarded them as media_files, but the live adapter path passed the unprocessed delivery_content directly to adapter.send(). Two bugs fixed: 1. Live adapter path now sends cleaned text (MEDIA tags stripped) instead of raw content — prevents 'MEDIA:/path' from appearing as literal text in Discord/Telegram/etc. 2. Live adapter path now sends each extracted media file via the adapter's native method (send_voice for audio, send_image_file for images, send_video for video, send_document as fallback) — files are uploaded as proper platform attachments. The file-type routing mirrors BasePlatformAdapter._process_message_background to ensure consistent behavior between normal gateway responses and cron-delivered responses. Adds 2 tests: - test_live_adapter_sends_media_as_attachments: verifies Discord adapter receives send_voice call for .mp3 file - test_live_adapter_sends_cleaned_text_not_raw: verifies MEDIA tag stripped from text sent via live adapter
…failure isolation Adapted from PR #5679 (0xbyt4) to cover edge cases not in the integration tests: video routing, unknown extension fallback to send_document, multi-file delivery, and single-failure isolation.
This was referenced Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the live adapter path in
_deliver_result()so cron deliveries via a running gateway send cleaned text (MEDIA tags stripped) and route extracted media files to native platform methods (send_voice,send_image_file,send_video,send_document).Before: Discord/Telegram users saw literal
MEDIA:/path/to/filetext instead of audio/image/video attachments.After: Media files are delivered as native platform attachments, matching how the standalone delivery path and live chat already work.
Root cause
_deliver_result()line 250 sent rawdelivery_contentthroughruntime_adapter.send(). Theextract_media()call at line 241 already extracts files, but its output (cleaned_delivery_content,media_files) was only consumed by the standalone fallback path — the live adapter path ignored both.Changes
cron/scheduler.py:_send_media_via_adapter()helper routes each file by extension to the adapter's typed send method — mirrorsBasePlatformAdapter._process_message_backgroundroutingcleaned_delivery_content(stripped) instead of rawdelivery_contentadapter.send()entirely, still delivers mediarun_coroutine_threadsafeisolation — one failure doesn't block remaining filesfrozensetfor module-level extension constantstests/cron/test_scheduler.py:Attribution
Core fix cherry-picked from PR #5909 by @kshitijk4poor.
Additional unit tests adapted from PR #5679 by @0xbyt4.
PR #4517 by @boobutler addressed the standalone path (merged in #5598).
Test plan
E2E verified: text+media, media-only, and plain-text delivery paths all correct.
Closes #5909, closes #5679, closes #4517.