How to invoke Agent using Bedrock Agent Runtime Client in AWS SDK with PHP

How to properly parse the result from invokeAgent.

`$client = new BedrockAgentRuntimeClient([
    'version' => 'latest',
    'region' => 'us-east-1',
    'credentials' => [
        'key' => '...',
        'secret' => '...',
    ],
]);

$payloadAgent = [
    'agentId' => '...',
    'agentAliasId' => '...',
    'sessionId' => '123456',
    'enableTrace' => false,
    'inputText' => 'prompt to send to the agent',
];

$completion = '';
try {
    $response = $client->invokeAgent($payloadAgent);
    print_r($response);

    foreach ($response['completion'] as $chunkEvent) {
        $chunk = $chunkEvent['chunk'];
        $decodedResponse = utf8_decode($chunk['bytes']);
        $completion .= $decodedResponse;
    }
    
} catch (AwsException|Exception $e) {
    echo $e->getMessage();
}`

Output is:
Failed to parse unknown message type. in /vendor/aws/aws-sdk-php/src/Api/Parser/EventParsingIterator.php:74

How to fetch the output as how it is displayed in case of using AWS Console and testing the agent there?