[BUG] [BUG] Claude Code on the Web: empty text block with cache_control causes 400 after sending an image, permanently breaks the session

Resolved 💬 3 comments Opened Apr 24, 2026 by WinterDDo Closed Apr 27, 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?

Summary

Sending an image in a Claude Code on the Web session can produce an empty text content block that has cache_control attached. Anthropic API rejects this with a 400 error (cache_control cannot be set for empty text blocks). Once the bad block is in the conversation history, every subsequent turn fails with the same error — the session is permanently unusable and there is no in-UI way to delete the offending message.

Environment

  • Claude Code on the Web (claude.ai/code), not the CLI
  • Browser: Chrome (please fill in your version — in browser menu → About Chrome)
  • OS: macOS (please fill in your version)
  • Session: multiple, across different repos (mixue_usa_franchise_Website and others)
  • Repo has .claude/settings.json with a UserPromptSubmit hook injecting additionalContext

Steps to Reproduce

  1. Open a Claude Code on the Web session on any repo
  2. Paste or attach an image (e.g. screenshot from clipboard) without typing any accompanying text and send
  3. Wait for the response — it may succeed once or fail immediately
  4. Send any follow-up message (text or image)
  5. Observe: every subsequent turn fails with the 400 error shown below

Expected Behavior

  • Empty text blocks should not have cache_control attached on the client side
  • Or: the API should tolerate empty blocks gracefully
  • Or: the UI should let users remove/edit the offending assistant message after such an error

Actual Behavior

  • The session enters a permanently broken state
  • Try sending it again retries all produce the same 400
  • Editing the most recent user message does not help if the bad block is upstream
  • The only recovery is to edit a message from before the bad block or abandon the session

Error Payload

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

Additional related request_ids from the same broken session:

  • req_011CaMsgBnQAWK1wzzMMYC4e — earlier variant: messages: text content blocks must be non-empty
  • req_011CaMsQ44cNwYHivCHXT6gqmessages.680.content.4.text: cache_control cannot be set for empty text blocks
  • req_011CaMscjQonwGjBfBdHWwnEmessages.68?.content.7.text: cache_control cannot be set for empty text blocks

All from within the same session, different turns, different message indices — suggesting multiple empty blocks accumulated over time.

Impact

  • Session is unrecoverable through normal UI actions
  • Hours of conversation context lost
  • Workflow forced into "start a new session" pattern

Workaround I Found

Always type at least one character of accompanying text when attaching an image. Pasting an image with an empty caption appears to be the trigger. Non-empty captions have not reproduced the issue for me.

Suggested Fix Direction

On the client side (Claude Code on the Web), before constructing the API request:

  1. Strip content blocks whose text is empty, OR
  2. Do not attach cache_control to empty text blocks, OR
  3. Coerce empty text blocks to a single-space placeholder

Screenshots

[Attach screenshot of the error banner + UI here — drag the PNG into this comment box]

What Should Happen?

Summary

Sending an image in a Claude Code on the Web session can produce an empty text content block that has cache_control attached. Anthropic API rejects this with a 400 error (cache_control cannot be set for empty text blocks). Once the bad block is in the conversation history, every subsequent turn fails with the same error — the session is permanently unusable and there is no in-UI way to delete the offending message.

Environment

  • Claude Code on the Web (claude.ai/code), not the CLI
  • Browser: Chrome (please fill in your version — in browser menu → About Chrome)
  • OS: macOS (please fill in your version)
  • Session: multiple, across different repos (mixue_usa_franchise_Website and others)
  • Repo has .claude/settings.json with a UserPromptSubmit hook injecting additionalContext

Steps to Reproduce

  1. Open a Claude Code on the Web session on any repo
  2. Paste or attach an image (e.g. screenshot from clipboard) without typing any accompanying text and send
  3. Wait for the response — it may succeed once or fail immediately
  4. Send any follow-up message (text or image)
  5. Observe: every subsequent turn fails with the 400 error shown below

Expected Behavior

  • Empty text blocks should not have cache_control attached on the client side
  • Or: the API should tolerate empty blocks gracefully
  • Or: the UI should let users remove/edit the offending assistant message after such an error

Actual Behavior

  • The session enters a permanently broken state
  • Try sending it again retries all produce the same 400
  • Editing the most recent user message does not help if the bad block is upstream
  • The only recovery is to edit a message from before the bad block or abandon the session

Error Payload

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

Additional related request_ids from the same broken session:

  • req_011CaMsgBnQAWK1wzzMMYC4e — earlier variant: messages: text content blocks must be non-empty
  • req_011CaMsQ44cNwYHivCHXT6gqmessages.680.content.4.text: cache_control cannot be set for empty text blocks
  • req_011CaMscjQonwGjBfBdHWwnEmessages.68?.content.7.text: cache_control cannot be set for empty text blocks

All from within the same session, different turns, different message indices — suggesting multiple empty blocks accumulated over time.

Impact

  • Session is unrecoverable through normal UI actions
  • Hours of conversation context lost
  • Workflow forced into "start a new session" pattern

Workaround I Found

Always type at least one character of accompanying text when attaching an image. Pasting an image with an empty caption appears to be the trigger. Non-empty captions have not reproduced the issue for me.

Suggested Fix Direction

On the client side (Claude Code on the Web), before constructing the API request:

  1. Strip content blocks whose text is empty, OR
  2. Do not attach cache_control to empty text blocks, OR
  3. Coerce empty text blocks to a single-space placeholder

Screenshots

[Attach screenshot of the error banner + UI here — drag the PNG into this comment box]

Error Messages/Logs

Steps to Reproduce

Summary

Sending an image in a Claude Code on the Web session can produce an empty text content block that has cache_control attached. Anthropic API rejects this with a 400 error (cache_control cannot be set for empty text blocks). Once the bad block is in the conversation history, every subsequent turn fails with the same error — the session is permanently unusable and there is no in-UI way to delete the offending message.

Environment

  • Claude Code on the Web (claude.ai/code), not the CLI
  • Browser: Chrome (please fill in your version — in browser menu → About Chrome)
  • OS: macOS (please fill in your version)
  • Session: multiple, across different repos (mixue_usa_franchise_Website and others)
  • Repo has .claude/settings.json with a UserPromptSubmit hook injecting additionalContext

Steps to Reproduce

  1. Open a Claude Code on the Web session on any repo
  2. Paste or attach an image (e.g. screenshot from clipboard) without typing any accompanying text and send
  3. Wait for the response — it may succeed once or fail immediately
  4. Send any follow-up message (text or image)
  5. Observe: every subsequent turn fails with the 400 error shown below

Expected Behavior

  • Empty text blocks should not have cache_control attached on the client side
  • Or: the API should tolerate empty blocks gracefully
  • Or: the UI should let users remove/edit the offending assistant message after such an error

Actual Behavior

  • The session enters a permanently broken state
  • Try sending it again retries all produce the same 400
  • Editing the most recent user message does not help if the bad block is upstream
  • The only recovery is to edit a message from before the bad block or abandon the session

Error Payload

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

Additional related request_ids from the same broken session:

  • req_011CaMsgBnQAWK1wzzMMYC4e — earlier variant: messages: text content blocks must be non-empty
  • req_011CaMsQ44cNwYHivCHXT6gqmessages.680.content.4.text: cache_control cannot be set for empty text blocks
  • req_011CaMscjQonwGjBfBdHWwnEmessages.68?.content.7.text: cache_control cannot be set for empty text blocks

All from within the same session, different turns, different message indices — suggesting multiple empty blocks accumulated over time.

Impact

  • Session is unrecoverable through normal UI actions
  • Hours of conversation context lost
  • Workflow forced into "start a new session" pattern

Workaround I Found

Always type at least one character of accompanying text when attaching an image. Pasting an image with an empty caption appears to be the trigger. Non-empty captions have not reproduced the issue for me.

Suggested Fix Direction

On the client side (Claude Code on the Web), before constructing the API request:

  1. Strip content blocks whose text is empty, OR
  2. Do not attach cache_control to empty text blocks, OR
  3. Coerce empty text blocks to a single-space placeholder

Screenshots

[Attach screenshot of the error banner + UI here — drag the PNG into this comment box]

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

claude code 4.7

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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