Skip to content

Conversation

@oyiz-michael
Copy link
Contributor

Fixes #7692

Summary

Clarifies that BedrockResponse.is_json() always returns True regardless of the content_type parameter due to AWS Bedrock Agents only supporting TEXT content type in the responseBody.

Changes

Please provide a summary of what's being changed

  • Enhanced BedrockResponse class docstring explaining AWS Bedrock limitation
  • Added comprehensive Note section to is_json() method docstring with AWS documentation reference
  • Added "Content Type Behavior" tip box in bedrock_agents.md user guide

Context

Amazon Bedrock Agents only support TEXT content type per the AWS Lambda integration documentation. All response bodies are automatically serialized as JSON strings regardless of the content_type parameter.

The content_type parameter is maintained for API consistency but does not affect the actual response format sent to Bedrock Agents.

User experience

Before:
Users were confused why BedrockResponse.is_json() always returns True even when setting content_type="text/plain". The behavior was not documented, leading to assumptions that the content_type parameter would control the response format.

After:
Clear documentation in both the API reference (via docstrings) and user guide explains:

  • Why is_json() always returns True
  • The AWS Bedrock limitation (TEXT-only content type)
  • That content_type parameter is kept for API consistency
  • Link to AWS documentation for additional context

Users will now understand this is expected behavior due to AWS platform constraints, not a bug.


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

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Addresses aws-powertools#7692

- Added comprehensive docstring to BedrockResponse.is_json() explaining
  why it always returns True regardless of content_type parameter
- Updated BedrockResponse class docstring with note about Bedrock Agents
  only supporting TEXT content type
- Added tip in bedrock_agents.md documentation to clarify content_type
  behavior for users
- Included AWS documentation reference for context

The content_type parameter is maintained for API consistency but does not
affect the actual response format sent to Bedrock Agents, as they only
support TEXT content type per AWS Lambda integration docs.
@oyiz-michael oyiz-michael requested a review from a team as a code owner November 26, 2025 13:57
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation event_handlers labels Nov 26, 2025
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 26, 2025
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation event_handlers size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: explain why BedrockResponse.is_json always returns True regardless of Content-Type

1 participant