⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@strands-agent
Copy link
Contributor

Description

Adds support for using S3 URIs as sources for documents, images, and videos in Bedrock model requests. This enables users to reference large files stored in S3 instead of embedding them as bytes.

Changes

  1. Document source: Now supports s3Location in addition to bytes
  2. Image source: Now supports s3Location in addition to bytes
  3. Video source: Now supports s3Location in addition to bytes

Usage Example

from strands import Agent

agent = Agent()

messages = [
    {
        "role": "user",
        "content": [
            {"text": "Summarize the following PDF."},
            {
                "document": {
                    "format": "pdf",
                    "name": "document-pdf",
                    "source": {
                        "s3Location": {
                            "uri": "s3://my-bucket/documents/report.pdf",
                            "bucketOwner": "123456789012"  # optional
                        }
                    }
                }
            },
        ],
    },
]

result = agent(messages)

Backward Compatibility

When both bytes and s3Location are provided in a source, bytes takes priority to maintain backward compatibility (as tested by test_format_request_filters_nested_image_s3_fields).

Related Issues

Closes #1482

Type of Change

New feature

Testing

  • Added tests for s3Location source in documents
  • Added tests for s3Location source in images
  • Added tests for s3Location source in videos
  • Verified existing test test_format_request_filters_nested_image_s3_fields still passes (bytes takes priority)

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective or that my feature works
  • My changes generate no new warnings

…sources

Adds support for using S3 URIs as sources for documents, images, and
videos in Bedrock model requests. This enables users to reference
large files stored in S3 instead of embedding them as bytes.

When both bytes and s3Location are provided, bytes takes priority
to maintain backward compatibility.

Closes strands-agents#1482
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/models/bedrock.py 80.00% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

- Add S3Location TypedDict to media.py for proper type definitions
- Update DocumentSource, ImageSource, VideoSource to include s3Location option
- Change source TypedDicts to total=False to allow either bytes or s3Location
- Rename variables to avoid mypy 'Name already defined' errors
  - 'formatted_source' → 'image_source' in image block
  - 'formatted_source' → 'video_source' in video block
- All lint/mypy checks now pass


class VideoSource(TypedDict):
class VideoSource(TypedDict, total=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all breaking changes moving from required to optional fields. We'll need to discuss this as a team if this is an acceptable breakage. As of now, I am not inclined to merge this.

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.

[FEATURE] Allow s3Location as Document and Image Source

2 participants