Session becomes permanently broken with 'image dimensions exceed max allowed size: 8000 pixels' even when all images are under 8000px

Resolved 💬 3 comments Opened Feb 28, 2026 by exp78 Closed Mar 28, 2026

Bug Description

A Claude Code session becomes permanently unusable when the API returns error 400: "At least one of the image dimensions exceed max allowed size: 8000 pixels". Once this error occurs, every subsequent API call fails — including /compact, new messages, and even /debug. The session is completely bricked.

Key Issue

All images stored in the session JSONL are well under 8000px:

  • Screenshot: 920x1999
  • Android icon: 432x432
  • Android icon: 192x192
  • iOS icon: 120x120

Despite this, the API consistently rejects every request with the 8000px error at varying message/content indices (messages.3.content.1, messages.1.content.21), suggesting the issue may be in how Claude Code constructs the API request from JSONL data, not in the stored images themselves.

Steps to Reproduce

  1. Have a long session with multiple compaction points
  2. Read several image files (small icons, screenshots)
  3. At some point the API returns the 8000px error
  4. Session becomes permanently broken — no recovery possible through normal means

Error Messages

API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.3.content.1.image.source.base64.data: At least one 
of the image dimensions exceed max allowed size: 8000 pixels"}}

On /compact attempt:

Error: Error during compaction: Error: API Error: 400 {"type":"error",
"error":{"type":"invalid_request_error","message":"messages.1.content.21.image.source.base64.data: 
At least one of the image dimensions exceed max allowed size: 8000 pixels"}}

Workaround

Manually replacing all base64 image data in the session JSONL file with a tiny 1x1 PNG fixes the issue, confirming the problem is related to image handling in the API request construction.

Expected Behavior

  • Claude Code should validate image dimensions before sending to the API
  • If an image is too large, it should be automatically downscaled rather than bricking the session
  • /compact should be able to strip problematic images to recover the session
  • At minimum, there should be a recovery mechanism (e.g., /clear-images) instead of permanent session death

Environment

  • Claude Code v2.1.63
  • macOS Darwin 25.1.0
  • Model: claude-opus-4-6

Additional Context

The session had multiple compaction points (7 compactions). The error appeared after reading small Android/iOS app icons (all under 500x500px). The session JSONL contained only 4 image blocks total, none exceeding 920x1999px. The bug may be related to how images are re-serialized during API message construction after multiple compactions.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗