Skip to content

Conversation

@alexgromero
Copy link
Contributor

Issue #, if available:

Description of changes:
This PR adds comprehensive integration tests for Amazon Bedrock Runtime client covering all streaming patterns:

  • Non-streaming operations using converse
  • Output streaming operations using converse_stream
  • Bidirectional streaming operations using invoke_model_with_bidirectional_stream

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

@alexgromero alexgromero requested a review from a team as a code owner November 24, 2025 22:19
Copy link
Contributor

@jonathan343 jonathan343 left a comment

Choose a reason for hiding this comment

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

Thanks Alessandra, this looks pretty good already. Just have a few questions

Copy link
Contributor

@jonathan343 jonathan343 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

Comment on lines 221 to 222
if not isinstance(out, InvokeModelWithBidirectionalStreamOutputChunk):
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

What else are we receiving in the stream that we're skipping here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The stream can yield both normal OutputChunk events and modeled error events (InternalServerException, ValidationException, ThrottlingException, etc.). Those error types don't have a bytes_ payload, so the isinstance check narrows the type and keeps pyright happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be successful then if we get an error chunk as the last part of our stream and just ignore it? I don't immediately remember how termination of the stream works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. You're right that if we receive error events after getting some successful chunks the test would still pass since we just continue and the assertions only check that we got some output. Should we fail explicitly on error events? or is it acceptable for the stream to send partial results followed by an error?

Copy link
Contributor

Choose a reason for hiding this comment

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

A successful stream shouldn't terminate with errors so I think we'd want to consider that a failure case. I know there have been a lot of unintuitive behaviors with the Bedrock APIs and how they surface errors. I would not be surprised if we get back partial data before it fails, so we should account for that in the test.

If we're seeing typing issues, let's take a look at that. I wonder if we're missing partial definitions or type unions somewhere.

Copy link
Contributor

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

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

Thanks @alexgromero!

@alexgromero alexgromero merged commit fe0c6af into awslabs:develop Nov 26, 2025
@alexgromero alexgromero deleted the bedrock-runtime-integration-tests branch December 3, 2025 16:56
nateprewitt added a commit that referenced this pull request Jan 2, 2026
* Add integration tests for Bedrock Runtime (#37)

* Add integration tests for Transcribe Streaming (#38)

* Update integration tests to use the latest Amazon Nova 2 models (#39)

* Update to latest bedrock-runtime model

* Release: aws-sdk-bedrock-runtime-0.3.0

* Release: AWS SDK Transcribe Streaming 0.3.0

* Release: AWS SDK Sagemaker Runtime HTTP2 0.3.0

* Release: aws-sdk-python 0.3.0

---------

Co-authored-by: Alessandra Romero <24320222+alexgromero@users.noreply.github.com>
Co-authored-by: jonathan343 <43360731+jonathan343@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants