Skip to content

fix: normalize media format mappings#2399

Open
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/media-format-mapping
Open

fix: normalize media format mappings#2399
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/media-format-mapping

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Fixes part of #2204.

Summary

  • use explicit Anthropic image media-type mapping for common formats, including webp, instead of relying only on platform mimetypes
  • accept 3gp as a video input format alias and map it to Bedrock's three_gp enum value when formatting requests
  • add focused regressions for WebP image MIME type and Bedrock 3GP video formatting

I kept this PR scoped to the two deterministic provider-format bugs. The broader type/guardContent expansion mentioned in the issue should be handled separately.

To verify

  • python -m pytest tests/strands/models/test_anthropic.py::test_format_request_with_image tests/strands/models/test_anthropic.py::test_format_request_with_webp_image_uses_explicit_media_type tests/strands/models/test_bedrock.py::test_format_request_video_s3_location tests/strands/models/test_bedrock.py::test_format_request_video_3gp_maps_bedrock_enum -q
  • python -m ruff check src/strands/models/anthropic.py src/strands/models/bedrock.py src/strands/types/media.py tests/strands/models/test_anthropic.py tests/strands/models/test_bedrock.py
  • python -m ruff format --check src/strands/models/anthropic.py src/strands/models/bedrock.py src/strands/types/media.py tests/strands/models/test_anthropic.py tests/strands/models/test_bedrock.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant