[BUG] Session becomes unrecoverable after interrupted tool call - /clear and /compact also fail

Resolved 💬 4 comments Opened Apr 16, 2026 by Hogna67 Closed May 26, 2026

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

  1. Run a long session with many tool calls (~100+ turns)
  2. Have a tool call interrupted mid-execution (e.g. network issue or timeout)
  3. Try to send any message → API error
  4. Try /compact → same API error ("Error during compaction")
  5. Try /clear → same API error
  6. Session is now completely dead with no recovery path except + New session

Expected Behavior

  • /clear should reset session state without making an API call first,

so it doesn't carry the broken history into the reset request.

  • /compact should 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?

  1. When a tool call is interrupted, the session history should roll back or sanitize the incomplete turn — empty text blocks should never be persisted.
  2. /clear should reset local session state without making an API call first, so a broken session can always be cleared regardless of history state.
  3. /compact should 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

  1. Start a long Claude Code session in the Desktop App (100+ conversation turns with tool calls)
  2. Have a tool call interrupted mid-execution (e.g. stop generation, network issue, or timeout)
  3. Try to send any message → API Error 400: "cache_control cannot be set for empty text blocks"
  4. Try /compact → "Error during compaction" with same API Error 400
  5. Try /clear → same API Error 400, session still broken
  6. 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.

View original on GitHub ↗

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