feat(gateway): native multi-image sending for Telegram, Discord, Slack, Mattermost, Email, Signal#17909
Merged
Conversation
Adds a new `send_multiple_images` method to the ``BasePlatformAdapter`` that implements the default "One image per message" loop and allows for platform-specific overriding. Implements such an override for the Signal adapter, batching images and trying (best-effort) to work around rate-limits for voluminous batches using a specific scheduler. Also implements batching + rate-limit handling in the `send_message` tool. New tests added for the Signal adapter, its rate-limit scheduler and the `send_message` tool
…ck, Mattermost, Email Ports PR #17888's send_multiple_images ABC to every gateway platform that has a native multi-attachment API, so images arrive as a single bundled message instead of N separate ones. Native overrides: - Telegram: send_media_group (10 photos per album, chunks over); animated GIFs peeled off and routed through send_animation (albums don't support animations) - Discord: channel.send(files=[...]) (10 attachments per message, chunks over); URL images downloaded into BytesIO so they render inline; forum channels use create_thread with files=[...] - Slack: files_upload_v2(file_uploads=[...]) (10 per call, chunks over); respects thread_ts; records thread participation - Mattermost: single post with file_ids list (5 per post — Mattermost cap, chunks over) - Email: single SMTP message with multiple MIME attachments (no chunk cap, SMTP size governs); remote URLs remain linked in body (parity with existing send_image) All platforms fall back to the base per-image loop on any failure, so a single bad image in a batch never loses the rest. Matrix, WhatsApp, and single-attachment platforms (BlueBubbles, Feishu, WeCom, WeChat, DingTalk) continue to use the base default loop — their server APIs only accept one attachment per message anyway. Tests: adds tests/gateway/test_send_multiple_images.py with 19 targeted tests covering base default loop, chunking, animation peel-off, fallback paths, and empty-batch no-ops across all five new overrides. Co-authored-by: Maxence Groine <maxence@groine.fr>
15 tasks
4 tasks
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
Salvages #17888 (multi-image sending in Signal) and extends the new
send_multiple_imagesABC to every gateway platform with a native multi-attachment API, so images arrive as a single bundled message instead of N separate ones.Changes
Two commits:
1.
feat(gateway/signal): …— cherry-picked from #17888 by @MaxyMoos:send_multiple_images(chat_id, images, metadata, human_delay)method onBasePlatformAdapterwith a default per-image loop fallbacksignal_rate_limit.py— process-wide 50-token / 4s-refill scheduler shared between adapter +send_messagetool, with serverRetry-afterfeedbackrun.py+base.pypartition images out ofmedia_files/local_filesso they batch separately2.
feat(gateway): native send_multiple_images for Telegram, Discord, Slack, Mattermost, Email— new, authored by teknium1:bot.send_media_group(), 10 per album; animated GIFs peeled off and routed throughsend_animation(albums don't support animations)channel.send(files=[...]), 10 per message; URL images downloaded intoBytesIOso they render inline; forum channels route viacreate_thread(files=[...])files_upload_v2(file_uploads=[...]), 10 per call; respectsthread_ts; records thread participationfile_idslist, 5 per post (Mattermost's hard cap)All platforms fall back to the base per-image loop on any failure — one bad image never loses the rest of the batch.
Platforms that stay on the base default loop (server APIs accept only one attachment per message):
Matrix, WhatsApp, BlueBubbles, Feishu, WeCom, WeChat, DingTalk.
Validation
tests/gateway/test_send_multiple_images.py(new)tests/gateway/test_signal.py+test_signal_rate_limit.py(from PR #17888)tests/tools/test_send_message_tool.pytests/gateway/test_send_image_file.pytests/gateway/full suiteCo-authored-by: Maxence Groine maxence@groine.fr
Closes #17888