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

Oversized PDF kills the REPL

Open josmithiii opened this issue 1 month ago • 12 comments

See CLI transcript below:

In Claude Code Version: 2.0.37 ...

⏺ PDF too large. Please double press esc to edit your message and try again.

Do not read a PDF, just read my message

⏺ PDF too large. Please double press esc to edit your message and try again.

Please commit what we have so far

⏺ PDF too large. Please double press esc to edit your message and try again.

Do not read any PDFs right now ⎿  Interrupted · What should Claude do instead?

Do not read any PDFs right now

⏺ PDF too large. Please double press esc to edit your message and try again.

josmithiii avatar Nov 13 '25 02:11 josmithiii

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/9789
  2. https://github.com/anthropics/claude-code/issues/6231
  3. https://github.com/anthropics/claude-code/issues/8077

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Nov 13 '25 02:11 github-actions[bot]

This issue should be reopened as it is not a duplicate of the referenced issues.

Why This Is a Distinct Bug

This issue (#11527) and #9789 describe a specific bug where Claude Code enters an infinite error loop that makes the REPL completely unusable:

  • After encountering an oversized PDF, Claude responds with "PDF too large. Please double press esc to edit your message and try again"
  • Every subsequent input (regardless of content) receives the same error message
  • The REPL becomes permanently stuck in this state and cannot accept any other commands
  • User must kill the session to recover

Why the Referenced "Duplicates" Are Different

The issues marked as duplicates describe different symptoms:

  • #6231 and #6197: PDF error persists in the conversation history and causes API errors on subsequent API calls, but the REPL still attempts to process commands
  • #8077: Session crashes/terminates completely with tool_use/tool_result mismatch errors

This bug is about the REPL entering a persistent error state where it stops processing any input at all and only echoes the PDF error message.

Evidence

Issue #9789 was incorrectly auto-closed as a duplicate of #6231, and users confirmed "Still happening" after closure. The infinite loop behavior is a specific manifestation that requires its own fix - likely in the TUI/REPL error handling rather than just PDF size validation or API error handling.

Please reopen this issue so the specific infinite loop bug can be tracked and fixed.

josmithiii avatar Nov 13 '25 04:11 josmithiii

Workaround: Prevent PDF crashes with CLAUDE.md configuration

I've been experiencing the same crash issue when Claude Code tries to read large PDFs. Found a reliable workaround by adding mandatory instructions to .claude/CLAUDE.md:

PDF Processing

NEVER use the Read tool to open PDF files directly

ALWAYS extract PDFs to text first using pdftotext via Bash before

processing

Reading large PDFs can cause crashes and loss of work

The # prefix makes these instructions high-priority and enforceable.

Workflow that works:

  1. Use pdftotext via Bash to extract PDF to .txt file first
  2. Process the text file instead of the PDF
  3. Keep extracted .txt files alongside PDFs for future reference

This completely avoids the crash issue and is actually faster since text files are easier to search/process. Would be great if this could be built into Claude Code as a default behavior or at least a warning before attempting to read large PDFs.

rpcsteve avatar Nov 15 '25 03:11 rpcsteve

I have this exact same problem in: Claude Code v2.0.42 Sonnet 4.5 · Claude Pro

Here is a transcript:

I don't have access to previous sessions, so I can't see what happened, but I can address both issues:

File Size Restrictions

Looking at the Read tool description available to me, I don't see explicit size limits documented for PDFs. The description says PDFs are "processed page by page, extracting both text and visual content," but doesn't specify a maximum file size. A 5MB PDF hitting a size limit suggests there is one, but I don't have that specific information in my current documentation.

Why I Got Stuck

The behavior you described—repeatedly giving the same "PDF too large" response to all follow-on questions regardless of context—is definitely a bug/error state. That shouldn't happen. Once I encounter an error with one request, I should still be able to:

  • Answer different questions
  • Respond to context changes
  • Understand when you're asking about something else entirely

Getting stuck in a loop repeating the same error message is not correct behavior.

What You Can Do

Since this is a technical limitation question about Claude Code itself, you could:

  1. Check the Claude Code documentation at https://code.claude.com/docs/
  2. Report this as an issue at https://github.com/anthropics/claude-code/issues (especially the "stuck in loop" behavior)

Is there something else I can help you with regarding the documentation or the project? (And I'll wait for your explicit instruction before attempting to read that PDF!)

Can you try to look at the PDF file again? When compared to the HTML documentatoin, it looks terrible and isn't even close...

● Read(docs\build\latex\eips-tools.pdf) ⎿  Read PDF (513.6KB)

● PDF too large. Please double press esc to edit your message and try again.

Are you stuck again?

● PDF too large. Please double press esc to edit your message and try again.

version

● PDF too large. Please double press esc to edit your message and try again.

/exit

dbotham avatar Nov 17 '25 21:11 dbotham

⏺ PDF too large. Please double press esc to edit your message and try again.

MLDMoritz avatar Nov 21 '25 18:11 MLDMoritz

Impacts 2.0.55. A workaround is that you can use /rewind to restore to the message before the read.

meawoppl avatar Dec 01 '25 23:12 meawoppl

It is a hang at the pure repl level, the json SDK seems to continue to function. I suspect a hung bit of state in the outer typescript.

meawoppl avatar Dec 01 '25 23:12 meawoppl

Happening to me also in v2.0.59 :/

mcarlson avatar Dec 07 '25 05:12 mcarlson

I have this exact same issue, but I can't rewind it because I referenced a PDF in a question Claude asked me. If I rewind, I'll need to redo the whole plan Claude created for me. This is very annoying and it would be nice if it could be fixed.

see the screenshots below

Image Image
Version: 2.0.65

Staninna avatar Dec 17 '25 10:12 Staninna