Skip to content

Bedrock Agent Return Control responses are returned as Java toString() output instead of JSON #6555

@borghol

Description

@borghol

Describe the bug

When invoking a Bedrock Agent using the AWS Java SDK (v2), the response event payload is being transformed into a Java object’s toString() output instead of proper JSON. This makes the response unusable without doing custom parsing or regex cleanup.

Environment:
• SDK: aws-java-sdk-v2
• Service: Bedrock Agent Runtime
• Invocation method: InvokeAgentRequest via BedrockAgentRuntimeClient
• Language: Java 17 (adjust if necessary)

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Responses should be provided as valid JSON strings, or at least as strongly typed objects representing the Bedrock Agent event model. At a minimum, there should be a documented utility for converting the SDK event types to raw JSON.

Current Behavior

The agent returns structured JSON (e.g. {"type": "TEXT", "text": "Hello"}) in the parameter value, but the SDK surfaces it as something like:

{type=TEXT, text=Hello}

Reproduction Steps

  • Set up Bedrock Action Group to return control with an API schema that returns an object in its body, i.e.:
{ "productId": "123", "quantity": 3}

When called, the return control value will be:

{ productId=123, quantity=3 }

Possible Solution

Parameters should be returned as the JSON string supplied by the agent and not the marshalled version of Java's SDK

Additional Information/Context

No response

AWS Java SDK version used

2.38.2

JDK version used

17

Operating System and version

MacOS locally, amazoncorretto:17 docker image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions