[BUG] API Error: "messages.87.content.1.text: cache_control cannot be set for empty text blocks"

Resolved 💬 3 comments Opened May 1, 2026 by dan-p-p Closed May 5, 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?

When using Claude Code for the web, at some point in the session, on two sessions within 2 hours, I hit 'messages.87.content.1.text: cache_control cannot be set for empty text blocks' and the session is dead. All prompts from thereon return this error.

Somewhere in the conversation history, a message has an empty text block (often with a cache_control marker on it). Once that empty block lands in the persisted history, every subsequent request replays it and gets rejected by the API.

What Should Happen?

It's maybe produced by a tool call that returned an empty result, or a streaming hiccup that finalized a block before any text arrived. The web client should be stripping empty blocks before sending, and isn't.

Error Messages/Logs

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

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaaftDNPHGnYU5shDU4Mz"}

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011Caag2ZFSL7EZXTaHdHt3V"}

Steps to Reproduce

Unclear. There does not seem to be a single trigger that caused this.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.126

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

_No response_

View original on GitHub ↗

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