Skip to content

fix(bedrock): skip S3 location sources for models that do not support them#2076

Open
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/bedrock-s3-location-unsupported-models
Open

fix(bedrock): skip S3 location sources for models that do not support them#2076
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/bedrock-s3-location-unsupported-models

Conversation

@Zelys-DFKH
Copy link
Copy Markdown

Problem

When using S3 location sources for documents, images, or videos with non-Nova Bedrock models (Anthropic Claude, Meta Llama, Mistral, Cohere), the Converse API returns a ValidationException with the message source.type: Field required. The SDK forwards the S3 location unconditionally, with no model capability check, so users receive a confusing error instead of a clear warning.

S3 location sources are only supported by Amazon Nova models. All other model families require inline bytes.

Solution

Added _MODELS_SUPPORT_S3_LOCATION = ["amazon.nova"] alongside the existing _MODELS_INCLUDE_STATUS capability constant. Added a _supports_s3_location property and updated _handle_location to check model support before formatting the S3 location. When the model does not support S3 locations, a warning is logged and the content block is dropped, matching the behavior of the existing non-S3 location fallback.

Testing

  • Updated test_format_request_image_s3_location_only, test_format_request_document_s3_location, and test_format_request_video_s3_location to use amazon.nova-pro-v1:0.
  • Added test_format_request_s3_location_skipped_for_unsupported_models to verify all three S3 location content types are dropped with a warning for non-Nova models.
  • 2489 tests pass, lint clean.

Fixes #1744

Documentation PR

N/A

Type of Change

Bug fix

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

… them

S3 location sources for documents, images, and videos are only supported
by Amazon Nova models. Other model families (Anthropic Claude, Meta Llama,
Mistral, Cohere) reject them with a ValidationException. This adds a
`_MODELS_SUPPORT_S3_LOCATION` capability constant, a `_supports_s3_location`
property, and updates `_handle_location` to warn and skip the content block
when the current model does not support S3 locations.

Fixes strands-agents#1744
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.

[BUG] S3Location Does Not Work With All Models in Bedrock

1 participant