Base64 data URI in tool output triggers 'Could not process image' API error, poisons conversation
Bug Description
When Claude Code generates a base64-encoded SVG data URI (e.g., for inlining into CSS) and the resulting data:image/svg+xml;base64,... string appears in tool output (Bash), the API attempts to process it as an image rather than treating it as plain text. This results in:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"Could not process image"}}
The error is unrecoverable — retrying produces the same error because the poisoned tool output remains in conversation history. The conversation is effectively dead.
Reproduction Steps
- Create an SVG file (e.g., a wallpaper group pattern tile, ~5.5KB)
- Base64-encode it and construct a data URI:
``bash``
echo -n "data:image/svg+xml;base64,$(base64 -i /tmp/pattern.svg | tr -d '\n')" > /tmp/datauri.txt
- The data URI (~7.4KB) appears in the Bash tool result
- On the next model turn, the API tries to interpret the
data:image/...string as an image attachment - Image processing fails → 400 error
- Every subsequent message replays the same tool result → permanent failure
Expected Behavior
Base64 data URIs in tool output should be treated as opaque text, not parsed as inline images. The model should be able to read the string and embed it in CSS or other files without the API layer intercepting it.
Environment
- Claude Code mobile app (remote control session)
- Model: Claude (conversation from 2026-05-01)
- SVG file: ~5.5KB, data URI: ~7.4KB
Workaround
Write the data URI to a file and use Read to access it in chunks, or avoid letting the full data URI appear in Bash output (e.g., redirect to file without head/preview).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗