Password-protected PDF poisons conversation history, making session permanently unusable

Resolved 💬 4 comments Opened Feb 12, 2026 by hugotomita1201 Closed Feb 15, 2026

Bug Description

When Claude Code reads a password-protected PDF (via the Read tool), the API returns an invalid_request error. However, the PDF content gets permanently baked into the conversation history. Every subsequent message — even a simple "hello" — replays the history containing the problematic PDF content, causing the API to reject the request again with the same error. The session enters an unrecoverable infinite error loop.

Steps to Reproduce

  1. Start a Claude Code session
  2. Read a password-protected PDF file (e.g., Read(/tmp/some-encrypted.pdf))
  3. The API returns: "PDF is password protected. Please double press esc to edit your message and try again."
  4. Send any follow-up message (e.g., "hello")
  5. The same error appears again immediately
  6. Every subsequent message triggers the same error — the session is permanently broken

Expected Behavior

  • Claude Code should detect the password-protected PDF error and not persist the PDF content into the conversation history
  • Or: the error should be recoverable — the user should be able to continue the conversation after a failed PDF read
  • At minimum: context compaction should strip out the problematic content so the session can recover

Actual Behavior

  • The invalid_request error repeats on every single message
  • The model field shows <synthetic> and isApiErrorMessage: true, meaning the API is never actually reached — Claude Code generates the error locally
  • Even after context compaction/compression, the poisoned PDF content survives and continues triggering the error
  • The only recovery is to abandon the session entirely and start a new one

Evidence from Session Transcript

From the .jsonl session file, the error appeared 26 times in a row. Every assistant response was identical:

{
  "model": "<synthetic>",
  "role": "assistant",
  "content": [{"type": "text", "text": "PDF is password protected. Please double press esc to edit your message and try again."}],
  "error": "invalid_request",
  "isApiErrorMessage": true
}

The session had 12,038 lines and was a long-running productive session before the PDF read corrupted it.

Environment

  • Claude Code version: 2.1.39
  • OS: macOS (Darwin 25.2.0)
  • Model: claude-opus-4-6

Suggested Fix

  1. Don't persist failed PDF reads into history — if a PDF read returns invalid_request, treat it like a tool failure and don't add the raw content to the conversation messages array
  2. Allow recovery — provide a way to remove/skip the problematic message so the user can continue the session
  3. Detect the loop — if the same invalid_request error fires N times in a row, break the loop and inform the user rather than repeating indefinitely

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗