Skip to content

[BUG] Media type handling bugs and missing format support #2204

@opieter-aws

Description

@opieter-aws

Steps to Reproduce

Bugs:

  • WebP images get wrong MIME type with Anthropic provider. anthropic.py:132 uses mimetypes.types_map.get(f".{content['image']['format']}", "application/octet-stream"). Python's mimetypes module returns "application/octet-stream" for .webp, not "image/webp". WebP images will fail or be misprocessed. TypeScript uses an explicit switch statement that correctly maps webp.

  • GuardContent wraps unsupported image formats and missing image type support.bedrock.py:450-451 wraps ALL image formats in guardContent without format validation. TypeScript explicitly checks for png/jpeg only and skips unsupported formats. Additionally, GuardContent type (content.py) only has a "text" field — missing "image" support that TypeScript has. Wrapping unsupported formats will cause Bedrock API errors.

  • Video format "3gp" not mapped to "three_gp" for Bedrock API. bedrock.py:647 passes video format as-is. TypeScript maps "3gp""three_gp" to match the Bedrock API enum. 3GP videos will be rejected by Bedrock.

Missing format support (non-breaking gaps):

  • DocumentFormat missing "json" and "xml" (TypeScript has them)
  • ImageFormat missing "jpg" alias for jpeg (TypeScript has it)
  • ToolResultContent missing video support (TypeScript has VideoBlock)
  • DocumentSource missing { text: string } and { content: [...] } source types (TypeScript has them)

Expected Behavior

  1. WebP images should get "image/webp" MIME type
  2. GuardContent should only wrap supported image formats (png, jpeg) and support image type
  3. "3gp" video format should be mapped to "three_gp"
  4. Format types should support json, xml documents; jpg alias; video in tool results; text document sources

Actual Behavior

  1. WebP → "application/octet-stream" → Anthropic API error
  2. Unsupported image formats wrapped in guardContent → Bedrock API error
  3. "3gp" sent as-is → Bedrock API error
  4. Missing format types limit what content can be represented

Additional context

This was a finding from an agentic cross-SDK consistency scan between Python and TypeScript SDKs (strands-agents/sdk-typescript#789). The finding has been triaged, but verify that this needs an actual fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions