openclaw - 💡(How to fix) Fix Inbound images from Slack exceed Anthropic 5MB base64 limit (no auto-resize) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59910Fetched 2026-04-08 02:38:55
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

  1. Observe the image exceeds 5 MB maximum error

Root Cause

MAX_IMAGE_BYTES in src/media/constants.ts is set to 6MB, but Anthropic's base64 image limit is 5MB (5,242,880 bytes).

The optimization pipeline in loadWebMedia (src/web/media.ts) targets the 6MB cap, so images between 5-6MB pass through but are rejected by the provider.

Code Example

LLM request rejected: messages.107.content.1.image.source.base64: image exceeds 5 MB maximum: 5387944 bytes > 5242880 bytes

---

// src/media/constants.ts line 1
// Before:
export const MAX_IMAGE_BYTES = 6 * 1024 * 1024; // 6MB

// After:
export const MAX_IMAGE_BYTES = 5 * 1024 * 1024; // 5MB – matches Anthropic base64 limit
RAW_BUFFERClick to expand / collapse

Bug

Images sent via Slack are stored raw (Slack does not compress uploads like Telegram does). When the image is between 5MB and 6MB, it passes OpenClaw's MAX_IMAGE_BYTES (6MB) check but gets rejected by Anthropic's API:

LLM request rejected: messages.107.content.1.image.source.base64: image exceeds 5 MB maximum: 5387944 bytes > 5242880 bytes

The same image sent via Telegram works fine because Telegram compresses photos automatically before delivery.

Root Cause

MAX_IMAGE_BYTES in src/media/constants.ts is set to 6MB, but Anthropic's base64 image limit is 5MB (5,242,880 bytes).

The optimization pipeline in loadWebMedia (src/web/media.ts) targets the 6MB cap, so images between 5-6MB pass through but are rejected by the provider.

Suggested Fix

Quick fix — lower the constant:

// src/media/constants.ts line 1
// Before:
export const MAX_IMAGE_BYTES = 6 * 1024 * 1024; // 6MB

// After:
export const MAX_IMAGE_BYTES = 5 * 1024 * 1024; // 5MB – matches Anthropic base64 limit

This ensures optimizeImageToJpeg / optimizeImageWithFallback in src/web/media.ts will resize any image above 5MB before it reaches the LLM.

Better fix — make the limit provider-aware:

Different providers have different limits (Anthropic 5MB, OpenAI 20MB, Gemini 20MB). Ideally the optimization cap should come from the target model's constraints rather than a single global constant. This would avoid unnecessarily downscaling images for providers that accept larger payloads.

Reproduction

  1. Send a 5-6MB image via Slack DM to an OpenClaw bot using an Anthropic model
  2. Observe the image exceeds 5 MB maximum error
  3. Send the same image via Telegram — works fine (Telegram compresses to ~1-2MB)

Environment

  • OpenClaw version: 2026.2.6
  • Channel: Slack (socket mode)
  • Model: anthropic/claude-opus-4-6

extent analysis

TL;DR

Lower the MAX_IMAGE_BYTES constant to 5MB to match Anthropic's base64 image limit.

Guidance

  • Update the MAX_IMAGE_BYTES constant in src/media/constants.ts to 5MB to ensure images are resized before reaching the LLM.
  • Consider implementing a provider-aware limit to avoid unnecessary downscaling for providers with higher limits.
  • Verify the fix by sending a 5-6MB image via Slack DM to an OpenClaw bot using an Anthropic model and checking for the image exceeds 5 MB maximum error.
  • Test the image sending process via Telegram to ensure the fix does not introduce any regressions.

Example

// src/media/constants.ts
export const MAX_IMAGE_BYTES = 5 * 1024 * 1024; // 5MB – matches Anthropic base64 limit

Notes

The suggested fix assumes that lowering the MAX_IMAGE_BYTES constant is sufficient to resolve the issue. However, a more robust solution would be to implement a provider-aware limit to accommodate different providers' constraints.

Recommendation

Apply the workaround by lowering the MAX_IMAGE_BYTES constant to 5MB, as this is a straightforward fix that can be implemented immediately. A more comprehensive solution would require additional development to implement a provider-aware limit.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING