Description
Heya - When using streamText with Amazon Bedrock, if a conversation has prior tool calls, any subsequent step with no active tools (activeTools: [] or toolChoice: none) will fail. This only happens with Bedrock and no other provider I have tested.
Steps to Reproduce:
- Use
streamText with a Bedrock model and a tool.
- In the
prepareStep callback, set activeTools to an empty array for the second turn of the conversation to force a text-only response.
- The call fails when the agent tries to generate the final answer.
Minimal Code Example:
const aws = createAmazonBedrock();
const stream = streamText({
model: aws('anthropic.claude-3-5-sonnet-20241022-v2:0'),
tools: {
weather: tool({
description: 'Get the weather in a location',
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => ({
result: `The weather in ${city} is 20°C.`,
}),
}),
},
stopWhen: [
stepCountIs(5)
],
prepareStep: ({ stepNumber }) => {
if (stepNumber > 0) {
return {
activeTools: [] // or `toolChoice: 'none'`
};
}
return undefined;
},
toolChoice: 'auto',
prompt: 'What is the weather in Toronto, Calgary, and Vancouver?',
});
Expected Behavior:
The request should succeed, and the model should generate a final text response without calling any tools.
Actual Behavior:
The API call fails with the error: The toolConfig field must be defined when using toolUse and toolResult content blocks.
AI SDK Version
- ai: 5.0.0-beta.26
- @ai-sdk/amazon-bedrock: 3.0.0-beta.9
- @ai-sdk/react:2.0.0-beta.26
Description
Heya - When using
streamTextwith Amazon Bedrock, if a conversation has prior tool calls, any subsequent step with no active tools (activeTools: []ortoolChoice: none) will fail. This only happens with Bedrock and no other provider I have tested.Steps to Reproduce:
streamTextwith a Bedrock model and a tool.prepareStepcallback, setactiveToolsto an empty array for the second turn of the conversation to force a text-only response.Minimal Code Example:
Expected Behavior:
The request should succeed, and the model should generate a final text response without calling any tools.
Actual Behavior:
The API call fails with the error:
The toolConfig field must be defined when using toolUse and toolResult content blocks.AI SDK Version