claude-code - 💡(How to fix) Fix [BUG] Image upload in cloud environment poisons session — all subsequent API calls return 400, /compact cannot recover [1 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#56088Fetched 2026-05-05 05:58:32
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

Uploading an image file to an active Claude Code session produced a malformed assistant turn that cannot be recovered from. Every subsequent message returns HTTP 400 from the messages API. /compact fails with the same error because it replays the poisoned history.

Error Messages/Logs

The image upload created an assistant message containing an empty text block, and the prompt cache breakpoint was attached to that empty block. Subsequent requests fail validation on either the empty text or the cache_control marker on it. Because the bad turn is now in persistent history, every replay including /compact triggers the same validation error.

Root Cause

Uploading an image file to an active Claude Code session produced a malformed assistant turn that cannot be recovered from. Every subsequent message returns HTTP 400 from the messages API. /compact fails with the same error because it replays the poisoned history.

Code Example

### Actual behavior
- First post-upload send returns: `400 invalid_request_error — messages.115.content.1.text: cache_control cannot be set for empty text blocks`
- All further sends return: `400 invalid_request_error — messages: text content blocks must be non-empty`
- `/context` works (local, no API call)
- `/compact` fails with the same 400 (sends poisoned history to API)
- Session is permanently wedged

### Request IDs
- `req_011CahytTreECx4LmdC6TyYm`
- `req_011Cahyu89zvaSC7Yv7rRBdG`
- `req_011CahyyHNFX6Wh8fjjDX4S8`
- `req_011Cahz6eHY4rxdvmK2lvpwS` (from failed `/compact`)
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?

Uploading an image file to an active Claude Code session produced a malformed assistant turn that cannot be recovered from. Every subsequent message returns HTTP 400 from the messages API. /compact fails with the same error because it replays the poisoned history.

What Should Happen?

Image is attached to the next user turn and the assistant responds normally.

Error Messages/Logs

### Actual behavior
- First post-upload send returns: `400 invalid_request_error — messages.115.content.1.text: cache_control cannot be set for empty text blocks`
- All further sends return: `400 invalid_request_error — messages: text content blocks must be non-empty`
- `/context` works (local, no API call)
- `/compact` fails with the same 400 (sends poisoned history to API)
- Session is permanently wedged

### Request IDs
- `req_011CahytTreECx4LmdC6TyYm`
- `req_011Cahyu89zvaSC7Yv7rRBdG`
- `req_011CahyyHNFX6Wh8fjjDX4S8`
- `req_011Cahz6eHY4rxdvmK2lvpwS` (from failed `/compact`)

Steps to Reproduce

  1. Start a Claude Code session in the desktop app using the cloud environment
  2. Have an active conversation with tool use (in my case, WebSearch/WebFetch discussion)
  3. Attempt to upload an image file to the session
  4. Send any subsequent message

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude Desktop app 1.5354.0

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

Probable root cause (speculation)

The image upload created an assistant message containing an empty text block, and the prompt cache breakpoint was attached to that empty block. Subsequent requests fail validation on either the empty text or the cache_control marker on it. Because the bad turn is now in persistent history, every replay including /compact triggers the same validation error.

Severity

Medium-high. Session-destroying, no in-app recovery, triggered by a normal user action (file upload). Data loss risk if user has not been checkpointing.

Additional context

Conversation was at 125.7k / 1.0M tokens (13%) when the failure occurred, so this is not a context-limit issue.

extent analysis

TL;DR

Remove the empty text block created by the image upload to prevent validation errors and allow the session to recover.

Guidance

  • Verify that the issue is caused by the empty text block by checking the request IDs and error messages for patterns related to cache_control and empty text blocks.
  • Attempt to manually remove the problematic turn from the conversation history to see if the session recovers.
  • Consider adding a check before sending messages to ensure that text blocks are not empty and do not contain cache_control markers.
  • Investigate why the image upload is creating an empty text block and attach the image to the next user turn instead.

Example

No code snippet is provided as the issue does not contain sufficient information about the implementation details.

Notes

The root cause of the issue is likely related to the image upload creating an empty text block, but the exact implementation details are unclear. The provided guidance is based on the error messages and the probable root cause speculation.

Recommendation

Apply a workaround to remove or prevent the creation of empty text blocks until a permanent fix is available, as the issue has a medium-high severity and can cause session-destroying errors.

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] Image upload in cloud environment poisons session — all subsequent API calls return 400, /compact cannot recover [1 comments, 2 participants]