Skip to content

InvokeAgentCommand doesn't return chunk #6519

@davidgamify

Description

@davidgamify

Checkboxes for prior research

Describe the bug

When I call the InvokeAgentCommand send function, I receive a response, but the response doesn't include the chunk. When I use the same parameters in python3 (boto3), I get chunk in the result.

Regression Issue

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

SDK version number

"@aws-sdk/client-bedrock-agent-runtime": "^3.658.0"

Which JavaScript Runtime is this issue in?

React Native

Details of the browser/Node.js/ReactNative version

v22.7.0

Reproduction Steps

  const testInput = {
    agentId, // required
    agentAliasId, // required
    sessionId: _sessionId, // required
    inputText: question,
  };

  const command = new InvokeAgentCommand(testInput);
  const response = await client.send(command);
  console.log ("!!!response: ", response);
  let completion = ""
  for await (const chunkEvent of response.completion) {
    if (chunkEvent.chunk) {
      const chunk = chunkEvent.chunk;
      let decoded = new TextDecoder("utf-8").decode(chunk.bytes);
      completion += decoded;
    }
  }
  LOG.debug("!!!completion: ", completion);

Observed Behavior

!!!response in log =

{
  "$metadata": {
    "httpStatusCode": 200,
    "requestId": "ae975225-b133-42c4-a8eb-0d425e650a40",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "contentType": "application/json",
  "sessionId": "96c1843f-8f91-4ff8-8742-753c4a0dbf91",
  "completion": {
    "options": {
      "messageStream": {
        "options": {
          "inputStream": {},
          "decoder": {
            "headerMarshaller": {},
            "messageBuffer": [],
            "isEndOfStream": false
          }
        }
      }
    }
  }
}

Expected Behavior

I would expect response to look like:

{
  "$metadata": {
    "httpStatusCode": 200,
    "requestId": "ae975225-b133-42c4-a8eb-0d425e650a40",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "contentType": "application/json",
  "sessionId": "96c1843f-8f91-4ff8-8742-753c4a0dbf91",
  "completion": {
    "chunk" : [
...chunk data here...
    ],
    "options": {
      "messageStream": {
        "options": {
          "inputStream": {},
          "decoder": {
            "headerMarshaller": {},
            "messageBuffer": [],
            "isEndOfStream": false
          }
        }
      }
    }
  }
}

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions