[BUG] CLI streaming files silently hangs and fails when token limit is exceeded
Resolved 💬 8 comments Opened Jul 31, 2025 by nsheff Closed Jan 6, 2026
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: Linux CLI
- Claude CLI version: 1.0.64 (Claude Code)
- Operating System: Ubuntu 24.04
- Terminal: gnome-terminal
Bug Description
When sending a PDF attachment, there are two problems:
- Claude complains about a PDF being > 100 pages, even when it is not.
- If the PDF passes the 100 page filter, and then the number of tokens exceeds claude's window size, the claude silently fails and then hangs for 15 minutes until the API timeout.
Steps to Reproduce
Problem 1: incorrect PDF page count:
# Get Berkshire Hathaway quarterly report
wget https://www.berkshirehathaway.com/qtrly/3rdqtr24.pdf
# Count pages
pdfinfo 3rdqtr24.pdf | grep "Pages"
Pages: 58
# Ask Claude to summarize
claude -p --system-prompt "Summarize this PDF" 3rdqtr24.pdf
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"A maximum of 100 PDF pages may be provided."}}
Problem 2:
# Get a large-ish PDF
wget https://urc.ucdavis.edu/sites/g/files/dgvnsk3561/files/local_resources/documents/pdf_documents/How_To_Make_an_Effective_Poster2.pdf
# Count pages
pdfinfo How_To_Make_an_Effective_Poster2.pdf | grep Pages
Pages: 54
# Ask Claude to summarize
claude -p --system-prompt "Summarize this PDF" 3rdqtr24.pdf
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"A maximum of 100 PDF pages may be provided."}}
# That's wrong, but let's make it smaller. Strip PDF to 50 pages.
qpdf How_To_Make_an_Effective_Poster2.pdf --pages . 1-50 -- smaller.pdf
# Now ask claude to summarize
claude -p --system-prompt "Summarize this PDF" small.pdf # Hangs and times out.
# That process hangs and never completes, with no error message. Let's run --debug to see what happens.
[ERROR] Error streaming, falling back to non-streaming mode: 400 {"type":"error","error":{"type":"invalid_request_error","message":"input length and `max_tokens` exceed context limit: 176410 + 32000 > 200000, decrease input length or `max_tokens` and try again"}}
Sometimes the summary works despite the error message, other times it hangs and never completes.
Expected Behavior
Problem 1:
Claude should provide a correct error message
Problem 2:
Claude should provide an error, and steps to solve, instead of hanging.
Actual Behavior
Problem 1:
Claude provides an incorrect error message
Problem 2:
Claude hangs
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗