@ai-sdk/amazon-bedrock 5.0.124 → 5.0.126

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,39 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 5.0.126
4
+
5
+ ### Patch Changes
6
+
7
+ - b6de62e: fix(amazon-bedrock): make document names unique within a request
8
+
9
+ Bedrock Converse rejects requests that contain duplicate document names. Different filenames could sanitize to the same name (e.g. `rates.v1.pdf` and `rates.v2.pdf` both became `rates`), and repeated filenames were sent as-is, so these requests failed. Repeated names now get a numeric suffix such as `invoice (2)`.
10
+
11
+ - 22b4461: Forward disabled thinking in Anthropic Converse requests when using `reasoning: 'none'` or `reasoningConfig: { type: 'disabled' }`, omitting the unsupported thinking field for Claude 3.5 and earlier. Apply model-specific fallbacks and effort limits when disabled thinking is unsupported, preserving explicit reasoning effort during the adaptive fallback.
12
+ - Updated dependencies [63bf860]
13
+ - Updated dependencies [57086ff]
14
+ - Updated dependencies [01d7a03]
15
+ - Updated dependencies [599a97f]
16
+ - Updated dependencies [8375141]
17
+ - Updated dependencies [7eac057]
18
+ - Updated dependencies [436374e]
19
+ - Updated dependencies [9026c7d]
20
+ - Updated dependencies [95348b3]
21
+ - @ai-sdk/anthropic@4.0.90
22
+ - @ai-sdk/provider-utils@5.0.70
23
+ - @ai-sdk/openai@4.0.104
24
+
25
+ ## 5.0.125
26
+
27
+ ### Patch Changes
28
+
29
+ - 27a53b4: Fix string interpolation in Amazon Bedrock unsupported provider tool warnings and OpenAI / OpenAI-compatible completion errors for unexpected system messages.
30
+ - Updated dependencies [e64ed82]
31
+ - Updated dependencies [02dbab1]
32
+ - Updated dependencies [27a53b4]
33
+ - @ai-sdk/provider-utils@5.0.69
34
+ - @ai-sdk/openai@4.0.103
35
+ - @ai-sdk/anthropic@4.0.89
36
+
3
37
  ## 5.0.124
4
38
 
5
39
  ### Patch Changes
@@ -6,7 +6,7 @@ import { z } from "zod/v4";
6
6
  import { EventStreamCodec } from "@smithy/eventstream-codec";
7
7
  import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
8
8
  //#region src/version.ts
9
- const VERSION = "5.0.124";
9
+ const VERSION = "5.0.126";
10
10
  //#endregion
11
11
  //#region src/amazon-bedrock-sigv4-fetch.ts
12
12
  /**
package/dist/index.js CHANGED
@@ -341,7 +341,7 @@ async function prepareTools$1({ tools, toolChoice, modelId, modelFamily, reasoni
341
341
  } });
342
342
  } else toolWarnings.push({
343
343
  type: "unsupported",
344
- feature: "tool ${tool.id}"
344
+ feature: `tool ${tool.id}`
345
345
  });
346
346
  }
347
347
  } else for (const tool of providerToolsForRequest) toolWarnings.push({
@@ -596,7 +596,17 @@ async function convertToAmazonBedrockChatMessages(prompt, isMistral = false) {
596
596
  const messages = [];
597
597
  let documentCounter = 0;
598
598
  const generateDocumentName = () => `document-${++documentCounter}`;
599
- const getDocumentName = (filename) => filename && sanitizeDocumentName(filename) || generateDocumentName();
599
+ const usedDocumentNames = /* @__PURE__ */ new Set();
600
+ const getDocumentName = (filename) => {
601
+ const baseName = filename && sanitizeDocumentName(filename) || generateDocumentName();
602
+ let name = baseName;
603
+ for (let suffix = 2; usedDocumentNames.has(name); suffix++) {
604
+ const suffixText = ` (${suffix})`;
605
+ name = `${baseName.slice(0, 200 - suffixText.length).trim()}${suffixText}`;
606
+ }
607
+ usedDocumentNames.add(name);
608
+ return name;
609
+ };
600
610
  for (let i = 0; i < blocks.length; i++) {
601
611
  const block = blocks[i];
602
612
  const isLastBlock = i === blocks.length - 1;
@@ -1011,7 +1021,7 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1011
1021
  schema: anthropicProviderOptions
1012
1022
  });
1013
1023
  const warnings = [];
1014
- const { supportsStructuredOutput: modelSupportsStructuredOutput, rejectsSamplingParameters, rejectsForcedToolUse, isKnownModel } = getModelCapabilities(this.modelId);
1024
+ const { supportsStructuredOutput: modelSupportsStructuredOutput, rejectsSamplingParameters, rejectsForcedToolUse, rejectsThinkingDisabled, rejectsThinkingDisabledAboveHighEffort, supportsBetweenToolsThinking, isKnownModel } = getModelCapabilities(this.modelId);
1015
1025
  if (frequencyPenalty != null) warnings.push({
1016
1026
  type: "unsupported",
1017
1027
  feature: "frequencyPenalty"
@@ -1080,6 +1090,8 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1080
1090
  modelFamily: this.config.modelFamily,
1081
1091
  reasoningBudgetTokens: amazonBedrockOptions.reasoningConfig?.budgetTokens
1082
1092
  });
1093
+ const hasExplicitDisabledThinking = amazonBedrockOptions.reasoningConfig?.type === "disabled";
1094
+ const explicitReasoningEffort = amazonBedrockOptions.reasoningConfig?.maxReasoningEffort;
1083
1095
  amazonBedrockOptions = resolveAmazonBedrockReasoningConfig({
1084
1096
  reasoning,
1085
1097
  amazonBedrockOptions,
@@ -1088,7 +1100,33 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1088
1100
  isOpenAIModel,
1089
1101
  modelId: this.modelId
1090
1102
  });
1091
- const isThinkingEnabled = amazonBedrockOptions.reasoningConfig?.type === "enabled" || amazonBedrockOptions.reasoningConfig?.type === "adaptive";
1103
+ let thinkingType = amazonBedrockOptions.reasoningConfig?.type;
1104
+ let maxReasoningEffort = amazonBedrockOptions.reasoningConfig?.maxReasoningEffort;
1105
+ if (isAnthropicModel$1 && thinkingType === "disabled") {
1106
+ if (/claude-(?:instant|v?2|3-(?:5-)?(?:haiku|sonnet|opus))(?=[-.:]|$)/.test(this.modelId)) thinkingType = void 0;
1107
+ else if (rejectsThinkingDisabled) {
1108
+ thinkingType = supportsBetweenToolsThinking ? "between_tools" : "adaptive";
1109
+ if (!hasExplicitDisabledThinking && thinkingType === "adaptive") {
1110
+ maxReasoningEffort ??= explicitReasoningEffort;
1111
+ if (maxReasoningEffort == null && amazonBedrockOptions.additionalModelRequestFields?.output_config?.effort == null) maxReasoningEffort = "low";
1112
+ }
1113
+ if (hasExplicitDisabledThinking || thinkingType === "adaptive") warnings.push({
1114
+ type: hasExplicitDisabledThinking ? "unsupported" : "compatibility",
1115
+ feature: hasExplicitDisabledThinking ? "providerOptions.amazonBedrock.reasoningConfig" : "reasoning",
1116
+ details: `thinking cannot be disabled for ${this.modelId}. Using '${thinkingType}' thinking instead.`
1117
+ });
1118
+ }
1119
+ const effort = maxReasoningEffort ?? amazonBedrockOptions.additionalModelRequestFields?.output_config?.effort;
1120
+ if ((thinkingType === "disabled" && rejectsThinkingDisabledAboveHighEffort || thinkingType === "between_tools") && (effort === "xhigh" || effort === "max")) {
1121
+ warnings.push({
1122
+ type: "unsupported",
1123
+ feature: maxReasoningEffort != null ? "providerOptions.amazonBedrock.reasoningConfig.maxReasoningEffort" : "providerOptions.amazonBedrock.additionalModelRequestFields.output_config.effort",
1124
+ details: `effort '${effort}' is not supported by ${this.modelId} with '${thinkingType}' thinking. The effort has been lowered to 'high'.`
1125
+ });
1126
+ maxReasoningEffort = "high";
1127
+ }
1128
+ }
1129
+ const isThinkingEnabled = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
1092
1130
  const structuredOutputMode = amazonBedrockOptions.structuredOutputMode ?? anthropicOptions?.structuredOutputMode ?? "auto";
1093
1131
  if (structuredOutputMode === "jsonTool") {
1094
1132
  const additionalModelRequestFields = { ...amazonBedrockOptions.additionalModelRequestFields };
@@ -1135,7 +1173,6 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1135
1173
  anthropic_beta: mergedBetas
1136
1174
  };
1137
1175
  }
1138
- const thinkingType = amazonBedrockOptions.reasoningConfig?.type;
1139
1176
  const thinkingBudget = thinkingType === "enabled" ? amazonBedrockOptions.reasoningConfig?.budgetTokens : void 0;
1140
1177
  const thinkingDisplay = thinkingType === "adaptive" ? amazonBedrockOptions.reasoningConfig?.display : void 0;
1141
1178
  const isAnthropicThinkingEnabled = isAnthropicModel$1 && isThinkingEnabled;
@@ -1146,7 +1183,7 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1146
1183
  ...topK != null && { topK },
1147
1184
  ...stopSequences != null && { stopSequences }
1148
1185
  };
1149
- if (isAnthropicThinkingEnabled) {
1186
+ if (isAnthropicModel$1) {
1150
1187
  if (thinkingBudget != null) {
1151
1188
  if (inferenceConfig.maxTokens != null) inferenceConfig.maxTokens += thinkingBudget;
1152
1189
  else inferenceConfig.maxTokens = thinkingBudget + 4096;
@@ -1164,7 +1201,11 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1164
1201
  ...thinkingDisplay != null && { display: thinkingDisplay }
1165
1202
  }
1166
1203
  };
1167
- } else if (!isAnthropicModel$1) {
1204
+ else if (thinkingType === "disabled" || thinkingType === "between_tools") amazonBedrockOptions.additionalModelRequestFields = {
1205
+ ...amazonBedrockOptions.additionalModelRequestFields,
1206
+ thinking: { type: thinkingType }
1207
+ };
1208
+ } else {
1168
1209
  if (amazonBedrockOptions.reasoningConfig?.budgetTokens != null) warnings.push({
1169
1210
  type: "unsupported",
1170
1211
  feature: "budgetTokens",
@@ -1176,7 +1217,6 @@ var AmazonBedrockChatLanguageModel = class AmazonBedrockChatLanguageModel {
1176
1217
  details: "adaptive thinking type applies only to Anthropic models on Bedrock."
1177
1218
  });
1178
1219
  }
1179
- const maxReasoningEffort = amazonBedrockOptions.reasoningConfig?.maxReasoningEffort;
1180
1220
  if (maxReasoningEffort != null) {
1181
1221
  if (isAnthropicModel$1) amazonBedrockOptions.additionalModelRequestFields = {
1182
1222
  ...amazonBedrockOptions.additionalModelRequestFields,
@@ -2334,7 +2374,7 @@ const amazonBedrockImageResponseSchema = lazySchema(() => zodSchema(z.object({
2334
2374
  })));
2335
2375
  //#endregion
2336
2376
  //#region src/version.ts
2337
- const VERSION = "5.0.124";
2377
+ const VERSION = "5.0.126";
2338
2378
  //#endregion
2339
2379
  //#region src/amazon-bedrock-sigv4-fetch.ts
2340
2380
  /**