@ai-sdk/anthropic 4.0.7 → 4.0.9

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,19 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 2e45d9c: fix(anthropic): wrap invalid tool input in object
8
+
9
+ ## 4.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 0aa0ff3: fix(anthropic): forward `thinking: { type: 'disabled' }` to the API instead of stripping it
14
+
15
+ Previously, setting `providerOptions.anthropic.thinking = { type: 'disabled' }` (or top-level `reasoning: 'none'`) was accepted by the schema but silently dropped from the outgoing request. For models that default thinking on (e.g. Sonnet 5), this left thinking enabled and could consume a small `max_tokens` budget entirely. The `disabled` value is now sent to the Anthropic Messages API.
16
+
3
17
  ## 4.0.7
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2891,7 +2891,7 @@ async function convertToAnthropicPrompt({
2891
2891
  type: "tool_use",
2892
2892
  id: part.toolCallId,
2893
2893
  name: part.toolName,
2894
- input: part.input,
2894
+ input: toAnthropicToolInput(part.input),
2895
2895
  ...caller && { caller },
2896
2896
  cache_control: cacheControl
2897
2897
  });
@@ -3291,6 +3291,9 @@ function moveToolUseBlocksToEnd(content) {
3291
3291
  flushSegment();
3292
3292
  return result;
3293
3293
  }
3294
+ function toAnthropicToolInput(input) {
3295
+ return typeof input === "object" && input !== null && !Array.isArray(input) ? input : { rawInvalidInput: input };
3296
+ }
3294
3297
 
3295
3298
  // src/map-anthropic-stop-reason.ts
3296
3299
  function mapAnthropicStopReason({
@@ -3710,6 +3713,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3710
3713
  }
3711
3714
  const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
3712
3715
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3716
+ const sendThinking = isThinking || thinkingType === "disabled";
3713
3717
  let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3714
3718
  const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
3715
3719
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
@@ -3723,7 +3727,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3723
3727
  top_p: topP,
3724
3728
  stop_sequences: stopSequences,
3725
3729
  // provider specific settings:
3726
- ...isThinking && {
3730
+ ...sendThinking && {
3727
3731
  thinking: {
3728
3732
  type: thinkingType,
3729
3733
  ...thinkingBudget != null && { budget_tokens: thinkingBudget },
@@ -6291,7 +6295,7 @@ var AnthropicSkills = class {
6291
6295
  };
6292
6296
 
6293
6297
  // src/version.ts
6294
- var VERSION = true ? "4.0.7" : "0.0.0-test";
6298
+ var VERSION = true ? "4.0.9" : "0.0.0-test";
6295
6299
 
6296
6300
  // src/anthropic-provider.ts
6297
6301
  var ANTHROPIC_API_URL = "https://api.anthropic.com";