claude-code - 💡(How to fix) Fix [BUG] 400 "cache_control cannot be set for empty text blocks" when pasting an image without a caption [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55156Fetched 2026-05-01 05:44:48
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×5commented ×2cross-referenced ×2

Error Message

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"}

Root Cause

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

Fix Action

Fix / Workaround

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

Code Example

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"}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

extent analysis

TL;DR

The issue can be worked around by ensuring that a caption is provided when sending screenshots, as the error occurs when the API receives an empty text block.

Guidance

  • The error message cache_control cannot be set for empty text blocks suggests that the issue is related to the API request being made with an empty text block when a screenshot is pasted without a caption.
  • To verify, try adding a caption to the screenshot before sending it and see if the error persists.
  • The "Try again" button not responding to clicks may be a separate issue, potentially related to the error handling mechanism in the Claude Code app.
  • Checking the API documentation for any specific requirements or restrictions on sending empty text blocks may provide further insight into the issue.

Example

No code snippet is provided as the issue seems to be related to the API request and error handling in the Claude Code app, rather than a specific code snippet.

Notes

The issue may be specific to the Opus Claude model and the Anthropic API, and may not occur with other models or APIs. The fact that the issue is reproducible in different sessions suggests that it may be a bug in the Claude Code app or the API.

Recommendation

Apply workaround: ensure that a caption is provided when sending screenshots to avoid the error. This is a temporary solution until the root cause of the issue can be identified and fixed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] 400 "cache_control cannot be set for empty text blocks" when pasting an image without a caption [2 comments, 2 participants]