Skip to content

tools.media.image.maxBytes config setting is not used for inbound images #2954

@ApeWare

Description

@ApeWare

Summary

The tools.media.image.maxBytes config setting exists in the schema but is not wired into the actual inbound image processing pipeline. Large images from messaging platforms (e.g., Slack) crash the LLM request because they exceed the API's base64 size limits.

Expected Behavior

Setting tools.media.image.maxBytes = 3000000 (3MB) should cause images over that threshold to be automatically resized before being sent to the LLM.

Actual Behavior

The setting is ignored. The code uses a hardcoded constant instead:

Evidence

  1. /dist/media/constants.js hardcodes:
export const MAX_IMAGE_BYTES = 6 * 1024 * 1024; // 6MB
  1. /dist/agents/pi-embedded-runner/run/attempt.js:624 uses the hardcoded constant:
maxBytes: MAX_IMAGE_BYTES,  // Uses hardcoded constant, NOT config
  1. /dist/agents/pi-embedded-helpers/images.js - sanitizeSessionMessagesImages calls sanitizeContentBlocksImages without passing opts.maxBytes, so it defaults to the hardcoded 5MB.

Suggested Fix

The config value config.tools?.media?.image?.maxBytes should be read and passed through to:

  1. detectAndLoadPromptImages in attempt.js
  2. sanitizeSessionMessagesImages in pi-embedded-helpers/images.js
  3. sanitizeContentBlocksImages in tool-images.js

Reproduction

  1. Configure tools.media.image.maxBytes = 3000000 (3MB)
  2. Send a 3.5MB image via Slack DM
  3. Agent crashes because the image isn't resized before hitting the LLM

Workaround

Manually edit /dist/media/constants.js to lower MAX_IMAGE_BYTES (gets overwritten on updates).

Environment

  • Clawdbot version: 2026.1.24-3
  • Channel: Slack (Socket Mode)
  • Model: anthropic/claude-opus-4-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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