Description
When using the Amazon Bedrock provider (v2.2.8), along with streamText and a high-ish (~20) value for maxSteps, it's not uncommon to run into an error like the following around half the time:
APICallError [AI_APICallError]: undefined: The text field in the ContentBlock object at messages.7.content.0 is blank. Add text to the text field, and try again.
at file:///<snip>/lib/node_modules/@ai-sdk/amazon-bedrock/node_modules/@ai-sdk/provider-utils/dist/index.mjs:667:14
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async postToApi (file:///<snip>/lib/node_modules/@ai-sdk/amazon-bedrock/node_modules/@ai-sdk/provider-utils/dist/index.mjs:567:28)
at async BedrockChatLanguageModel.doStream (file:///<snip>/lib/node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs:740:50)
at async fn (file://///<snip>/node_modules/ai/dist/index.mjs:5622:25)
at async file://///<snip>/node_modules/ai/dist/index.mjs:470:22
at async _retryWithExponentialBackoff (file://///<snip>/node_modules/ai/dist/index.mjs:271:12)
at async streamStep (file://///<snip>/node_modules/ai/dist/index.mjs:5577:15)
It also dumps out the messages in question:
messages: [
// irrelevant messages omitted for brevity
{
role: 'assistant',
content: [
{
text: '\n' +
'\n' +
"Let's also check the <snip> to see if there are any issues there:"
},
{ toolUse: [Object] }
]
},
{ role: 'user', content: [ { toolResult: [Object] } ] },
{
// >>> This appears to be the message that's breaking the API, messages.7
role: 'assistant',
content: [ { text: '\n\n' }, { toolUse: [Object] } ]
},
{ role: 'user', content: [ { toolResult: [Object] } ] }
],
In particular, it seems not to like this content block: { text: '\n\n' }.
I don't have specific repro steps, but it seems to happen somewhat consistently for higher maxSteps, as mentioned earlier.
Also, using Claude Sonnet 3.7, reasoning not enabled.
Description
When using the Amazon Bedrock provider (v2.2.8), along with streamText and a high-ish (~20) value for maxSteps, it's not uncommon to run into an error like the following around half the time:
It also dumps out the messages in question:
In particular, it seems not to like this content block:
{ text: '\n\n' }.I don't have specific repro steps, but it seems to happen somewhat consistently for higher maxSteps, as mentioned earlier.
Also, using Claude Sonnet 3.7, reasoning not enabled.