Auto-downscale/summarize images to avoid 2000px many-image error
Summary
Claude Code fails mid-session with:
An image in the conversation exceeds the dimension limit for many-image requests (2000px). Run /compact to remove old images from context, or start a new session.
This happens even when the context window is at ~10-20% used, so /compact is an overreaction — it wipes useful text history just to shed one oversized image. The limit is about image dimensions, not context size, but the user-facing remedy conflates the two.
Repro
Common agentic workflows that trigger this quickly:
- Device automation via MCP servers (each step = a fresh screenshot)
- Browser automation / visual web research (many page screenshots)
- Any loop where the model iteratively captures screenshots and acts on them
Expected behavior
Claude Code should handle this on ingest, without user intervention:
- Auto-downscale any incoming image to ≤2000px on its longest edge before appending it to the conversation. The API limit is known and fixed — there's no reason Claude Code should ever forward an image that will fail.
- (Stretch) After N images accumulate, auto-summarize older screenshots to text and drop the image bytes, so long agentic runs don't silently degrade or suddenly die.
Actual behavior
The request fails outright and the user is told to /compact, which also discards text history they may still need. In agentic loops this is especially bad because the model itself doesn't proactively summarize-and-drop older screenshots — it just keeps stacking them until the API rejects the call.
Why this matters
Agentic use cases (mobile MCP, browser automation, visual research loops) are exactly where Claude Code's agent loop shines — and also where this error hits hardest and earliest. The fix is local to Claude Code (resize before send); no API change required.
Environment
- Platform: Windows 11
- Model: Claude Opus 4.7 (1M context)
- Trigger: agentic screenshot-heavy session; context still well under 50%
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗