[BUG] 400 "cache_control cannot be set for empty text blocks" when pasting an image without a caption

Resolved 💬 4 comments Opened May 1, 2026 by datonko-gi Closed Jun 20, 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?

Hitting a 400 from the API regularly across different chats when I paste screenshots into the input.
messages.N.content.M.text: cache_control cannot be set for empty text blocks
The chat gets stuck. The "Try again" button does not react at all when I click it, so the only way out is to start a new session.

<img width="1442" height="1387" alt="Image" src="https://github.com/user-attachments/assets/e5825233-a3e7-4b92-91c9-b9607af544d9" />

What Should Happen?

The request should go through normally. Pasting a screenshot without a caption should not break the chat. If the request does fail, "Try again" should actually retry.

Error Messages/Logs

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.28.content.1.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011CaaiFS3hK2oAN7ehJA4s2"}

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.2.content.5.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011CaahMj9eNenvVfvGGDwmX"}

Steps to Reproduce

  1. Open Claude Code in Code mode.
  2. In any session, paste one or more screenshots from the clipboard into the input.
  3. Press Enter without typing any caption.
  4. The API returns 400 "cache_control cannot be set for empty text blocks".
  5. Click "Try again" - nothing happens, the button does not react.
  6. The only way to continue is to open a new session.

Reproduces in different sessions, see the two attached screenshots (single screenshot fails on content.1, four screenshots in a row fail on content.5).

Workaround: type at least one character of caption before sending. Easy to forget.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.121

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

This is the Claude desktop app in Code mode, not a CLI terminal session. The Terminal/Shell field above does not really apply, picked Windows Terminal as the closest neutral Windows option.

Attached: two screenshots from two different chat sessions today, both fail with the same cache_control cannot be set for empty text blocks error after I pasted screenshots into the input. The first one fails on content.1 (single image), the second on content.5 (four images in a row).

Both sessions are now permanently stuck because "Try again" does not respond to clicks. Only opening a fresh session unblocks the chat.

I checked my local session jsonl files under ~/.claude/projects/ and could not find any persisted message with an empty text block, so the empty text:"" block is being produced at API request assembly time, not at message save time.

View original on GitHub ↗

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