Skip to content

[FEATURE] Make BedrockModel._format_request and _convert_non_streaming_to_streaming public #2308

@celealramos

Description

@celealramos

Problem Statement

Currently, BedrockModel._format_request and BedrockModel._convert_non_streaming_to_streaming are private methods (prefixed with _). Users who subclass BedrockModel or build custom model wrappers around it cannot reliably call or override these methods without depending on private API that may change without notice. This makes it difficult to:

  • Re-use methods without the risk that method signatures may cause breaking changes

Proposed Solution

Rename the private methods to public:

_format_request becomes format_request
_convert_non_streaming_to_streaming becomes convert_non_streaming_to_streaming
Keep the old private method names as deprecated aliases that:

  • Emit a DeprecationWarning directing users to the new public method name
  • Delegate to the public method
  • Are scheduled for removal in September 2026
  • This provides a clean migration path for any existing code referencing the private methods

Use Case

Subclassing BedrockModel: users who extend BedrockModel to add custom request formatting (e.g., injecting guardrails, adding metadata, transforming tool specs) can now override format_request as a stable public API.

Alternatives Solutions

Remove the deprecated aliases immediately — this would break existing code that references _format_request or _convert_non_streaming_to_streaming. The deprecation period provides a graceful migration.

Additional Context

Other model providers in the SDK (OpenAIModel, AnthropicModel, OllamaModel, LiteLLMModel, MistralModel, LlamaAPIModel, SageMakerModel, WriterModel) already expose format_request as a public method. BedrockModel is the only provider where this was private. This change brings it in line with the rest of the SDK.

The internal call sites within BedrockModel (in converse and count_tokens_using_bedrock) are updated to use the new public names directly. Tests are updated accordingly and new tests verify that the deprecated aliases emit warnings and correctly delegate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions