/compact fails with 500 Internal Server Error after reading large PDF
Resolved 💬 3 comments Opened Jan 18, 2026 by Nubaeon Closed Jan 22, 2026
/compact fails with 500 Internal Server Error after reading large PDF
Description
When a session hits context limit after reading a large PDF, both auto-compact and manual /compact fail with a 500 Internal Server Error. The session becomes stuck - cannot compact, cannot continue.
Steps to Reproduce
- Start a Claude Code session
- Read a large PDF file (in my case, 15.3MB)
- Continue working until context limit is reached
- Context limit triggers: "Context limit reached · /compact or /clear to continue"
- Run
/compact - Result: 500 error instead of successful compaction
Error Message
❯ /compact
⎿ Error: Error during compaction: Error: API Error: 500
{"type":"error","error":{"type":"api_error","message":"Internal server
error"},"request_id":"req_011CXFTieFCEbw6FQYkcFHL7"}
Context
Files read before the error:
● Read(~/empirical-ai/empirica-paper/latex/paper.pdf)
⎿ Read PDF (1.1MB)
● Read(~/Downloads/Empirica_AI_Control.pdf)
⎿ Read PDF (15.3MB)
⎿ Context limit reached · /compact or /clear to continue
Expected Behavior
/compactshould successfully summarize the conversation, even if large PDFs were read- Or: if PDF content cannot be summarized, provide a more helpful error message explaining why and suggesting alternatives
- Or: warn before reading very large files that may cause compaction issues
Actual Behavior
- 500 Internal Server Error
- Session is stuck - cannot compact, cannot continue
- Only option is
/clearwhich loses all in-memory context
Impact
- High for long-running sessions where contextual understanding has built up over time
- Losing context means losing the "earned understanding" the AI developed about the project
- Users working with documentation/papers (common use case) are particularly affected
Environment
- Claude Code CLI
- Linux (Ubuntu-based)
- Large PDF files (15MB+)
Suggested Improvements
- Graceful handling: If summarization model can't handle PDF content, strip/simplify it before summarization
- Pre-read warning: Warn when reading files that may cause compaction issues
- Partial compaction: Allow compacting everything except problematic content
- Better error message: Instead of generic 500, explain what content is causing issues
Workaround
Currently the only workaround is /clear which loses all context. For users with external context management (like breadcrumbs or other session tracking), some state can be recovered, but the conversational context is lost.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗