Skip to content

feat(gateway): support inbound media and file attachments#655

Closed
iamninihuang wants to merge 2 commits intoopenabdev:mainfrom
iamninihuang:feat/gateway-media-attachments
Closed

feat(gateway): support inbound media and file attachments#655
iamninihuang wants to merge 2 commits intoopenabdev:mainfrom
iamninihuang:feat/gateway-media-attachments

Conversation

@iamninihuang
Copy link
Copy Markdown
Contributor

What problem does this solve?

Currently, the Custom Gateway adapter only supports receiving plain text (GwContent.text). If a user sends an image, file, or voice message via a custom gateway (like LINE, Telegram, etc.), the bot ignores it because the schema lacks attachment support.

How does it solve it?

This PR introduces comprehensive media support for the Gateway adapter, mirroring the logic already present in Discord and Slack adapters:

  1. Schema Update: Expands GwContent with an optional attachments: Vec<GwAttachment> array.
  2. Image Processing: Automatically downloads, compresses, and base64 encodes image attachments using media::download_and_encode_image.
  3. Text File Inlining: Supports inline reading of text-based files (with a 1MB total size limit and a 5 file cap) via media::download_and_read_text_file.
  4. Voice Messages (STT): If stt.enabled is true, it transcribes audio attachments using media::download_and_transcribe. To support this, stt_config is now propagated to the Gateway params.
  5. Fallback: Logs an info message and passes a text block for unsupported file types (like PDFs) so the agent knows a file was uploaded.

Is this the best approach?

Yes. It leverages the existing, battle-tested functions in src/media.rs that the Discord and Slack adapters rely on, ensuring consistent memory bounds (e.g., resizing images to 1200px max, 10MB limits, 1MB text caps) and consistent ContentBlock structures across all platforms.

@iamninihuang iamninihuang requested a review from thepagent as a code owner April 30, 2026 19:17
@github-actions github-actions Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 3 days label Apr 30, 2026
@github-actions
Copy link
Copy Markdown

⚠️ This PR is missing a Discord Discussion URL in the body.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

This PR will be automatically closed in 3 days if the link is not added.

@github-actions github-actions Bot added the pending-screening PR awaiting automated screening label Apr 30, 2026
@thepagent
Copy link
Copy Markdown
Collaborator

@thepagent thepagent closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon PR missing Discord Discussion URL — will auto-close in 3 days pending-screening PR awaiting automated screening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants