Skip to content
This repository was archived by the owner on May 26, 2026. It is now read-only.
This repository was archived by the owner on May 26, 2026. It is now read-only.

Discord PNG images rejected by Anthropic -- image pipeline should normalize format #692

@ezra-letta

Description

@ezra-letta

Bug

PNG images sent via Discord are rejected by Anthropic with:

messages.N.content.N.image.source.base64: The image was sp...

JPEG images sent to the same conversation, same agent, same model work fine.

Reproduction

  1. Send a PNG screenshot via Discord desktop → Anthropic 400 error
  2. Send the same image saved as JPEG → works
  3. Send from Discord mobile (which auto-compresses to JPEG) → works
  4. Send via Telegram (which always serves as JPEG) → works

Root cause

prepareImage() in src/core/bot.ts processes images through sharp for resizing but preserves the input format. PNGs pass through as PNGs. Anthropic appears to reject certain PNG encodings or large PNG base64 payloads.

The Telegram adapter sidesteps this because Telegram always serves photos as JPEG (mimeType: 'image/jpeg'). Discord preserves the original upload format.

Suggested fix

Add a format normalization step in prepareImage() -- convert to JPEG (or WebP) via sharp before base64 encoding, regardless of input format:

buffer = await sharp(buffer)
  .resize({ width: MAX_IMAGE_DIMENSION, height: MAX_IMAGE_DIMENSION, fit: 'inside', withoutEnlargement: true })
  .jpeg({ quality: 90 })
  .toBuffer();
mediaType = 'image/jpeg';

This would make the Discord path behave like the Telegram path and prevent format-dependent failures.

Environment

  • LettaBot 0.2.0 (built from main)
  • Letta Cloud
  • Anthropic (Claude Sonnet)
  • Discord channel with attachmentsDir configured
  • Raspberry Pi 5 host

Workaround

Users can save images as JPEG before sending, or send from Discord mobile (auto-compresses to JPEG).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions