@ai-sdk/anthropic 3.0.127 → 3.0.129

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,23 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.129
4
+
5
+ ### Patch Changes
6
+
7
+ - ed0cd89: fix(anthropic): preserve tools when disabling tool calls
8
+ - b5d3c2f: fix(anthropic): preserve failed tool search results in conversation history
9
+
10
+ ## 3.0.128
11
+
12
+ ### Patch Changes
13
+
14
+ - bedd5bb: feat(anthropic): add Claude Haiku 5.5 support
15
+
16
+ - add the `claude-haiku-5-5` model ID to `@ai-sdk/anthropic` and `@ai-sdk/google-vertex`, `anthropic.claude-haiku-5-5` and `us.anthropic.claude-haiku-5-5` to `@ai-sdk/amazon-bedrock`, and `anthropic/claude-haiku-5.5` to `@ai-sdk/gateway`
17
+ - recognize `claude-haiku-5-5` as a known model with a 128k max output token limit and all five effort levels; thinking can be disabled up to `high` effort, and `xhigh` and `max` are lowered to `high` with a warning when thinking is disabled
18
+ - `claude-haiku-5-5` does not support thinking token budgets: `thinking: { type: 'enabled', budgetTokens }` is converted to adaptive thinking with a warning
19
+ - use the JSON tool fallback for structured output on Amazon Bedrock for `claude-haiku-5-5`
20
+
3
21
  ## 3.0.127
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -220,7 +220,7 @@ interface AnthropicMessageMetadata {
220
220
  } | null;
221
221
  }
222
222
 
223
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
223
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-haiku-5-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
224
224
  /**
225
225
  * Anthropic provider options for system messages.
226
226
  */
package/dist/index.d.ts CHANGED
@@ -220,7 +220,7 @@ interface AnthropicMessageMetadata {
220
220
  } | null;
221
221
  }
222
222
 
223
- type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
223
+ type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-haiku-5-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
224
224
  /**
225
225
  * Anthropic provider options for system messages.
226
226
  */
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils27 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.127" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -1990,7 +1990,12 @@ async function prepareTools({
1990
1990
  betas
1991
1991
  };
1992
1992
  case "none":
1993
- return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
1993
+ return {
1994
+ tools: anthropicTools2,
1995
+ toolChoice: { type: "none" },
1996
+ toolWarnings,
1997
+ betas
1998
+ };
1994
1999
  case "tool":
1995
2000
  if (rejectsForcedToolUse) {
1996
2001
  toolWarnings.push({
@@ -2439,7 +2444,7 @@ async function convertToAnthropicMessagesPrompt({
2439
2444
  toolNameMapping,
2440
2445
  toolsetNames = {}
2441
2446
  }) {
2442
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2447
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2443
2448
  const betas = /* @__PURE__ */ new Set();
2444
2449
  const blocks = groupIntoBlocks(prompt);
2445
2450
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -3251,6 +3256,18 @@ async function convertToAnthropicMessagesPrompt({
3251
3256
  }
3252
3257
  if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
3253
3258
  const output = part.output;
3259
+ if (output.type === "error-json" || output.type === "json" && output.value != null && typeof output.value === "object" && !Array.isArray(output.value) && "type" in output.value && output.value.type === "tool_search_tool_result_error") {
3260
+ anthropicContent.push({
3261
+ type: "tool_search_tool_result",
3262
+ tool_use_id: part.toolCallId,
3263
+ content: {
3264
+ type: "tool_search_tool_result_error",
3265
+ error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
3266
+ },
3267
+ cache_control: cacheControl
3268
+ });
3269
+ break;
3270
+ }
3254
3271
  if (output.type !== "json") {
3255
3272
  warnings.push({
3256
3273
  type: "other",
@@ -3822,6 +3839,7 @@ var AnthropicMessagesLanguageModel = class {
3822
3839
  rejectsSamplingParameters,
3823
3840
  rejectsThinkingDisabledAboveHighEffort,
3824
3841
  rejectsThinkingDisabled,
3842
+ rejectsBudgetThinking,
3825
3843
  rejectsForcedToolUse,
3826
3844
  supportsBetweenToolsThinking,
3827
3845
  isKnownModel
@@ -3939,15 +3957,16 @@ var AnthropicMessagesLanguageModel = class {
3939
3957
  details: `thinking cannot be disabled for ${this.modelId}; it always uses adaptive thinking. The thinking setting has been removed. Lower 'effort' to reduce thinking.`
3940
3958
  });
3941
3959
  anthropicOptions.thinking = void 0;
3942
- } else if (requestedType === "enabled") {
3943
- warnings.push({
3944
- type: "unsupported",
3945
- feature: "providerOptions.anthropic.thinking",
3946
- details: `budget-based thinking is not supported by ${this.modelId}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`
3947
- });
3948
- anthropicOptions.thinking = { type: "adaptive" };
3949
3960
  }
3950
3961
  }
3962
+ if (rejectsBudgetThinking && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) != null && "type" in anthropicOptions.thinking && anthropicOptions.thinking.type === "enabled") {
3963
+ warnings.push({
3964
+ type: "unsupported",
3965
+ feature: "providerOptions.anthropic.thinking",
3966
+ details: rejectsThinkingDisabled ? `budget-based thinking is not supported by ${this.modelId}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.` : `budget-based thinking is not supported by ${this.modelId}. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`
3967
+ });
3968
+ anthropicOptions.thinking = { type: "adaptive" };
3969
+ }
3951
3970
  const thinking = anthropicOptions == null ? void 0 : anthropicOptions.thinking;
3952
3971
  const thinkingType = thinking != null && "type" in thinking ? thinking.type : void 0;
3953
3972
  if (rejectsThinkingDisabledAboveHighEffort && thinkingType === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
@@ -5826,6 +5845,7 @@ function getModelCapabilities(modelId) {
5826
5845
  rejectsSamplingParameters: true,
5827
5846
  rejectsThinkingDisabledAboveHighEffort: true,
5828
5847
  rejectsThinkingDisabled: true,
5848
+ rejectsBudgetThinking: true,
5829
5849
  rejectsForcedToolUse: true,
5830
5850
  supportsBetweenToolsThinking: true,
5831
5851
  isKnownModel: true
@@ -5837,10 +5857,23 @@ function getModelCapabilities(modelId) {
5837
5857
  rejectsSamplingParameters: true,
5838
5858
  rejectsThinkingDisabledAboveHighEffort: true,
5839
5859
  rejectsThinkingDisabled: true,
5860
+ rejectsBudgetThinking: true,
5840
5861
  rejectsForcedToolUse: true,
5841
5862
  supportsBetweenToolsThinking: false,
5842
5863
  isKnownModel: true
5843
5864
  };
5865
+ } else if (modelId.includes("claude-haiku-5-5")) {
5866
+ return {
5867
+ maxOutputTokens: 128e3,
5868
+ supportsStructuredOutput: true,
5869
+ rejectsSamplingParameters: true,
5870
+ rejectsThinkingDisabledAboveHighEffort: true,
5871
+ rejectsThinkingDisabled: false,
5872
+ rejectsBudgetThinking: true,
5873
+ rejectsForcedToolUse: false,
5874
+ supportsBetweenToolsThinking: false,
5875
+ isKnownModel: true
5876
+ };
5844
5877
  } else if (modelId.includes("claude-opus-5")) {
5845
5878
  return {
5846
5879
  maxOutputTokens: 128e3,
@@ -5848,6 +5881,7 @@ function getModelCapabilities(modelId) {
5848
5881
  rejectsSamplingParameters: true,
5849
5882
  rejectsThinkingDisabledAboveHighEffort: true,
5850
5883
  rejectsThinkingDisabled: false,
5884
+ rejectsBudgetThinking: false,
5851
5885
  rejectsForcedToolUse: false,
5852
5886
  supportsBetweenToolsThinking: false,
5853
5887
  isKnownModel: true
@@ -5859,6 +5893,7 @@ function getModelCapabilities(modelId) {
5859
5893
  rejectsSamplingParameters: true,
5860
5894
  rejectsThinkingDisabledAboveHighEffort: false,
5861
5895
  rejectsThinkingDisabled: true,
5896
+ rejectsBudgetThinking: true,
5862
5897
  rejectsForcedToolUse: true,
5863
5898
  supportsBetweenToolsThinking: false,
5864
5899
  isKnownModel: true
@@ -5870,6 +5905,7 @@ function getModelCapabilities(modelId) {
5870
5905
  rejectsSamplingParameters: true,
5871
5906
  rejectsThinkingDisabledAboveHighEffort: false,
5872
5907
  rejectsThinkingDisabled: true,
5908
+ rejectsBudgetThinking: true,
5873
5909
  rejectsForcedToolUse: false,
5874
5910
  supportsBetweenToolsThinking: false,
5875
5911
  isKnownModel: true
@@ -5881,6 +5917,7 @@ function getModelCapabilities(modelId) {
5881
5917
  rejectsSamplingParameters: true,
5882
5918
  rejectsThinkingDisabledAboveHighEffort: false,
5883
5919
  rejectsThinkingDisabled: false,
5920
+ rejectsBudgetThinking: false,
5884
5921
  rejectsForcedToolUse: false,
5885
5922
  supportsBetweenToolsThinking: false,
5886
5923
  isKnownModel: true
@@ -5892,6 +5929,7 @@ function getModelCapabilities(modelId) {
5892
5929
  rejectsSamplingParameters: false,
5893
5930
  rejectsThinkingDisabledAboveHighEffort: false,
5894
5931
  rejectsThinkingDisabled: false,
5932
+ rejectsBudgetThinking: false,
5895
5933
  rejectsForcedToolUse: false,
5896
5934
  supportsBetweenToolsThinking: false,
5897
5935
  isKnownModel: true
@@ -5903,6 +5941,7 @@ function getModelCapabilities(modelId) {
5903
5941
  rejectsSamplingParameters: false,
5904
5942
  rejectsThinkingDisabledAboveHighEffort: false,
5905
5943
  rejectsThinkingDisabled: false,
5944
+ rejectsBudgetThinking: false,
5906
5945
  rejectsForcedToolUse: false,
5907
5946
  supportsBetweenToolsThinking: false,
5908
5947
  isKnownModel: true
@@ -5914,6 +5953,7 @@ function getModelCapabilities(modelId) {
5914
5953
  rejectsSamplingParameters: false,
5915
5954
  rejectsThinkingDisabledAboveHighEffort: false,
5916
5955
  rejectsThinkingDisabled: false,
5956
+ rejectsBudgetThinking: false,
5917
5957
  rejectsForcedToolUse: false,
5918
5958
  supportsBetweenToolsThinking: false,
5919
5959
  isKnownModel: true
@@ -5925,6 +5965,7 @@ function getModelCapabilities(modelId) {
5925
5965
  rejectsSamplingParameters: false,
5926
5966
  rejectsThinkingDisabledAboveHighEffort: false,
5927
5967
  rejectsThinkingDisabled: false,
5968
+ rejectsBudgetThinking: false,
5928
5969
  rejectsForcedToolUse: false,
5929
5970
  supportsBetweenToolsThinking: false,
5930
5971
  isKnownModel: true
@@ -5936,6 +5977,7 @@ function getModelCapabilities(modelId) {
5936
5977
  rejectsSamplingParameters: false,
5937
5978
  rejectsThinkingDisabledAboveHighEffort: false,
5938
5979
  rejectsThinkingDisabled: false,
5980
+ rejectsBudgetThinking: false,
5939
5981
  rejectsForcedToolUse: false,
5940
5982
  supportsBetweenToolsThinking: false,
5941
5983
  isKnownModel: true
@@ -5947,6 +5989,7 @@ function getModelCapabilities(modelId) {
5947
5989
  rejectsSamplingParameters: false,
5948
5990
  rejectsThinkingDisabledAboveHighEffort: false,
5949
5991
  rejectsThinkingDisabled: false,
5992
+ rejectsBudgetThinking: false,
5950
5993
  rejectsForcedToolUse: false,
5951
5994
  supportsBetweenToolsThinking: false,
5952
5995
  isKnownModel: true
@@ -5958,6 +6001,7 @@ function getModelCapabilities(modelId) {
5958
6001
  rejectsSamplingParameters: false,
5959
6002
  rejectsThinkingDisabledAboveHighEffort: false,
5960
6003
  rejectsThinkingDisabled: false,
6004
+ rejectsBudgetThinking: false,
5961
6005
  rejectsForcedToolUse: false,
5962
6006
  supportsBetweenToolsThinking: false,
5963
6007
  isKnownModel: false
@@ -5969,6 +6013,7 @@ function getModelCapabilities(modelId) {
5969
6013
  rejectsSamplingParameters: true,
5970
6014
  rejectsThinkingDisabledAboveHighEffort: true,
5971
6015
  rejectsThinkingDisabled: false,
6016
+ rejectsBudgetThinking: false,
5972
6017
  rejectsForcedToolUse: false,
5973
6018
  supportsBetweenToolsThinking: false,
5974
6019
  isKnownModel: false
@@ -5980,6 +6025,7 @@ function getModelCapabilities(modelId) {
5980
6025
  rejectsSamplingParameters: false,
5981
6026
  rejectsThinkingDisabledAboveHighEffort: false,
5982
6027
  rejectsThinkingDisabled: false,
6028
+ rejectsBudgetThinking: false,
5983
6029
  rejectsForcedToolUse: false,
5984
6030
  supportsBetweenToolsThinking: false,
5985
6031
  isKnownModel: false