[BUG] Session becomes unrecoverable after interrupted tool call - /clear and /compact also fail
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
markdown## Environment
- Platform: Claude Code Desktop App (Windows 11)
- Model: Claude Opus 4.6 1M
Description
After a long session (~130+ conversation turns), an interrupted tool call caused
the session to enter an unrecoverable state. Every subsequent message fails with
the same API error, and neither /compact nor /clear can fix it.
Error Messages
First error:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.130.content.1.text: cache_control cannot be set for
empty text blocks"}}
All subsequent errors (including after /compact and /clear):
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages: text content blocks must be non-empty"}}
Steps to Reproduce
- Run a long session with many tool calls (~100+ turns)
- Have a tool call interrupted mid-execution (e.g. network issue or timeout)
- Try to send any message → API error
- Try
/compact→ same API error ("Error during compaction") - Try
/clear→ same API error - Session is now completely dead with no recovery path except
+ New session
Expected Behavior
/clearshould reset session state without making an API call first,
so it doesn't carry the broken history into the reset request.
/compactshould sanitize empty text blocks before sending to API.
Root Cause (suspected)
An empty text content block (with cache_control set) was written into
session history when a tool call was interrupted. The app does not sanitize
empty blocks before sending, and /clear appears to make an API call before
clearing — so it also fails with the same broken history.
Workaround
Only workaround is opening a new session entirely.
What Should Happen?
- When a tool call is interrupted, the session history should roll back or sanitize the incomplete turn — empty text blocks should never be persisted.
/clearshould reset local session state without making an API call first, so a broken session can always be cleared regardless of history state./compactshould filter out empty text content blocks before sending to the API, instead of failing with the same error.
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.130.content.1.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011Ca71wobUadrt2SuxWcK77"}
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011Ca72J9qCn9oWjkaFXBPY4"}
Error during compaction: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011Ca73S7CXvvJkTnCxnYNL5"}
(Same error persists after /clear as well — session is completely unrecoverable)
Steps to Reproduce
- Start a long Claude Code session in the Desktop App (100+ conversation turns with tool calls)
- Have a tool call interrupted mid-execution (e.g. stop generation, network issue, or timeout)
- Try to send any message → API Error 400: "cache_control cannot be set for empty text blocks"
- Try /compact → "Error during compaction" with same API Error 400
- Try /clear → same API Error 400, session still broken
- No recovery possible except opening a new session via "+ New session"
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Version 1.2773.0 (884b37)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Terminal.app (macOS)
Additional Information
This issue occurred in the Claude Code Desktop App (not CLI).
The session had approximately 130+ conversation turns before the error appeared.
The broken state persisted across /compact, /clear, and multiple retry attempts.
The only recovery was opening a new session.
Screenshots attached showing the error sequence.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗