@ai-sdk/anthropic 4.0.79 → 4.0.80

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,14 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.80
4
+
5
+ ### Patch Changes
6
+
7
+ - 40d0aec: feat(vertex-anthropic): forward 'providerOptions.vertex.labels' as a header
8
+ - 40a4ce1: Fall back to automatic tool choice with a warning when manual thinking is enabled with a required or named tool choice, avoiding an Anthropic API 400 error. Named tool choices send only the selected tool.
9
+ - Updated dependencies [2e89fa4]
10
+ - @ai-sdk/provider-utils@5.0.60
11
+
3
12
  ## 4.0.79
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1843,7 +1843,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
1843
1843
  toolWarnings.push({
1844
1844
  type: "unsupported",
1845
1845
  feature: "toolChoice",
1846
- details: "toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made."
1846
+ details: "toolChoice 'required' is not supported with this model or thinking configuration. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made."
1847
1847
  });
1848
1848
  return {
1849
1849
  tools: anthropicTools,
@@ -1875,7 +1875,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
1875
1875
  toolWarnings.push({
1876
1876
  type: "unsupported",
1877
1877
  feature: "toolChoice",
1878
- details: `toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${toolChoice.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`
1878
+ details: `toolChoice 'tool' is not supported with this model or thinking configuration. Only the '${toolChoice.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`
1879
1879
  });
1880
1880
  return {
1881
1881
  tools: anthropicTools.filter((tool) => "name" in tool && tool.name === toolChoice.toolName),
@@ -3921,7 +3921,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
3921
3921
  supportsStructuredOutput: false,
3922
3922
  supportsStrictTools,
3923
3923
  defaultEagerInputStreaming,
3924
- rejectsForcedToolUse
3924
+ rejectsForcedToolUse: rejectsForcedToolUse || thinkingType === "enabled"
3925
3925
  } : {
3926
3926
  tools: tools ?? [],
3927
3927
  toolChoice,
@@ -3930,7 +3930,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
3930
3930
  supportsStructuredOutput,
3931
3931
  supportsStrictTools,
3932
3932
  defaultEagerInputStreaming,
3933
- rejectsForcedToolUse
3933
+ rejectsForcedToolUse: rejectsForcedToolUse || thinkingType === "enabled"
3934
3934
  });
3935
3935
  const cacheWarnings = cacheControlValidator.getWarnings();
3936
3936
  return {
@@ -3964,8 +3964,9 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
3964
3964
  options
3965
3965
  });
3966
3966
  }
3967
- async getHeaders({ betas, headers }) {
3968
- return combineHeaders(this.config.headers ? await resolve(this.config.headers) : void 0, headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
3967
+ async getHeaders({ betas, headers, providerOptions }) {
3968
+ const combinedHeaders = combineHeaders(this.config.headers ? await resolve(this.config.headers) : void 0, headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
3969
+ return this.config.transformRequestHeaders ? this.config.transformRequestHeaders(combinedHeaders, providerOptions) : combinedHeaders;
3969
3970
  }
3970
3971
  async getBetasFromHeaders(requestHeaders) {
3971
3972
  const configBetaHeader = (this.config.headers ? await resolve(this.config.headers) : void 0)?.["anthropic-beta"] ?? "";
@@ -4005,7 +4006,8 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4005
4006
  url: this.buildRequestUrl(false),
4006
4007
  headers: await this.getHeaders({
4007
4008
  betas,
4008
- headers: options.headers
4009
+ headers: options.headers,
4010
+ providerOptions: options.providerOptions
4009
4011
  }),
4010
4012
  body: this.transformRequestBody(args, betas),
4011
4013
  failedResponseHandler: anthropicFailedResponseHandler,
@@ -4425,7 +4427,8 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
4425
4427
  url,
4426
4428
  headers: await this.getHeaders({
4427
4429
  betas,
4428
- headers: options.headers
4430
+ headers: options.headers,
4431
+ providerOptions: options.providerOptions
4429
4432
  }),
4430
4433
  body: this.transformRequestBody(body, betas),
4431
4434
  failedResponseHandler: anthropicFailedResponseHandler,
@@ -6933,7 +6936,7 @@ var AnthropicSkills = class {
6933
6936
  };
6934
6937
  //#endregion
6935
6938
  //#region src/version.ts
6936
- const VERSION = "4.0.79";
6939
+ const VERSION = "4.0.80";
6937
6940
  //#endregion
6938
6941
  //#region src/anthropic-provider.ts
6939
6942
  const ANTHROPIC_API_URL = "https://api.anthropic.com";