Bug Description
/compact fails with an error when the conversation reaches the context limit — the exact situation where /compact is needed most. This creates a deadlock: the user cannot compact, cannot continue, and is forced to /clear (losing all context).
Steps to Reproduce
- Use Claude Code in a long session until "Context limit reached · /compact or /clear to continue" appears
- Run
/compact
- Observe the error
Error Messages
First attempt:
❯ /compact
Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.
Subsequent attempts — same error, then the session becomes completely unresponsive:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must contain non-whitespace text"},"request_id":"req_011CXnuVCF3KmwzeqdM4gFNZ"}
Expected Behavior
/compact should always succeed, especially when the context limit is reached. Possible approaches:
- Progressively drop older messages before attempting compaction
- Use a smaller/faster model for the compaction summary when context is too large
- Truncate the conversation to fit within limits before summarizing
Environment
- Claude Code version: 2.1.31
- OS: Ubuntu Linux 6.8.0-94-generic (x86_64)
- Model: claude-opus-4-5-20251101
Impact
High — This is a Catch-22: /compact is the recommended action when context is full, but it fails precisely in that situation. The only workaround is /clear, which destroys all session context including task progress. This happens consistently across sessions and projects.
Additional Context
The "Press esc twice to go up a few messages and try again" suggestion does not help — the error persists regardless. After the compaction failure, the session often enters a broken state where even normal messages fail with the text content blocks must contain non-whitespace text API error.
Bug Description
/compactfails with an error when the conversation reaches the context limit — the exact situation where/compactis needed most. This creates a deadlock: the user cannot compact, cannot continue, and is forced to/clear(losing all context).Steps to Reproduce
/compactError Messages
First attempt:
Subsequent attempts — same error, then the session becomes completely unresponsive:
Expected Behavior
/compactshould always succeed, especially when the context limit is reached. Possible approaches:Environment
Impact
High — This is a Catch-22:
/compactis the recommended action when context is full, but it fails precisely in that situation. The only workaround is/clear, which destroys all session context including task progress. This happens consistently across sessions and projects.Additional Context
The "Press esc twice to go up a few messages and try again" suggestion does not help — the error persists regardless. After the compaction failure, the session often enters a broken state where even normal messages fail with the
text content blocks must contain non-whitespace textAPI error.