feat: Make BedrockModel._format_request and _convert_non_streaming_to…#2315
Open
celealramos wants to merge 1 commit into
Open
feat: Make BedrockModel._format_request and _convert_non_streaming_to…#2315celealramos wants to merge 1 commit into
celealramos wants to merge 1 commit into
Conversation
…_streaming public
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.
…_streaming public
Description
Users building custom Bedrock integrations need to format requests and convert non-streaming responses outside of the standard stream() flow. For example, to inspect or modify the request before sending, or to integrate with custom invocation pipelines. Currently these capabilities are only available through private methods (_format_request, _convert_non_streaming_to_streaming), making them fragile to depend on and inconsistent with other providers (Anthropic, Mistral, Ollama, Writer) that already expose public format_request.
Public API Changes
BedrockModel now exposes two public methods that delegate to the existing private implementations:
Before: rely on private API (fragile, undocumented)
model = BedrockModel(model_id="us.anthropic.claude-sonnet-4-20250514-v1:0")
request = model._format_request(messages, tool_specs)
events = model._convert_non_streaming_to_streaming(response)
After: stable public API
model = BedrockModel(model_id="us.anthropic.claude-sonnet-4-20250514-v1:0")
request = model.format_request(messages, tool_specs)
events = model.convert_non_streaming_to_streaming(response)
The private methods now emit a DeprecationWarning when called directly, with removal planned for September 2026. Internal call sites continue dispatching through the private methods (with warnings suppressed) so subclass overrides are honored without behavioral changes.
Related Issues
#2308
Documentation PR
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.