Skip to content

Bedrock ConverseStream: toolResult DocumentType rejects valid JSON #7330

@rbrtj

Description

@rbrtj

Checkboxes for prior research

Describe the bug

When using the Bedrock ConverseStream API, sending a toolResult field with a value that is a valid JSON type results in the error:

Bad Request - The format of the value at messages.3.content.0.toolResult.content.0.json is invalid. Provide a json object for the field and try again.

According to the API documentation and Smithy DocumentType spec, the toolResult field should accept any JSON-serializable value, not just objects.

Model used: claude-3-7-sonnet-20250219-v1

Regression Issue

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

SDK version number

@aws-sdk/client-bedrock-runtime": "^3.744.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.17.1

Reproduction Steps

  1. Use HTTP client (I'm using axios) to make a direct HTTP request to the Bedrock ConverseStream API endpoint.
  2. In the request payload, set the toolResult.content field to an array containing a json property with a non-object JSON value.
{
  messages: [
    {
      role: "user",
      content: [
        {
          toolResult: {
            toolUseId: "some-id",
            content: [
              { json: [] } // or { json: "foo" }, { json: 123 }, { json: true }, { json: null }
            ]
          }
        }
      ]
    }
  ]
}
  1. Send the request to the Bedrock ConverseStream endpoint
  2. Observe that the API responds with the error Provide a json object for the field and try again.
  3. If you use an object for json (e.g., {json: { foo: "bar" } }) the request succeeds

Observed Behavior

When toolResult.content contains a json value that is not an object, the Bedrock ConverseStream API responds with an error message.

 Bad Request - The format of the value at messages.2.content.0.toolResult.content.0.json is invalid. Provide a json object for the field and try again.`

Expected Behavior

Either the API is updated to accept all valid JSON values or the types are updated to clarify that only objects are accepted.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.p2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.service-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions