@ai-sdk/amazon-bedrock 3.0.0-beta.11 → 3.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.0.0-beta.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 0893170: fix(amazon-bedrock): handle empty activeTools with tool conversation history
8
+ - Updated dependencies [e7fcc86]
9
+ - @ai-sdk/provider-utils@3.0.0-beta.7
10
+
3
11
  ## 3.0.0-beta.11
4
12
 
5
13
  ### Patch Changes
package/dist/index.js CHANGED
@@ -181,7 +181,7 @@ function prepareTools({
181
181
  if (tools == null) {
182
182
  return {
183
183
  toolConfig: {
184
- tools: hasToolContent ? [] : void 0,
184
+ tools: void 0,
185
185
  toolChoice: void 0
186
186
  },
187
187
  toolWarnings: []
@@ -225,7 +225,7 @@ function prepareTools({
225
225
  case "none":
226
226
  return {
227
227
  toolConfig: {
228
- tools: hasToolContent ? [] : void 0,
228
+ tools: void 0,
229
229
  toolChoice: void 0
230
230
  },
231
231
  toolWarnings
@@ -651,7 +651,6 @@ var BedrockChatLanguageModel = class {
651
651
  description: "Respond with a JSON object.",
652
652
  inputSchema: responseFormat.schema
653
653
  } : void 0;
654
- const { system, messages } = await convertToBedrockChatMessages(prompt);
655
654
  const isThinking = ((_b = bedrockOptions.reasoningConfig) == null ? void 0 : _b.type) === "enabled";
656
655
  const thinkingBudget = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.budgetTokens;
657
656
  const inferenceConfig = {
@@ -690,10 +689,37 @@ var BedrockChatLanguageModel = class {
690
689
  details: "topP is not supported when thinking is enabled"
691
690
  });
692
691
  }
692
+ const activeTools = jsonResponseTool != null ? [jsonResponseTool] : tools != null ? tools : [];
693
+ let filteredPrompt = prompt;
694
+ if (activeTools.length === 0) {
695
+ const hasToolContent = prompt.some(
696
+ (message) => "content" in message && Array.isArray(message.content) && message.content.some(
697
+ (part) => part.type === "tool-call" || part.type === "tool-result"
698
+ )
699
+ );
700
+ if (hasToolContent) {
701
+ filteredPrompt = prompt.map(
702
+ (message) => message.role === "system" ? message : {
703
+ ...message,
704
+ content: message.content.filter(
705
+ (part) => part.type !== "tool-call" && part.type !== "tool-result"
706
+ )
707
+ }
708
+ ).filter(
709
+ (message) => message.role === "system" || message.content.length > 0
710
+ );
711
+ warnings.push({
712
+ type: "unsupported-setting",
713
+ setting: "toolContent",
714
+ details: "Tool calls and results removed from conversation because Bedrock does not support tool content without active tools."
715
+ });
716
+ }
717
+ }
718
+ const { system, messages } = await convertToBedrockChatMessages(filteredPrompt);
693
719
  const { toolConfig, toolWarnings } = prepareTools({
694
- tools: jsonResponseTool != null ? [jsonResponseTool] : tools != null ? tools : [],
720
+ tools: activeTools,
695
721
  toolChoice: jsonResponseTool != null ? { type: "tool", toolName: jsonResponseTool.name } : toolChoice,
696
- prompt
722
+ prompt: filteredPrompt
697
723
  });
698
724
  const { reasoningConfig: _, ...filteredBedrockOptions } = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
699
725
  return {