Skip to content

feat: Make BedrockModel._format_request and _convert_non_streaming_to…#2315

Open
celealramos wants to merge 1 commit into
strands-agents:mainfrom
celealramos:feat/make-bedrock-model-methods-public
Open

feat: Make BedrockModel._format_request and _convert_non_streaming_to…#2315
celealramos wants to merge 1 commit into
strands-agents:mainfrom
celealramos:feat/make-bedrock-model-methods-public

Conversation

@celealramos
Copy link
Copy Markdown

…_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

  • I ran hatch run prepare

Checklist

  • [ x] I have read the CONTRIBUTING document
  • [ x] I have added any necessary tests that prove my fix is effective or my feature works
  • [x ] I have updated the documentation accordingly
  • [ x] 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
  • [x ] 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.

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.

1 participant