@ai-sdk/amazon-bedrock 4.0.205 → 4.0.206

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,11 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 4.0.206
4
+
5
+ ### Patch Changes
6
+
7
+ - 0d40f58: Fix disabled Anthropic thinking in Converse requests by forwarding `reasoningConfig: { type: 'disabled' }` for supported models and omitting the field for Claude 3.5 and earlier. Apply model-specific thinking fallbacks and effort limits with warnings, preserving explicit reasoning effort.
8
+
3
9
  ## 4.0.205
4
10
 
5
11
  ### Patch Changes
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
35
35
  var import_aws4fetch = require("aws4fetch");
36
36
 
37
37
  // src/version.ts
38
- var VERSION = true ? "4.0.205" : "0.0.0-test";
38
+ var VERSION = true ? "4.0.206" : "0.0.0-test";
39
39
 
40
40
  // src/bedrock-sigv4-fetch.ts
41
41
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
@@ -23,7 +23,7 @@ import {
23
23
  import { AwsV4Signer } from "aws4fetch";
24
24
 
25
25
  // src/version.ts
26
- var VERSION = true ? "4.0.205" : "0.0.0-test";
26
+ var VERSION = true ? "4.0.206" : "0.0.0-test";
27
27
 
28
28
  // src/bedrock-sigv4-fetch.ts
29
29
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
package/dist/index.js CHANGED
@@ -1045,13 +1045,41 @@ var BedrockChatLanguageModel = class {
1045
1045
  const openAIModelId = (_c = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _c[1];
1046
1046
  const isOpenAIModel = openAIModelId != null;
1047
1047
  const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
1048
- const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
1049
1048
  const {
1050
1049
  supportsStructuredOutput: modelSupportsStructuredOutput,
1051
1050
  rejectsForcedToolUse,
1051
+ rejectsThinkingDisabled,
1052
+ rejectsThinkingDisabledAboveHighEffort,
1053
+ supportsBetweenToolsThinking,
1052
1054
  isKnownModel
1053
1055
  } = (0, import_internal2.getModelCapabilities)(this.modelId);
1054
- const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
1056
+ let thinkingType = (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type;
1057
+ let maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
1058
+ if (isAnthropicModel2 && thinkingType === "disabled") {
1059
+ if (/claude-(?:instant|v?2|3-(?:5-)?(?:haiku|sonnet|opus))(?=[-.:]|$)/.test(
1060
+ this.modelId
1061
+ )) {
1062
+ thinkingType = void 0;
1063
+ } else if (rejectsThinkingDisabled) {
1064
+ thinkingType = supportsBetweenToolsThinking ? "between_tools" : "adaptive";
1065
+ warnings.push({
1066
+ type: "unsupported",
1067
+ feature: "providerOptions.bedrock.reasoningConfig",
1068
+ details: `thinking cannot be disabled for ${this.modelId}. Using '${thinkingType}' thinking instead.`
1069
+ });
1070
+ }
1071
+ const effort = maxReasoningEffort != null ? maxReasoningEffort : (_h = (_g = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _g.output_config) == null ? void 0 : _h.effort;
1072
+ if ((thinkingType === "disabled" && rejectsThinkingDisabledAboveHighEffort || thinkingType === "between_tools") && (effort === "xhigh" || effort === "max")) {
1073
+ warnings.push({
1074
+ type: "unsupported",
1075
+ feature: maxReasoningEffort != null ? "providerOptions.bedrock.reasoningConfig.maxReasoningEffort" : "providerOptions.bedrock.additionalModelRequestFields.output_config.effort",
1076
+ details: `effort '${effort}' is not supported by ${this.modelId} with '${thinkingType}' thinking. The effort has been lowered to 'high'.`
1077
+ });
1078
+ maxReasoningEffort = "high";
1079
+ }
1080
+ }
1081
+ const isThinkingEnabled = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
1082
+ const structuredOutputMode = (_j = (_i = bedrockOptions.structuredOutputMode) != null ? _i : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _j : "auto";
1055
1083
  if (structuredOutputMode === "jsonTool") {
1056
1084
  const additionalModelRequestFields = {
1057
1085
  ...bedrockOptions.additionalModelRequestFields
@@ -1082,7 +1110,7 @@ var BedrockChatLanguageModel = class {
1082
1110
  toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
1083
1111
  modelId: this.modelId,
1084
1112
  modelFamily: this.config.modelFamily,
1085
- reasoningBudgetTokens: (_i = bedrockOptions.reasoningConfig) == null ? void 0 : _i.budgetTokens,
1113
+ reasoningBudgetTokens: (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.budgetTokens,
1086
1114
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
1087
1115
  });
1088
1116
  warnings.push(...toolWarnings);
@@ -1093,16 +1121,15 @@ var BedrockChatLanguageModel = class {
1093
1121
  };
1094
1122
  }
1095
1123
  if (betas.size > 0 || bedrockOptions.anthropicBeta) {
1096
- const existingBetas = (_j = bedrockOptions.anthropicBeta) != null ? _j : [];
1124
+ const existingBetas = (_l = bedrockOptions.anthropicBeta) != null ? _l : [];
1097
1125
  const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
1098
1126
  bedrockOptions.additionalModelRequestFields = {
1099
1127
  ...bedrockOptions.additionalModelRequestFields,
1100
1128
  anthropic_beta: mergedBetas
1101
1129
  };
1102
1130
  }
1103
- const thinkingType = (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.type;
1104
- const thinkingBudget = thinkingType === "enabled" ? (_l = bedrockOptions.reasoningConfig) == null ? void 0 : _l.budgetTokens : void 0;
1105
- const thinkingDisplay = thinkingType === "adaptive" ? (_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.display : void 0;
1131
+ const thinkingBudget = thinkingType === "enabled" ? (_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.budgetTokens : void 0;
1132
+ const thinkingDisplay = thinkingType === "adaptive" ? (_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.display : void 0;
1106
1133
  const isAnthropicThinkingEnabled = isAnthropicModel2 && isThinkingEnabled;
1107
1134
  const inferenceConfig = {
1108
1135
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
@@ -1111,7 +1138,7 @@ var BedrockChatLanguageModel = class {
1111
1138
  ...topK != null && { topK },
1112
1139
  ...stopSequences != null && { stopSequences }
1113
1140
  };
1114
- if (isAnthropicThinkingEnabled) {
1141
+ if (isAnthropicModel2) {
1115
1142
  if (thinkingBudget != null) {
1116
1143
  if (inferenceConfig.maxTokens != null) {
1117
1144
  inferenceConfig.maxTokens += thinkingBudget;
@@ -1133,9 +1160,14 @@ var BedrockChatLanguageModel = class {
1133
1160
  ...thinkingDisplay != null && { display: thinkingDisplay }
1134
1161
  }
1135
1162
  };
1163
+ } else if (thinkingType === "disabled" || thinkingType === "between_tools") {
1164
+ bedrockOptions.additionalModelRequestFields = {
1165
+ ...bedrockOptions.additionalModelRequestFields,
1166
+ thinking: { type: thinkingType }
1167
+ };
1136
1168
  }
1137
- } else if (!isAnthropicModel2) {
1138
- if (((_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.budgetTokens) != null) {
1169
+ } else {
1170
+ if (((_o = bedrockOptions.reasoningConfig) == null ? void 0 : _o.budgetTokens) != null) {
1139
1171
  warnings.push({
1140
1172
  type: "unsupported",
1141
1173
  feature: "budgetTokens",
@@ -1150,7 +1182,6 @@ var BedrockChatLanguageModel = class {
1150
1182
  });
1151
1183
  }
1152
1184
  }
1153
- const maxReasoningEffort = (_o = bedrockOptions.reasoningConfig) == null ? void 0 : _o.maxReasoningEffort;
1154
1185
  if (maxReasoningEffort != null) {
1155
1186
  if (isAnthropicModel2) {
1156
1187
  bedrockOptions.additionalModelRequestFields = {
@@ -2400,7 +2431,7 @@ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2400
2431
  var import_aws4fetch = require("aws4fetch");
2401
2432
 
2402
2433
  // src/version.ts
2403
- var VERSION = true ? "4.0.205" : "0.0.0-test";
2434
+ var VERSION = true ? "4.0.206" : "0.0.0-test";
2404
2435
 
2405
2436
  // src/bedrock-sigv4-fetch.ts
2406
2437
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {