Media Handling

March 28, 2026 · View on GitHub

Mercury downloads media attachments from chat platforms, saves them to the workspace's inbox, and passes them to the agent. The agent can also produce files via the outbox/ directory.

Inbox (Incoming)

Incoming media is saved to the conversation's workspace:

workspaces/<name>/inbox/<timestamp>-<filename>

Examples:

workspaces/acme/inbox/
├── 1741243200000-photo.jpg
├── 1741243500000-voice.ogg
└── 1741244000000-report.pdf

The agent receives attachments as XML in the prompt:

<attachments>
  <attachment type="image" path="inbox/1741243200000-photo.jpg" mime="image/jpeg" size="12345" />
</attachments>

Outbox (Outgoing)

The agent writes files to outbox/ during a run. After the agent exits, the runtime scans for files with mtime >= startTime and attaches them to the reply:

workspaces/<name>/outbox/
├── chart.png
└── summary.pdf

Previous outbox files are not deleted — only files created or modified during the current run are sent.

Platform-Specific Download

PlatformMechanism
WhatsAppBaileys socket downloadMediaMessage()
DiscordCDN URL download
Slackurl_private with bot token auth
Chat APIBase64 decoded from request body

Platform-Specific Upload

PlatformMechanism
WhatsAppsock.sendMessage() with typed content (image/video/audio/document)
Discordthread.post({ files })
Slackfiles.uploadV2 API
Chat APIBase64 encoded in response body

Supported Types

TypeExtensions
Imagejpg, png, gif, webp
Videomp4, mov, avi
Audioogg, mp3, wav, m4a
Documentpdf, doc, docx, txt, csv, xls, xlsx