Skip to content

feat: outbound image/file attachments from agent → Discord #298

@DrVictorChen

Description

@DrVictorChen

Description

Support sending images and files from the agent back to Discord as native attachments. Currently OpenAB only supports inbound attachments (Discord → agent via base64 ImageContent blocks, PR #158), but the outbound path (edit_message) only writes .content(text) with no CreateAttachment.

Use Case

  • Agent captures a screenshot (e.g. via peekaboo on macOS) and posts it back to the thread
  • Agent generates a chart, diagram, or report and shares it visually
  • Agent produces a file (CSV, PDF) and attaches it to the reply

Current workaround: The agent calls the Discord REST API directly via curl with the bot token to POST multipart form data. This works but is hacky — agent needs the bot token and channel ID, messages land outside OpenAB's thread context, and it's not portable across agents.

Proposed Solution

Detection: Agent response contains ![alt](/path/to/file) markers (markdown image syntax, natural for LLM agents).

Handling in discord.rs:

  1. Parse agent response for file markers via regex
  2. Validate: file exists, size ≤ 25 MB (Discord limit), path in allowlisted directories only (security)
  3. Upload via serenity CreateAttachment::path()
  4. Strip markers from text content
  5. Send attachments as follow-up messages

Security:

  • Path allowlist (e.g. /tmp/, agent working dir) to prevent exfiltration
  • Size cap at Discord's 25 MB limit
  • Rate limit on attachments per message

Environment: OpenAB v0.7.2, macOS + launchd multi-agent (Claude/Cursor/Codex/Copilot). Confirmed with maintainer on Discord that PRs are welcome.

Happy to submit a PR after feedback on detection format and security model.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions