claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] This error kills the active session: API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

Open specul8 opened this issue 3 months ago • 23 comments

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 this error is returned by Claude Code in VSCode, there is no way to continue working in the same session, as each subsequent response returns the same error: API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

What Should Happen?

There should be a way to clear the API call in Claude Code so the session can continue.

Error Messages/Logs

API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

Steps to Reproduce

I think this happens when Claude code uses the browser to open a page that contains an infinite react loop (e.g. 2 assignments to the same button on a page) and the console fills up with too much data. If it happens again, I will update this with sample code and steps to reproduce (although I imagine the problem is fairly clear from the error message, and the fix I am requesting is a way to "force clear" the API call so the session can continue - e.g. --forceClearAPI).

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

1.0.123 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

specul8 avatar Sep 24 '25 03:09 specul8

I have this exact issue on Mac Sonoma.

Psi-am-i avatar Sep 29 '25 08:09 Psi-am-i

same issue!

rijhsinghani avatar Oct 04 '25 23:10 rijhsinghani

I am getting the same issue when I am giving it an image (size: 1.1Mb), OS: macOS Sequoia.

RusticGeist avatar Oct 07 '25 10:10 RusticGeist

Similar issue on Sequoia 15.1.1

Was having it look through a directory of PDFs to help rename and organize.

nathangross avatar Oct 07 '25 12:10 nathangross

Same issue with Claude Code 2.0.13 When uploading too many images or even a single image that exceeds size limits, Claude Code returns this error: API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}} After this error occurs, the chat session becomes completely unusable and there is no way to continue working in that session. Even restarting Claude Code and using the /resume command doesn't help - the chat remains permanently broken and unusable. This is a blocking and severe error that forces users to abandon their entire conversation history and context.

Maxymize avatar Oct 10 '25 08:10 Maxymize

I am also facing the exact same error and now it looks like there is no solution but to lose the current chat/context and start with fresh new session.

inauman avatar Oct 13 '25 18:10 inauman

i have the same issue here, mac mini Tahoe 26.0.1. Claude CLI for Vscode. Now I have to copy the entire message over and hopefully Claude don't lose context, cause I am about to waste a whole hour of conversation for a project, thanks for nothing Anthropics. Bunch of useless bots.

Vestal39560 avatar Oct 24 '25 23:10 Vestal39560

Same issue here. Macbook pro, Sequoia, Version 15.7.2. A long running conversation ended with an API error. Now regardless of what input I provide, each prompt results in the same API error (413)

catastrophe-brandon avatar Nov 12 '25 18:11 catastrophe-brandon

Ditto! I've tried to feed Claude Code in VSCode a log of .5 mln lines and now session is locked out with error API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

OS and versions: Arch Linux 6.17.8-zen1-1-zen aur/vscodium-bin 1.105.17075-1 Claude Code for VS Code 2.0.42

noctuum avatar Nov 16 '25 15:11 noctuum

Same issue multiple times

limitall avatar Nov 18 '25 14:11 limitall

Happens to me too:

API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

and:

Error: Error during compaction: Error: API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

villesau avatar Nov 19 '25 11:11 villesau

Same error. Mine happened when Claude was reading various image files I have locally. I imagine it's because it read multiple so each request is sending all of the image files in the conversation history? I wasn't even able to run /compact to try to workaround it. Session is just dead now.

  ⎿  Read image (1.5MB)
  ⎿ API Error: 413 
    {"error":{"type":"request_too_large","message":"Request 
    exceeds the maximum size"}}

kenneth-liao avatar Nov 20 '25 05:11 kenneth-liao

Same error. Mine happened when Claude was reading various image files I have locally.

Same. Only seen this when dealing with images (and/or playwright MCP).

villesau avatar Nov 21 '25 11:11 villesau

The original bug description describes the possibility of needing to open a webpage with an infinite loop. That's not required to cause this bug. It's easy to reproduce locally 100% of the time. I have a minimal reproduction case, but it requires large files that I can't upload to github. Here are steps to reproduce.

  1. Create an empty directory.
  2. Create a CLAUDE.md file with contents You will read files from ./downloads and answer questions.
  3. Create a folder in the directory ./downloads.
  4. Insert two PDFs into the downloads directory. I took https://arxiv.org/pdf/2508.02324 and split the pdf into two using the print to pdf function and selecting a page range from 1 to 20 for the first pdf and 20 to 46 for the second pdf.

You should have a structure that looks like this:

.
  ├── CLAUDE.md
  └── downloads/
      ├── qwen_image_part_1.pdf (28.1 MB)
      └── qwen_image_part_2.pdf (18.0 MB)

Then in the top of the directory run claude. In your prompt type read.

jsermeno avatar Nov 21 '25 15:11 jsermeno

same issue. any comments from maintainers/developers?

dkadirbekovbeeline avatar Nov 25 '25 16:11 dkadirbekovbeeline

Same issue occurred in the middle of work! It stopped and i got the message!

API Error: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

AhmedNadar avatar Nov 25 '25 22:11 AhmedNadar

Maybe because they have issues with Claude Opus 4.5! https://status.claude.com/

Image

AhmedNadar avatar Nov 25 '25 23:11 AhmedNadar

Same issue here. Happened when reading PDF.

celve avatar Nov 28 '25 06:11 celve

Yeah, this wouldn't bother me much except that it permanently nukes my session.

It's kind of a big deal that without warning, you can cross a threshold that forces you to start a new session with a complete (potentially significant) loss of context.

jfcantu avatar Nov 30 '25 01:11 jfcantu

for a quick (hacky) fix until this is more permanently addressed: use /export to dump the context into a text file, and then /clear to start a new conversation, then reference the exported text file and continue the chat. Explicitly asking it not to load the problematic large file/image was sufficient to avoid falling into the same trap.

manihamidi avatar Dec 01 '25 13:12 manihamidi