[BUG]
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?
Bug Report: MCP Tool Large Screenshot Causes Unescapable Infinite Loop
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
Bug Description
When using an MCP tool (e.g., chrome-devtools) to take a screenshot, if the resulting image is too large (5MB+), Claude Code enters an infinite loop that cannot be escaped through normal means.
The error message displayed is:
Image was too large. Double press esc to go back and try again with a smaller image.
However, the suggested action (double press ESC) does not work effectively. The only way to break out of this loop is to use the /clear command, which loses all conversation context.
Steps to Reproduce
- Configure an MCP tool that can take screenshots (e.g.,
chrome-devtools) - Use the MCP tool to navigate to a page and take a screenshot
- The screenshot is saved successfully (in my case, to
/var/folders/.../screenshot.png) - Claude automatically attempts to read the image
- If the image is large (5MB-20MB), the error appears: "Image was too large"
- Try any of the following:
- Type "continue" → Claude retries viewing the same large image → same error
- Press stop → Ask a new question → Claude still tries to view the image → same error
- Double press ESC → Does not effectively cancel the operation
- The loop continues indefinitely until
/clearis used
Expected Behavior
- Graceful failure: When an image is too large, Claude should acknowledge the failure and move on without retrying
- Effective cancellation: The ESC key or stop button should completely cancel the image viewing attempt
- No automatic retry: Claude should not automatically retry viewing the same too-large image
- Alternative options: Claude could offer to:
- Skip the image and continue the conversation
- Suggest resizing the image
- Provide the file path for manual inspection
Actual Behavior
- Claude enters an infinite retry loop
- Cannot escape without
/clear - Loses all conversation context when forced to use
/clear - The "double press ESC" suggestion in the error message does not resolve the issue
Environment Info
- Platform: macOS (darwin)
- Terminal: Standard terminal / iTerm2
- MCP Tool: chrome-devtools (but likely affects any MCP tool that returns large images)
- Image Size: ~5MB-20MB (screenshot of a full webpage)
Screenshots / Logs
● chrome-devtools - navigate_page (MCP)(type: "url", url: "https://example.pages.dev/login")
└ # navigate_page response
Successfully navigated to https://example.pages.dev/login.
## Pages
0: https://example.pages.dev/login [selected]
● chrome-devtools - list_network_requests (MCP)(resourceTypes: ["fetch","xhr"])
└ # list_network_requests response
## Network requests
No requests found.
# take_screenshot response
Took a screenshot of the current page's viewport.
Saved screenshot to /var/folders/.../screenshot.png.
● Read(/var/folders/.../screenshot.png)
└ Read image (5MB)
● Image was too large. Double press esc to go back and try again with a smaller image.
> continue
● Image was too large. Double press esc to go back and try again with a smaller image.
Impact
- Workflow disruption: Users are forced to lose all conversation context
- No graceful recovery: The only workaround (
/clear) is destructive - Poor UX: The error message suggests an action (double ESC) that doesn't fully resolve the issue
Suggested Fix
- Implement a maximum retry count (e.g., 1 attempt) for large images
- After failure, mark the image as "skipped" and continue normally
- Provide a clear way to cancel image processing without clearing the entire conversation
- Consider adding a configuration option for maximum image size threshold
Additional Context
This bug is particularly problematic when using MCP tools for web automation/testing, where screenshots are commonly used but their sizes can vary significantly depending on the page content and viewport settings.
---
<img width="826" height="511" alt="Image" src="https://github.com/user-attachments/assets/9365aeea-7c45-43d5-85bd-25a0c9295e2f" />
Thank you for your attention to this issue!
What Should Happen?
- When an image is too large, Claude should gracefully fail and move on without retrying
- The ESC key or stop button should completely cancel the image viewing attempt
- Claude should NOT automatically retry viewing the same too-large image in a loop
- User should be able to continue the conversation normally after the error
- The suggested action "Double press ESC" should actually work to escape the loop
Error Messages/Logs
● chrome-devtools - navigate_page (MCP)(type: "url", url: "https://psychological-cloudflare.pages.dev/login")
└ # navigate_page response
Successfully navigated to https://psychological-cloudflare.pages.dev/login.
## Pages
0: https://psychological-cloudflare.pages.dev/login [selected]
● chrome-devtools - list_network_requests (MCP)(resourceTypes: ["fetch","xhr"])
└ # list_network_requests response
## Network requests
No requests found.
# take_screenshot response
Took a screenshot of the current page's viewport.
Saved screenshot to /var/folders/l6/vqzbztvn2j58pk7xw5yvqrkm0000gn/T/chrome-devtools-mcp-QjiI7D/screenshot.png.
● Read(/var/folders/l6/vqzbztvn2j58pk7xw5yvqrkm0000gn/T/chrome-devtools-mcp-QjiI7D/screenshot.png)
└ Read image (5MB)
● Image was too large. Double press esc to go back and try again with a smaller image.
> continue
● Image was too large. Double press esc to go back and try again with a smaller image.
[Loop continues indefinitely - only /clear can escape]
Steps to Reproduce
- Configure an MCP tool that can take screenshots (e.g.,
chrome-devtools-mcp)
- In Claude Code, use the MCP tool to navigate to a webpage:
- Ask Claude to navigate to a URL and take a screenshot
- The MCP tool successfully takes a screenshot and saves it (e.g., 5MB+ PNG file)
- Claude automatically attempts to read/view the screenshot image
- Error appears: "Image was too large. Double press esc to go back and try again with a smaller image."
- Try to escape the loop:
- Type "continue" → Claude retries viewing the same large image → same error
- Press stop → Ask a different question → Claude still tries to view the image → same error
- Double press ESC → Does NOT effectively cancel the operation
- The loop continues indefinitely. The ONLY way to escape is using
/clearcommand, which loses all conversation context.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.61
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
7 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Hi, I Built claude-code-image-sanitizer to stop this from happening. It resizes screenshots on the fly so they never exceed the limit. If you're already stuck in the loop, there's a repair tool to fix corrupted
sessions.
Would appreciate any feedback or contributions.
running /compact seems to save the conversation and allows me to continue. Though it basically clears the memory and I need claude to look at the codebase to continue
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Also seeing
Request too large. Double press esc to go back and try with a smaller fileIts when I'm feeding any a lot of images into a convo....not sure if thats a hint or notThe bug is actual. i see this error from time to time with smaller images: "_Read image (4.1MB)_"
This bug just happened to me. First, it tried to read two PNG files (4MB and 8MB) and said they were over 20MB and froze. Then I asked it to analyze one at a time, and the same error appeared. "Image was too large. Double press esc to go back and try again with a smaller image."