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
Open
fix(bedrock): skip S3 location sources for models that do not support them#2076Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ValidationExceptionwith the messagesource.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_STATUScapability constant. Added a_supports_s3_locationproperty and updated_handle_locationto 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
test_format_request_image_s3_location_only,test_format_request_document_s3_location, andtest_format_request_video_s3_locationto useamazon.nova-pro-v1:0.test_format_request_s3_location_skipped_for_unsupported_modelsto verify all three S3 location content types are dropped with a warning for non-Nova models.Fixes #1744
Documentation PR
N/A
Type of Change
Bug fix
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.