API Error 400: text content blocks must contain non-whitespace text - conversation becomes permanently stuck
Bug Description
After context compaction (or possibly other conversation state changes), Claude Code enters a state where every subsequent message fails with:
API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must contain non-whitespace text"}}
Once this error occurs, the session is permanently broken - all further messages produce the same error. The only recovery is starting a new session.
Steps to Reproduce
- Use Claude Code in a long-running session that triggers context compaction
- At some point (not deterministic), the session breaks
- Every subsequent message returns the 400 error above
Example Output
❯ i'm i understanding correctly that false positives are the issue?
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages:
text content blocks must contain non-whitespace
text"},"request_id":"req_011CXqG4nc2Er4HWtqvQUaWg"}
❯ test
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages:
text content blocks must contain non-whitespace
text"},"request_id":"req_011CXqGBVdkvEZdV6UoH37aU"}
Expected Behavior
Messages should be sent successfully, or if compaction produces invalid state, Claude Code should detect and recover automatically (e.g., by dropping empty content blocks before sending to the API).
Actual Behavior
The conversation becomes permanently stuck. Every message fails because the corrupted (empty/whitespace-only) content block is part of the conversation history sent with each request.
Frequency
Happens frequently, across multiple sessions.
Workaround
Start a new session. All unsaved context is lost.
Environment
- Claude Code CLI
- Linux (Ubuntu)
- Model: claude-opus-4-5-20251101
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗