[BUG] Infinite retry loop when viewing large images in many-image context (2000px limit)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When a conversation already contains multiple images (15+), attempting to view a large image (>2000px dimension) triggers an API error. Instead of handling this gracefully, Claude Code enters an infinite retry loop with the same failing request.
Error Message:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages.23.content.5.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}}
What Should Happen?
Claude Code should:
- Detect the "many-image requests" size limit error
- Auto-compress the image and retry, OR
- Provide alternative (metadata/thumbnail), OR
- Clearly explain the limitation to the user
Instead of silently retrying the same failing request indefinitely.
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error", "message":"messages.23.content.5.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}, "request_id":"req_011CXhNo9yEk1fbuj6JhweZR"}
The same error repeats multiple times with different request_ids, indicating retry attempts.
Steps to Reproduce
- Start a conversation and use the view tool to load 15+ images
- Attempt to view a new image with dimensions > 2000px
- Observe: API returns 400 error
- Observe: Claude Code retries the same request without any error handling
- User must manually intervene to break the loop
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Latest (Claude Desktop Mac with Code module)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Root Cause Analysis
The API enforces stricter image size limits (2000px max dimension) for "many-image requests" compared to single-image requests. Claude Code does not:
- Track the number of images already in the conversation context
- Handle this specific error type
- Implement any fallback strategy
Suggested Fix
- Catch invalid_request_error with "many-image requests" in the message
- Implement auto-compression (resize to <2000px) and retry
- Or fall back to returning image metadata instead of visual content
- Add clear user-facing error message explaining the limitation
Related Issue
Related to #22351 but with more specific reproduction steps and error details.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗