Session becomes permanently broken with 'image dimensions exceed max allowed size: 8000 pixels' even when all images are under 8000px
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
- Have a long session with multiple compaction points
- Read several image files (small icons, screenshots)
- At some point the API returns the 8000px error
- 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
/compactshould 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗