Skip to content

feat(discord): implement message attachment ingress #750

Description

@Aaronontheweb

Summary

The Discord adapter does not handle message attachments. DiscordGatewayMessage has no attachment fields, DiscordNetGatewayClient.OnMessageReceivedAsync ignores message.Attachments, and all inbound messages arrive with hasMedia=False. Users sending images or files in Discord get no indication their attachments were received.

Current State

  • DiscordGatewayMessage (in DiscordTransportContracts.cs) has no attachment/media fields
  • DiscordNetGatewayClient.OnMessageReceivedAsync extracts only message.Content (text)
  • DiscordSessionBindingActor always sends hasMedia=False to the session pipeline
  • ChannelAttachments config exists in audience profiles but has no effect since attachments are never extracted

Expected Behavior

Match Slack's attachment ingress pipeline:

  • Extract message.Attachments from Discord.Net's SocketUserMessage
  • Validate against ChannelAttachments.AllowedCategories and MaxFileBytes for the session's audience
  • Download attachments to the session media directory
  • Include attachment metadata in ChannelInput so the LLM receives them
  • Support images, PDFs, documents, and other file types based on audience config

Reference Implementation

The Slack adapter has a complete attachment pipeline to mirror:

  • SlackThreadBindingActor — attachment ingress handling, download, and ChannelInput assembly
  • SlackFileFlowIntegrationTests.cs — comprehensive test coverage for file ingress scenarios
  • ChannelAttachmentPolicy — shared validation logic for attachment categories and size limits

Test Coverage Required

Following the Slack test patterns in SlackFileFlowIntegrationTests.cs:

  • Image attachment accepted for allowed audience
  • Attachment rejected when category not in AllowedCategories
  • Attachment rejected when exceeding MaxFileBytes
  • Multiple attachments in a single message
  • Attachment with text content (mixed message)
  • Attachment-only message (no text)
  • Attachment download failure degrades gracefully

Discovered During

Live Discord integration testing — sent an image in a public channel thread, session logged hasMedia=False and bot had no awareness of the attachment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions