Read tool loops indefinitely on large Playwright screenshots with 'Image was too large' error
Resolved 💬 3 comments Opened Feb 22, 2026 by gongpyung Closed Feb 25, 2026
Bug Description
When Claude Code attempts to read large screenshots (e.g., taken by Playwright), it enters an unrecoverable loop, repeatedly failing with the error:
Image was too large. Double press esc to go back and try again with a smaller image.
The agent keeps retrying the same Read operation without any fallback strategy, even after multiple failures. User intervention (e.g., asking to resize or skip) does not break the loop — the same error persists.
Steps to Reproduce
- Use Playwright (or any tool) to capture full-page screenshots (typically large PNG files)
- Ask Claude Code to read/analyze those screenshots using the Read tool
- Observe that Claude Code repeatedly attempts to read the image and fails
Expected Behavior
- Claude Code should detect the size limit and automatically resize the image before retrying (e.g., using
sipson macOS orconvert/magickon Linux) - Or at minimum, fail gracefully after 1-2 attempts with a clear message suggesting the user resize the image, rather than looping indefinitely
- The agent should not churn for minutes on the same unrecoverable error
Actual Behavior
- The Read tool fails with "Image was too large"
- Claude Code retries the exact same operation repeatedly
- The agent churns for 3+ minutes without progress
- User messages like "resize and retry" or "is this a bug?" are acknowledged but the same error recurs
- The session becomes effectively stuck
Environment
- Claude Code CLI
- macOS (Darwin)
- Screenshots generated by Playwright (full-page PNG captures, likely several MB)
Suggested Improvements
- Auto-resize: When an image exceeds the size limit, automatically downscale it before reading (e.g.,
sips --resampleWidth 1600) - Retry cap: Limit image read retries to 1-2 attempts, then provide actionable guidance
- Proactive size check: Check file size before attempting to read, and resize preemptively if it exceeds a threshold
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗