VS Code extension: JPEG screenshots stored as image/png in message history, causing API 400 error

Open 💬 1 comment Opened Mar 6, 2026 by luke9378297089

Bug Description

When pasting a JPEG screenshot into the Claude Code VS Code extension chat, the image is added to the conversation history with media_type: \"image/png\" instead of \"image/jpeg\". On subsequent API calls (especially after context compression/resumption), the Anthropic API rejects the request with a 400 error, interrupting the session.

Error

API Error: 400 {
  \"type\": \"error\",
  \"error\": {
    \"type\": \"invalid_request_error\",
    \"message\": \"messages.7.content.1.image.source.base64: The image was specified using the image/png media type, but the image appears to be a image/jpeg image\"
  }
}

Steps to Reproduce

  1. Open Claude Code in VS Code
  2. Paste a JPEG screenshot into the chat
  3. Continue the conversation (or wait for context compression)
  4. Observe 400 error — session is interrupted and cannot resume

Expected Behavior

The extension should detect the actual image format (JPEG vs PNG) from the image bytes/magic number and set media_type accordingly before sending to the Anthropic API.

Environment

  • Claude Code VS Code extension
  • OS: macOS

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗