[BUG] Web client: resuming after stream idle timeout sends empty text block with cache_control, API returns 400

Resolved 💬 3 comments Opened Apr 26, 2026 by tate-apa Closed May 29, 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?

On Claude Code for web (claude.ai/code), when a turn fails with Stream idle timeout - partial response received and the session is resumed, the next request fails immediately with a 400 from the API:

messages.146.content.2.text: cache_control cannot be set for empty text blocks

The session is then permanently wedged — every subsequent retry hits the same 400 because the malformed message is already in conversation history. The work-in-progress branch survives, but the conversation thread is unusable and has to be abandoned.

This has happened across multiple sessions.

What Should Happen?

Resuming after a stream idle timeout should either succeed or fail with a recoverable error. The client should not persist a partial assistant message containing an empty text content block with cache_control attached, since the API correctly rejects that shape.

At minimum, the request builder should strip cache_control from any content block whose text is empty/whitespace before sending.

Error Messages/Logs

API Error: Stream idle timeout - partial response received

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

Steps to Reproduce

Open a session on https://claude.ai/code
Start a long-running turn that touches multiple files (mine was a docs edit producing a +445/-85 diff in progress)
Wait until the turn fails with Stream idle timeout - partial response received
Click Try sending it again / let the session resume
Observe: the resume request fails with the 400 above
Every subsequent retry returns the same 400 — session is unrecoverable

Session ID: session_01NmLisCL5qXLUSfNkeXfagc
Failing request ID: req_011CaSxVDgHyrY7cZ8G1uQGC

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

unkown

Platform

Other

Operating System

Windows

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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