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
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:
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
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
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:
Reproduction Steps
When called, the return control value will be:
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