API Error 400 "Could not process image" makes session unrecoverable

Resolved 💬 3 comments Opened Apr 27, 2026 by lastdomovoi Closed May 1, 2026

Summary

A failed image block poisons the Claude Code session context: after the first 400 invalid_request_error: Could not process image, every subsequent user input is sent to the API along with the same offending image block and is rejected with the same 400. The session is unusable until /clear, which destroys the entire accumulated context.

Error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"},"request_id":"<id>"}

Request IDs (same session, consecutive attempts):

  • req_011CaUJEcokw1AVh3MAfq27H
  • req_011CaUJG445LKhvWonwtvav4
  • req_011CaUJGMgj1QArEcusAXT6d
  • req_011CaUJGx4h7bJqDcThe7sqY

Reproduction

The poisoning happens when raw binary image data ends up inside a Bash tool result. Concretely, the trigger was downloading a PNG attachment via gh api straight to stdout (without -o/redirect to a file), e.g.:

gh api "https://github.com/user-attachments/assets/<uuid>"

The PNG bytes were streamed back into the Bash tool output, captured as part of the conversation context, and on the next turn Claude Code apparently attached them as an image block to the request. From that point on, every request — including any attempt to ask the assistant to "delete the image" — fails with:

400 invalid_request_error: Could not process image

Minimal repro recipe (no private data needed):

  1. Run a Bash command that prints binary image bytes to stdout, e.g.

curl -sL https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
(or any gh api call that returns a binary image asset).

  1. After Claude Code captures that output, send any normal follow-up message.
  2. Subsequent requests fail with Could not process image 400 and the session can no longer recover.

Transcript (excerpt, translated)

❯ and?
  ⎿ API Error: 400 ... "Could not process image" ...

❯ and?
  ⎿ API Error: 400 ... "Could not process image" ...

❯ delete the image
  ⎿ API Error: 400 ... "Could not process image" ...

Asking the assistant to "delete the image" does not help — the removal request itself is sent along with the offending block and is rejected by the same 400.

Expected behavior

When the API returns invalid_request_error: Could not process image, Claude Code should:

  1. Catch this specific error and drop (or replace with a placeholder) the offending block locally from the session history, instead of resending it.
  2. Inform the user that the data was discarded and let the conversation continue.
  3. Ideally also: avoid promoting raw binary stdout from Bash to image content blocks in the first place — Bash tool output that isn't valid UTF-8 text should probably be truncated/replaced with a \"<binary output, N bytes>\" placeholder rather than forwarded to the model as image data.
  4. Expose a recovery command (e.g. /drop-last-image) or document a way to recover without /clear.

Actual behavior

The session is fully stuck. The only way to continue is /clear, which loses all accumulated context — particularly painful in long 1M-context sessions.

Environment

  • Claude Code (CLI)
  • Model: Opus 4.7 (1M context) — claude-opus-4-7[1m]
  • Platform: darwin 24.6.0 (macOS, zsh)

View original on GitHub ↗

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