@ai-sdk/anthropic 3.0.20 → 3.0.21

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.
@@ -987,8 +987,25 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
987
987
 
988
988
  // tool search tool results:
989
989
  case 'tool_search_tool_result': {
990
- const providerToolName =
991
- serverToolCalls[part.tool_use_id] ?? 'tool_search_tool_regex';
990
+ let providerToolName = serverToolCalls[part.tool_use_id];
991
+
992
+ if (providerToolName == null) {
993
+ const bm25CustomName = toolNameMapping.toCustomToolName(
994
+ 'tool_search_tool_bm25',
995
+ );
996
+ const regexCustomName = toolNameMapping.toCustomToolName(
997
+ 'tool_search_tool_regex',
998
+ );
999
+
1000
+ if (bm25CustomName !== 'tool_search_tool_bm25') {
1001
+ providerToolName = 'tool_search_tool_bm25';
1002
+ } else if (regexCustomName !== 'tool_search_tool_regex') {
1003
+ providerToolName = 'tool_search_tool_regex';
1004
+ } else {
1005
+ providerToolName = 'tool_search_tool_regex';
1006
+ }
1007
+ }
1008
+
992
1009
  if (part.content.type === 'tool_search_tool_search_result') {
993
1010
  content.push({
994
1011
  type: 'tool-result',
@@ -1480,9 +1497,25 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
1480
1497
 
1481
1498
  // tool search tool results:
1482
1499
  case 'tool_search_tool_result': {
1483
- const providerToolName =
1484
- serverToolCalls[part.tool_use_id] ??
1485
- 'tool_search_tool_regex';
1500
+ let providerToolName = serverToolCalls[part.tool_use_id];
1501
+
1502
+ if (providerToolName == null) {
1503
+ const bm25CustomName = toolNameMapping.toCustomToolName(
1504
+ 'tool_search_tool_bm25',
1505
+ );
1506
+ const regexCustomName = toolNameMapping.toCustomToolName(
1507
+ 'tool_search_tool_regex',
1508
+ );
1509
+
1510
+ if (bm25CustomName !== 'tool_search_tool_bm25') {
1511
+ providerToolName = 'tool_search_tool_bm25';
1512
+ } else if (regexCustomName !== 'tool_search_tool_regex') {
1513
+ providerToolName = 'tool_search_tool_regex';
1514
+ } else {
1515
+ providerToolName = 'tool_search_tool_regex';
1516
+ }
1517
+ }
1518
+
1486
1519
  if (part.content.type === 'tool_search_tool_search_result') {
1487
1520
  controller.enqueue({
1488
1521
  type: 'tool-result',
@@ -64,6 +64,7 @@ const factory = createProviderToolFactoryWithOutputSchema<
64
64
  id: 'anthropic.tool_search_bm25_20251119',
65
65
  inputSchema: toolSearchBm25_20251119InputSchema,
66
66
  outputSchema: toolSearchBm25_20251119OutputSchema,
67
+ supportsDeferredResults: true,
67
68
  });
68
69
 
69
70
  /**
@@ -76,6 +76,7 @@ const factory = createProviderToolFactoryWithOutputSchema<
76
76
  id: 'anthropic.tool_search_regex_20251119',
77
77
  inputSchema: toolSearchRegex_20251119InputSchema,
78
78
  outputSchema: toolSearchRegex_20251119OutputSchema,
79
+ supportsDeferredResults: true,
79
80
  });
80
81
 
81
82
  /**