CLI sends empty text block with cache_control causing API rejection

Resolved 💬 6 comments Opened Apr 28, 2026 by myspaceny Closed Jun 25, 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?

not be set for empty text blocks"},"request_id":"req_011CaWsJshAnP9riH8goD8TT"}

What Should Happen?

Description:
The bug: CLI creates empty text blocks tagged with cache_control and sends them to the API
The API correctly rejects these malformed requests
This happens when using the documented ENABLE_PROMPT_CACHING_1H=1 flag
Include your request ID: req_011CaWvuSQDtDtjbL6WShFxE
Mention the workaround: /clear command fixes it temporarily

Error Messages/Logs

i keep getting API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.682.content.1.text: cache_control can

Steps to Reproduce

Set ENABLE_PROMPT_CACHING_1H=1
Use Claude Code CLI normally
Observe API rejection errors

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

unknow

Claude Code Version

unknown

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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