Image Upload Exceeds Size Limit Causing Persistent API Request Failure

Open 💬 39 comments Opened Jul 3, 2025 by alessandrobologna

Bug Description
after submitting an image too large, the context is polluted and any other request returns the error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.17.content.1.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}}

Environment Info

  • Platform: darwin
  • Terminal: cursor
  • Version: 1.0.41
  • Feedback ID: 635919c9-d04d-4562-9842-2a0a15d8e011

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:882:11)\n    at execSync (node:child_process:954:15)\n    at JI (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n    at file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:9038\n    at Q (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n    at _X (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:8184)\n    at w_ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:7265)\n    at U9 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:11432)","timestamp":"2025-07-03T16:45:23.855Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_click not found\n    at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n    at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n    at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n    at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n    at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n    at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n    at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n    at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n    at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n    at A.Q.updateContainer (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:71:1835)","timestamp":"2025-07-03T16:45:27.222Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_click not found\n    at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n    at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n    at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n    at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n    at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n    at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n    at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n    at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n    at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n    at A.Q.updateContainer (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:71:1835)","timestamp":"2025-07-03T16:45:27.236Z"},{"error":"Error: Tool mcp__puppeteer__puppeteer_screenshot not found\n    at dT2 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:5596)\n    at ZU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19802)\n    at UP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n    at wP (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n    at o$ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)\n    at MU (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37887)\n    at EJ (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:34977)\n    at f5 (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:4822)\n    at DB (file:///Users/alessandro/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:32233)\n    at A.Q.updateContainer (file:///Users

Note: Error logs were truncated.

View original on GitHub ↗

39 Comments

baryon · 9 months ago

I didn’t upload any images and still encountered this issue—I only asked CC to modify the copy on the webpage and didn’t upload any images to him. After this error appeared, even the /compact command started returning the same error.

/compact 
  ⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"
    invalid_request_error","message":"messages.95.content.12.image.source.base64.data: At 
    least one of the image dimensions exceed max allowed size: 8000 
    pixels"},"request_id":"req_********************"}
gthb · 9 months ago

Found my session afflicted with this same thing soon (within a day) after I started working with the chrome-devtools MCP server. That was going great until the session was entirely incapacitated by this error. And yep, /compact is failing too in this session — presumably because it's trying to read that same poisoned item in the context. I'll hazard a guess that a screenshot of the remote-controlled Chrome window (or of a canvas that I have in there in a scrollable container) landed in the context despite violating some size-limit invariant, and then there's no coming back from that.

saynth-ai · 9 months ago

Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.380.content.0.image.source.base64.data: At least one of
the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CU35RmzHC6WGfCL6kKbKB"}

lukasmalkmus · 8 months ago

Same here! Would be nice to have a command to remove the bad message from the context to compact or instruct otherwise.

JimSander-uniphore · 8 months ago

My Experience: 12+ Hours of Work Lost

I encountered this exact issue and lost over 12 hours of productive working history with Claude Code. The session became completely unrecoverable after an image >8000 pixels was added to the context.

Impact:

  • All subsequent requests returned the same API 400 error
  • No way to remove or compact the problematic message
  • Had to abandon the entire session and lose all conversation history
  • Now extremely hesitant to use images in any Claude Code session due to this risk

Critical Need: This needs a recovery mechanism urgently. Suggestions:

  • Pre-validate image dimensions before adding to context
  • Provide a command to remove specific messages from context (like /remove-message <index>)
  • Make /compact resilient to skip/remove invalid messages instead of failing
  • Add a /recover command to sanitize corrupted contexts

This is a severe UX issue that makes the tool feel fragile when working with visual content, especially when using MCP servers that generate screenshots automatically.

---

_Meta note: This comment was drafted by Claude Code itself—the very tool that caused the problem. Even the offender agrees this needs fixing! 😅_

tokmakoff · 8 months ago

/rewind worked for me as a recovery mechanism. I went back in the context stack however-many prompts to before the bad image from Chrome was added.

JoeEarly · 8 months ago

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8.content.5.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CVFsFR3Yo8qKa9SEVzj8F"}

Has any of the dev team looked at this?

vovanrew · 8 months ago

Same issue to be

``API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.7.content.5.image.source.base64.data: At least one of the
image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CVFv8L4ojR1WvfaonMrw1"}
``

JoeEarly · 7 months ago
Same issue to be `` image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CVFv8L4ojR1WvfaonMrw1"}` ``

Well thanks for stating the obvious fella, my query was more in relation to has anyone looked at this from a dev POV with the view to fixing the ability to recover cleanly

Keeline · 7 months ago

This is a vexing problem and I have been burned by it many times. Yesterday I decided to take a new approach. I use Claude Code on a MacBook Pro with Sequoia. I asked it to write a Bash script to check the pixel and byte sizes to ensure they are within the limits for any image view. If it is too large, it should use ImageMagick to resize or make a copy with the appropriate specs.

I further instructed it to add it to CLAUDE.md as a priority rule to use the script every time an image might be read into the session.

I decided to add some other instructions such as a mandate of using shellcheck on Bash scripts and lint for PHP and Python before they try to run them. I was also tired of nonsensical time references to I required the session to check the current date-time before making a statement.

I can provide the code for image screening (check_image_previe.sh). It is 154 lines with comments.

In the CLAUDE.md below I have added backslashes before the triple-backticks for the formatting in github. But they may cause a problem if left in for use. With the right prompt, this would be generated by Claude Code. But it shows the intent.

Having worked with Claude Code since May 2025, this is hopefully going to rein in some of the most frequent issues I have with it. Something akin to this should be part of the core system. Creating a fatal error loop that can't be resolved without starting a new session is a serious blocker for professional use of an otherwise good system.

James D. Keeline

# Claude Code Instructions

## Image Preview Safety
**CRITICAL:** Always use `./check_image_preview.sh <image_file>` before reading any image with the Read tool. This prevents Claude Code from attempting to load oversized images that cause infinite error loops and context loss.

### Image Constraints
- Maximum file size: 5MB
- Maximum dimensions: 2000px width OR height
- Script automatically checks both constraints
- Use `--fix` flag to auto-create compliant versions

### Example Usage
\```bash
# Check image before viewing
./check_image_preview.sh "/path/to/image.jpg"

# Auto-fix oversized images
./check_image_preview.sh --fix "/path/to/image.png"

# If it passes, then safe to use:
# Read "/path/to/image.jpg"
\```

This workflow prevents system crashes and preserves work context.

## Script Development Standards

### Bash Scripts
Always run shellcheck before finalizing any bash script:
\```bash
/opt/homebrew/bin/shellcheck script_name.sh
\```
Fix all warnings and errors. Common issues:
- Quote variables to prevent word splitting: `"$var"`
- Declare and assign separately: `local var; var=$(command)`
- Remove unused variables

### PHP Scripts
Check syntax before execution:
\```bash
php -l script_name.php
\```

### Python Scripts
Use appropriate syntax checkers:
- `python -m py_compile script.py` (built-in)
- `flake8 script.py` (if installed)
- `pylint script.py` (if installed)

**Always lint scripts during development to catch errors early.**

## Temporal References

**CRITICAL:** Always run `date` command before making any date/time-based statements or assumptions in conversations.

\```bash
date
\```

Current session time reference: Sat Nov 22 22:13:24 PST 2025

This ensures accuracy when discussing:
- File timestamps and modifications
- Log analysis and debugging
- Scheduling or time-sensitive operations
- Historical context of changes%
jhilgert · 7 months ago

Hey everyone,

ran into the same problem that an oversized image corrupted my conversation with Claude Code. Since it had been running for 1 hour before - without any additional message from me - I was not able to simply rewind. Thus, I looked into the directory, which stores the conversation files (simple .jsonl files) and then basically asked Claude to fix itself. Here is its solution, which worked like a charm. Hope this helps some people until a proper fix is out:

Fixing Claude Code Conversation Stuck on Oversized Image

The Problem

When Claude Code tries to read an image larger than 5MB, the API rejects it with an error like:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.16.content.2.tool_result.content.0.image.source.base64: image exceeds 5 MB maximum: 6521204 bytes > 5242880 bytes"}}

The base64 image data is already saved in the conversation history (.jsonl file), so every subsequent message keeps sending the same oversized image, causing a loop of API errors. Even new messages won't work.

The Solution

1. Find the conversation file

Conversation files are stored in ~/.claude/projects/<project-path>/ with UUID-style names:

ls -la ~/.claude/projects/*/
# Look for files like: e45adf17-b504-4108-87f3-53c5eff292da.jsonl

2. Identify the problematic lines

Find which lines are huge (contain base64 image data):

awk '{print NR, length($0)}' <file>.jsonl | sort -k2 -n -r | head -10

Lines with millions of bytes are the culprits (normal lines are a few KB at most).

3. Create a backup

cp <file>.jsonl <file>.jsonl.backup

4. Fix with this Python script

import json

file_path = "<your-file>.jsonl"
problem_lines = [84, 85, 86]  # 1-indexed line numbers from step 2

with open(file_path, 'r') as f:
    lines = f.readlines()

for line_num in problem_lines:
    idx = line_num - 1  # Convert to 0-indexed
    data = json.loads(lines[idx])

    # Get tool_use_id and replace image content with text
    tool_use_id = data['message']['content'][0]['tool_use_id']
    data['message']['content'] = [{
        "tool_use_id": tool_use_id,
        "type": "tool_result",
        "content": "[Image removed - exceeded 5MB limit]"
    }]

    # IMPORTANT: Remove toolUseResult entirely (causes render crash if malformed)
    if 'toolUseResult' in data:
        del data['toolUseResult']

    lines[idx] = json.dumps(data) + '\n'

with open(file_path, 'w') as f:
    f.writelines(lines)

print("Fixed!")

5. Restart Claude Code

The conversation should now load without errors.

Key Points

  • The fix replaces base64 image data with a text placeholder
  • Must delete toolUseResult key entirely (not just modify it) - otherwise Claude Code crashes trying to render it with Cannot destructure property 'numLines' from null
  • Keep the tool_use_id to maintain conversation continuity
  • Original file size drops dramatically (e.g., 51MB -> 262KB)

Prevention

Before reading large images, resize them first:

# Resize to max 2000px width, quality 80%
convert large-image.jpg -resize 2000x -quality 80 smaller-image.jpg

# Or use ImageMagick to check size first
identify -format "%b" image.jpg
JimSander-uniphore · 7 months ago

Ah, that's a great idea, I already have directives to manage the same repetitive calls that just pipe to <grep|jq|awk,whatever> and to stuff/redirect calls into a file and use the output file instead.

Never occurred to me to check image ... derp 🙂
Since I already have ffmpeg, I figured let it do the dirty work, no special scripts.

# Image optimization
- Before reading image files with Read tool, check file size with `stat -f%z <file>` (macOS) or `stat -c%s <file>` (Linux)
- If image size > 5MB (5242880 bytes):
1. Create optimized version: `ffmpeg -i <input> -vf "scale='min(1920,iw)':'min(1080,ih)':force_original_aspect_ratio=decrease" -q:v 2 /tmp/<basename>_optimized.<ext> 2>/dev/null`
2. Use Read tool on /tmp/<basename>_optimized.<ext> instead of original
3. Inform user that optimized version was used due to size
- Supported formats: jpg, jpeg, png, webp
- If ffmpeg fails or format unsupported, read original and warn user about large file size

I like the shellcheck and lint suggestions, that should prevent some wasted confirmations.

As I sat on this draft for a day, another submitter had a similar but cleaner directives: see jhilgert's solution using convert and ImageMagick

________________________________
From: Keeline @.*>
Sent: Sunday, November 23, 2025 7:26 PM
To: anthropics/claude-code
@.*>
Cc: Jim Sander @.>; Comment @.>
Subject: Re: [anthropics/claude-code] Image Upload Exceeds Size Limit Causing Persistent API Request Failure (Issue #2939)

CAUTION: This is an external email originated outside of Uniphore. Do not click links or open attachments unless you recognize the sender and know the content is safe.

[https://avatars.githubusercontent.com/u/11981137?s=20&v=4]Keeline left a comment (anthropics/claude-code#2939)<https://github.com/anthropics/claude-code/issues/2939#issuecomment-3568641667>

This is a vexing problem and I have been burned by it many times. Yesterday I decided to take a new approach. I use Claude Code on a MacBook Pro with Sequoia. I asked it to write a Bash script to check the pixel and byte sizes to ensure they are within the limits for any image view. If it is too large, it should use ImageMagick to resize or make a copy with the appropriate specs.

I further instructed it to add it to CLAUDE.md as a priority rule to use the script every time an image might be read into the session.

I decided to add some other instructions such as a mandate of using shellcheck on Bash scripts and lint for PHP and Python before they try to run them. I was also tired of nonsensical time references to I required the session to check the current date-time before making a statement.

I can provide the code for image screening (check_image_previe.sh). It is 154 lines with comments.

In the CLAUDE.md below I have added backslashes before the triple-backticks for the formatting in github. But they may cause a problem if left in for use. With the right prompt, this would be generated by Claude Code. But it shows the intent.

Having worked with Claude Code since May 2025, this is hopefully going to rein in some of the most frequent issues I have with it. Something akin to this should be part of the core system. Creating a fatal error loop that can't be resolved without starting a new session is a serious blocker for professional use of an otherwise good system.

James D. Keeline

Claude Code Instructions

Image Preview Safety

CRITICAL: Always use ./check_image_preview.sh <image_file> before reading any image with the Read tool. This prevents Claude Code from attempting to load oversized images that cause infinite error loops and context loss.

Image Constraints

  • Maximum file size: 5MB
  • Maximum dimensions: 2000px width OR height
  • Script automatically checks both constraints
  • Use --fix flag to auto-create compliant versions

Example Usage

\```bash

Check image before viewing

./check_image_preview.sh "/path/to/image.jpg"

Auto-fix oversized images

./check_image_preview.sh --fix "/path/to/image.png"

If it passes, then safe to use:

Read "/path/to/image.jpg"

\```

This workflow prevents system crashes and preserves work context.

Script Development Standards

Bash Scripts

Always run shellcheck before finalizing any bash script:
\``bash
/opt/homebrew/bin/shellcheck script_name.sh
\
``
Fix all warnings and errors. Common issues:

  • Quote variables to prevent word splitting: "$var"
  • Declare and assign separately: local var; var=$(command)
  • Remove unused variables

PHP Scripts

Check syntax before execution:
\``bash
php -l script_name.php
\
``

Python Scripts

Use appropriate syntax checkers:

  • python -m py_compile script.py (built-in)
  • flake8 script.py (if installed)
  • pylint script.py (if installed)

Always lint scripts during development to catch errors early.

Temporal References

CRITICAL: Always run date command before making any date/time-based statements or assumptions in conversations.

\``bash
date
\
``

Current session time reference: Sat Nov 22 22:13:24 PST 2025

This ensures accuracy when discussing:

  • File timestamps and modifications
  • Log analysis and debugging
  • Scheduling or time-sensitive operations
  • Historical context of changes%


Reply to this email directly, view it on GitHub<https://github.com/anthropics/claude-code/issues/2939#issuecomment-3568641667>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A6RZPPBXX4HLDAL2IRQU3M336JNEJAVCNFSM6AAAAACAXKPDIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNRYGY2DCNRWG4>.
You are receiving this because you commented.Message ID: @.***>

This transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution, or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

PUBLIC
This transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution, or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

MussaCharles · 7 months ago

Hey everyone 👋

After repeatedly facing this issue, I decided to build
claude-code-image-sanitizer
using some of the feedback and insights shared across related issues.

What it does:

  • Automatically resizes oversized screenshots before they're sent to Claude's API
  • Works with Playwright, Puppeteer, Chrome DevTools MCP, and other screenshot tools
  • Includes a session repair tool to fix already-corrupted sessions

Would love any feedback/contributions!

i6media · 6 months ago

In our case it seems that a fairly large filename is causing this issue. When a screenshot is taken with a Mac it'll be called "Scherm­afbeelding 2025-12-30 om 10.25.40.png" (Dutch). When we drag&drop to Claude CLI it throws the "image upload exceeds" error, even when it's only 1mb. However when we rename it to "Bug.png" it does process the image correctly.

lukyrys · 6 months ago
● mobile-mcp - mobile_take_screenshot (MCP)(device: "emulator-5554")
  ⎿  [Image]
  ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.61.content.4.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image
     requests: 2000 pixels"},"request_id":"req_011CWfUPVdjTEZuLaF9Beexi"}
yuzutas0 · 6 months ago

+1

Keeline · 6 months ago
In our case it seems that a fairly large filename is causing this issue. When a screenshot is taken with a Mac it'll be called "Scherm­afbeelding 2025-12-30 om 10.25.40.png" (Dutch). When we drag&drop to Claude CLI it throws the "image upload exceeds" error, even when it's only 1mb. However when we rename it to "Bug.png" it does process the image correctly.

You have not shared the size in bytes and pixel dimensions for your image. It is very easy to exceed the 2000 pixels in either dimension or the 2 MB byte limit. A Mac screenshot is double resolution (144 dpi vs 72 dpi). Even partial screen caps can do it.

It is probably not related to the length of the file name (as shown) or even the spaces.

The error message from Claude will usually state what is violated (bytes or pixels).

bendytree · 6 months ago

Fwiw, if you don't want to muck around in .claude... the /clear command fixed the issue for me

AsifKibria · 6 months ago

Solution: Claude Code Toolkit

I created a tool to fix this issue:

# Quick fix via CLI
npx @asifkibria/claude-code-toolkit scan
npx @asifkibria/claude-code-toolkit fix

Optional: Install as MCP Server
For ongoing maintenance, you can add it as an MCP server and ask Claude to check its own health:

claude mcp add --scope user toolkit -- npx -y @asifkibria/claude-code-toolkit claude-code-toolkit-server

Then just ask Claude: "Check my Claude Code health" or "Fix any issues"
Then restart Claude Code.

What it does:

  • Scans all your conversation files for oversized images
  • Replaces them with placeholder text
  • Creates backups before making any changes
  • Restores your conversation without losing context

GitHub: https://github.com/AsifKibria/claude-code-toolkit
npm: https://www.npmjs.com/package/@asifkibria/claude-code-toolkit

lukyrys · 6 months ago
## Solution: Claude Code Toolkit ... GitHub: https://github.com/AsifKibria/claude-code-toolkit npm: https://www.npmjs.com/package/@asifkibria/claude-code-toolkit

@AsifKibria
Thanks for tool, but how its help with blocked conversation ? I need quit claude-code, fix with your tool and then resume?

DavideDaniel · 5 months ago

The toolkit does not help the claude chrome extension either so a better way is needed within Claude product suite itself. A way to clear only a previous message is likely what's required. Even just deleting the image with a placeholder like the toolkit is doing.

sitefinitysteve · 5 months ago

@DavideDaniel 100% the last request didn’t even really succeed so why bother recovering, I’d be happy to resubmit or adjust and resubmit. Seems like a no brainer fix if they aren’t going to resize it to a size that works.

pattihis · 5 months ago

In my case, I copy/paste data from Excel columns, expecting it to be inserted in Claude as text, but it generated a huge image that broke conversation with

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.6.content.3.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels"},"request_id":"req_011CXRuS9pn1Bzn64KoKZExz"}

Context was very important so I did not want to clear it.

The tool from @AsifKibria fixed the issue in seconds. Thank you!!

AsifKibria · 5 months ago
> ## Solution: Claude Code Toolkit > ... > GitHub: https://github.com/AsifKibria/claude-code-toolkit npm: https://www.npmjs.com/package/@asifkibria/claude-code-toolkit @AsifKibria Thanks for tool, but how its help with blocked conversation ? I need quit claude-code, fix with your tool and then resume?

Yes.

Just run (if you don't want it to be installed globally or as MCP),
npx @asifkibria/claude-code-toolkit health
And
npx @asifkibria/claude-code-toolkit fix

Then you can continue your chat, without iuuses.

bigperson · 5 months ago

I encountered this problem in claude extension for google chrome :(

busenazsahinn · 5 months ago
I encountered this problem in claude extension for google chrome :(

Same here. I've been getting this error message for the past couple of days and couldn't find a solution. Any updates?

eeshansrivastava89 · 5 months ago

This is happening for me as well. Using the Claudian plugin with Obsidian. The entire conversation is now blocked after this image size issue.

sebastienkothe · 5 months ago

Cross-posting from ChromeDevTools/chrome-devtools-mcp#879 where this issue is being discussed from the MCP server side.

The problem: MCP servers like chrome-devtools-mcp return screenshots as base64 images that can easily exceed Claude API's dimension limits (8000px for single images, 2000px when 20+ images are in context). When this happens, the Claude Code session becomes permanently corrupted — every subsequent message (including /compact) fails with the same API 400 error, making the entire session unrecoverable without manual intervention.

Why this is a Claude Code issue (not just MCP): While MCP servers could add resizing as a workaround, Claude Code should handle this gracefully regardless of the image source. Specifically:

  • Pre-validate image dimensions before adding to context
  • Make /compact resilient — skip or remove invalid messages instead of crashing on them
  • Provide a recovery command (e.g. /remove-message or /recover) to sanitize corrupted contexts

Multiple users are impacted across different MCP servers (chrome-devtools, mobile-mcp, Marionette for Flutter) and even direct image paste. The workarounds people have built (CLAUDE.md rules, external sanitizer scripts, manual .jsonl surgery) show this is a real and recurring pain point.

Ref: ChromeDevTools/chrome-devtools-mcp#879

Berfc · 4 months ago

I have the same issur for Claude Browser extension:
messages.5.content.14.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels

OBugroviy · 4 months ago

Wow, this issue still hasn't been fixed!
I encountered this issue in version 2.1.78 of VS Code.

<img width="982" height="442" alt="Image" src="https://github.com/user-attachments/assets/f480ef23-d544-4998-8c26-ba651b10325d" />

sitefinitysteve · 4 months ago
Wow, this issue still hasn't been fixed! I encountered this issue in version 2.1.78 of VS Code.

Nuts eh… it knows it’ll be an issue, so instead of just resizing it and continuing on, just stops and breaks, and that’s I guess just fine?

sebastienkothe · 4 months ago

Workaround: We ran into this too. Images > 2000px break the session.

We added this to our CLAUDE.md to force resize after every screenshot capture:

sips -Z 1600 /path/to/screenshot.png

sips -Z 1600 resizes the image to fit within 1600px (longest side) while keeping aspect ratio. We chain it after every adb pull or xcrun simctl io call. Not a fix, but it prevents the crash reliably.

yurukusa · 3 months ago

/tmp/gh-comment-2939.md

ryanhugh · 3 months ago

<img width="383" height="313" alt="Image" src="https://github.com/user-attachments/assets/9b746d06-6093-4e4c-ae4f-4f6f36c4fc61" />

Same issue in the Claude Browser connector

dragonfax · 3 months ago

Got this today, no idea what to do. Can't get past it.

This is in Claude in Chrome.

<img width="369" height="311" alt="Image" src="https://github.com/user-attachments/assets/c11ff447-fdc3-4114-8171-82413e50c3af" />

XiaTiaoQAQ · 3 months ago

Same issue in Claude in Chrome.

msaidbilgehan · 3 months ago

I guess the issue getting worse.

Host: MacOS
Browser: Chrome Version 146.0.7680.178 (Official Build) (arm64)
Extension: Claude 1.0.66 - Claude in Chrome (Beta)

<img width="345" height="239" alt="Image" src="https://github.com/user-attachments/assets/25da92fa-7ab0-4cd0-94ec-20d84d90452d" />

antoinekm · 3 months ago

For folks hitting this specifically when using the chrome-devtools-mcp server: I've opened a PR upstream that adds opt-in CLI flags to cap screenshot size before it's embedded in the MCP response.

PR: https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/1823 (tracked at ChromeDevTools/chrome-devtools-mcp#879)

The flags let operators cap dimensions and switch to JPEG so a single screenshot can't blow past the per-image dimension limits enforced by hosted LLM APIs (typically in the 2000-8000 px range, sometimes lower when many images are in the same request):

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "node",
      "args": [
        "/absolute/path/to/chrome-devtools-mcp/build/src/bin/chrome-devtools-mcp.js",
        "--screenshot-format=jpeg",
        "--screenshot-max-width=2000",
        "--screenshot-max-height=2000"
      ]
    }
  }
}

(See the PR for instructions on running the branch locally before it's merged.)

Important caveats:

  1. This only helps if your "context polluted" errors are coming from chrome-devtools-mcp screenshots specifically. Other MCPs that return inline images will still hit the same wall.
  2. It's a per-call cap. Once an oversized image is already in the conversation history, this server-side fix can't retroactively shrink it. You still need to start a new session to recover.
  3. The real fix is the one already discussed in this thread: Claude Code should evict or downsample image content from the replayed history during compaction (or proactively, before hitting the limit), so this stops being a problem for any MCP that returns images. Until that lands, the server-side cap is just a way to delay the inevitable for chrome-devtools-mcp users.

Posting this here because @OrKoN from the chrome-devtools-mcp team explicitly invited a cross-post in ChromeDevTools/chrome-devtools-mcp#879. Hope it helps anyone blocked in the meantime.

QuicksilverSlick · 3 months ago

💡 Session Recovery Workaround (No ffmpeg needed)

If your session is bricked by an oversized image, here's a clean recovery method that preserves your full context:

  1. Go to ~/.claude/projects/ (or C:\Users\<You>\.claude\projects\ on Windows)
  2. Find your project folder and locate the most recent .jsonl file (by modified date)
  3. Start a fresh session in your project directory
  4. Run /init to re-initialize project context
  5. Drag the .jsonl file into the chat and tell Claude: "Analyze this session log and get fully caught up on where we left off."

This works because the .jsonl files contain the complete conversation history. Feeding it into a fresh session gives you all the context without the corrupted state (the stuck oversized image causing the 400 error loop).

Full write-up with details: https://github.com/anthropics/claude-code/issues/13480#issuecomment-4237000378